in internal/pkg/eql/parser/eql_parser.go [2643:3253]
func (p *EqlParser) exp(_p int) (localctx IExpContext) {
var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext()
_parentState := p.GetState()
localctx = NewExpContext(p, p.GetParserRuleContext(), _parentState)
var _prevctx IExpContext = localctx
var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning.
_startState := 10
p.EnterRecursionRule(localctx, 10, EqlParserRULE_exp, _p)
var _la int
var _alt int
p.EnterOuterAlt(localctx, 1)
p.SetState(80)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
switch p.GetTokenStream().LA(1) {
case EqlParserLPAR:
localctx = NewExpInParenContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(46)
p.Match(EqlParserLPAR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(47)
p.exp(0)
}
{
p.SetState(48)
p.Match(EqlParserRPAR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserNOT:
localctx = NewExpNotContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(50)
p.Match(EqlParserNOT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(51)
p.exp(18)
}
case EqlParserTRUE, EqlParserFALSE:
localctx = NewExpBooleanContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(52)
p.Boolean()
}
case EqlParserBEGIN_EVARIABLE:
localctx = NewExpEVariableContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(53)
p.Match(EqlParserBEGIN_EVARIABLE)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(54)
p.VariableExp()
}
{
p.SetState(55)
p.Match(EqlParserRDICT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserBEGIN_VARIABLE:
localctx = NewExpVariableContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(57)
p.Match(EqlParserBEGIN_VARIABLE)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(58)
p.VariableExp()
}
{
p.SetState(59)
p.Match(EqlParserRDICT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserNAME:
localctx = NewExpFunctionContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(61)
p.Match(EqlParserNAME)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(62)
p.Match(EqlParserLPAR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
p.SetState(64)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
_la = p.GetTokenStream().LA(1)
if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&28703588352) != 0 {
{
p.SetState(63)
p.Arguments()
}
}
{
p.SetState(66)
p.Match(EqlParserRPAR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserLARR:
localctx = NewExpArrayContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(67)
p.Match(EqlParserLARR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
p.SetState(69)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
_la = p.GetTokenStream().LA(1)
if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&102629376) != 0 {
{
p.SetState(68)
p.Array()
}
}
{
p.SetState(71)
p.Match(EqlParserRARR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserLDICT:
localctx = NewExpDictContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(72)
p.Match(EqlParserLDICT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
p.SetState(74)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
_la = p.GetTokenStream().LA(1)
if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&109051904) != 0 {
{
p.SetState(73)
p.Dict()
}
}
{
p.SetState(76)
p.Match(EqlParserRDICT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserSTEXT, EqlParserDTEXT:
localctx = NewExpTextContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(77)
_la = p.GetTokenStream().LA(1)
if !(_la == EqlParserSTEXT || _la == EqlParserDTEXT) {
p.GetErrorHandler().RecoverInline(p)
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
case EqlParserFLOAT:
localctx = NewExpFloatContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(78)
p.Match(EqlParserFLOAT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
case EqlParserNUMBER:
localctx = NewExpNumberContext(p, localctx)
p.SetParserRuleContext(localctx)
_prevctx = localctx
{
p.SetState(79)
p.Match(EqlParserNUMBER)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
default:
p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
goto errorExit
}
p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1))
p.SetState(114)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
_alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext())
if p.HasError() {
goto errorExit
}
for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
if _alt == 1 {
if p.GetParseListeners() != nil {
p.TriggerExitRuleEvent()
}
_prevctx = localctx
p.SetState(112)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) {
case 1:
localctx = NewExpArithmeticMulDivModContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticMulDivModContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(82)
if !(p.Precpred(p.GetParserRuleContext(), 20)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 20)", ""))
goto errorExit
}
{
p.SetState(83)
_la = p.GetTokenStream().LA(1)
if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&28672) != 0) {
p.GetErrorHandler().RecoverInline(p)
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
{
p.SetState(84)
var _x = p.exp(21)
localctx.(*ExpArithmeticMulDivModContext).right = _x
}
case 2:
localctx = NewExpArithmeticAddSubContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticAddSubContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(85)
if !(p.Precpred(p.GetParserRuleContext(), 19)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 19)", ""))
goto errorExit
}
{
p.SetState(86)
_la = p.GetTokenStream().LA(1)
if !(_la == EqlParserADD || _la == EqlParserSUB) {
p.GetErrorHandler().RecoverInline(p)
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
{
p.SetState(87)
var _x = p.exp(20)
localctx.(*ExpArithmeticAddSubContext).right = _x
}
case 3:
localctx = NewExpArithmeticEQContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticEQContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(88)
if !(p.Precpred(p.GetParserRuleContext(), 17)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 17)", ""))
goto errorExit
}
{
p.SetState(89)
p.Match(EqlParserEQ)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(90)
var _x = p.exp(18)
localctx.(*ExpArithmeticEQContext).right = _x
}
case 4:
localctx = NewExpArithmeticNEQContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticNEQContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(91)
if !(p.Precpred(p.GetParserRuleContext(), 16)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 16)", ""))
goto errorExit
}
{
p.SetState(92)
p.Match(EqlParserNEQ)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(93)
var _x = p.exp(17)
localctx.(*ExpArithmeticNEQContext).right = _x
}
case 5:
localctx = NewExpArithmeticLTEContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticLTEContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(94)
if !(p.Precpred(p.GetParserRuleContext(), 15)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 15)", ""))
goto errorExit
}
{
p.SetState(95)
p.Match(EqlParserLTE)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(96)
var _x = p.exp(16)
localctx.(*ExpArithmeticLTEContext).right = _x
}
case 6:
localctx = NewExpArithmeticGTEContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticGTEContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(97)
if !(p.Precpred(p.GetParserRuleContext(), 14)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 14)", ""))
goto errorExit
}
{
p.SetState(98)
p.Match(EqlParserGTE)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(99)
var _x = p.exp(15)
localctx.(*ExpArithmeticGTEContext).right = _x
}
case 7:
localctx = NewExpArithmeticLTContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticLTContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(100)
if !(p.Precpred(p.GetParserRuleContext(), 13)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 13)", ""))
goto errorExit
}
{
p.SetState(101)
p.Match(EqlParserLT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(102)
var _x = p.exp(14)
localctx.(*ExpArithmeticLTContext).right = _x
}
case 8:
localctx = NewExpArithmeticGTContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpArithmeticGTContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(103)
if !(p.Precpred(p.GetParserRuleContext(), 12)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 12)", ""))
goto errorExit
}
{
p.SetState(104)
p.Match(EqlParserGT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(105)
var _x = p.exp(13)
localctx.(*ExpArithmeticGTContext).right = _x
}
case 9:
localctx = NewExpLogicalAndContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpLogicalAndContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(106)
if !(p.Precpred(p.GetParserRuleContext(), 11)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 11)", ""))
goto errorExit
}
{
p.SetState(107)
p.Match(EqlParserAND)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(108)
var _x = p.exp(12)
localctx.(*ExpLogicalAndContext).right = _x
}
case 10:
localctx = NewExpLogicalORContext(p, NewExpContext(p, _parentctx, _parentState))
localctx.(*ExpLogicalORContext).left = _prevctx
p.PushNewRecursionContext(localctx, _startState, EqlParserRULE_exp)
p.SetState(109)
if !(p.Precpred(p.GetParserRuleContext(), 10)) {
p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 10)", ""))
goto errorExit
}
{
p.SetState(110)
p.Match(EqlParserOR)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(111)
var _x = p.exp(11)
localctx.(*ExpLogicalORContext).right = _x
}
case antlr.ATNInvalidAltNumber:
goto errorExit
}
}
p.SetState(116)
p.GetErrorHandler().Sync(p)
if p.HasError() {
goto errorExit
}
_alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext())
if p.HasError() {
goto errorExit
}
}
errorExit:
if p.HasError() {
v := p.GetError()
localctx.SetException(v)
p.GetErrorHandler().ReportError(p, v)
p.GetErrorHandler().Recover(p, v)
p.SetError(nil)
}
p.UnrollRecursionContexts(_parentctx)
if false {
goto errorExit // Trick to prevent compiler error if the label is not used
}
return localctx
}