parseEntry method

Object? parseEntry([
  1. int marker_kind = 0
])

Implementation

Object? parseEntry([int marker_kind = 0]) {
  //
  // Indicate that we are running the regular parser and that it's
  // ok to use the utility functions to query the parser.
  //
  taking_actions = true;

  //
  // Reset the token stream and get the first token.
  //
  tokStream.reset();
  lastToken = tokStream.getPrevious(tokStream.peek());
  int curtok, current_kind;
  if (marker_kind == 0) {
    curtok = tokStream.getToken();
    current_kind = tokStream.getKind(curtok);
  } else {
    curtok = lastToken;
    current_kind = marker_kind;
  }

  //
  // Start parsing.
  //
  reallocateStacks(); // make initial allocation
  stateStackTop = -1;
  currentAction = START_STATE;

  ProcessTerminals:
  for (;;) {
    //
    // 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;
    }

    try {
      stateStack[++stateStackTop] = currentAction;
    } on RangeError {
      reallocateStacks();
      stateStack[stateStackTop] = currentAction;
    }

    locationStack[stateStackTop] = curtok;

    currentAction = tAction1(currentAction, current_kind);

    if (currentAction <= NUM_RULES) {
      stateStackTop--; // make reduction look like a shift-reduce
      processReductions();
    } else if (currentAction > ERROR_ACTION) {
      lastToken = curtok;
      curtok = tokStream.getToken();
      current_kind = tokStream.getKind(curtok);
      currentAction -= ERROR_ACTION;
      processReductions();
    } else if (currentAction < ACCEPT_ACTION) {
      lastToken = curtok;
      curtok = tokStream.getToken();
      current_kind = tokStream.getKind(curtok);
    } else {
      break ProcessTerminals;
    }
  }

  taking_actions = false; // indicate that we are done

  if (currentAction == ERROR_ACTION) {
    throw BadParseException(curtok);
  }

  return parseStack[marker_kind == 0 ? 0 : 1];
}