Skip to content

Commit

Permalink
ruleToStopState
Browse files Browse the repository at this point in the history
  • Loading branch information
canastro committed Mar 12, 2021
1 parent 7857faf commit 3d6f006
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion runtime/Dart/lib/src/atn/src/atn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ATN {
List<RuleStartState> ruleToStartState = <RuleStartState>[];

/// Maps from rule index to stop state number.
late List<RuleStopState> ruleToStopState;
List<RuleStopState>? ruleToStopState;

Map<String, TokensStartState> modeNameToStartState = {};

Expand Down
6 changes: 3 additions & 3 deletions runtime/Dart/lib/src/atn/src/atn_deserializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class ATNDeserializer {
if (state is! RuleStopState) {
continue;
}
atn.ruleToStopState[state.ruleIndex] = state;
atn.ruleToStopState![state.ruleIndex] = state;
atn.ruleToStartState[state.ruleIndex].stopState = state;
}

Expand Down Expand Up @@ -368,7 +368,7 @@ class ATNDeserializer {

final returnTransition = EpsilonTransition(
ruleTransition.followState, outermostPrecedenceReturn);
atn.ruleToStopState[ruleTransition.target.ruleIndex]
atn.ruleToStopState![ruleTransition.target.ruleIndex]
.addTransition(returnTransition);
}
}
Expand Down Expand Up @@ -527,7 +527,7 @@ class ATNDeserializer {
excludeTransition =
(endState as StarLoopEntryState).loopBackState!.transition(0);
} else {
endState = atn.ruleToStopState[idx];
endState = atn.ruleToStopState![idx];
}

// all non-excluded transitions that currently target end state need to target blockEnd instead
Expand Down
3 changes: 2 additions & 1 deletion runtime/Dart/lib/src/atn/src/parser_atn_simulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,8 @@ class ParserATNSimulator extends ATNSimulator {
if (lookToEndOfRule && config.state.onlyHasEpsilonTransitions()) {
final nextTokens = atn.nextTokens(config.state);
if (nextTokens.contains(Token.EPSILON)) {
ATNState endOfRuleState = atn.ruleToStopState[config.state.ruleIndex];
ATNState endOfRuleState =
atn.ruleToStopState![config.state.ruleIndex];
result.add(ATNConfig.dup(config, state: endOfRuleState), mergeCache);
}
}
Expand Down
6 changes: 3 additions & 3 deletions runtime/Dart/lib/src/parser_interpreter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ParserInterpreter extends Parser {
try {
visitState(p);
} on RecognitionException catch (e) {
state = atn.ruleToStopState[p.ruleIndex].stateNumber;
state = atn.ruleToStopState![p.ruleIndex].stateNumber;
context!.exception = e;
errorHandler.reportError(this, e);
recover(e);
Expand Down Expand Up @@ -267,8 +267,8 @@ class ParserInterpreter extends Parser {
context,
(transition as PrecedencePredicateTransition).precedence,
)) {
throw FailedPredicateException(this,
'precpred(context, ${(transition).precedence})');
throw FailedPredicateException(
this, 'precpred(context, ${(transition).precedence})');
}
break;

Expand Down

0 comments on commit 3d6f006

Please sign in to comment.