diff --git a/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.java b/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.java index 4889a853c58d0151527c1d4fb42d577b416dc93f..67e2115a5b25f864f603b88c8e1f5f867fd578d5 100644 --- a/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.java +++ b/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.java @@ -2,25 +2,93 @@ /* Generated By:JavaCC: Do not edit this line. UnlParser.java */ package fr.tetras_libre.unltools.unl.parser; -import fr.tetras_libre.unltools.unl.*; - -import java.util.Set; +import java.io.FileInputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; import java.util.SortedSet; import java.util.TreeSet; +import java.util.Set; import java.util.Vector; +import fr.tetras_libre.unltools.unl.*; public class UnlParser implements UnlParserConstants { /* Test program */ - /*public static void main(String args[]) throws ParseException, Exception { + public static void main(String args[]) throws ParseException, Exception { if (args.length != 1) throw new Exception("Please pass the file name as first and only arg."); UnlParser parser = new UnlParser(new BufferedReader(new InputStreamReader(new FileInputStream(args[0])))); parser.createUnlDocumentList(); - }*/ + } - private final java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); +/*--------------------------------- + * Unl DOCUMENT STRUCTURE + *---------------------------------*/ + final public +UnlDocument unlDocument() throws ParseException, ParseException {Token docLabel; + UnlDocument doc = null; + UnlDocumentNode node; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DOC:{ + docLabel = jj_consume_token(DOC); +doc = new UnlDocument(docLabel.image); + break; + } + default: + jj_la1[0] = jj_gen; + ; + } +// If there is no doc element, create it... + if (null == doc) { doc = new UnlDocument("[D]"); } ; + label_1: + while (true) { + try { + node = structuredElement(); + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DEUXPOINT:{ + ; + break; + } + default: + jj_la1[1] = jj_gen; + break label_2; + } + jj_consume_token(DEUXPOINT); + } +doc.add(node); + } catch (Exception ex) { +node = new UnlDocumentNode(ex.getMessage()); + doc.setError(ex.getMessage()); + doc.add(node); + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PARAGRAPH: + case TITLE: + case SENTENCE: + case END_PARAGRAPH:{ + ; + break; + } + default: + jj_la1[2] = jj_gen; + break label_1; + } + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case END_DOC:{ + jj_consume_token(END_DOC); + break; + } + default: + jj_la1[3] = jj_gen; + ; + } +{if ("" != null) return doc;} + throw new Error("Missing return statement in function"); +} final public UnlDocumentNode structuredElement() throws ParseException {Token t; UnlDocumentNode sent; @@ -54,362 +122,219 @@ public class UnlParser implements UnlParserConstants { throw new ParseException(); } throw new Error("Missing return statement in function"); - } - - final public UnlDocumentNode title() throws ParseException { - Graph g; - Token t; - t = jj_consume_token(TITLE); - g = relationList(); - jj_consume_token(END_TITLE); - { - if ("" != null) return new UnlDocumentNode(UnlDocumentNodeType.Title, t.image, g); - } - throw new Error("Missing return statement in function"); - } - - /** - * Generated Token Manager. - */ - public UnlParserTokenManager token_source; - /** - * Current token. - */ - public Token token; - /** - * Next token. - */ - public Token jj_nt; - SimpleCharStream jj_input_stream; - private int jj_ntk; - private int jj_gen; - private int[] jj_expentry; - private int jj_kind = -1; - - final public UnlDocumentNode sentence() throws ParseException { - Graph g; - Token t; - t = jj_consume_token(SENTENCE); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case GENERIC_TOKEN: { - g = relationList(); - break; - } - case NODELIST: { - g = nodeAndRelations(); - break; - } - default: - jj_la1[5] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(END_SENTENCE); - { - if ("" != null) return new UnlDocumentNode(UnlDocumentNodeType.Sentence, t.image, g); - } - throw new Error("Missing return statement in function"); - } +} - /*--------------------------------- - * Unl DOCUMENT STRUCTURE - *---------------------------------*/ - final public UnlDocument unlDocument() throws ParseException { - Token docLabel; - UnlDocument doc = null; - UnlDocumentNode node; - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case DOC: { - docLabel = jj_consume_token(DOC); - doc = new UnlDocument(docLabel.image); - break; - } - default: - jj_la1[0] = jj_gen; - } -// If there is no doc element, create it... - if (null == doc) { - doc = new UnlDocument("[D]"); - } - label_1: - while (true) { - try { - node = structuredElement(); - label_2: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case DEUXPOINT: { - break; - } - default: - jj_la1[1] = jj_gen; - break label_2; - } - jj_consume_token(DEUXPOINT); - } - doc.add(node); - } catch (Exception ex) { - node = new UnlDocumentNode(ex.getMessage()); - doc.setError(ex.getMessage()); - doc.add(node); - } - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case PARAGRAPH: - case TITLE: - case SENTENCE: - case END_PARAGRAPH: { - break; - } - default: - jj_la1[2] = jj_gen; - break label_1; - } - } - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case END_DOC: { - jj_consume_token(END_DOC); - break; - } - default: - jj_la1[3] = jj_gen; - } - { - if ("" != null) return doc; - } - throw new Error("Missing return statement in function"); - } + final public UnlDocumentNode title() throws ParseException {Graph g; +Token t; + t = jj_consume_token(TITLE); + g = relationList(); + jj_consume_token(END_TITLE); +{if ("" != null) return new UnlDocumentNode(UnlDocumentNodeType.Title, t.image, g);} + throw new Error("Missing return statement in function"); +} - final public GraphRelation relation() throws ParseException { - Token rl; - Token subGraphNumber = null; - GraphNode n1, n2; - rl = jj_consume_token(GENERIC_TOKEN); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case COLON_NUMBER: { - subGraphNumber = jj_consume_token(COLON_NUMBER); - break; - } - default: - jj_la1[7] = jj_gen; - } - jj_consume_token(PARO); - n1 = node(); - jj_consume_token(COMMA); - n2 = node(); - jj_consume_token(PARF); - if (null == subGraphNumber) { - if ("" != null) return new GraphRelation(n1, n2, rl.image); - } else { - if ("" != null) return new GraphRelation(n1, n2, rl.image, subGraphNumber.image); - } - throw new Error("Missing return statement in function"); + final public UnlDocumentNode sentence() throws ParseException {Graph g; +Token t; + t = jj_consume_token(SENTENCE); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case GENERIC_TOKEN:{ + g = relationList(); + break; + } + case NODELIST:{ + g = nodeAndRelations(); + break; + } + default: + jj_la1[5] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } + jj_consume_token(END_SENTENCE); +{if ("" != null) return new UnlDocumentNode(UnlDocumentNodeType.Sentence, t.image, g);} + throw new Error("Missing return statement in function"); +} - final public Restriction restriction() throws ParseException { - Token label; - Token direction; - UniversalWord uw; - label = jj_consume_token(GENERIC_TOKEN); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case CHEVRD: { - direction = jj_consume_token(CHEVRD); - break; - } - case CHEVRG: { - direction = jj_consume_token(CHEVRG); - break; - } - default: - jj_la1[15] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - uw = embeddedUniversalWord(label.image); - { - if ("" != null) return new Restriction(label.image, direction.image.charAt(0), uw); - } - throw new Error("Missing return statement in function"); +/*--------------------------------- + * RELATIONS + *---------------------------------*/ + final public +Graph relationList() throws ParseException {GraphRelation rel; + Graph g = new Graph(); + label_3: + while (true) { + rel = relation(); +g.add(rel); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case GENERIC_TOKEN:{ + ; + break; + } + default: + jj_la1[6] = jj_gen; + break label_3; + } } +{if ("" != null) return g;} + throw new Error("Missing return statement in function"); +} - /*--------------------------------- - * RELATIONS - *---------------------------------*/ - final public Graph relationList() throws ParseException { - GraphRelation rel; - Graph g = new Graph(); - label_3: - while (true) { - rel = relation(); - g.add(rel); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case GENERIC_TOKEN: { - break; - } - default: - jj_la1[6] = jj_gen; - break label_3; - } - } - { - if ("" != null) return g; - } - throw new Error("Missing return statement in function"); + final public GraphRelation relation() throws ParseException {Token rl; + Token subGraphNumber = null; + GraphNode n1, n2; + rl = jj_consume_token(GENERIC_TOKEN); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COLON_NUMBER:{ + subGraphNumber = jj_consume_token(COLON_NUMBER); + break; + } + default: + jj_la1[7] = jj_gen; + ; } + jj_consume_token(PARO); + n1 = node(); + jj_consume_token(COMMA); + n2 = node(); + jj_consume_token(PARF); +if (null == subGraphNumber) + {if ("" != null) return new GraphRelation(n1, n2, rl.image);} + else + {if ("" != null) return new GraphRelation(n1, n2, rl.image, subGraphNumber.image);} + throw new Error("Missing return statement in function"); +} - final public SubGraphReferenceNode decoratedSubGraphNumber() throws ParseException { - Token num; - Set attr; - num = jj_consume_token(COLON_NUMBER); - attr = attributes(); - { - if ("" != null) return new SubGraphReferenceNode(num.image, attr); - } - throw new Error("Missing return statement in function"); + final public GraphNode node() throws ParseException {UniversalWordNode uwn; + SubGraphReferenceNode sgn; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DBLQUOTED: + case GENERIC_TOKEN:{ + uwn = decoratedUniversalWord(); +{if ("" != null) return (GraphNode) uwn;} + break; + } + case COLON_NUMBER:{ + sgn = decoratedSubGraphNumber(); +{if ("" != null) return (GraphNode) sgn;} + break; + } + default: + jj_la1[8] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } + throw new Error("Missing return statement in function"); +} - /*--------------------------------- - * RULES FOR TESTS - *---------------------------------*/ + final public SubGraphReferenceNode decoratedSubGraphNumber() throws ParseException {Token num; + Set attr; + num = jj_consume_token(COLON_NUMBER); + attr = attributes(); +{if ("" != null) return new SubGraphReferenceNode(num.image, attr);} + throw new Error("Missing return statement in function"); +} - /*--------------------------------- - * NODES AND RELATIONS ([W] syntax) - *---------------------------------*/ +/*--------------------------------- + * NODES AND RELATIONS ([W] syntax) + *---------------------------------*/ // For the moment, only accept isolated node. - final public Graph nodeAndRelations() throws ParseException { - GraphNode n; - Graph g = new Graph(); - jj_consume_token(NODELIST); - n = node(); - jj_consume_token(END_NODELIST); - g.add(n); - { - if ("" != null) return g; - } - throw new Error("Missing return statement in function"); - } + final public Graph nodeAndRelations() throws ParseException {GraphNode n; + Graph g = new Graph(); + jj_consume_token(NODELIST); + n = node(); + jj_consume_token(END_NODELIST); +g.add(n); + {if ("" != null) return g;} + throw new Error("Missing return statement in function"); +} - /*--------------------------------- - * DECORATED UW - *---------------------------------*/ - final public UniversalWordNode decoratedUniversalWord() throws ParseException { - UniversalWord uw; - Token num = null; - Set attr; - uw = universalWord(); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case COLON_NUMBER: { - num = jj_consume_token(COLON_NUMBER); - break; - } - default: - jj_la1[9] = jj_gen; - } - attr = attributes(); - if (null == num) { - { - if ("" != null) return new UniversalWordNode(uw, attr); - } - } else { - { - if ("" != null) return new UniversalWordNode(uw, attr, num.image); - } - } - throw new Error("Missing return statement in function"); +/*--------------------------------- + * DECORATED UW + *---------------------------------*/ + final public UniversalWordNode decoratedUniversalWord() throws ParseException {UniversalWord uw; + Token num = null; + Set attr; + uw = universalWord(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COLON_NUMBER:{ + num = jj_consume_token(COLON_NUMBER); + break; + } + default: + jj_la1[9] = jj_gen; + ; } - - final public GraphNode node() throws ParseException { - UniversalWordNode uwn; - SubGraphReferenceNode sgn; - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case DBLQUOTED: - case GENERIC_TOKEN: { - uwn = decoratedUniversalWord(); - { - if ("" != null) return uwn; - } - break; - } - case COLON_NUMBER: { - sgn = decoratedSubGraphNumber(); - { - if ("" != null) return sgn; - } - break; - } - default: - jj_la1[8] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); + attr = attributes(); +if (null == num) { + {if ("" != null) return new UniversalWordNode(uw, attr);} + } else { + {if ("" != null) return new UniversalWordNode(uw, attr, num.image);} } + throw new Error("Missing return statement in function"); +} - /*--------------------------------- - * UNIVERSAL WORD - *---------------------------------*/ - final public UniversalWord universalWord() throws ParseException { - String hw; - SortedSet restrictions; - hw = headword(); - restrictions = restrictionList(); - { - if ("" != null) return new UniversalWord(hw, restrictions); - } - throw new Error("Missing return statement in function"); + final public Set attributes() throws ParseException {Set attr = (Set) new TreeSet(); + Token a; + label_4: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ATTR:{ + ; + break; + } + default: + jj_la1[10] = jj_gen; + break label_4; + } + a = jj_consume_token(ATTR); +attr.add(a.image); } +{if ("" != null) return attr;} + throw new Error("Missing return statement in function"); +} - final public Set attributes() throws ParseException { - Set attr = new TreeSet(); - Token a; - label_4: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case ATTR: { - break; - } - default: - jj_la1[10] = jj_gen; - break label_4; - } - a = jj_consume_token(ATTR); - attr.add(a.image); - } - { - if ("" != null) return attr; - } - throw new Error("Missing return statement in function"); - } +/*--------------------------------- + * UNIVERSAL WORD + *---------------------------------*/ + final public +UniversalWord universalWord() throws ParseException {String hw; +SortedSet restrictions; + hw = headword(); + restrictions = restrictionList(); +{if ("" != null) return new UniversalWord(hw, restrictions);} + throw new Error("Missing return statement in function"); +} - final public String headword() throws ParseException { - Token t; - StringBuffer hw = new StringBuffer(); - label_5: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case GENERIC_TOKEN: { - t = jj_consume_token(GENERIC_TOKEN); - hw.append(t.image); - hw.append(" "); - break; - } - case DBLQUOTED: { - t = jj_consume_token(DBLQUOTED); - hw.append(t.image); - hw.append(" "); - break; - } - default: - jj_la1[11] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case DBLQUOTED: - case GENERIC_TOKEN: { - break; - } - default: - jj_la1[12] = jj_gen; + final public String headword() throws ParseException {Token t; + StringBuffer hw = new StringBuffer(); + label_5: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case GENERIC_TOKEN:{ + t = jj_consume_token(GENERIC_TOKEN); +hw.append(t.image); + hw.append(" "); + break; + } + case DBLQUOTED:{ + t = jj_consume_token(DBLQUOTED); +hw.append(t.image); + hw.append(" "); + break; + } + default: + jj_la1[11] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DBLQUOTED: + case GENERIC_TOKEN:{ + ; + break; + } + default: + jj_la1[12] = jj_gen; break label_5; } } @@ -421,72 +346,173 @@ int last = hw.length()-1; throw new Error("Missing return statement in function"); } - /* Putain de syntaxe à la con ! */ + final public SortedSet restrictionList() throws ParseException {Restriction r; + SortedSet restrictions = (SortedSet) new TreeSet(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PARO:{ + jj_consume_token(PARO); + r = restriction(); +restrictions.add(r); + label_6: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[13] = jj_gen; + break label_6; + } + jj_consume_token(COMMA); + r = restriction(); +restrictions.add(r); + } + jj_consume_token(PARF); + break; + } + default: + jj_la1[14] = jj_gen; + ; + } +{if ("" != null) return restrictions;} + throw new Error("Missing return statement in function"); +} + + final public Restriction restriction() throws ParseException {Token label; + Token direction; + UniversalWord uw; + label = jj_consume_token(GENERIC_TOKEN); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CHEVRD:{ + direction = jj_consume_token(CHEVRD); + break; + } + case CHEVRG:{ + direction = jj_consume_token(CHEVRG); + break; + } + default: + jj_la1[15] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + uw = embeddedUniversalWord(label.image); +{if ("" != null) return new Restriction(label.image, direction.image.charAt(0), uw);} + throw new Error("Missing return statement in function"); +} + +/* Putain de syntaxe à la con ! */ /* Un UW dans une restriction n'a pas forcément la même syntaxe qu'une UW "normale". En effet, la restricition peut être factorisée. */ - final public UniversalWord embeddedUniversalWord(String inheritedLabel) throws ParseException { - String hw; - SortedSet restrictions; - hw = headword(); - restrictions = embeddedRestrictionList(inheritedLabel); - { - if ("" != null) return new UniversalWord(hw, restrictions); - } - throw new Error("Missing return statement in function"); + final public UniversalWord embeddedUniversalWord(String inheritedLabel) throws ParseException {String hw; + SortedSet restrictions; + hw = headword(); + restrictions = embeddedRestrictionList(inheritedLabel); +{if ("" != null) return new UniversalWord(hw, restrictions);} + throw new Error("Missing return statement in function"); +} + + final public SortedSet embeddedRestrictionList(String inheritedLabel) throws ParseException {UniversalWord uw; + SortedSet restrictions; + Token direction; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CHEVRD: + case CHEVRG:{ +restrictions = (SortedSet) new TreeSet(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CHEVRD:{ + direction = jj_consume_token(CHEVRD); + break; + } + case CHEVRG:{ + direction = jj_consume_token(CHEVRG); + break; + } + default: + jj_la1[16] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + uw = embeddedUniversalWord(inheritedLabel); +restrictions.add(new Restriction(inheritedLabel, direction.image.charAt(0), uw)); + break; + } + default: + jj_la1[17] = jj_gen; + restrictions = restrictionList(); } +{if ("" != null) return restrictions;} + throw new Error("Missing return statement in function"); +} + +/*--------------------------------- + * RULES FOR TESTS + *---------------------------------*/ + +/** + * List of universal words separated by commas. + */ + final public void universalWordList() throws ParseException { + decoratedUniversalWord(); +System.out.println("UW"); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + jj_consume_token(COMMA); + universalWordList(); + break; + } + default: + jj_la1[18] = jj_gen; - final public SortedSet restrictionList() throws ParseException { - Restriction r; - SortedSet restrictions = new TreeSet(); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case PARO: { - jj_consume_token(PARO); - r = restriction(); - restrictions.add(r); - label_6: - while (true) { - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case COMMA: { - break; - } - default: - jj_la1[13] = jj_gen; - break label_6; - } - jj_consume_token(COMMA); - r = restriction(); - restrictions.add(r); - } - jj_consume_token(PARF); - break; - } - default: - jj_la1[14] = jj_gen; - } - { - if ("" != null) return restrictions; - } - throw new Error("Missing return statement in function"); } + jj_consume_token(0); +} - /** - * List of universal words separated by commas. - */ - final public void universalWordList() throws ParseException { - decoratedUniversalWord(); - System.out.println("UW"); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case COMMA: { - jj_consume_token(COMMA); - universalWordList(); - break; - } - default: - jj_la1[18] = jj_gen; +/** + * Simple unl graph. + */ + final public void isolatedUnlGraph() throws ParseException { + relationList(); + jj_consume_token(0); +} - } - jj_consume_token(0); +/** + * Main entry point: unl document List. + */ + final public Vector<UnlDocument> createUnlDocumentList() throws ParseException {UnlDocument doc; +Vector<UnlDocument> list = new Vector<UnlDocument>(); + label_7: + while (true) { + doc = unlDocument(); +list.add(doc); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DOC: + case PARAGRAPH: + case TITLE: + case SENTENCE: + case END_PARAGRAPH:{ + ; + break; + } + default: + jj_la1[19] = jj_gen; + break label_7; + } } +{if ("" != null) return list;} + throw new Error("Missing return statement in function"); +} + + /** Generated Token Manager. */ + public UnlParserTokenManager token_source; + SimpleCharStream jj_input_stream; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private int jj_gen; final private int[] jj_la1 = new int[20]; static private int[] jj_la1_0; static private int[] jj_la1_1; @@ -590,127 +616,52 @@ int last = hw.length()-1; } - /** - * Get the next Token. - */ - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - jj_gen++; - return token; - } - - /** - * Simple unl graph. - */ - final public void isolatedUnlGraph() throws ParseException { - relationList(); - jj_consume_token(0); - } - - final public SortedSet embeddedRestrictionList(String inheritedLabel) throws ParseException { - UniversalWord uw; - SortedSet restrictions; - Token direction; - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case CHEVRD: - case CHEVRG: { - restrictions = new TreeSet(); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case CHEVRD: { - direction = jj_consume_token(CHEVRD); - break; - } - case CHEVRG: { - direction = jj_consume_token(CHEVRG); - break; - } - default: - jj_la1[16] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - uw = embeddedUniversalWord(inheritedLabel); - restrictions.add(new Restriction(inheritedLabel, direction.image.charAt(0), uw)); - break; - } - default: - jj_la1[17] = jj_gen; - restrictions = restrictionList(); - } - { - if ("" != null) return restrictions; - } - throw new Error("Missing return statement in function"); - } - - /** - * Get the specific Token. - */ - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } +/** Get the next Token. */ + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } - private int jj_ntk_f() { - if ((jj_nt = token.next) == null) - return (jj_ntk = (token.next = token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } +/** Get the specific Token. */ + final public Token getToken(int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } - /** - * Main entry point: unl document List. - */ - final public Vector<UnlDocument> createUnlDocumentList() throws ParseException { - UnlDocument doc; - Vector<UnlDocument> list = new Vector<UnlDocument>(); - label_7: - while (true) { - doc = unlDocument(); - list.add(doc); - switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { - case DOC: - case PARAGRAPH: - case TITLE: - case SENTENCE: - case END_PARAGRAPH: { - break; - } - default: - jj_la1[19] = jj_gen; - break label_7; - } - } - { - if ("" != null) return list; - } - throw new Error("Missing return statement in function"); - } + private int jj_ntk_f() { + if ((jj_nt=token.next) == null) + return (jj_ntk = (token.next=token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } - /** - * Generate ParseException. - */ - public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[39]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 20; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1 << j)) != 0) { - la1tokens[j] = true; - } - if ((jj_la1_1[i] & (1 << j)) != 0) { - la1tokens[32 + j] = true; + private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); + private int[] jj_expentry; + private int jj_kind = -1; + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[39]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 20; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1<<j)) != 0) { + la1tokens[j] = true; + } + if ((jj_la1_1[i] & (1<<j)) != 0) { + la1tokens[32+j] = true; } } } diff --git a/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.jj b/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.jj index a05304d4e80f8642e6cab2d74dd3a12049c69be0..b5976bbc809ba1a02f203e16393e4b424a5c3afc 100644 --- a/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.jj +++ b/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParser.jj @@ -72,7 +72,7 @@ TOKEN : /* Character classes */ // QUESTION: Quels sont les caractères officiellement acceptés dans les headwords... | <#HEADWORD_CHARACTERS : ( <ALPHANUM> | "'" | "#" | "&" | "/" | ["\u00c0"-"\u00ff"] | - ("." ~["@"]) ) > + ("." ~["@"]) | "=" ) > // | <#HEADWORD_CHARACTERS : ( <ALPHANUM> | "'" | "#" | "&" | "/" | "+" | "@" | "=" | "$" | "�" | "�" | "[" | "]" | // "\u221a" | "\u00a9" | diff --git a/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParserTokenManager.java b/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParserTokenManager.java index b84e9b6f78aa7b2cb5db2697a08d94706b94aaa6..10808c7b830dba491b837f13129d6fc77d49c39b 100644 --- a/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParserTokenManager.java +++ b/unl-tools-infrastructure/src/main/java/fr/tetras_libre/unltools/unl/parser/UnlParserTokenManager.java @@ -1,6 +1,14 @@ /* UnlParserTokenManager.java */ /* Generated By:JavaCC: Do not edit this line. UnlParserTokenManager.java */ package fr.tetras_libre.unltools.unl.parser; +import java.io.FileInputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.Set; +import java.util.Vector; +import fr.tetras_libre.unltools.unl.*; /** Token Manager. */ @SuppressWarnings ("unused") @@ -201,7 +209,7 @@ private int jjMoveNfa_0(int startState, int curPos) switch(jjstateSet[--i]) { case 0: - if ((0x3ffa0c800000000L & l) != 0L) + if ((0x23ffa0c800000000L & l) != 0L) { if (kind > 37) kind = 37; @@ -274,7 +282,7 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 36; break; case 21: - if ((0x3ffa0c800000000L & l) == 0L) + if ((0x23ffa0c800000000L & l) == 0L) break; if (kind > 37) kind = 37;