# Generated from gsl/grammar/G4Visitor.g4 by ANTLR 4.7
# encoding: utf-8
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys

def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\31")
        buf.write("\u00c8\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\3\2\3\2\3\2\3\2\3\2\3\2\3\2\7\2$\n\2\f\2\16\2\'")
        buf.write("\13\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4")
        buf.write("\3\4\7\4\66\n\4\f\4\16\49\13\4\3\4\5\4<\n\4\5\4>\n\4\3")
        buf.write("\4\3\4\3\4\3\4\3\4\3\4\7\4F\n\4\f\4\16\4I\13\4\3\4\5\4")
        buf.write("L\n\4\5\4N\n\4\3\4\3\4\3\4\3\4\3\4\7\4U\n\4\f\4\16\4X")
        buf.write("\13\4\3\4\5\4[\n\4\5\4]\n\4\3\4\5\4`\n\4\3\5\3\5\3\5\3")
        buf.write("\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5l\n\5\3\6\3\6\3\6\3\6\3")
        buf.write("\6\5\6s\n\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\5")
        buf.write("\7\177\n\7\3\b\3\b\3\b\3\b\3\b\3\b\6\b\u0087\n\b\r\b\16")
        buf.write("\b\u0088\3\b\3\b\3\b\3\b\3\b\6\b\u0090\n\b\r\b\16\b\u0091")
        buf.write("\5\b\u0094\n\b\3\b\3\b\3\b\3\b\3\b\3\b\6\b\u009c\n\b\r")
        buf.write("\b\16\b\u009d\3\b\3\b\5\b\u00a2\n\b\3\b\3\b\5\b\u00a6")
        buf.write("\n\b\3\b\5\b\u00a9\n\b\5\b\u00ab\n\b\3\b\3\b\5\b\u00af")
        buf.write("\n\b\3\b\5\b\u00b2\n\b\3\b\3\b\5\b\u00b6\n\b\5\b\u00b8")
        buf.write("\n\b\3\t\3\t\3\n\3\n\3\13\3\13\5\13\u00c0\n\13\3\f\3\f")
        buf.write("\3\r\3\r\3\16\3\16\3\16\2\2\17\2\4\6\b\n\f\16\20\22\24")
        buf.write("\26\30\32\2\3\4\2\3\5\24\24\2\u00db\2\34\3\2\2\2\4*\3")
        buf.write("\2\2\2\6_\3\2\2\2\bk\3\2\2\2\nr\3\2\2\2\f~\3\2\2\2\16")
        buf.write("\u00b7\3\2\2\2\20\u00b9\3\2\2\2\22\u00bb\3\2\2\2\24\u00bf")
        buf.write("\3\2\2\2\26\u00c1\3\2\2\2\30\u00c3\3\2\2\2\32\u00c5\3")
        buf.write("\2\2\2\34\35\7\3\2\2\35\36\5\24\13\2\36\37\7\4\2\2\37")
        buf.write(" \7\5\2\2 !\5\24\13\2!%\7\13\2\2\"$\5\4\3\2#\"\3\2\2\2")
        buf.write("$\'\3\2\2\2%#\3\2\2\2%&\3\2\2\2&(\3\2\2\2\'%\3\2\2\2(")
        buf.write(")\7\2\2\3)\3\3\2\2\2*+\5\26\f\2+,\7\f\2\2,-\5\6\4\2-.")
        buf.write("\7\13\2\2.\5\3\2\2\2/`\5\16\b\2\60\61\5\24\13\2\61=\7")
        buf.write("\16\2\2\62\67\5\b\5\2\63\64\7\6\2\2\64\66\5\b\5\2\65\63")
        buf.write("\3\2\2\2\669\3\2\2\2\67\65\3\2\2\2\678\3\2\2\28;\3\2\2")
        buf.write("\29\67\3\2\2\2:<\7\6\2\2;:\3\2\2\2;<\3\2\2\2<>\3\2\2\2")
        buf.write("=\62\3\2\2\2=>\3\2\2\2>?\3\2\2\2?@\7\17\2\2@`\3\2\2\2")
        buf.write("AM\7\20\2\2BG\5\n\6\2CD\7\6\2\2DF\5\n\6\2EC\3\2\2\2FI")
        buf.write("\3\2\2\2GE\3\2\2\2GH\3\2\2\2HK\3\2\2\2IG\3\2\2\2JL\7\6")
        buf.write("\2\2KJ\3\2\2\2KL\3\2\2\2LN\3\2\2\2MB\3\2\2\2MN\3\2\2\2")
        buf.write("NO\3\2\2\2O`\7\21\2\2P\\\7\22\2\2QV\5\f\7\2RS\7\6\2\2")
        buf.write("SU\5\f\7\2TR\3\2\2\2UX\3\2\2\2VT\3\2\2\2VW\3\2\2\2WZ\3")
        buf.write("\2\2\2XV\3\2\2\2Y[\7\6\2\2ZY\3\2\2\2Z[\3\2\2\2[]\3\2\2")
        buf.write("\2\\Q\3\2\2\2\\]\3\2\2\2]^\3\2\2\2^`\7\23\2\2_/\3\2\2")
        buf.write("\2_\60\3\2\2\2_A\3\2\2\2_P\3\2\2\2`\7\3\2\2\2ab\5\24\13")
        buf.write("\2bc\7\f\2\2cd\5\16\b\2dl\3\2\2\2ef\5\24\13\2fg\7\f\2")
        buf.write("\2gh\7\20\2\2hi\5\16\b\2ij\7\21\2\2jl\3\2\2\2ka\3\2\2")
        buf.write("\2ke\3\2\2\2l\t\3\2\2\2ms\5\16\b\2no\7\20\2\2op\5\16\b")
        buf.write("\2pq\7\21\2\2qs\3\2\2\2rm\3\2\2\2rn\3\2\2\2s\13\3\2\2")
        buf.write("\2tu\5\24\13\2uv\7\b\2\2vw\5\16\b\2w\177\3\2\2\2xy\5\24")
        buf.write("\13\2yz\7\b\2\2z{\7\20\2\2{|\5\16\b\2|}\7\21\2\2}\177")
        buf.write("\3\2\2\2~t\3\2\2\2~x\3\2\2\2\177\r\3\2\2\2\u0080\u0094")
        buf.write("\7\7\2\2\u0081\u0094\5\26\f\2\u0082\u0083\7\16\2\2\u0083")
        buf.write("\u0086\5\26\f\2\u0084\u0085\7\r\2\2\u0085\u0087\5\26\f")
        buf.write("\2\u0086\u0084\3\2\2\2\u0087\u0088\3\2\2\2\u0088\u0086")
        buf.write("\3\2\2\2\u0088\u0089\3\2\2\2\u0089\u008a\3\2\2\2\u008a")
        buf.write("\u008b\7\17\2\2\u008b\u0094\3\2\2\2\u008c\u008f\5\26\f")
        buf.write("\2\u008d\u008e\7\r\2\2\u008e\u0090\5\26\f\2\u008f\u008d")
        buf.write("\3\2\2\2\u0090\u0091\3\2\2\2\u0091\u008f\3\2\2\2\u0091")
        buf.write("\u0092\3\2\2\2\u0092\u0094\3\2\2\2\u0093\u0080\3\2\2\2")
        buf.write("\u0093\u0081\3\2\2\2\u0093\u0082\3\2\2\2\u0093\u008c\3")
        buf.write("\2\2\2\u0094\u00ab\3\2\2\2\u0095\u00a2\7\7\2\2\u0096\u00a2")
        buf.write("\5\26\f\2\u0097\u0098\7\16\2\2\u0098\u009b\5\26\f\2\u0099")
        buf.write("\u009a\7\r\2\2\u009a\u009c\5\26\f\2\u009b\u0099\3\2\2")
        buf.write("\2\u009c\u009d\3\2\2\2\u009d\u009b\3\2\2\2\u009d\u009e")
        buf.write("\3\2\2\2\u009e\u009f\3\2\2\2\u009f\u00a0\7\17\2\2\u00a0")
        buf.write("\u00a2\3\2\2\2\u00a1\u0095\3\2\2\2\u00a1\u0096\3\2\2\2")
        buf.write("\u00a1\u0097\3\2\2\2\u00a2\u00a8\3\2\2\2\u00a3\u00a5\7")
        buf.write("\t\2\2\u00a4\u00a6\7\n\2\2\u00a5\u00a4\3\2\2\2\u00a5\u00a6")
        buf.write("\3\2\2\2\u00a6\u00a9\3\2\2\2\u00a7\u00a9\7\n\2\2\u00a8")
        buf.write("\u00a3\3\2\2\2\u00a8\u00a7\3\2\2\2\u00a9\u00ab\3\2\2\2")
        buf.write("\u00aa\u0093\3\2\2\2\u00aa\u00a1\3\2\2\2\u00ab\u00b8\3")
        buf.write("\2\2\2\u00ac\u00ae\5\30\r\2\u00ad\u00af\7\t\2\2\u00ae")
        buf.write("\u00ad\3\2\2\2\u00ae\u00af\3\2\2\2\u00af\u00b1\3\2\2\2")
        buf.write("\u00b0\u00b2\7\n\2\2\u00b1\u00b0\3\2\2\2\u00b1\u00b2\3")
        buf.write("\2\2\2\u00b2\u00b8\3\2\2\2\u00b3\u00b5\5\32\16\2\u00b4")
        buf.write("\u00b6\7\n\2\2\u00b5\u00b4\3\2\2\2\u00b5\u00b6\3\2\2\2")
        buf.write("\u00b6\u00b8\3\2\2\2\u00b7\u00aa\3\2\2\2\u00b7\u00ac\3")
        buf.write("\2\2\2\u00b7\u00b3\3\2\2\2\u00b8\17\3\2\2\2\u00b9\u00ba")
        buf.write("\t\2\2\2\u00ba\21\3\2\2\2\u00bb\u00bc\7\25\2\2\u00bc\23")
        buf.write("\3\2\2\2\u00bd\u00c0\5\20\t\2\u00be\u00c0\5\22\n\2\u00bf")
        buf.write("\u00bd\3\2\2\2\u00bf\u00be\3\2\2\2\u00c0\25\3\2\2\2\u00c1")
        buf.write("\u00c2\5\20\t\2\u00c2\27\3\2\2\2\u00c3\u00c4\5\22\n\2")
        buf.write("\u00c4\31\3\2\2\2\u00c5\u00c6\7\26\2\2\u00c6\33\3\2\2")
        buf.write("\2\35%\67;=GKMVZ\\_kr~\u0088\u0091\u0093\u009d\u00a1\u00a5")
        buf.write("\u00a8\u00aa\u00ae\u00b1\u00b5\u00b7\u00bf")
        return buf.getvalue()


class G4VisitorParser ( Parser ):

    grammarFileName = "G4Visitor.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'visitor'", "'for'", "'grammar'", "','", 
                     "'.'", "':'", "'*'", "'?'", "';'", "'='", "'|'", "'('", 
                     "')'", "'['", "']'", "'{'", "'}'" ]

    symbolicNames = [ "<INVALID>", "VISITOR", "FOR", "GRAMMAR", "COMMA", 
                      "DOT", "COLON", "STAR", "QUESTION", "SEMI", "EQUALS", 
                      "OR", "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", 
                      "LBRACE", "RBRACE", "LC_NAME", "UC_NAME", "ATTRIBUTE_REF", 
                      "NUMBER", "COMMENT", "WS" ]

    RULE_visitor = 0
    RULE_visitorRule = 1
    RULE_body = 2
    RULE_objectParam = 3
    RULE_listItem = 4
    RULE_dictItem = 5
    RULE_expr = 6
    RULE_lcName = 7
    RULE_ucName = 8
    RULE_identifier = 9
    RULE_ruleName = 10
    RULE_tokenName = 11
    RULE_attributeRef = 12

    ruleNames =  [ "visitor", "visitorRule", "body", "objectParam", "listItem", 
                   "dictItem", "expr", "lcName", "ucName", "identifier", 
                   "ruleName", "tokenName", "attributeRef" ]

    EOF = Token.EOF
    VISITOR=1
    FOR=2
    GRAMMAR=3
    COMMA=4
    DOT=5
    COLON=6
    STAR=7
    QUESTION=8
    SEMI=9
    EQUALS=10
    OR=11
    LPAREN=12
    RPAREN=13
    LBRACKET=14
    RBRACKET=15
    LBRACE=16
    RBRACE=17
    LC_NAME=18
    UC_NAME=19
    ATTRIBUTE_REF=20
    NUMBER=21
    COMMENT=22
    WS=23

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



    class VisitorContext(ParserRuleContext):

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

        def VISITOR(self):
            return self.getToken(G4VisitorParser.VISITOR, 0)

        def FOR(self):
            return self.getToken(G4VisitorParser.FOR, 0)

        def GRAMMAR(self):
            return self.getToken(G4VisitorParser.GRAMMAR, 0)

        def SEMI(self):
            return self.getToken(G4VisitorParser.SEMI, 0)

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

        def identifier(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(G4VisitorParser.IdentifierContext)
            else:
                return self.getTypedRuleContext(G4VisitorParser.IdentifierContext,i)


        def visitorRule(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(G4VisitorParser.VisitorRuleContext)
            else:
                return self.getTypedRuleContext(G4VisitorParser.VisitorRuleContext,i)


        def getRuleIndex(self):
            return G4VisitorParser.RULE_visitor

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitVisitor" ):
                return visitor.visitVisitor(self)
            else:
                return visitor.visitChildren(self)




    def visitor(self):

        localctx = G4VisitorParser.VisitorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_visitor)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 26
            self.match(G4VisitorParser.VISITOR)
            self.state = 27
            localctx.name = self.identifier()
            self.state = 28
            self.match(G4VisitorParser.FOR)
            self.state = 29
            self.match(G4VisitorParser.GRAMMAR)
            self.state = 30
            localctx.grammarName = self.identifier()
            self.state = 31
            self.match(G4VisitorParser.SEMI)
            self.state = 35
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << G4VisitorParser.VISITOR) | (1 << G4VisitorParser.FOR) | (1 << G4VisitorParser.GRAMMAR) | (1 << G4VisitorParser.LC_NAME))) != 0):
                self.state = 32
                self.visitorRule()
                self.state = 37
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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

    class VisitorRuleContext(ParserRuleContext):

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

        def ruleName(self):
            return self.getTypedRuleContext(G4VisitorParser.RuleNameContext,0)


        def EQUALS(self):
            return self.getToken(G4VisitorParser.EQUALS, 0)

        def body(self):
            return self.getTypedRuleContext(G4VisitorParser.BodyContext,0)


        def SEMI(self):
            return self.getToken(G4VisitorParser.SEMI, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_visitorRule

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitVisitorRule" ):
                return visitor.visitVisitorRule(self)
            else:
                return visitor.visitChildren(self)




    def visitorRule(self):

        localctx = G4VisitorParser.VisitorRuleContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_visitorRule)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 40
            self.ruleName()
            self.state = 41
            self.match(G4VisitorParser.EQUALS)
            self.state = 42
            self.body()
            self.state = 43
            self.match(G4VisitorParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BodyContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return G4VisitorParser.RULE_body

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class ExprBodyContext(BodyContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.BodyContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def expr(self):
            return self.getTypedRuleContext(G4VisitorParser.ExprContext,0)


        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprBody" ):
                return visitor.visitExprBody(self)
            else:
                return visitor.visitChildren(self)


    class ListBodyContext(BodyContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.BodyContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def LBRACKET(self):
            return self.getToken(G4VisitorParser.LBRACKET, 0)
        def RBRACKET(self):
            return self.getToken(G4VisitorParser.RBRACKET, 0)
        def listItem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(G4VisitorParser.ListItemContext)
            else:
                return self.getTypedRuleContext(G4VisitorParser.ListItemContext,i)

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitListBody" ):
                return visitor.visitListBody(self)
            else:
                return visitor.visitChildren(self)


    class DictBodyContext(BodyContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.BodyContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def LBRACE(self):
            return self.getToken(G4VisitorParser.LBRACE, 0)
        def RBRACE(self):
            return self.getToken(G4VisitorParser.RBRACE, 0)
        def dictItem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(G4VisitorParser.DictItemContext)
            else:
                return self.getTypedRuleContext(G4VisitorParser.DictItemContext,i)

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitDictBody" ):
                return visitor.visitDictBody(self)
            else:
                return visitor.visitChildren(self)


    class ObjectBodyContext(BodyContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.BodyContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def identifier(self):
            return self.getTypedRuleContext(G4VisitorParser.IdentifierContext,0)

        def LPAREN(self):
            return self.getToken(G4VisitorParser.LPAREN, 0)
        def RPAREN(self):
            return self.getToken(G4VisitorParser.RPAREN, 0)
        def objectParam(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(G4VisitorParser.ObjectParamContext)
            else:
                return self.getTypedRuleContext(G4VisitorParser.ObjectParamContext,i)

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitObjectBody" ):
                return visitor.visitObjectBody(self)
            else:
                return visitor.visitChildren(self)



    def body(self):

        localctx = G4VisitorParser.BodyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_body)
        self._la = 0 # Token type
        try:
            self.state = 93
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,10,self._ctx)
            if la_ == 1:
                localctx = G4VisitorParser.ExprBodyContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 45
                self.expr()
                pass

            elif la_ == 2:
                localctx = G4VisitorParser.ObjectBodyContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 46
                self.identifier()
                self.state = 47
                self.match(G4VisitorParser.LPAREN)
                self.state = 59
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << G4VisitorParser.VISITOR) | (1 << G4VisitorParser.FOR) | (1 << G4VisitorParser.GRAMMAR) | (1 << G4VisitorParser.LC_NAME) | (1 << G4VisitorParser.UC_NAME))) != 0):
                    self.state = 48
                    self.objectParam()
                    self.state = 53
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,1,self._ctx)
                    while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                        if _alt==1:
                            self.state = 49
                            self.match(G4VisitorParser.COMMA)
                            self.state = 50
                            self.objectParam() 
                        self.state = 55
                        self._errHandler.sync(self)
                        _alt = self._interp.adaptivePredict(self._input,1,self._ctx)

                    self.state = 57
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==G4VisitorParser.COMMA:
                        self.state = 56
                        self.match(G4VisitorParser.COMMA)




                self.state = 61
                self.match(G4VisitorParser.RPAREN)
                pass

            elif la_ == 3:
                localctx = G4VisitorParser.ListBodyContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 63
                self.match(G4VisitorParser.LBRACKET)
                self.state = 75
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << G4VisitorParser.VISITOR) | (1 << G4VisitorParser.FOR) | (1 << G4VisitorParser.GRAMMAR) | (1 << G4VisitorParser.DOT) | (1 << G4VisitorParser.LPAREN) | (1 << G4VisitorParser.LBRACKET) | (1 << G4VisitorParser.LC_NAME) | (1 << G4VisitorParser.UC_NAME) | (1 << G4VisitorParser.ATTRIBUTE_REF))) != 0):
                    self.state = 64
                    self.listItem()
                    self.state = 69
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,4,self._ctx)
                    while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                        if _alt==1:
                            self.state = 65
                            self.match(G4VisitorParser.COMMA)
                            self.state = 66
                            self.listItem() 
                        self.state = 71
                        self._errHandler.sync(self)
                        _alt = self._interp.adaptivePredict(self._input,4,self._ctx)

                    self.state = 73
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==G4VisitorParser.COMMA:
                        self.state = 72
                        self.match(G4VisitorParser.COMMA)




                self.state = 77
                self.match(G4VisitorParser.RBRACKET)
                pass

            elif la_ == 4:
                localctx = G4VisitorParser.DictBodyContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 78
                self.match(G4VisitorParser.LBRACE)
                self.state = 90
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << G4VisitorParser.VISITOR) | (1 << G4VisitorParser.FOR) | (1 << G4VisitorParser.GRAMMAR) | (1 << G4VisitorParser.LC_NAME) | (1 << G4VisitorParser.UC_NAME))) != 0):
                    self.state = 79
                    self.dictItem()
                    self.state = 84
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,7,self._ctx)
                    while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                        if _alt==1:
                            self.state = 80
                            self.match(G4VisitorParser.COMMA)
                            self.state = 81
                            self.dictItem() 
                        self.state = 86
                        self._errHandler.sync(self)
                        _alt = self._interp.adaptivePredict(self._input,7,self._ctx)

                    self.state = 88
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==G4VisitorParser.COMMA:
                        self.state = 87
                        self.match(G4VisitorParser.COMMA)




                self.state = 92
                self.match(G4VisitorParser.RBRACE)
                pass


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

    class ObjectParamContext(ParserRuleContext):

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

        def identifier(self):
            return self.getTypedRuleContext(G4VisitorParser.IdentifierContext,0)


        def EQUALS(self):
            return self.getToken(G4VisitorParser.EQUALS, 0)

        def expr(self):
            return self.getTypedRuleContext(G4VisitorParser.ExprContext,0)


        def LBRACKET(self):
            return self.getToken(G4VisitorParser.LBRACKET, 0)

        def RBRACKET(self):
            return self.getToken(G4VisitorParser.RBRACKET, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_objectParam

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitObjectParam" ):
                return visitor.visitObjectParam(self)
            else:
                return visitor.visitChildren(self)




    def objectParam(self):

        localctx = G4VisitorParser.ObjectParamContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_objectParam)
        try:
            self.state = 105
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 95
                self.identifier()
                self.state = 96
                self.match(G4VisitorParser.EQUALS)
                self.state = 97
                self.expr()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 99
                self.identifier()
                self.state = 100
                self.match(G4VisitorParser.EQUALS)
                self.state = 101
                self.match(G4VisitorParser.LBRACKET)
                self.state = 102
                self.expr()
                self.state = 103
                self.match(G4VisitorParser.RBRACKET)
                pass


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

    class ListItemContext(ParserRuleContext):

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

        def expr(self):
            return self.getTypedRuleContext(G4VisitorParser.ExprContext,0)


        def LBRACKET(self):
            return self.getToken(G4VisitorParser.LBRACKET, 0)

        def RBRACKET(self):
            return self.getToken(G4VisitorParser.RBRACKET, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_listItem

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitListItem" ):
                return visitor.visitListItem(self)
            else:
                return visitor.visitChildren(self)




    def listItem(self):

        localctx = G4VisitorParser.ListItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_listItem)
        try:
            self.state = 112
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [G4VisitorParser.VISITOR, G4VisitorParser.FOR, G4VisitorParser.GRAMMAR, G4VisitorParser.DOT, G4VisitorParser.LPAREN, G4VisitorParser.LC_NAME, G4VisitorParser.UC_NAME, G4VisitorParser.ATTRIBUTE_REF]:
                self.enterOuterAlt(localctx, 1)
                self.state = 107
                self.expr()
                pass
            elif token in [G4VisitorParser.LBRACKET]:
                self.enterOuterAlt(localctx, 2)
                self.state = 108
                self.match(G4VisitorParser.LBRACKET)
                self.state = 109
                self.expr()
                self.state = 110
                self.match(G4VisitorParser.RBRACKET)
                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 DictItemContext(ParserRuleContext):

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

        def identifier(self):
            return self.getTypedRuleContext(G4VisitorParser.IdentifierContext,0)


        def COLON(self):
            return self.getToken(G4VisitorParser.COLON, 0)

        def expr(self):
            return self.getTypedRuleContext(G4VisitorParser.ExprContext,0)


        def LBRACKET(self):
            return self.getToken(G4VisitorParser.LBRACKET, 0)

        def RBRACKET(self):
            return self.getToken(G4VisitorParser.RBRACKET, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_dictItem

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitDictItem" ):
                return visitor.visitDictItem(self)
            else:
                return visitor.visitChildren(self)




    def dictItem(self):

        localctx = G4VisitorParser.DictItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_dictItem)
        try:
            self.state = 124
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 114
                self.identifier()
                self.state = 115
                self.match(G4VisitorParser.COLON)
                self.state = 116
                self.expr()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 118
                self.identifier()
                self.state = 119
                self.match(G4VisitorParser.COLON)
                self.state = 120
                self.match(G4VisitorParser.LBRACKET)
                self.state = 121
                self.expr()
                self.state = 122
                self.match(G4VisitorParser.RBRACKET)
                pass


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

    class ExprContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return G4VisitorParser.RULE_expr

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class TokenExprContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.ExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def tokenName(self):
            return self.getTypedRuleContext(G4VisitorParser.TokenNameContext,0)

        def STAR(self):
            return self.getToken(G4VisitorParser.STAR, 0)
        def QUESTION(self):
            return self.getToken(G4VisitorParser.QUESTION, 0)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitTokenExpr" ):
                return visitor.visitTokenExpr(self)
            else:
                return visitor.visitChildren(self)


    class RefExprContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.ExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def attributeRef(self):
            return self.getTypedRuleContext(G4VisitorParser.AttributeRefContext,0)

        def QUESTION(self):
            return self.getToken(G4VisitorParser.QUESTION, 0)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRefExpr" ):
                return visitor.visitRefExpr(self)
            else:
                return visitor.visitChildren(self)


    class RuleExprContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a G4VisitorParser.ExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def DOT(self):
            return self.getToken(G4VisitorParser.DOT, 0)
        def ruleName(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(G4VisitorParser.RuleNameContext)
            else:
                return self.getTypedRuleContext(G4VisitorParser.RuleNameContext,i)

        def LPAREN(self):
            return self.getToken(G4VisitorParser.LPAREN, 0)
        def RPAREN(self):
            return self.getToken(G4VisitorParser.RPAREN, 0)
        def STAR(self):
            return self.getToken(G4VisitorParser.STAR, 0)
        def QUESTION(self):
            return self.getToken(G4VisitorParser.QUESTION, 0)
        def OR(self, i:int=None):
            if i is None:
                return self.getTokens(G4VisitorParser.OR)
            else:
                return self.getToken(G4VisitorParser.OR, i)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRuleExpr" ):
                return visitor.visitRuleExpr(self)
            else:
                return visitor.visitChildren(self)



    def expr(self):

        localctx = G4VisitorParser.ExprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_expr)
        self._la = 0 # Token type
        try:
            self.state = 181
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [G4VisitorParser.VISITOR, G4VisitorParser.FOR, G4VisitorParser.GRAMMAR, G4VisitorParser.DOT, G4VisitorParser.LPAREN, G4VisitorParser.LC_NAME]:
                localctx = G4VisitorParser.RuleExprContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 168
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,21,self._ctx)
                if la_ == 1:
                    self.state = 145
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,16,self._ctx)
                    if la_ == 1:
                        self.state = 126
                        self.match(G4VisitorParser.DOT)
                        pass

                    elif la_ == 2:
                        self.state = 127
                        self.ruleName()
                        pass

                    elif la_ == 3:
                        self.state = 128
                        self.match(G4VisitorParser.LPAREN)
                        self.state = 129
                        self.ruleName()
                        self.state = 132 
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while True:
                            self.state = 130
                            self.match(G4VisitorParser.OR)
                            self.state = 131
                            self.ruleName()
                            self.state = 134 
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)
                            if not (_la==G4VisitorParser.OR):
                                break

                        self.state = 136
                        self.match(G4VisitorParser.RPAREN)
                        pass

                    elif la_ == 4:
                        self.state = 138
                        self.ruleName()
                        self.state = 141 
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while True:
                            self.state = 139
                            self.match(G4VisitorParser.OR)
                            self.state = 140
                            self.ruleName()
                            self.state = 143 
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)
                            if not (_la==G4VisitorParser.OR):
                                break

                        pass


                    pass

                elif la_ == 2:
                    self.state = 159
                    self._errHandler.sync(self)
                    token = self._input.LA(1)
                    if token in [G4VisitorParser.DOT]:
                        self.state = 147
                        self.match(G4VisitorParser.DOT)
                        pass
                    elif token in [G4VisitorParser.VISITOR, G4VisitorParser.FOR, G4VisitorParser.GRAMMAR, G4VisitorParser.LC_NAME]:
                        self.state = 148
                        self.ruleName()
                        pass
                    elif token in [G4VisitorParser.LPAREN]:
                        self.state = 149
                        self.match(G4VisitorParser.LPAREN)
                        self.state = 150
                        self.ruleName()
                        self.state = 153 
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while True:
                            self.state = 151
                            self.match(G4VisitorParser.OR)
                            self.state = 152
                            self.ruleName()
                            self.state = 155 
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)
                            if not (_la==G4VisitorParser.OR):
                                break

                        self.state = 157
                        self.match(G4VisitorParser.RPAREN)
                        pass
                    else:
                        raise NoViableAltException(self)

                    self.state = 166
                    self._errHandler.sync(self)
                    token = self._input.LA(1)
                    if token in [G4VisitorParser.STAR]:
                        self.state = 161
                        self.match(G4VisitorParser.STAR)
                        self.state = 163
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if _la==G4VisitorParser.QUESTION:
                            self.state = 162
                            self.match(G4VisitorParser.QUESTION)


                        pass
                    elif token in [G4VisitorParser.QUESTION]:
                        self.state = 165
                        self.match(G4VisitorParser.QUESTION)
                        pass
                    else:
                        raise NoViableAltException(self)

                    pass


                pass
            elif token in [G4VisitorParser.UC_NAME]:
                localctx = G4VisitorParser.TokenExprContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 170
                self.tokenName()
                self.state = 172
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==G4VisitorParser.STAR:
                    self.state = 171
                    self.match(G4VisitorParser.STAR)


                self.state = 175
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==G4VisitorParser.QUESTION:
                    self.state = 174
                    self.match(G4VisitorParser.QUESTION)


                pass
            elif token in [G4VisitorParser.ATTRIBUTE_REF]:
                localctx = G4VisitorParser.RefExprContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 177
                self.attributeRef()
                self.state = 179
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==G4VisitorParser.QUESTION:
                    self.state = 178
                    self.match(G4VisitorParser.QUESTION)


                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 LcNameContext(ParserRuleContext):

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

        def LC_NAME(self):
            return self.getToken(G4VisitorParser.LC_NAME, 0)

        def VISITOR(self):
            return self.getToken(G4VisitorParser.VISITOR, 0)

        def FOR(self):
            return self.getToken(G4VisitorParser.FOR, 0)

        def GRAMMAR(self):
            return self.getToken(G4VisitorParser.GRAMMAR, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_lcName

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitLcName" ):
                return visitor.visitLcName(self)
            else:
                return visitor.visitChildren(self)




    def lcName(self):

        localctx = G4VisitorParser.LcNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_lcName)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 183
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << G4VisitorParser.VISITOR) | (1 << G4VisitorParser.FOR) | (1 << G4VisitorParser.GRAMMAR) | (1 << G4VisitorParser.LC_NAME))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class UcNameContext(ParserRuleContext):

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

        def UC_NAME(self):
            return self.getToken(G4VisitorParser.UC_NAME, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_ucName

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitUcName" ):
                return visitor.visitUcName(self)
            else:
                return visitor.visitChildren(self)




    def ucName(self):

        localctx = G4VisitorParser.UcNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_ucName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 185
            self.match(G4VisitorParser.UC_NAME)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IdentifierContext(ParserRuleContext):

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

        def lcName(self):
            return self.getTypedRuleContext(G4VisitorParser.LcNameContext,0)


        def ucName(self):
            return self.getTypedRuleContext(G4VisitorParser.UcNameContext,0)


        def getRuleIndex(self):
            return G4VisitorParser.RULE_identifier

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitIdentifier" ):
                return visitor.visitIdentifier(self)
            else:
                return visitor.visitChildren(self)




    def identifier(self):

        localctx = G4VisitorParser.IdentifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_identifier)
        try:
            self.state = 189
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [G4VisitorParser.VISITOR, G4VisitorParser.FOR, G4VisitorParser.GRAMMAR, G4VisitorParser.LC_NAME]:
                self.enterOuterAlt(localctx, 1)
                self.state = 187
                self.lcName()
                pass
            elif token in [G4VisitorParser.UC_NAME]:
                self.enterOuterAlt(localctx, 2)
                self.state = 188
                self.ucName()
                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 RuleNameContext(ParserRuleContext):

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

        def lcName(self):
            return self.getTypedRuleContext(G4VisitorParser.LcNameContext,0)


        def getRuleIndex(self):
            return G4VisitorParser.RULE_ruleName

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRuleName" ):
                return visitor.visitRuleName(self)
            else:
                return visitor.visitChildren(self)




    def ruleName(self):

        localctx = G4VisitorParser.RuleNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_ruleName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 191
            self.lcName()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class TokenNameContext(ParserRuleContext):

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

        def ucName(self):
            return self.getTypedRuleContext(G4VisitorParser.UcNameContext,0)


        def getRuleIndex(self):
            return G4VisitorParser.RULE_tokenName

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitTokenName" ):
                return visitor.visitTokenName(self)
            else:
                return visitor.visitChildren(self)




    def tokenName(self):

        localctx = G4VisitorParser.TokenNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_tokenName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 193
            self.ucName()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class AttributeRefContext(ParserRuleContext):

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

        def ATTRIBUTE_REF(self):
            return self.getToken(G4VisitorParser.ATTRIBUTE_REF, 0)

        def getRuleIndex(self):
            return G4VisitorParser.RULE_attributeRef

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitAttributeRef" ):
                return visitor.visitAttributeRef(self)
            else:
                return visitor.visitChildren(self)




    def attributeRef(self):

        localctx = G4VisitorParser.AttributeRefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_attributeRef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.match(G4VisitorParser.ATTRIBUTE_REF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx





