Example #1
0
 public void exitRule() {
   if (matchedEOF) {
     // if we have matched EOF, it cannot consume past EOF so we use LT(1) here
     _ctx.stop = _input.LT(1); // LT(1) will be end of file
   } else {
     _ctx.stop = _input.LT(-1); // stop node is what we just matched
   }
   // trigger event on _ctx, before it reverts to parent
   if (_parseListeners != null) triggerExitRuleEvent();
   setState(_ctx.invokingState);
   _ctx = (ParserRuleContext) _ctx.parent;
 }
Example #2
0
  public void unrollRecursionContexts(ParserRuleContext _parentctx) {
    _precedenceStack.pop();
    _ctx.stop = _input.LT(-1);
    ParserRuleContext retctx = _ctx; // save current ctx (return value)

    // unroll so _ctx is as it was before call to recursive method
    if (_parseListeners != null) {
      while (_ctx != _parentctx) {
        triggerExitRuleEvent();
        _ctx = (ParserRuleContext) _ctx.parent;
      }
    } else {
      _ctx = _parentctx;
    }

    // hook into tree
    retctx.parent = _parentctx;

    if (_buildParseTrees && _parentctx != null) {
      // add return ctx into invoking rule's tree
      _parentctx.addChild(retctx);
    }
  }