Example #1
0
 public UserRepository()
 {
     _db = IdentContext.Create();
 }
Example #2
0
        private ExprContext expr(int _p)
        {
            ParserRuleContext _parentctx = _ctx;
            int         _parentState     = State;
            ExprContext _localctx        = new ExprContext(_ctx, _parentState);
            ExprContext _prevctx         = _localctx;
            int         _startState      = 4;

            EnterRecursionRule(_localctx, 4, RULE_expr, _p);
            int _la;

            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 29;
                    _errHandler.Sync(this);
                    switch (_input.La(1))
                    {
                    case INT:
                    {
                        _localctx = new IntContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;

                        State = 23; Match(INT);
                    }
                    break;

                    case ID:
                    {
                        _localctx = new IdentContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 24; Match(ID);
                    }
                    break;

                    case T__2:
                    {
                        _localctx = new ParensContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 25; Match(T__2);
                        State     = 26; expr(0);
                        State     = 27; Match(T__3);
                    }
                    break;

                    default:
                        throw new NoViableAltException(this);
                    }
                    _ctx.stop = _input.Lt(-1);
                    State     = 39;
                    _errHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(_input, 4, _ctx);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                    {
                        if (_alt == 1)
                        {
                            if (_parseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                State = 37;
                                _errHandler.Sync(this);
                                switch (Interpreter.AdaptivePredict(_input, 3, _ctx))
                                {
                                case 1:
                                {
                                    _localctx = new MultExprContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 31;
                                    if (!(Precpred(_ctx, 5)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 5)");
                                    }
                                    State = 32;
                                    ((MultExprContext)_localctx).op = _input.Lt(1);
                                    _la = _input.La(1);
                                    if (!(_la == MUL || _la == DIV))
                                    {
                                        ((MultExprContext)_localctx).op = _errHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        if (_input.La(1) == TokenConstants.Eof)
                                        {
                                            matchedEOF = true;
                                        }

                                        _errHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 33; expr(6);
                                }
                                break;

                                case 2:
                                {
                                    _localctx = new AddExprContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 34;
                                    if (!(Precpred(_ctx, 4)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 4)");
                                    }
                                    State = 35;
                                    ((AddExprContext)_localctx).op = _input.Lt(1);
                                    _la = _input.La(1);
                                    if (!(_la == ADD || _la == SUB))
                                    {
                                        ((AddExprContext)_localctx).op = _errHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        if (_input.La(1) == TokenConstants.Eof)
                                        {
                                            matchedEOF = true;
                                        }

                                        _errHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 36; expr(5);
                                }
                                break;
                                }
                            }
                        }
                        State = 41;
                        _errHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(_input, 4, _ctx);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }