public void addFollowLink(int ruleIndex, ATNState right) { // add follow edge from end of invoked rule RuleStopState stop = atn.ruleToStopState[ruleIndex]; // System.out.println("add follow link from "+ruleIndex+" to "+right); epsilon(stop, right); }
protected Handle makeBlock(BlockStartState start, BlockAST blkAST, List<Handle> alts) { BlockEndState end = newState(BlockEndState.class, blkAST); start.endState = end; for (Handle alt : alts) { // hook alts up to decision block epsilon(start, alt.left); epsilon(alt.right, end); // no back link in ATN so must walk entire alt to see if we can // strip out the epsilon to 'end' state TailEpsilonRemover opt = new TailEpsilonRemover(atn); opt.visit(alt.left); } Handle h = new Handle(start, end); // FASerializer ser = new FASerializer(g, h.left); // System.out.println(blkAST.toStringTree()+":\n"+ser); blkAST.atnState = start; return h; }
public ATN getATN() { if ( atn==null ) { ParserATNFactory factory = new ParserATNFactory(this); atn = factory.createATN(); } return atn; }
public static void optimize(Grammar g, ATN atn) { optimizeSets(g, atn); optimizeStates(atn); }
@Override public Handle rule(GrammarAST ruleAST, String name, Handle blk) { Rule r = g.getRule(name); RuleStartState start = atn.ruleToStartState[r.index]; epsilon(start, blk.left); RuleStopState stop = atn.ruleToStopState[r.index]; epsilon(blk.right, stop); Handle h = new Handle(start, stop); // ATNPrinter ser = new ATNPrinter(g, h.left); // System.out.println(ruleAST.toStringTree()+":\n"+ser.asString()); ruleAST.atnState = start; return h; }
public boolean expectNonGreedy(BlockAST blkAST) { if ( blockHasWildcardAlt(blkAST) ) { return true; } return false; }
/** For a non-lexer, just build a simple token reference atom. */ @Override public Handle stringLiteral(TerminalAST stringLiteralAST) { return tokenRef(stringLiteralAST); }
public ATN getATN() { if ( atn==null ) { ParserATNFactory factory = new ParserATNFactory(this); atn = factory.createATN(); } return atn; }
public void addFollowLink(int ruleIndex, ATNState right) { // add follow edge from end of invoked rule RuleStopState stop = atn.ruleToStopState[ruleIndex]; // System.out.println("add follow link from "+ruleIndex+" to "+right); epsilon(stop, right); }
public boolean expectNonGreedy(BlockAST blkAST) { if ( blockHasWildcardAlt(blkAST) ) { return true; } return false; }
public void addFollowLink(int ruleIndex, ATNState right) { // add follow edge from end of invoked rule RuleStopState stop = atn.ruleToStopState[ruleIndex]; // System.out.println("add follow link from "+ruleIndex+" to "+right); epsilon(stop, right); }