# Generated from D:/Programming/Projects/Apitax/apitax/grammar/src\Ah2.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\39")
        buf.write("\u00ad\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\4\22\t\22\4\23\t\23")
        buf.write("\4\24\t\24\4\25\t\25\3\2\3\2\3\2\3\3\6\3/\n\3\r\3\16\3")
        buf.write("\60\3\4\3\4\3\4\3\4\3\4\3\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\5\5E\n\5\3\5\3\5\3\5\3\5\3\5\3")
        buf.write("\5\3\5\3\5\3\5\7\5P\n\5\f\5\16\5S\13\5\3\6\3\6\3\6\3\6")
        buf.write("\3\6\5\6Z\n\6\3\7\3\7\3\7\5\7_\n\7\3\b\3\b\3\b\5\bd\n")
        buf.write("\b\3\t\3\t\3\t\5\ti\n\t\3\n\3\n\3\n\3\13\3\13\3\13\5\13")
        buf.write("q\n\13\3\13\3\13\3\f\3\f\5\fw\n\f\3\f\3\f\3\f\3\r\3\r")
        buf.write("\3\r\3\r\5\r\u0080\n\r\3\16\3\16\3\16\5\16\u0085\n\16")
        buf.write("\3\16\3\16\3\17\3\17\3\20\3\20\3\20\3\20\5\20\u008f\n")
        buf.write("\20\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22")
        buf.write("\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24")
        buf.write("\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\2\3\b\26\2\4")
        buf.write("\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(\2\6\3\2\t\n")
        buf.write("\3\2\7\b\3\2\64\65\3\2\61\62\2\u00b4\2*\3\2\2\2\4.\3\2")
        buf.write("\2\2\69\3\2\2\2\bD\3\2\2\2\nT\3\2\2\2\f^\3\2\2\2\16`\3")
        buf.write("\2\2\2\20e\3\2\2\2\22j\3\2\2\2\24m\3\2\2\2\26t\3\2\2\2")
        buf.write("\30\177\3\2\2\2\32\u0081\3\2\2\2\34\u0088\3\2\2\2\36\u008e")
        buf.write("\3\2\2\2 \u0090\3\2\2\2\"\u0096\3\2\2\2$\u009c\3\2\2\2")
        buf.write("&\u00a2\3\2\2\2(\u00a8\3\2\2\2*+\5\4\3\2+,\7\2\2\3,\3")
        buf.write("\3\2\2\2-/\5\6\4\2.-\3\2\2\2/\60\3\2\2\2\60.\3\2\2\2\60")
        buf.write("\61\3\2\2\2\61\5\3\2\2\2\62:\5\26\f\2\63:\5\24\13\2\64")
        buf.write(":\5\b\5\2\65:\5\n\6\2\66:\5\f\7\2\67:\5\32\16\28:\78\2")
        buf.write("\29\62\3\2\2\29\63\3\2\2\29\64\3\2\2\29\65\3\2\2\29\66")
        buf.write("\3\2\2\29\67\3\2\2\298\3\2\2\2:\7\3\2\2\2;<\b\5\1\2<E")
        buf.write("\5\30\r\2=E\5\36\20\2>E\5\34\17\2?E\5\26\f\2@A\7\"\2\2")
        buf.write("AB\5\b\5\2BC\7#\2\2CE\3\2\2\2D;\3\2\2\2D=\3\2\2\2D>\3")
        buf.write("\2\2\2D?\3\2\2\2D@\3\2\2\2EQ\3\2\2\2FG\f\5\2\2GH\7\13")
        buf.write("\2\2HP\5\b\5\5IJ\f\4\2\2JK\t\2\2\2KP\5\b\5\5LM\f\3\2\2")
        buf.write("MN\t\3\2\2NP\5\b\5\4OF\3\2\2\2OI\3\2\2\2OL\3\2\2\2PS\3")
        buf.write("\2\2\2QO\3\2\2\2QR\3\2\2\2R\t\3\2\2\2SQ\3\2\2\2TU\7)\2")
        buf.write("\2UV\5\34\17\2VY\7\f\2\2WZ\5\b\5\2XZ\5\24\13\2YW\3\2\2")
        buf.write("\2YX\3\2\2\2Z\13\3\2\2\2[_\5\22\n\2\\_\5\20\t\2]_\5\16")
        buf.write("\b\2^[\3\2\2\2^\\\3\2\2\2^]\3\2\2\2_\r\3\2\2\2`c\7&\2")
        buf.write("\2ad\7\64\2\2bd\5\26\f\2ca\3\2\2\2cb\3\2\2\2d\17\3\2\2")
        buf.write("\2eh\7(\2\2fi\5\34\17\2gi\5\24\13\2hf\3\2\2\2hg\3\2\2")
        buf.write("\2i\21\3\2\2\2jk\7\'\2\2kl\5\24\13\2l\23\3\2\2\2mp\7.")
        buf.write("\2\2nq\7\67\2\2oq\5\b\5\2pn\3\2\2\2po\3\2\2\2qr\3\2\2")
        buf.write("\2rs\7#\2\2s\25\3\2\2\2tv\7 \2\2uw\7\63\2\2vu\3\2\2\2")
        buf.write("vw\3\2\2\2wx\3\2\2\2xy\5\34\17\2yz\7!\2\2z\27\3\2\2\2")
        buf.write("{\u0080\7\30\2\2|\u0080\7\31\2\2}\u0080\7\67\2\2~\u0080")
        buf.write("\5(\25\2\177{\3\2\2\2\177|\3\2\2\2\177}\3\2\2\2\177~\3")
        buf.write("\2\2\2\u0080\31\3\2\2\2\u0081\u0084\7/\2\2\u0082\u0085")
        buf.write("\7\67\2\2\u0083\u0085\5\b\5\2\u0084\u0082\3\2\2\2\u0084")
        buf.write("\u0083\3\2\2\2\u0085\u0086\3\2\2\2\u0086\u0087\7#\2\2")
        buf.write("\u0087\33\3\2\2\2\u0088\u0089\t\4\2\2\u0089\35\3\2\2\2")
        buf.write("\u008a\u008f\5$\23\2\u008b\u008f\5&\24\2\u008c\u008f\5")
        buf.write("\"\22\2\u008d\u008f\5 \21\2\u008e\u008a\3\2\2\2\u008e")
        buf.write("\u008b\3\2\2\2\u008e\u008c\3\2\2\2\u008e\u008d\3\2\2\2")
        buf.write("\u008f\37\3\2\2\2\u0090\u0091\7\60\2\2\u0091\u0092\5\34")
        buf.write("\17\2\u0092\u0093\7\27\2\2\u0093\u0094\7\3\2\2\u0094\u0095")
        buf.write("\7#\2\2\u0095!\3\2\2\2\u0096\u0097\7\60\2\2\u0097\u0098")
        buf.write("\5\34\17\2\u0098\u0099\7\27\2\2\u0099\u009a\7\4\2\2\u009a")
        buf.write("\u009b\7#\2\2\u009b#\3\2\2\2\u009c\u009d\7\60\2\2\u009d")
        buf.write("\u009e\5\34\17\2\u009e\u009f\7\27\2\2\u009f\u00a0\7\5")
        buf.write("\2\2\u00a0\u00a1\7#\2\2\u00a1%\3\2\2\2\u00a2\u00a3\7\60")
        buf.write("\2\2\u00a3\u00a4\5\34\17\2\u00a4\u00a5\7\27\2\2\u00a5")
        buf.write("\u00a6\7\6\2\2\u00a6\u00a7\7#\2\2\u00a7\'\3\2\2\2\u00a8")
        buf.write("\u00a9\t\5\2\2\u00a9\u00aa\7\67\2\2\u00aa\u00ab\7#\2\2")
        buf.write("\u00ab)\3\2\2\2\20\609DOQY^chpv\177\u0084\u008e")
        return buf.getvalue()


class Ah2Parser ( Parser ):

    grammarFileName = "Ah2.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'str'", "'num'", "'dict'", "'list'", 
                     "'+'", "'-'", "'*'", "'/'", "'^'", "'='", "'>'", "'<'", 
                     "'>='", "'<='", "'!='", "'!'", "'_'", "'.'", "':'", 
                     "'%'", "','", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "'{%'", "'%}'", "'{'", "'}'", "'{{'", 
                     "'}}'", "'('", "')'" ]

    symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "PLUS", "MINUS", "MUL", "DIV", "POW", 
                      "EQUAL", "GT", "LT", "GE", "LE", "NE", "NOT", "ULINE", 
                      "DOT", "COLON", "PERCENT", "COMMA", "BOOLEAN", "NUMBER", 
                      "INT", "FLOAT", "EXECUTEOPEN", "EXECUTECLOSE", "BLOCKOPEN", 
                      "BLOCKCLOSE", "MUSTACHEOPEN", "MUSTACHECLOSE", "LPAREN", 
                      "RPAREN", "FALSE", "TRUE", "NAME", "IMPORT", "EXPORT", 
                      "SET", "IF", "THEN", "ELSE", "ENDIF", "COMMANDTAX", 
                      "LOG", "CAST", "DICT", "LIST", "REQUEST", "LABEL", 
                      "DOT_LABEL", "HEX", "STRING", "NEWLINE", "WS" ]

    RULE_prog = 0
    RULE_statements = 1
    RULE_statement = 2
    RULE_expr = 3
    RULE_set_var = 4
    RULE_scoping = 5
    RULE_name = 6
    RULE_exports = 7
    RULE_imports = 8
    RULE_execute = 9
    RULE_inject = 10
    RULE_variable_types = 11
    RULE_log = 12
    RULE_labels = 13
    RULE_casting = 14
    RULE_cast_str = 15
    RULE_cast_num = 16
    RULE_cast_dict = 17
    RULE_cast_list = 18
    RULE_complex_variables = 19

    ruleNames =  [ "prog", "statements", "statement", "expr", "set_var", 
                   "scoping", "name", "exports", "imports", "execute", "inject", 
                   "variable_types", "log", "labels", "casting", "cast_str", 
                   "cast_num", "cast_dict", "cast_list", "complex_variables" ]

    EOF = Token.EOF
    T__0=1
    T__1=2
    T__2=3
    T__3=4
    PLUS=5
    MINUS=6
    MUL=7
    DIV=8
    POW=9
    EQUAL=10
    GT=11
    LT=12
    GE=13
    LE=14
    NE=15
    NOT=16
    ULINE=17
    DOT=18
    COLON=19
    PERCENT=20
    COMMA=21
    BOOLEAN=22
    NUMBER=23
    INT=24
    FLOAT=25
    EXECUTEOPEN=26
    EXECUTECLOSE=27
    BLOCKOPEN=28
    BLOCKCLOSE=29
    MUSTACHEOPEN=30
    MUSTACHECLOSE=31
    LPAREN=32
    RPAREN=33
    FALSE=34
    TRUE=35
    NAME=36
    IMPORT=37
    EXPORT=38
    SET=39
    IF=40
    THEN=41
    ELSE=42
    ENDIF=43
    COMMANDTAX=44
    LOG=45
    CAST=46
    DICT=47
    LIST=48
    REQUEST=49
    LABEL=50
    DOT_LABEL=51
    HEX=52
    STRING=53
    NEWLINE=54
    WS=55

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

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

        def statements(self):
            return self.getTypedRuleContext(Ah2Parser.StatementsContext,0)


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

        def getRuleIndex(self):
            return Ah2Parser.RULE_prog

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

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

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




    def prog(self):

        localctx = Ah2Parser.ProgContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_prog)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 40
            self.statements()
            self.state = 41
            self.match(Ah2Parser.EOF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StatementsContext(ParserRuleContext):

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

        def statement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(Ah2Parser.StatementContext)
            else:
                return self.getTypedRuleContext(Ah2Parser.StatementContext,i)


        def getRuleIndex(self):
            return Ah2Parser.RULE_statements

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

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

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




    def statements(self):

        localctx = Ah2Parser.StatementsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_statements)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 44 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 43
                self.statement()
                self.state = 46 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << Ah2Parser.BOOLEAN) | (1 << Ah2Parser.NUMBER) | (1 << Ah2Parser.MUSTACHEOPEN) | (1 << Ah2Parser.LPAREN) | (1 << Ah2Parser.NAME) | (1 << Ah2Parser.IMPORT) | (1 << Ah2Parser.EXPORT) | (1 << Ah2Parser.SET) | (1 << Ah2Parser.COMMANDTAX) | (1 << Ah2Parser.LOG) | (1 << Ah2Parser.CAST) | (1 << Ah2Parser.DICT) | (1 << Ah2Parser.LIST) | (1 << Ah2Parser.LABEL) | (1 << Ah2Parser.DOT_LABEL) | (1 << Ah2Parser.STRING) | (1 << Ah2Parser.NEWLINE))) != 0)):
                    break

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

    class StatementContext(ParserRuleContext):

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

        def inject(self):
            return self.getTypedRuleContext(Ah2Parser.InjectContext,0)


        def execute(self):
            return self.getTypedRuleContext(Ah2Parser.ExecuteContext,0)


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


        def set_var(self):
            return self.getTypedRuleContext(Ah2Parser.Set_varContext,0)


        def scoping(self):
            return self.getTypedRuleContext(Ah2Parser.ScopingContext,0)


        def log(self):
            return self.getTypedRuleContext(Ah2Parser.LogContext,0)


        def NEWLINE(self):
            return self.getToken(Ah2Parser.NEWLINE, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_statement

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

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

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




    def statement(self):

        localctx = Ah2Parser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_statement)
        try:
            self.state = 55
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,1,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 48
                self.inject()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 49
                self.execute()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 50
                self.expr(0)
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 51
                self.set_var()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 52
                self.scoping()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 53
                self.log()
                pass

            elif la_ == 7:
                self.enterOuterAlt(localctx, 7)
                self.state = 54
                self.match(Ah2Parser.NEWLINE)
                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 variable_types(self):
            return self.getTypedRuleContext(Ah2Parser.Variable_typesContext,0)


        def casting(self):
            return self.getTypedRuleContext(Ah2Parser.CastingContext,0)


        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def inject(self):
            return self.getTypedRuleContext(Ah2Parser.InjectContext,0)


        def LPAREN(self):
            return self.getToken(Ah2Parser.LPAREN, 0)

        def expr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(Ah2Parser.ExprContext)
            else:
                return self.getTypedRuleContext(Ah2Parser.ExprContext,i)


        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

        def POW(self):
            return self.getToken(Ah2Parser.POW, 0)

        def MUL(self):
            return self.getToken(Ah2Parser.MUL, 0)

        def DIV(self):
            return self.getToken(Ah2Parser.DIV, 0)

        def PLUS(self):
            return self.getToken(Ah2Parser.PLUS, 0)

        def MINUS(self):
            return self.getToken(Ah2Parser.MINUS, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_expr

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

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

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



    def expr(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Ah2Parser.ExprContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 6
        self.enterRecursionRule(localctx, 6, self.RULE_expr, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 66
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Ah2Parser.BOOLEAN, Ah2Parser.NUMBER, Ah2Parser.DICT, Ah2Parser.LIST, Ah2Parser.STRING]:
                self.state = 58
                self.variable_types()
                pass
            elif token in [Ah2Parser.CAST]:
                self.state = 59
                self.casting()
                pass
            elif token in [Ah2Parser.LABEL, Ah2Parser.DOT_LABEL]:
                self.state = 60
                self.labels()
                pass
            elif token in [Ah2Parser.MUSTACHEOPEN]:
                self.state = 61
                self.inject()
                pass
            elif token in [Ah2Parser.LPAREN]:
                self.state = 62
                self.match(Ah2Parser.LPAREN)
                self.state = 63
                self.expr(0)
                self.state = 64
                self.match(Ah2Parser.RPAREN)
                pass
            else:
                raise NoViableAltException(self)

            self._ctx.stop = self._input.LT(-1)
            self.state = 79
            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:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 77
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,3,self._ctx)
                    if la_ == 1:
                        localctx = Ah2Parser.ExprContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 68
                        if not self.precpred(self._ctx, 3):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                        self.state = 69
                        self.match(Ah2Parser.POW)
                        self.state = 70
                        self.expr(3)
                        pass

                    elif la_ == 2:
                        localctx = Ah2Parser.ExprContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 71
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 72
                        _la = self._input.LA(1)
                        if not(_la==Ah2Parser.MUL or _la==Ah2Parser.DIV):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 73
                        self.expr(3)
                        pass

                    elif la_ == 3:
                        localctx = Ah2Parser.ExprContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 74
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 75
                        _la = self._input.LA(1)
                        if not(_la==Ah2Parser.PLUS or _la==Ah2Parser.MINUS):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 76
                        self.expr(2)
                        pass

             
                self.state = 81
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,4,self._ctx)

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

    class Set_varContext(ParserRuleContext):

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

        def SET(self):
            return self.getToken(Ah2Parser.SET, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def EQUAL(self):
            return self.getToken(Ah2Parser.EQUAL, 0)

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


        def execute(self):
            return self.getTypedRuleContext(Ah2Parser.ExecuteContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_set_var

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

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

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




    def set_var(self):

        localctx = Ah2Parser.Set_varContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_set_var)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 82
            self.match(Ah2Parser.SET)
            self.state = 83
            self.labels()
            self.state = 84
            self.match(Ah2Parser.EQUAL)
            self.state = 87
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Ah2Parser.BOOLEAN, Ah2Parser.NUMBER, Ah2Parser.MUSTACHEOPEN, Ah2Parser.LPAREN, Ah2Parser.CAST, Ah2Parser.DICT, Ah2Parser.LIST, Ah2Parser.LABEL, Ah2Parser.DOT_LABEL, Ah2Parser.STRING]:
                self.state = 85
                self.expr(0)
                pass
            elif token in [Ah2Parser.COMMANDTAX]:
                self.state = 86
                self.execute()
                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 ScopingContext(ParserRuleContext):

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

        def imports(self):
            return self.getTypedRuleContext(Ah2Parser.ImportsContext,0)


        def exports(self):
            return self.getTypedRuleContext(Ah2Parser.ExportsContext,0)


        def name(self):
            return self.getTypedRuleContext(Ah2Parser.NameContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_scoping

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

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

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




    def scoping(self):

        localctx = Ah2Parser.ScopingContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_scoping)
        try:
            self.state = 92
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Ah2Parser.IMPORT]:
                self.enterOuterAlt(localctx, 1)
                self.state = 89
                self.imports()
                pass
            elif token in [Ah2Parser.EXPORT]:
                self.enterOuterAlt(localctx, 2)
                self.state = 90
                self.exports()
                pass
            elif token in [Ah2Parser.NAME]:
                self.enterOuterAlt(localctx, 3)
                self.state = 91
                self.name()
                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 NameContext(ParserRuleContext):

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

        def NAME(self):
            return self.getToken(Ah2Parser.NAME, 0)

        def LABEL(self):
            return self.getToken(Ah2Parser.LABEL, 0)

        def inject(self):
            return self.getTypedRuleContext(Ah2Parser.InjectContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_name

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

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

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




    def name(self):

        localctx = Ah2Parser.NameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_name)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 94
            self.match(Ah2Parser.NAME)
            self.state = 97
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Ah2Parser.LABEL]:
                self.state = 95
                self.match(Ah2Parser.LABEL)
                pass
            elif token in [Ah2Parser.MUSTACHEOPEN]:
                self.state = 96
                self.inject()
                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 ExportsContext(ParserRuleContext):

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

        def EXPORT(self):
            return self.getToken(Ah2Parser.EXPORT, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def execute(self):
            return self.getTypedRuleContext(Ah2Parser.ExecuteContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_exports

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

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

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




    def exports(self):

        localctx = Ah2Parser.ExportsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_exports)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 99
            self.match(Ah2Parser.EXPORT)
            self.state = 102
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Ah2Parser.LABEL, Ah2Parser.DOT_LABEL]:
                self.state = 100
                self.labels()
                pass
            elif token in [Ah2Parser.COMMANDTAX]:
                self.state = 101
                self.execute()
                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 ImportsContext(ParserRuleContext):

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

        def IMPORT(self):
            return self.getToken(Ah2Parser.IMPORT, 0)

        def execute(self):
            return self.getTypedRuleContext(Ah2Parser.ExecuteContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_imports

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

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

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




    def imports(self):

        localctx = Ah2Parser.ImportsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_imports)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 104
            self.match(Ah2Parser.IMPORT)
            self.state = 105
            self.execute()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExecuteContext(ParserRuleContext):

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

        def COMMANDTAX(self):
            return self.getToken(Ah2Parser.COMMANDTAX, 0)

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

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

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


        def getRuleIndex(self):
            return Ah2Parser.RULE_execute

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

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

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




    def execute(self):

        localctx = Ah2Parser.ExecuteContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_execute)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 107
            self.match(Ah2Parser.COMMANDTAX)
            self.state = 110
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,9,self._ctx)
            if la_ == 1:
                self.state = 108
                self.match(Ah2Parser.STRING)
                pass

            elif la_ == 2:
                self.state = 109
                self.expr(0)
                pass


            self.state = 112
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class InjectContext(ParserRuleContext):

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

        def MUSTACHEOPEN(self):
            return self.getToken(Ah2Parser.MUSTACHEOPEN, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def MUSTACHECLOSE(self):
            return self.getToken(Ah2Parser.MUSTACHECLOSE, 0)

        def REQUEST(self):
            return self.getToken(Ah2Parser.REQUEST, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_inject

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

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

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




    def inject(self):

        localctx = Ah2Parser.InjectContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_inject)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 114
            self.match(Ah2Parser.MUSTACHEOPEN)
            self.state = 116
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==Ah2Parser.REQUEST:
                self.state = 115
                self.match(Ah2Parser.REQUEST)


            self.state = 118
            self.labels()
            self.state = 119
            self.match(Ah2Parser.MUSTACHECLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Variable_typesContext(ParserRuleContext):

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

        def BOOLEAN(self):
            return self.getToken(Ah2Parser.BOOLEAN, 0)

        def NUMBER(self):
            return self.getToken(Ah2Parser.NUMBER, 0)

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

        def complex_variables(self):
            return self.getTypedRuleContext(Ah2Parser.Complex_variablesContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_variable_types

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

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

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




    def variable_types(self):

        localctx = Ah2Parser.Variable_typesContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_variable_types)
        try:
            self.state = 125
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Ah2Parser.BOOLEAN]:
                self.enterOuterAlt(localctx, 1)
                self.state = 121
                self.match(Ah2Parser.BOOLEAN)
                pass
            elif token in [Ah2Parser.NUMBER]:
                self.enterOuterAlt(localctx, 2)
                self.state = 122
                self.match(Ah2Parser.NUMBER)
                pass
            elif token in [Ah2Parser.STRING]:
                self.enterOuterAlt(localctx, 3)
                self.state = 123
                self.match(Ah2Parser.STRING)
                pass
            elif token in [Ah2Parser.DICT, Ah2Parser.LIST]:
                self.enterOuterAlt(localctx, 4)
                self.state = 124
                self.complex_variables()
                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 LogContext(ParserRuleContext):

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

        def LOG(self):
            return self.getToken(Ah2Parser.LOG, 0)

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

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

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


        def getRuleIndex(self):
            return Ah2Parser.RULE_log

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

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

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




    def log(self):

        localctx = Ah2Parser.LogContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_log)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 127
            self.match(Ah2Parser.LOG)
            self.state = 130
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
            if la_ == 1:
                self.state = 128
                self.match(Ah2Parser.STRING)
                pass

            elif la_ == 2:
                self.state = 129
                self.expr(0)
                pass


            self.state = 132
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class LabelsContext(ParserRuleContext):

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

        def LABEL(self):
            return self.getToken(Ah2Parser.LABEL, 0)

        def DOT_LABEL(self):
            return self.getToken(Ah2Parser.DOT_LABEL, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_labels

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

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

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




    def labels(self):

        localctx = Ah2Parser.LabelsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_labels)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 134
            _la = self._input.LA(1)
            if not(_la==Ah2Parser.LABEL or _la==Ah2Parser.DOT_LABEL):
                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 CastingContext(ParserRuleContext):

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

        def cast_dict(self):
            return self.getTypedRuleContext(Ah2Parser.Cast_dictContext,0)


        def cast_list(self):
            return self.getTypedRuleContext(Ah2Parser.Cast_listContext,0)


        def cast_num(self):
            return self.getTypedRuleContext(Ah2Parser.Cast_numContext,0)


        def cast_str(self):
            return self.getTypedRuleContext(Ah2Parser.Cast_strContext,0)


        def getRuleIndex(self):
            return Ah2Parser.RULE_casting

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

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

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




    def casting(self):

        localctx = Ah2Parser.CastingContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_casting)
        try:
            self.state = 140
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 136
                self.cast_dict()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 137
                self.cast_list()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 138
                self.cast_num()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 139
                self.cast_str()
                pass


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

    class Cast_strContext(ParserRuleContext):

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

        def CAST(self):
            return self.getToken(Ah2Parser.CAST, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def COMMA(self):
            return self.getToken(Ah2Parser.COMMA, 0)

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_cast_str

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

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

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




    def cast_str(self):

        localctx = Ah2Parser.Cast_strContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_cast_str)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 142
            self.match(Ah2Parser.CAST)
            self.state = 143
            self.labels()
            self.state = 144
            self.match(Ah2Parser.COMMA)
            self.state = 145
            self.match(Ah2Parser.T__0)
            self.state = 146
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Cast_numContext(ParserRuleContext):

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

        def CAST(self):
            return self.getToken(Ah2Parser.CAST, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def COMMA(self):
            return self.getToken(Ah2Parser.COMMA, 0)

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_cast_num

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

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

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




    def cast_num(self):

        localctx = Ah2Parser.Cast_numContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_cast_num)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 148
            self.match(Ah2Parser.CAST)
            self.state = 149
            self.labels()
            self.state = 150
            self.match(Ah2Parser.COMMA)
            self.state = 151
            self.match(Ah2Parser.T__1)
            self.state = 152
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Cast_dictContext(ParserRuleContext):

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

        def CAST(self):
            return self.getToken(Ah2Parser.CAST, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def COMMA(self):
            return self.getToken(Ah2Parser.COMMA, 0)

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_cast_dict

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

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

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




    def cast_dict(self):

        localctx = Ah2Parser.Cast_dictContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_cast_dict)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 154
            self.match(Ah2Parser.CAST)
            self.state = 155
            self.labels()
            self.state = 156
            self.match(Ah2Parser.COMMA)
            self.state = 157
            self.match(Ah2Parser.T__2)
            self.state = 158
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Cast_listContext(ParserRuleContext):

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

        def CAST(self):
            return self.getToken(Ah2Parser.CAST, 0)

        def labels(self):
            return self.getTypedRuleContext(Ah2Parser.LabelsContext,0)


        def COMMA(self):
            return self.getToken(Ah2Parser.COMMA, 0)

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_cast_list

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

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

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




    def cast_list(self):

        localctx = Ah2Parser.Cast_listContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_cast_list)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 160
            self.match(Ah2Parser.CAST)
            self.state = 161
            self.labels()
            self.state = 162
            self.match(Ah2Parser.COMMA)
            self.state = 163
            self.match(Ah2Parser.T__3)
            self.state = 164
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Complex_variablesContext(ParserRuleContext):

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

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

        def RPAREN(self):
            return self.getToken(Ah2Parser.RPAREN, 0)

        def LIST(self):
            return self.getToken(Ah2Parser.LIST, 0)

        def DICT(self):
            return self.getToken(Ah2Parser.DICT, 0)

        def getRuleIndex(self):
            return Ah2Parser.RULE_complex_variables

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

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

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




    def complex_variables(self):

        localctx = Ah2Parser.Complex_variablesContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_complex_variables)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 166
            _la = self._input.LA(1)
            if not(_la==Ah2Parser.DICT or _la==Ah2Parser.LIST):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 167
            self.match(Ah2Parser.STRING)
            self.state = 168
            self.match(Ah2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[3] = self.expr_sempred
        pred = self._predicates.get(ruleIndex, None)
        if pred is None:
            raise Exception("No predicate with index:" + str(ruleIndex))
        else:
            return pred(localctx, predIndex)

    def expr_sempred(self, localctx:ExprContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 3)
         

            if predIndex == 1:
                return self.precpred(self._ctx, 2)
         

            if predIndex == 2:
                return self.precpred(self._ctx, 1)
         




