public boolean deleteChild(org.antlr.runtime.tree.Tree t) { for (int i=0; i<children.size(); i++) { Object c = children.get(i); if ( c == t ) { deleteChild(t.getChildIndex()); return true; } } return false; }
public boolean deleteChild(org.antlr.runtime.tree.Tree t) { for (int i=0; i<children.size(); i++) { Object c = children.get(i); if ( c == t ) { deleteChild(t.getChildIndex()); return true; } } return false; }
public boolean deleteChild(org.antlr.runtime.tree.Tree t) { for (int i=0; i<children.size(); i++) { Object c = children.get(i); if ( c == t ) { deleteChild(t.getChildIndex()); return true; } } return false; }
public boolean deleteChild(org.antlr.runtime.tree.Tree t) { for (int i=0; i<children.size(); i++) { Object c = children.get(i); if ( c == t ) { deleteChild(t.getChildIndex()); return true; } } return false; }
public boolean deleteChild(org.antlr.runtime.tree.Tree t) { for (int i=0; i<children.size(); i++) { Object c = children.get(i); if ( c == t ) { deleteChild(t.getChildIndex()); return true; } } return false; }
public GrammarAST stripLeftRecursion(GrammarAST altAST) { GrammarAST lrlabel=null; GrammarAST first = (GrammarAST)altAST.getChild(0); int leftRecurRuleIndex = 0; if ( first.getType() == ELEMENT_OPTIONS ) { first = (GrammarAST)altAST.getChild(1); leftRecurRuleIndex = 1; } Tree rref = first.getChild(1); // if label=rule if ( (first.getType()==RULE_REF && first.getText().equals(ruleName)) || (rref!=null && rref.getType()==RULE_REF && rref.getText().equals(ruleName)) ) { if ( first.getType()==ASSIGN || first.getType()==PLUS_ASSIGN ) lrlabel = (GrammarAST)first.getChild(0); // remove rule ref (first child unless options present) altAST.deleteChild(leftRecurRuleIndex); // reset index so it prints properly (sets token range of // ALT to start to right of left recur rule we deleted) GrammarAST newFirstChild = (GrammarAST)altAST.getChild(leftRecurRuleIndex); altAST.setTokenStartIndex(newFirstChild.getTokenStartIndex()); } return lrlabel; }
public GrammarAST stripLeftRecursion(GrammarAST altAST) { GrammarAST lrlabel=null; GrammarAST first = (GrammarAST)altAST.getChild(0); int leftRecurRuleIndex = 0; if ( first.getType() == ELEMENT_OPTIONS ) { first = (GrammarAST)altAST.getChild(1); leftRecurRuleIndex = 1; } Tree rref = first.getChild(1); // if label=rule if ( (first.getType()==RULE_REF && first.getText().equals(ruleName)) || (rref!=null && rref.getType()==RULE_REF && rref.getText().equals(ruleName)) ) { if ( first.getType()==ASSIGN || first.getType()==PLUS_ASSIGN ) lrlabel = (GrammarAST)first.getChild(0); // remove rule ref (first child unless options present) altAST.deleteChild(leftRecurRuleIndex); // reset index so it prints properly (sets token range of // ALT to start to right of left recur rule we deleted) GrammarAST newFirstChild = (GrammarAST)altAST.getChild(leftRecurRuleIndex); altAST.setTokenStartIndex(newFirstChild.getTokenStartIndex()); } return lrlabel; }
public GrammarAST stripLeftRecursion(GrammarAST altAST) { GrammarAST lrlabel=null; GrammarAST first = (GrammarAST)altAST.getChild(0); int leftRecurRuleIndex = 0; if ( first.getType() == ELEMENT_OPTIONS ) { first = (GrammarAST)altAST.getChild(1); leftRecurRuleIndex = 1; } Tree rref = first.getChild(1); // if label=rule if ( (first.getType()==RULE_REF && first.getText().equals(ruleName)) || (rref!=null && rref.getType()==RULE_REF && rref.getText().equals(ruleName)) ) { if ( first.getType()==ASSIGN || first.getType()==PLUS_ASSIGN ) lrlabel = (GrammarAST)first.getChild(0); // remove rule ref (first child unless options present) altAST.deleteChild(leftRecurRuleIndex); // reset index so it prints properly (sets token range of // ALT to start to right of left recur rule we deleted) GrammarAST newFirstChild = (GrammarAST)altAST.getChild(leftRecurRuleIndex); altAST.setTokenStartIndex(newFirstChild.getTokenStartIndex()); } return lrlabel; }
public GrammarAST stripLeftRecursion(GrammarAST altAST) { GrammarAST lrlabel=null; GrammarAST first = (GrammarAST)altAST.getChild(0); int leftRecurRuleIndex = 0; if ( first.getType() == ELEMENT_OPTIONS ) { first = (GrammarAST)altAST.getChild(1); leftRecurRuleIndex = 1; } Tree rref = first.getChild(1); // if label=rule if ( (first.getType()==RULE_REF && first.getText().equals(ruleName)) || (rref!=null && rref.getType()==RULE_REF && rref.getText().equals(ruleName)) ) { if ( first.getType()==ASSIGN || first.getType()==PLUS_ASSIGN ) lrlabel = (GrammarAST)first.getChild(0); // remove rule ref (first child unless options present) altAST.deleteChild(leftRecurRuleIndex); // reset index so it prints properly (sets token range of // ALT to start to right of left recur rule we deleted) GrammarAST newFirstChild = (GrammarAST)altAST.getChild(leftRecurRuleIndex); altAST.setTokenStartIndex(newFirstChild.getTokenStartIndex()); } return lrlabel; }
public GrammarAST stripLeftRecursion(GrammarAST altAST) { GrammarAST lrlabel=null; GrammarAST first = (GrammarAST)altAST.getChild(0); int leftRecurRuleIndex = 0; if ( first.getType() == ELEMENT_OPTIONS ) { first = (GrammarAST)altAST.getChild(1); leftRecurRuleIndex = 1; } Tree rref = first.getChild(1); // if label=rule if ( (first.getType()==RULE_REF && first.getText().equals(ruleName)) || (rref!=null && rref.getType()==RULE_REF && rref.getText().equals(ruleName)) ) { if ( first.getType()==ASSIGN || first.getType()==PLUS_ASSIGN ) lrlabel = (GrammarAST)first.getChild(0); // remove rule ref (first child unless options present) altAST.deleteChild(leftRecurRuleIndex); // reset index so it prints properly (sets token range of // ALT to start to right of left recur rule we deleted) GrammarAST newFirstChild = (GrammarAST)altAST.getChild(leftRecurRuleIndex); altAST.setTokenStartIndex(newFirstChild.getTokenStartIndex()); } return lrlabel; }
adaptor.addChild(newBlock, newAlt); while (previous.getChildCount() > 1) { adaptor.addChild(newAlt, previous.deleteChild(1)); adaptor.addChild(newBlock, newAlt); while (translatedAlt.getChildCount() > 1) { adaptor.addChild(newAlt, translatedAlt.deleteChild(1));
combinedRulesRoot.deleteChild( r );
combinedRulesRoot.deleteChild( r );
combinedRulesRoot.deleteChild( r );
combinedRulesRoot.deleteChild( r );
combinedRulesRoot.deleteChild( r );
root.deleteChild(0); return root;
alt2.deleteChild(0); if (alt2.getChildCount() == 0) { adaptor.addChild(alt2, adaptor.create(ANTLRParser.EPSILON, "EPSILON")); alt2.deleteChild(0); if (alt2.getChildCount() == 0) { adaptor.addChild(alt2, adaptor.create(ANTLRParser.EPSILON, "EPSILON"));