setPrecedenceStartState method
Set the start state for a specific precedence value.
@param precedence The current precedence. @param startState The start state corresponding to the specified precedence.
@throws IllegalStateException if this is not a precedence DFA. @see #isPrecedenceDfa()
Implementation
void setPrecedenceStartState(int precedence, DFAState startState) {
if (!isPrecedenceDfa()) {
throw StateError(
'Only precedence DFAs may contain a precedence start state.');
}
if (precedence < 0) {
return;
}
// synchronization on s0 here is ok. when the DFA is turned into a
// precedence DFA, s0 will be initialized once and not updated again
// s0.edges is never null for a precedence DFA
if (precedence >= s0!.edges!.length) {
final original = s0!.edges!;
s0!.edges = List.filled(precedence + 1, null);
List.copyRange(s0!.edges!, 0, original);
}
s0!.edges![precedence] = startState;
}