pushNewRecursionContext method

void pushNewRecursionContext(
  1. ParserRuleContext localctx,
  2. int state,
  3. int? ruleIndex
)
inherited

Like {@link #enterRule} but for recursive rules. Make the current context the child of the incoming localctx.

Implementation

void pushNewRecursionContext(
  ParserRuleContext localctx,
  int state,
  int? ruleIndex,
) {
  assert(context != null);
  final previous = context!;
  previous.parent = localctx;
  previous.invokingState = state;
  previous.stop = _input.LT(-1);

  context = localctx;
  context!.start = previous.start;
  if (buildParseTree) {
    context!.addAnyChild(previous);
  }

  if (_parseListeners != null) {
    triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules
  }
}