Exemplo n.º 1
0
        private ExpressionContext expression(int _p)
        {
            ParserRuleContext _parentctx = _ctx;
            int _parentState             = State;
            ExpressionContext _localctx  = new ExpressionContext(_ctx, _parentState);
            ExpressionContext _prevctx   = _localctx;
            int _startState = 2;

            EnterRecursionRule(_localctx, 2, RULE_expression, _p);
            int _la;

            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 27;
                    _errHandler.Sync(this);
                    switch (_input.La(1))
                    {
                    case SHIFT_RIGHT:
                    case SHIFT_LEFT:
                    {
                        _localctx = new ShiftContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;

                        State = 10;
                        ((ShiftContext)_localctx).op = _input.Lt(1);
                        _la = _input.La(1);
                        if (!(_la == SHIFT_RIGHT || _la == SHIFT_LEFT))
                        {
                            ((ShiftContext)_localctx).op = _errHandler.RecoverInline(this);
                        }
                        else
                        {
                            if (_input.La(1) == TokenConstants.Eof)
                            {
                                matchedEOF = true;
                            }

                            _errHandler.ReportMatch(this);
                            Consume();
                        }
                        State = 11; Match(NUMBER);
                        State = 12; expression(6);
                    }
                    break;

                    case UPPER:
                    case LOWER:
                    {
                        _localctx = new CaseContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 13;
                        ((CaseContext)_localctx).op = _input.Lt(1);
                        _la = _input.La(1);
                        if (!(_la == UPPER || _la == LOWER))
                        {
                            ((CaseContext)_localctx).op = _errHandler.RecoverInline(this);
                        }
                        else
                        {
                            if (_input.La(1) == TokenConstants.Eof)
                            {
                                matchedEOF = true;
                            }

                            _errHandler.ReportMatch(this);
                            Consume();
                        }
                        State = 14; expression(5);
                    }
                    break;

                    case SUBSTRING:
                    {
                        _localctx = new SubstringContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 15; Match(SUBSTRING);
                        State     = 16; Match(NUMBER);
                        State     = 19;
                        _errHandler.Sync(this);
                        _la = _input.La(1);
                        if (_la == COMMA)
                        {
                            {
                                State = 17; Match(COMMA);
                                State = 18; Match(NUMBER);
                            }
                        }

                        State = 21; expression(4);
                    }
                    break;

                    case OBRACKET:
                    {
                        _localctx = new BracketsContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 22; Match(OBRACKET);
                        State     = 23; expression(0);
                        State     = 24; Match(CBRACKET);
                    }
                    break;

                    case STRING:
                    {
                        _localctx = new StringContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 26; Match(STRING);
                    }
                    break;

                    default:
                        throw new NoViableAltException(this);
                    }
                    _ctx.stop = _input.Lt(-1);
                    State     = 34;
                    _errHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(_input, 3, _ctx);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                    {
                        if (_alt == 1)
                        {
                            if (_parseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                {
                                    _localctx = new Con_diffContext(new ExpressionContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expression);
                                    State = 29;
                                    if (!(Precpred(_ctx, 3)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 3)");
                                    }
                                    State = 30;
                                    ((Con_diffContext)_localctx).op = _input.Lt(1);
                                    _la = _input.La(1);
                                    if (!(_la == CONCANTENATE || _la == DIFFERENCE))
                                    {
                                        ((Con_diffContext)_localctx).op = _errHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        if (_input.La(1) == TokenConstants.Eof)
                                        {
                                            matchedEOF = true;
                                        }

                                        _errHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 31; expression(4);
                                }
                            }
                        }
                        State = 36;
                        _errHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(_input, 3, _ctx);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }
Exemplo n.º 2
0
 public override object VisitBrackets([NotNull] BracketsContext context)
 {
     return(Visit(context.expression()).ToString());
 }