ParserATNFactory.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:codebuff 作者:
/** Add an EOF transition to any rule end ATNState that points to nothing
    *  (i.e., for all those rules not invoked by another rule).  These
    *  are start symbols then.
 *
 *  Return the number of grammar entry points; i.e., how many rules are
 *  not invoked by another rule (they can only be invoked from outside).
 *  These are the start rules.
    */
public int addEOFTransitionToStartRules() {
    int n = 0;
    ATNState eofTarget = newState(null); // one unique EOF target for all rules
    for (Rule r : g.rules.values()) {
        ATNState stop = atn.ruleToStopState[r.index];
        if ( stop.getNumberOfTransitions()>0 ) continue;
        n++;
        Transition t = new AtomTransition(eofTarget, Token.EOF);
        stop.addTransition(t);
    }
    return n;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号