parseActions method

Object? parseActions()

Implementation

Object? parseActions() {
  //
  // Indicate that we are processing actions now (for the incremental
  // parser) and that it's ok to use the utility functions to query the
  // parser.
  //
  taking_actions = true;

  tokStream.reset();
  lastToken = tokStream.getPrevious(tokStream.peek());
  var curtok = (markerKind == 0 ? tokStream.getToken() : lastToken);

  try {
    //
    // Reparse the input...
    //
    stateStackTop = -1;
    currentAction = START_STATE;

    for (var i = 0; i < action!.size(); i++) {
      //
      // if the parser needs to stop processing, it may do so here.
      //
      if (monitor != null && monitor!.isCancelled()) {
        taking_actions = false; // indicate that we are done
        return null;
      }

      stateStack[++stateStackTop] = currentAction;
      locationStack[stateStackTop] = curtok;

      currentAction = action!.get(i);
      if (currentAction <= NUM_RULES) // a reduce action?
      {
        stateStackTop--; // turn reduction intoshift-reduction
        processReductions();
      } else // a shift or shift-reduce action
      {
        lastToken = curtok;
        curtok = tokStream.getToken();
        if (currentAction > ERROR_ACTION) // a shift-reduce action?
        {
          currentAction -= ERROR_ACTION;
          processReductions();
        }
      }
    }
  } catch (e) // if any exception is thrown, indicate BadParse
  {
    taking_actions = false; // indicate that we are done.
    throw BadParseException(curtok);
  }

  taking_actions = false; // indicate that we are done.
  action = null; // turn into garbage
  return parseStack[markerKind == 0 ? 0 : 1];
}