nextState method

int nextState(
  1. int state,
  2. int symbol
)

Returns the parse state reached by accepting symbol in state.

Implementation

int nextState(int state, int symbol) {
  final value = actionIndex(state, symbol);
  if (symbol >= tokenCount) return value;
  if (value <= 0 || value >= parseActions.length) return 0;
  final actions = parseActions[value].actions;
  if (actions.isEmpty) return 0;
  final action = actions.last;
  if (action.type == TreeSitterParseActionType.shift) {
    return action.extra ? state : action.state;
  }
  return 0;
}