StatisticsParserATNSimulator.java 文件源码

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

项目:antlrworks2 作者:
@Override
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, SimulatorState conflictState, int startIndex, int stopIndex) {
    super.reportAttemptingFullContext(dfa, conflictingAlts, conflictState, startIndex, stopIndex);
        int k;
        if (startIndex == stopIndex) {
            k = 1;
        } else if (startIndex == stopIndex - 1) {
            k = 2;
        } else {
            k = 0;
            for (int i = startIndex; i <= stopIndex; i++) {
                parser.getInputStream().seek(i);
                if (parser.getInputStream().LT(1).getChannel() == Token.DEFAULT_CHANNEL) {
                    k++;
                }
            }
        }

    fullContextFallback[dfa.decision]++;
    totalLookaheadSll[dfa.decision] += k;
    minLookaheadSll[dfa.decision] = Math.min(minLookaheadSll[dfa.decision], k);
    maxLookaheadSll[dfa.decision] = Math.max(maxLookaheadSll[dfa.decision], k);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号