Example #1
0
 /**
  * Always called by generated parsers upon entry to a rule. Access field {@link #_ctx} get the
  * current context.
  */
 public void enterRule(ParserRuleContext localctx, int state, int ruleIndex) {
   setState(state);
   _ctx = localctx;
   _ctx.start = _input.LT(1);
   if (_buildParseTrees) addContextToParseTree();
   if (_parseListeners != null) triggerEnterRuleEvent();
 }
Example #2
0
 public void enterRecursionRule(
     ParserRuleContext localctx, int state, int ruleIndex, int precedence) {
   setState(state);
   _precedenceStack.push(precedence);
   _ctx = localctx;
   _ctx.start = _input.LT(1);
   if (_parseListeners != null) {
     triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules
   }
 }
Example #3
0
  /**
   * Like {@link #enterRule} but for recursive rules. Make the current context the child of the
   * incoming localctx.
   */
  public void pushNewRecursionContext(ParserRuleContext localctx, int state, int ruleIndex) {
    ParserRuleContext previous = _ctx;
    previous.parent = localctx;
    previous.invokingState = state;
    previous.stop = _input.LT(-1);

    _ctx = localctx;
    _ctx.start = previous.start;
    if (_buildParseTrees) {
      _ctx.addChild(previous);
    }

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