@Override
protected int execDFA(DFA dfa, TokenStream input, int startIndex, SimulatorState state) {
int result = super.execDFA(dfa, input, startIndex, state);
if (!reportedLookahead) {
int stopIndex = input.index();
int k;
if (startIndex == stopIndex) {
k = 1;
} else if (startIndex == stopIndex - 1) {
k = 2;
} else {
k = 0;
for (int i = startIndex; i <= stopIndex; i++) {
input.seek(i);
if (input.LT(1).getChannel() == Token.DEFAULT_CHANNEL) {
k++;
}
}
}
if (!state.useContext) {
totalLookaheadSll[dfa.decision] += k;
minLookaheadSll[dfa.decision] = Math.min(minLookaheadSll[dfa.decision], k);
maxLookaheadSll[dfa.decision] = Math.max(maxLookaheadSll[dfa.decision], k);
}
else {
totalLookaheadLl[dfa.decision] += k;
minLookaheadLl[dfa.decision] = Math.min(minLookaheadLl[dfa.decision], k);
maxLookaheadLl[dfa.decision] = Math.max(maxLookaheadLl[dfa.decision], k);
}
reportedLookahead = true;
}
return result;
}
StatisticsParserATNSimulator.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:goworks
作者:
评论列表
文章目录