forked from jasder/antlr
ATNSimulator.deserialize derives rule stop states and (in the lexer) the outgoing transitions for those states
This commit is contained in:
parent
199e9892dc
commit
83d8903f9f
|
@ -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
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue