ATNSimulator.deserialize derives rule stop states and (in the lexer) the outgoing transitions for those states

This commit is contained in:
Sam Harwell 2012-08-10 19:22:05 -05:00
parent 199e9892dc
commit 83d8903f9f
1 changed files with 25 additions and 0 deletions

View File

@ -109,6 +109,17 @@ public abstract class ATNSimulator {
}
}
atn.ruleToStopState = new RuleStopState[nrules];
for (ATNState state : atn.states) {
if (!(state instanceof RuleStopState)) {
continue;
}
RuleStopState stopState = (RuleStopState)state;
atn.ruleToStopState[state.ruleIndex] = stopState;
atn.ruleToStartState[state.ruleIndex].stopState = stopState;
}
//
// MODES
//
@ -154,6 +165,20 @@ public abstract class ATNSimulator {
p += 6;
}
if (atn.grammarType == ATN.LEXER) {
for (ATNState state : atn.states) {
for (int i = 0; i < state.getNumberOfTransitions(); i++) {
Transition t = state.transition(i);
if (!(t instanceof RuleTransition)) {
continue;
}
RuleTransition ruleTransition = (RuleTransition)t;
atn.ruleToStopState[ruleTransition.target.ruleIndex].addTransition(new EpsilonTransition(ruleTransition.followState));
}
}
}
//
// DECISIONS
//