ParserInterpreter.java 文件源码

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

项目:Scratch-ApuC 作者:
public ParserInterpreter(String grammarFileName, Collection<String> tokenNames,
                         Collection<String> ruleNames, ATN atn, TokenStream input)
{
    super(input);
    this.grammarFileName = grammarFileName;
    this.atn = atn;
    this.tokenNames = tokenNames.toArray(new String[tokenNames.size()]);
    this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]);
    this.decisionToDFA = new DFA[atn.getNumberOfDecisions()];
    for (int i = 0; i < decisionToDFA.length; i++) {
        decisionToDFA[i] = new DFA(atn.getDecisionState(i), i);
    }

    // identify the ATN states where pushNewRecursionContext must be called
    this.pushRecursionContextStates = new BitSet(atn.states.size());
    for (ATNState state : atn.states) {
        if (!(state instanceof StarLoopEntryState)) {
            continue;
        }

        if (((StarLoopEntryState)state).precedenceRuleDecision) {
            this.pushRecursionContextStates.set(state.stateNumber);
        }
    }

    // get atn simulator that knows how to do predictions
    setInterpreter(new ParserATNSimulator(this, atn,
                                          decisionToDFA,
                                          sharedContextCache));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号