public void process() { // LEFT-RECURSION CHECK LeftRecursionDetector lr = new LeftRecursionDetector(g, g.atn); lr.check(); if ( !lr.listOfRecursiveCycles.isEmpty() ) return; // bail out if (g.isLexer()) { processLexer(); } else { // BUILD DFA FOR EACH DECISION processParser(); } }
public int nextPrecedence(int alt) { int p = precedence(alt); if ( altAssociativity.get(alt)==ASSOC.right ) return p; return p+1; }
@Override public void otherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); String altText = text(altTree); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); // We keep other alts with prefix alts since they are all added to the start of the generated rule, and // we want to retain any prior ordering between them prefixAndOtherAlts.add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
@Override public void prefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); int nextPrec = precedence(alt); // rewrite e to be e_[prec] altTree = addPrecedenceArgToRules(altTree, nextPrec); String altText = text(altTree); altText = altText.trim(); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAndOtherAlts.add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
@Override public void prefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); int nextPrec = precedence(alt); // rewrite e to be e_[prec] altTree = addPrecedenceArgToRules(altTree, nextPrec); String altText = text(altTree); altText = altText.trim(); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAndOtherAlts.add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public void process() { // LEFT-RECURSION CHECK LeftRecursionDetector lr = new LeftRecursionDetector(g, g.atn); lr.check(); if ( !lr.listOfRecursiveCycles.isEmpty() ) return; // bail out if (g.isLexer()) { processLexer(); } else { // BUILD DFA FOR EACH DECISION processParser(); } }
@Override public void otherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); String altText = text(altTree); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); otherAlts.add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
public int nextPrecedence(int alt) { int p = precedence(alt); if ( altAssociativity.get(alt)==ASSOC.right ) return p; return p+1; }
@Override public void prefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); int nextPrec = precedence(alt); // rewrite e to be e_[prec] altTree = addPrecedenceArgToRules(altTree, nextPrec); String altText = text(altTree); altText = altText.trim(); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAndOtherAlts.add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public void process() { // LEFT-RECURSION CHECK LeftRecursionDetector lr = new LeftRecursionDetector(g, g.atn); lr.check(); if ( !lr.listOfRecursiveCycles.isEmpty() ) return; // bail out if (g.isLexer()) { processLexer(); } else { // BUILD DFA FOR EACH DECISION processParser(); } }
@Override public void otherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); String altText = text(altTree); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); // We keep other alts with prefix alts since they are all added to the start of the generated rule, and // we want to retain any prior ordering between them prefixAndOtherAlts.add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
public int nextPrecedence(int alt) { int p = precedence(alt); if ( altAssociativity.get(alt)==ASSOC.right ) return p; return p+1; }
@Override public void prefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); int nextPrec = precedence(alt); // rewrite e to be e_[prec] altTree = addPrecedenceArgToRules(altTree, nextPrec); String altText = text(altTree); altText = altText.trim(); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAlts.add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public void process() { // LEFT-RECURSION CHECK LeftRecursionDetector lr = new LeftRecursionDetector(g, g.atn); lr.check(); if ( !lr.listOfRecursiveCycles.isEmpty() ) return; // bail out if (g.isLexer()) { processLexer(); } else { // BUILD DFA FOR EACH DECISION processParser(); } }
@Override public void otherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); String altText = text(altTree); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); // We keep other alts with prefix alts since they are all added to the start of the generated rule, and // we want to retain any prior ordering between them prefixAndOtherAlts.add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
public int nextPrecedence(int alt) { int p = precedence(alt); if ( altAssociativity.get(alt)==ASSOC.right ) return p; return p+1; }
@Override public void prefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); int nextPrec = precedence(alt); // rewrite e to be e_[prec] altTree = addPrecedenceArgToRules(altTree, nextPrec); String altText = text(altTree); altText = altText.trim(); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAndOtherAlts.add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public void process() { // LEFT-RECURSION CHECK LeftRecursionDetector lr = new LeftRecursionDetector(g, g.atn); lr.check(); if ( !lr.listOfRecursiveCycles.isEmpty() ) return; // bail out if (g.isLexer()) { processLexer(); } else { // BUILD DFA FOR EACH DECISION processParser(); } }
@Override public void otherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.dupTree(); stripAltLabel(altTree); String altText = text(altTree); String altLabel = altTree.altLabel!=null ? altTree.altLabel.getText() : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); // We keep other alts with prefix alts since they are all added to the start of the generated rule, and // we want to retain any prior ordering between them prefixAndOtherAlts.add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
public int nextPrecedence(int alt) { int p = precedence(alt); if ( altAssociativity.get(alt)==ASSOC.right ) return p; return p+1; }