# Generated from JSONPath.g4 by ANTLR 4.8
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys

if sys.version_info[1] > 5:
    from typing import TextIO
else:
    from typing.io import TextIO


def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\26")
        buf.write("\u00a1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\3\2\3\2\7\2%\n\2\f")
        buf.write("\2\16\2(\13\2\3\2\3\2\3\3\3\3\5\3.\n\3\3\4\3\4\3\4\3\4")
        buf.write("\5\4\64\n\4\3\5\3\5\3\5\3\5\5\5:\n\5\3\5\3\5\5\5>\n\5")
        buf.write("\3\5\3\5\5\5B\n\5\3\5\3\5\5\5F\n\5\3\5\5\5I\n\5\3\6\3")
        buf.write("\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6")
        buf.write("\3\6\3\6\3\6\3\6\3\6\3\6\5\6`\n\6\3\7\3\7\3\7\3\7\3\7")
        buf.write("\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\n\3\n\6\ns")
        buf.write("\n\n\r\n\16\nt\3\n\3\n\3\13\3\13\5\13{\n\13\3\13\3\13")
        buf.write("\5\13\177\n\13\3\13\3\13\5\13\u0083\n\13\3\13\3\13\3\f")
        buf.write("\3\f\3\f\5\f\u008a\n\f\3\f\3\f\5\f\u008e\n\f\3\f\5\f\u0091")
        buf.write("\n\f\3\r\3\r\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3")
        buf.write("\20\3\20\3\21\3\21\3\21\2\2\22\2\4\6\b\n\f\16\20\22\24")
        buf.write("\26\30\32\34\36 \2\4\3\2\b\n\3\2\23\24\2\u00a6\2\"\3\2")
        buf.write("\2\2\4-\3\2\2\2\6\63\3\2\2\2\bH\3\2\2\2\n_\3\2\2\2\fa")
        buf.write("\3\2\2\2\16f\3\2\2\2\20k\3\2\2\2\22n\3\2\2\2\24x\3\2\2")
        buf.write("\2\26\u0090\3\2\2\2\30\u0092\3\2\2\2\32\u0094\3\2\2\2")
        buf.write("\34\u0098\3\2\2\2\36\u009c\3\2\2\2 \u009e\3\2\2\2\"&\7")
        buf.write("\17\2\2#%\5\4\3\2$#\3\2\2\2%(\3\2\2\2&$\3\2\2\2&\'\3\2")
        buf.write("\2\2\')\3\2\2\2(&\3\2\2\2)*\7\2\2\3*\3\3\2\2\2+.\5\b\5")
        buf.write("\2,.\5\6\4\2-+\3\2\2\2-,\3\2\2\2.\5\3\2\2\2/\60\7\22\2")
        buf.write("\2\60\64\5\30\r\2\61\62\7\22\2\2\62\64\5\32\16\2\63/\3")
        buf.write("\2\2\2\63\61\3\2\2\2\64\7\3\2\2\2\65I\5\26\f\2\66\67\7")
        buf.write("\21\2\2\67I\5\36\20\28:\7\21\2\298\3\2\2\29:\3\2\2\2:")
        buf.write(";\3\2\2\2;I\5 \21\2<>\7\21\2\2=<\3\2\2\2=>\3\2\2\2>?\3")
        buf.write("\2\2\2?I\5\n\6\2@B\7\21\2\2A@\3\2\2\2AB\3\2\2\2BC\3\2")
        buf.write("\2\2CI\5\24\13\2DF\7\21\2\2ED\3\2\2\2EF\3\2\2\2FG\3\2")
        buf.write("\2\2GI\5\22\n\2H\65\3\2\2\2H\66\3\2\2\2H9\3\2\2\2H=\3")
        buf.write("\2\2\2HA\3\2\2\2HE\3\2\2\2I\t\3\2\2\2JK\7\3\2\2KL\7\4")
        buf.write("\2\2LM\7\5\2\2MN\5\f\7\2NO\7\6\2\2OP\7\7\2\2P`\3\2\2\2")
        buf.write("QR\7\3\2\2RS\7\4\2\2ST\7\5\2\2TU\5\16\b\2UV\7\6\2\2VW")
        buf.write("\7\7\2\2W`\3\2\2\2XY\7\3\2\2YZ\7\4\2\2Z[\7\5\2\2[\\\5")
        buf.write("\20\t\2\\]\7\6\2\2]^\7\7\2\2^`\3\2\2\2_J\3\2\2\2_Q\3\2")
        buf.write("\2\2_X\3\2\2\2`\13\3\2\2\2ab\7\20\2\2bc\5\26\f\2cd\t\2")
        buf.write("\2\2de\7\25\2\2e\r\3\2\2\2fg\7\20\2\2gh\5\26\f\2hi\7\n")
        buf.write("\2\2ij\7\24\2\2j\17\3\2\2\2kl\7\20\2\2lm\5\26\f\2m\21")
        buf.write("\3\2\2\2no\7\3\2\2or\t\3\2\2pq\7\13\2\2qs\t\3\2\2rp\3")
        buf.write("\2\2\2st\3\2\2\2tr\3\2\2\2tu\3\2\2\2uv\3\2\2\2vw\7\7\2")
        buf.write("\2w\23\3\2\2\2xz\7\3\2\2y{\7\25\2\2zy\3\2\2\2z{\3\2\2")
        buf.write("\2{|\3\2\2\2|~\7\f\2\2}\177\7\25\2\2~}\3\2\2\2~\177\3")
        buf.write("\2\2\2\177\u0082\3\2\2\2\u0080\u0081\7\f\2\2\u0081\u0083")
        buf.write("\7\25\2\2\u0082\u0080\3\2\2\2\u0082\u0083\3\2\2\2\u0083")
        buf.write("\u0084\3\2\2\2\u0084\u0085\7\7\2\2\u0085\25\3\2\2\2\u0086")
        buf.write("\u0087\7\21\2\2\u0087\u0091\5\30\r\2\u0088\u008a\7\21")
        buf.write("\2\2\u0089\u0088\3\2\2\2\u0089\u008a\3\2\2\2\u008a\u008b")
        buf.write("\3\2\2\2\u008b\u0091\5\32\16\2\u008c\u008e\7\21\2\2\u008d")
        buf.write("\u008c\3\2\2\2\u008d\u008e\3\2\2\2\u008e\u008f\3\2\2\2")
        buf.write("\u008f\u0091\5\34\17\2\u0090\u0086\3\2\2\2\u0090\u0089")
        buf.write("\3\2\2\2\u0090\u008d\3\2\2\2\u0091\27\3\2\2\2\u0092\u0093")
        buf.write("\7\23\2\2\u0093\31\3\2\2\2\u0094\u0095\7\3\2\2\u0095\u0096")
        buf.write("\t\3\2\2\u0096\u0097\7\7\2\2\u0097\33\3\2\2\2\u0098\u0099")
        buf.write("\7\3\2\2\u0099\u009a\7\25\2\2\u009a\u009b\7\7\2\2\u009b")
        buf.write("\35\3\2\2\2\u009c\u009d\7\r\2\2\u009d\37\3\2\2\2\u009e")
        buf.write("\u009f\7\16\2\2\u009f!\3\2\2\2\22&-\639=AEH_tz~\u0082")
        buf.write("\u0089\u008d\u0090")
        return buf.getvalue()


class JSONPathParser(Parser):
    grammarFileName = "JSONPath.g4"

    atn = ATNDeserializer().deserialize(serializedATN())

    decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)]

    sharedContextCache = PredictionContextCache()

    literalNames = ["<INVALID>", "'['", "'?'", "'('", "')'", "']'", "'>'",
                    "'<'", "'=='", "','", "':'", "'*'", "'[*]'", "'$'",
                    "'@'", "'.'", "'..'"]

    symbolicNames = [
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "<INVALID>",
        "ROOT",
        "CURRENT",
        "SINGLE_DOT",
        "DOUBLE_DOT",
        "LETTER",
        "STRING",
        "INT",
        "WS"]

    RULE_jsonpath = 0
    RULE_expression = 1
    RULE_doubleDotExpression = 2
    RULE_singleDotExpression = 3
    RULE_filters = 4
    RULE_numericFilter = 5
    RULE_stringFilter = 6
    RULE_booleanFilter = 7
    RULE_union = 8
    RULE_arraySlice = 9
    RULE_fieldAccessor = 10
    RULE_field = 11
    RULE_bracketField = 12
    RULE_arrayIndex = 13
    RULE_wildcard = 14
    RULE_bracketWildcard = 15

    ruleNames = [
        "jsonpath",
        "expression",
        "doubleDotExpression",
        "singleDotExpression",
        "filters",
        "numericFilter",
        "stringFilter",
        "booleanFilter",
        "union",
        "arraySlice",
        "fieldAccessor",
        "field",
        "bracketField",
        "arrayIndex",
        "wildcard",
        "bracketWildcard"]

    EOF = Token.EOF
    T__0 = 1
    T__1 = 2
    T__2 = 3
    T__3 = 4
    T__4 = 5
    T__5 = 6
    T__6 = 7
    T__7 = 8
    T__8 = 9
    T__9 = 10
    T__10 = 11
    T__11 = 12
    ROOT = 13
    CURRENT = 14
    SINGLE_DOT = 15
    DOUBLE_DOT = 16
    LETTER = 17
    STRING = 18
    INT = 19
    WS = 20

    def __init__(self, input: TokenStream, output: TextIO = sys.stdout):
        super().__init__(input, output)
        self.checkVersion("4.8")
        self._interp = ParserATNSimulator(
            self, self.atn, self.decisionsToDFA, self.sharedContextCache)
        self._predicates = None

    class JsonpathContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def ROOT(self):
            return self.getToken(JSONPathParser.ROOT, 0)

        def EOF(self):
            return self.getToken(JSONPathParser.EOF, 0)

        def expression(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(
                    JSONPathParser.ExpressionContext)
            else:
                return self.getTypedRuleContext(
                    JSONPathParser.ExpressionContext, i)

        def getRuleIndex(self):
            return JSONPathParser.RULE_jsonpath

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterJsonpath"):
                listener.enterJsonpath(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitJsonpath"):
                listener.exitJsonpath(self)

    def jsonpath(self):

        localctx = JSONPathParser.JsonpathContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_jsonpath)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 32
            self.match(JSONPathParser.ROOT)
            self.state = 36
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (
                (
                    (_la) & ~0x3f) == 0 and (
                    (1 << _la) & (
                        (1 << JSONPathParser.T__0) | (
                    1 << JSONPathParser.T__11) | (
                        1 << JSONPathParser.SINGLE_DOT) | (
                    1 << JSONPathParser.DOUBLE_DOT))) != 0):
                self.state = 33
                self.expression()
                self.state = 38
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 39
            self.match(JSONPathParser.EOF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExpressionContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def singleDotExpression(self):
            return self.getTypedRuleContext(
                JSONPathParser.SingleDotExpressionContext, 0)

        def doubleDotExpression(self):
            return self.getTypedRuleContext(
                JSONPathParser.DoubleDotExpressionContext, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_expression

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterExpression"):
                listener.enterExpression(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitExpression"):
                listener.exitExpression(self)

    def expression(self):

        localctx = JSONPathParser.ExpressionContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_expression)
        try:
            self.state = 43
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [JSONPathParser.T__0, JSONPathParser.T__11,
                         JSONPathParser.SINGLE_DOT]:
                self.enterOuterAlt(localctx, 1)
                self.state = 41
                self.singleDotExpression()
                pass
            elif token in [JSONPathParser.DOUBLE_DOT]:
                self.enterOuterAlt(localctx, 2)
                self.state = 42
                self.doubleDotExpression()
                pass
            else:
                raise NoViableAltException(self)

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DoubleDotExpressionContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def DOUBLE_DOT(self):
            return self.getToken(JSONPathParser.DOUBLE_DOT, 0)

        def field(self):
            return self.getTypedRuleContext(JSONPathParser.FieldContext, 0)

        def bracketField(self):
            return self.getTypedRuleContext(
                JSONPathParser.BracketFieldContext, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_doubleDotExpression

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterDoubleDotExpression"):
                listener.enterDoubleDotExpression(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitDoubleDotExpression"):
                listener.exitDoubleDotExpression(self)

    def doubleDotExpression(self):

        localctx = JSONPathParser.DoubleDotExpressionContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_doubleDotExpression)
        try:
            self.state = 49
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 2, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 45
                self.match(JSONPathParser.DOUBLE_DOT)
                self.state = 46
                self.field()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 47
                self.match(JSONPathParser.DOUBLE_DOT)
                self.state = 48
                self.bracketField()
                pass

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SingleDotExpressionContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def fieldAccessor(self):
            return self.getTypedRuleContext(
                JSONPathParser.FieldAccessorContext, 0)

        def SINGLE_DOT(self):
            return self.getToken(JSONPathParser.SINGLE_DOT, 0)

        def wildcard(self):
            return self.getTypedRuleContext(JSONPathParser.WildcardContext, 0)

        def bracketWildcard(self):
            return self.getTypedRuleContext(
                JSONPathParser.BracketWildcardContext, 0)

        def filters(self):
            return self.getTypedRuleContext(JSONPathParser.FiltersContext, 0)

        def arraySlice(self):
            return self.getTypedRuleContext(
                JSONPathParser.ArraySliceContext, 0)

        def union(self):
            return self.getTypedRuleContext(JSONPathParser.UnionContext, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_singleDotExpression

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterSingleDotExpression"):
                listener.enterSingleDotExpression(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitSingleDotExpression"):
                listener.exitSingleDotExpression(self)

    def singleDotExpression(self):

        localctx = JSONPathParser.SingleDotExpressionContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_singleDotExpression)
        self._la = 0  # Token type
        try:
            self.state = 70
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 7, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 51
                self.fieldAccessor()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 52
                self.match(JSONPathParser.SINGLE_DOT)
                self.state = 53
                self.wildcard()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 55
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == JSONPathParser.SINGLE_DOT:
                    self.state = 54
                    self.match(JSONPathParser.SINGLE_DOT)

                self.state = 57
                self.bracketWildcard()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 59
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == JSONPathParser.SINGLE_DOT:
                    self.state = 58
                    self.match(JSONPathParser.SINGLE_DOT)

                self.state = 61
                self.filters()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 63
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == JSONPathParser.SINGLE_DOT:
                    self.state = 62
                    self.match(JSONPathParser.SINGLE_DOT)

                self.state = 65
                self.arraySlice()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 67
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == JSONPathParser.SINGLE_DOT:
                    self.state = 66
                    self.match(JSONPathParser.SINGLE_DOT)

                self.state = 69
                self.union()
                pass

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FiltersContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def numericFilter(self):
            return self.getTypedRuleContext(
                JSONPathParser.NumericFilterContext, 0)

        def stringFilter(self):
            return self.getTypedRuleContext(
                JSONPathParser.StringFilterContext, 0)

        def booleanFilter(self):
            return self.getTypedRuleContext(
                JSONPathParser.BooleanFilterContext, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_filters

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterFilters"):
                listener.enterFilters(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitFilters"):
                listener.exitFilters(self)

    def filters(self):

        localctx = JSONPathParser.FiltersContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_filters)
        try:
            self.state = 93
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 8, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 72
                self.match(JSONPathParser.T__0)
                self.state = 73
                self.match(JSONPathParser.T__1)
                self.state = 74
                self.match(JSONPathParser.T__2)
                self.state = 75
                self.numericFilter()
                self.state = 76
                self.match(JSONPathParser.T__3)
                self.state = 77
                self.match(JSONPathParser.T__4)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 79
                self.match(JSONPathParser.T__0)
                self.state = 80
                self.match(JSONPathParser.T__1)
                self.state = 81
                self.match(JSONPathParser.T__2)
                self.state = 82
                self.stringFilter()
                self.state = 83
                self.match(JSONPathParser.T__3)
                self.state = 84
                self.match(JSONPathParser.T__4)
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 86
                self.match(JSONPathParser.T__0)
                self.state = 87
                self.match(JSONPathParser.T__1)
                self.state = 88
                self.match(JSONPathParser.T__2)
                self.state = 89
                self.booleanFilter()
                self.state = 90
                self.match(JSONPathParser.T__3)
                self.state = 91
                self.match(JSONPathParser.T__4)
                pass

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class NumericFilterContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def CURRENT(self):
            return self.getToken(JSONPathParser.CURRENT, 0)

        def fieldAccessor(self):
            return self.getTypedRuleContext(
                JSONPathParser.FieldAccessorContext, 0)

        def INT(self):
            return self.getToken(JSONPathParser.INT, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_numericFilter

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterNumericFilter"):
                listener.enterNumericFilter(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitNumericFilter"):
                listener.exitNumericFilter(self)

    def numericFilter(self):

        localctx = JSONPathParser.NumericFilterContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_numericFilter)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 95
            self.match(JSONPathParser.CURRENT)
            self.state = 96
            self.fieldAccessor()
            self.state = 97
            _la = self._input.LA(1)
            if not (
                (((_la) & ~0x3f) == 0 and (
                    (1 << _la) & (
                        (1 << JSONPathParser.T__5) | (
                            1 << JSONPathParser.T__6) | (
                    1 << JSONPathParser.T__7))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 98
            self.match(JSONPathParser.INT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StringFilterContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def CURRENT(self):
            return self.getToken(JSONPathParser.CURRENT, 0)

        def fieldAccessor(self):
            return self.getTypedRuleContext(
                JSONPathParser.FieldAccessorContext, 0)

        def STRING(self):
            return self.getToken(JSONPathParser.STRING, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_stringFilter

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterStringFilter"):
                listener.enterStringFilter(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitStringFilter"):
                listener.exitStringFilter(self)

    def stringFilter(self):

        localctx = JSONPathParser.StringFilterContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_stringFilter)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 100
            self.match(JSONPathParser.CURRENT)
            self.state = 101
            self.fieldAccessor()
            self.state = 102
            self.match(JSONPathParser.T__7)
            self.state = 103
            self.match(JSONPathParser.STRING)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BooleanFilterContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def CURRENT(self):
            return self.getToken(JSONPathParser.CURRENT, 0)

        def fieldAccessor(self):
            return self.getTypedRuleContext(
                JSONPathParser.FieldAccessorContext, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_booleanFilter

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterBooleanFilter"):
                listener.enterBooleanFilter(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitBooleanFilter"):
                listener.exitBooleanFilter(self)

    def booleanFilter(self):

        localctx = JSONPathParser.BooleanFilterContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_booleanFilter)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 105
            self.match(JSONPathParser.CURRENT)
            self.state = 106
            self.fieldAccessor()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class UnionContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def STRING(self, i: int = None):
            if i is None:
                return self.getTokens(JSONPathParser.STRING)
            else:
                return self.getToken(JSONPathParser.STRING, i)

        def LETTER(self, i: int = None):
            if i is None:
                return self.getTokens(JSONPathParser.LETTER)
            else:
                return self.getToken(JSONPathParser.LETTER, i)

        def getRuleIndex(self):
            return JSONPathParser.RULE_union

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterUnion"):
                listener.enterUnion(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitUnion"):
                listener.exitUnion(self)

    def union(self):

        localctx = JSONPathParser.UnionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_union)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 108
            self.match(JSONPathParser.T__0)
            self.state = 109
            _la = self._input.LA(1)
            if not (_la == JSONPathParser.LETTER or _la ==
                    JSONPathParser.STRING):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 112
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 110
                self.match(JSONPathParser.T__8)
                self.state = 111
                _la = self._input.LA(1)
                if not (_la == JSONPathParser.LETTER or _la ==
                        JSONPathParser.STRING):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 114
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la == JSONPathParser.T__8):
                    break

            self.state = 116
            self.match(JSONPathParser.T__4)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ArraySliceContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def INT(self, i: int = None):
            if i is None:
                return self.getTokens(JSONPathParser.INT)
            else:
                return self.getToken(JSONPathParser.INT, i)

        def getRuleIndex(self):
            return JSONPathParser.RULE_arraySlice

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterArraySlice"):
                listener.enterArraySlice(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitArraySlice"):
                listener.exitArraySlice(self)

    def arraySlice(self):

        localctx = JSONPathParser.ArraySliceContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_arraySlice)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 118
            self.match(JSONPathParser.T__0)
            self.state = 120
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == JSONPathParser.INT:
                self.state = 119
                self.match(JSONPathParser.INT)

            self.state = 122
            self.match(JSONPathParser.T__9)
            self.state = 124
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == JSONPathParser.INT:
                self.state = 123
                self.match(JSONPathParser.INT)

            self.state = 128
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == JSONPathParser.T__9:
                self.state = 126
                self.match(JSONPathParser.T__9)
                self.state = 127
                self.match(JSONPathParser.INT)

            self.state = 130
            self.match(JSONPathParser.T__4)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FieldAccessorContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def SINGLE_DOT(self):
            return self.getToken(JSONPathParser.SINGLE_DOT, 0)

        def field(self):
            return self.getTypedRuleContext(JSONPathParser.FieldContext, 0)

        def bracketField(self):
            return self.getTypedRuleContext(
                JSONPathParser.BracketFieldContext, 0)

        def arrayIndex(self):
            return self.getTypedRuleContext(
                JSONPathParser.ArrayIndexContext, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_fieldAccessor

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterFieldAccessor"):
                listener.enterFieldAccessor(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitFieldAccessor"):
                listener.exitFieldAccessor(self)

    def fieldAccessor(self):

        localctx = JSONPathParser.FieldAccessorContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_fieldAccessor)
        self._la = 0  # Token type
        try:
            self.state = 142
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 15, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 132
                self.match(JSONPathParser.SINGLE_DOT)
                self.state = 133
                self.field()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 135
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == JSONPathParser.SINGLE_DOT:
                    self.state = 134
                    self.match(JSONPathParser.SINGLE_DOT)

                self.state = 137
                self.bracketField()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 139
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == JSONPathParser.SINGLE_DOT:
                    self.state = 138
                    self.match(JSONPathParser.SINGLE_DOT)

                self.state = 141
                self.arrayIndex()
                pass

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FieldContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def LETTER(self):
            return self.getToken(JSONPathParser.LETTER, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_field

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterField"):
                listener.enterField(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitField"):
                listener.exitField(self)

    def field(self):

        localctx = JSONPathParser.FieldContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_field)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 144
            self.match(JSONPathParser.LETTER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BracketFieldContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def STRING(self):
            return self.getToken(JSONPathParser.STRING, 0)

        def LETTER(self):
            return self.getToken(JSONPathParser.LETTER, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_bracketField

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterBracketField"):
                listener.enterBracketField(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitBracketField"):
                listener.exitBracketField(self)

    def bracketField(self):

        localctx = JSONPathParser.BracketFieldContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_bracketField)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 146
            self.match(JSONPathParser.T__0)
            self.state = 147
            _la = self._input.LA(1)
            if not (_la == JSONPathParser.LETTER or _la ==
                    JSONPathParser.STRING):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 148
            self.match(JSONPathParser.T__4)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ArrayIndexContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def INT(self):
            return self.getToken(JSONPathParser.INT, 0)

        def getRuleIndex(self):
            return JSONPathParser.RULE_arrayIndex

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterArrayIndex"):
                listener.enterArrayIndex(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitArrayIndex"):
                listener.exitArrayIndex(self)

    def arrayIndex(self):

        localctx = JSONPathParser.ArrayIndexContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_arrayIndex)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 150
            self.match(JSONPathParser.T__0)
            self.state = 151
            self.match(JSONPathParser.INT)
            self.state = 152
            self.match(JSONPathParser.T__4)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class WildcardContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def getRuleIndex(self):
            return JSONPathParser.RULE_wildcard

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterWildcard"):
                listener.enterWildcard(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitWildcard"):
                listener.exitWildcard(self)

    def wildcard(self):

        localctx = JSONPathParser.WildcardContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_wildcard)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 154
            self.match(JSONPathParser.T__10)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BracketWildcardContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None,
                     invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def getRuleIndex(self):
            return JSONPathParser.RULE_bracketWildcard

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterBracketWildcard"):
                listener.enterBracketWildcard(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitBracketWildcard"):
                listener.exitBracketWildcard(self)

    def bracketWildcard(self):

        localctx = JSONPathParser.BracketWildcardContext(
            self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_bracketWildcard)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 156
            self.match(JSONPathParser.T__11)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx
