예제 #1
0
    private bool arithmetic_expr_sempred(Arithmetic_exprContext _localctx, int predIndex)
    {
        switch (predIndex)
        {
        case 2: return(Precpred(Context, 4));

        case 3: return(Precpred(Context, 3));

        case 4: return(Precpred(Context, 2));
        }
        return(true);
    }
예제 #2
0
        public static QsiExpressionNode VisitExpr(ExprContext expr)
        {
            while (expr is Expr_parensContext parens)
            {
                expr = parens.expr();
            }

            return(expr switch
            {
                Predicate1Context context => VisitPredicate1(context),
                Predicate2Context context => VisitPredicate2(context),
                Like_predicateContext context => VisitLikePredicate(context),
                In_predicate_subqueryContext context => VisitInPredicateSubquery(context),
                In_predicateContext context => VisitInPredicate(context),
                Exists_predicateContext context => VisitExistsPredicate(context),
                Compound_predicate1Context context => VisitCompoundPredicate1(context),
                Compound_predicate2Context context => VisitCompoundPredicate2(context),
                Comparison_predicate1Context context => VisitComparisonPredicate1(context),
                Comparison_predicate2Context context => VisitComparisonPredicate2(context),
                Comparison_predicate3Context context => VisitComparisonPredicate3(context),
                Comparison_predicate4Context context => VisitComparisonPredicate4(context),
                Comparison_predicate5Context context => VisitComparisonPredicate5(context),
                Comparison_predicate6Context context => VisitComparisonPredicate6(context),
                Comparison_predicate7Context context => VisitComparisonPredicate7(context),
                Comparison_predicate8Context context => VisitComparisonPredicate8(context),
                Comparison_predicate9Context context => VisitComparisonPredicate9(context),
                Bool_test_exprContext context => VisitBoolTestExpr(context),
                Between_predicateContext context => VisitBetweenPredicate(context),
                Slot_ref_Context context => VisitSlotRef(context.slot_ref()),
                Sign_chain_exprContext context => VisitSignChainExpr(context),
                Literal_Context context => VisitLiteral(context.literal()),
                Function_call_expr_Context context => VisitFunctionCallExpr(context.function_call_expr()),
                Cast_expr_Context context => VisitCastExpr(context.cast_expr()),
                Case_expr_Context context => VisitCaseExpr(context.case_expr()),
                Analytic_expr_Context context => VisitAnalyticExpr(context.analytic_expr()),
                Timestamp_arithmetic_expr1Context context => VisitTimestampArithmeticExpr1(context),
                Timestamp_arithmetic_expr2Context context => VisitTimestampArithmeticExpr2(context),
                Timestamp_arithmetic_expr3Context context => VisitTimestampArithmeticExpr3(context),
                Arithmetic_exprContext context => VisitArithmeticExpr(context),
                Arithmetic_expr_factorialContext context => VisitArithmeticExprFactorial(context),
                Arithmetic_expr_bitnotContext context => VisitArithmeticExprBitnot(context),
                Subquery_Context context => VisitSubquery(context.subquery()),
                _ => throw TreeHelper.NotSupportedTree(expr)
            });
예제 #3
0
    private Arithmetic_exprContext arithmetic_expr(int _p)
    {
        ParserRuleContext _parentctx     = Context;
        int _parentState                 = State;
        Arithmetic_exprContext _localctx = new Arithmetic_exprContext(Context, _parentState);
        Arithmetic_exprContext _prevctx  = _localctx;
        int _startState = 6;

        EnterRecursionRule(_localctx, 6, RULE_arithmetic_expr, _p);
        int _la;

        try {
            int _alt;
            EnterOuterAlt(_localctx, 1);
            {
                State = 79;
                ErrorHandler.Sync(this);
                switch (TokenStream.LA(1))
                {
                case ID:
                {
                    _localctx = new AVarContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;

                    State = 71; Match(ID);
                }
                break;

                case NUMBER:
                {
                    _localctx = new ANumberContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 72; Match(NUMBER);
                }
                break;

                case T__9:
                {
                    _localctx = new AParensContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 73; Match(T__9);
                    State     = 74; arithmetic_expr(0);
                    State     = 75; Match(T__10);
                }
                break;

                case T__18:
                {
                    _localctx = new ANegContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 77; Match(T__18);
                    State     = 78; arithmetic_expr(1);
                }
                break;

                default:
                    throw new NoViableAltException(this);
                }
                Context.Stop = TokenStream.LT(-1);
                State        = 92;
                ErrorHandler.Sync(this);
                _alt = Interpreter.AdaptivePredict(TokenStream, 8, Context);
                while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER)
                {
                    if (_alt == 1)
                    {
                        if (ParseListeners != null)
                        {
                            TriggerExitRuleEvent();
                        }
                        _prevctx = _localctx;
                        {
                            State = 90;
                            ErrorHandler.Sync(this);
                            switch (Interpreter.AdaptivePredict(TokenStream, 7, Context))
                            {
                            case 1:
                            {
                                _localctx = new AArithmeticContext(new Arithmetic_exprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_arithmetic_expr);
                                State = 81;
                                if (!(Precpred(Context, 4)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 4)");
                                }
                                State = 82; ((AArithmeticContext)_localctx).op = Match(T__14);
                                State = 83; arithmetic_expr(5);
                            }
                            break;

                            case 2:
                            {
                                _localctx = new AArithmeticContext(new Arithmetic_exprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_arithmetic_expr);
                                State = 84;
                                if (!(Precpred(Context, 3)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 3)");
                                }
                                State = 85;
                                ((AArithmeticContext)_localctx).op = TokenStream.LT(1);
                                _la = TokenStream.LA(1);
                                if (!(_la == T__15 || _la == T__16))
                                {
                                    ((AArithmeticContext)_localctx).op = ErrorHandler.RecoverInline(this);
                                }
                                else
                                {
                                    ErrorHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 86; arithmetic_expr(4);
                            }
                            break;

                            case 3:
                            {
                                _localctx = new AArithmeticContext(new Arithmetic_exprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_arithmetic_expr);
                                State = 87;
                                if (!(Precpred(Context, 2)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 2)");
                                }
                                State = 88;
                                ((AArithmeticContext)_localctx).op = TokenStream.LT(1);
                                _la = TokenStream.LA(1);
                                if (!(_la == T__17 || _la == T__18))
                                {
                                    ((AArithmeticContext)_localctx).op = ErrorHandler.RecoverInline(this);
                                }
                                else
                                {
                                    ErrorHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 89; arithmetic_expr(3);
                            }
                            break;
                            }
                        }
                    }
                    State = 94;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 8, Context);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            UnrollRecursionContexts(_parentctx);
        }
        return(_localctx);
    }
예제 #4
0
 public ANumberContext(Arithmetic_exprContext context)
 {
     CopyFrom(context);
 }
예제 #5
0
 public AParensContext(Arithmetic_exprContext context)
 {
     CopyFrom(context);
 }
예제 #6
0
 public virtual void CopyFrom(Arithmetic_exprContext context)
 {
     base.CopyFrom(context);
 }