# Generated from C:/Users/Emery/PycharmProjects/SpecularLang\SpecLang.g4 by ANTLR 4.8
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
	from typing import TextIO
else:
	from typing.io import TextIO


def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3-")
        buf.write("\u00b7\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\3\2\3\2\3\2\7\2\"\n\2\f\2\16\2%\13\2\3")
        buf.write("\2\6\2(\n\2\r\2\16\2)\3\3\3\3\3\3\3\3\5\3\60\n\3\3\3\5")
        buf.write("\3\63\n\3\3\4\3\4\3\4\3\4\3\4\3\4\5\4;\n\4\3\5\3\5\3\5")
        buf.write("\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5J\n\5\3\6")
        buf.write("\5\6M\n\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\5\7V\n\7\3\7\3\7")
        buf.write("\3\7\5\7[\n\7\3\b\3\b\3\b\3\b\3\t\3\t\5\tc\n\t\3\n\3\n")
        buf.write("\3\n\3\n\3\n\3\n\3\n\7\nl\n\n\f\n\16\no\13\n\3\n\5\nr")
        buf.write("\n\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3")
        buf.write("\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16")
        buf.write("\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17")
        buf.write("\3\17\3\17\3\17\3\17\7\17\u009a\n\17\f\17\16\17\u009d")
        buf.write("\13\17\3\17\3\17\5\17\u00a1\n\17\3\17\3\17\3\17\3\17\3")
        buf.write("\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17")
        buf.write("\7\17\u00b2\n\17\f\17\16\17\u00b5\13\17\3\17\4m\u009b")
        buf.write("\3\34\20\2\4\6\b\n\f\16\20\22\24\26\30\32\34\2\b\4\2\"")
        buf.write("\"((\4\2\35\35!!\4\2\"%()\3\2\36\37\3\2 !\3\2\f\r\2\u00c2")
        buf.write("\2#\3\2\2\2\4/\3\2\2\2\6:\3\2\2\2\bI\3\2\2\2\nL\3\2\2")
        buf.write("\2\fR\3\2\2\2\16\\\3\2\2\2\20b\3\2\2\2\22d\3\2\2\2\24")
        buf.write("s\3\2\2\2\26z\3\2\2\2\30\u0080\3\2\2\2\32\u0087\3\2\2")
        buf.write("\2\34\u00a0\3\2\2\2\36\37\5\n\6\2\37 \7*\2\2 \"\3\2\2")
        buf.write("\2!\36\3\2\2\2\"%\3\2\2\2#!\3\2\2\2#$\3\2\2\2$\'\3\2\2")
        buf.write("\2%#\3\2\2\2&(\5\32\16\2\'&\3\2\2\2()\3\2\2\2)\'\3\2\2")
        buf.write("\2)*\3\2\2\2*\3\3\2\2\2+,\5\6\4\2,-\7*\2\2-\60\3\2\2\2")
        buf.write(".\60\5\20\t\2/+\3\2\2\2/.\3\2\2\2\60\62\3\2\2\2\61\63")
        buf.write("\5\4\3\2\62\61\3\2\2\2\62\63\3\2\2\2\63\5\3\2\2\2\64;")
        buf.write("\5\f\7\2\65;\5\n\6\2\66\67\7\3\2\2\678\5\b\5\289\7\4\2")
        buf.write("\29;\3\2\2\2:\64\3\2\2\2:\65\3\2\2\2:\66\3\2\2\2;\7\3")
        buf.write("\2\2\2<=\7\21\2\2=J\t\2\2\2>?\t\2\2\2?J\7\22\2\2@A\7\23")
        buf.write("\2\2AB\t\2\2\2BC\7\24\2\2CJ\t\2\2\2DJ\7&\2\2EJ\7\'\2\2")
        buf.write("FG\7\5\2\2GH\7\6\2\2HJ\7\"\2\2I<\3\2\2\2I>\3\2\2\2I@\3")
        buf.write("\2\2\2ID\3\2\2\2IE\3\2\2\2IF\3\2\2\2J\t\3\2\2\2KM\7\32")
        buf.write("\2\2LK\3\2\2\2LM\3\2\2\2MN\3\2\2\2NO\7(\2\2OP\7\7\2\2")
        buf.write("PQ\5\34\17\2Q\13\3\2\2\2RS\7\b\2\2SU\t\2\2\2TV\5\16\b")
        buf.write("\2UT\3\2\2\2UV\3\2\2\2VW\3\2\2\2WX\7\6\2\2XZ\7\"\2\2Y")
        buf.write("[\7\17\2\2ZY\3\2\2\2Z[\3\2\2\2[\r\3\2\2\2\\]\7\t\2\2]")
        buf.write("^\7\"\2\2^_\7\n\2\2_\17\3\2\2\2`c\5\22\n\2ac\5\30\r\2")
        buf.write("b`\3\2\2\2ba\3\2\2\2c\21\3\2\2\2de\7\26\2\2ef\5\34\17")
        buf.write("\2fg\7\13\2\2gh\7,\2\2hi\5\4\3\2im\7-\2\2jl\5\24\13\2")
        buf.write("kj\3\2\2\2lo\3\2\2\2mn\3\2\2\2mk\3\2\2\2nq\3\2\2\2om\3")
        buf.write("\2\2\2pr\5\26\f\2qp\3\2\2\2qr\3\2\2\2r\23\3\2\2\2st\7")
        buf.write("\27\2\2tu\5\34\17\2uv\7\13\2\2vw\7,\2\2wx\5\4\3\2xy\7")
        buf.write("-\2\2y\25\3\2\2\2z{\7\30\2\2{|\7\13\2\2|}\7,\2\2}~\5\4")
        buf.write("\3\2~\177\7-\2\2\177\27\3\2\2\2\u0080\u0081\7\20\2\2\u0081")
        buf.write("\u0082\5\34\17\2\u0082\u0083\7\13\2\2\u0083\u0084\7,\2")
        buf.write("\2\u0084\u0085\5\4\3\2\u0085\u0086\7-\2\2\u0086\31\3\2")
        buf.write("\2\2\u0087\u0088\7\31\2\2\u0088\u0089\7\"\2\2\u0089\u008a")
        buf.write("\7\13\2\2\u008a\u008b\7,\2\2\u008b\u008c\5\4\3\2\u008c")
        buf.write("\u008d\7-\2\2\u008d\33\3\2\2\2\u008e\u008f\b\17\1\2\u008f")
        buf.write("\u0090\t\3\2\2\u0090\u00a1\5\34\17\13\u0091\u0092\7\t")
        buf.write("\2\2\u0092\u0093\5\34\17\2\u0093\u0094\7\n\2\2\u0094\u00a1")
        buf.write("\3\2\2\2\u0095\u0096\7\3\2\2\u0096\u009b\7\"\2\2\u0097")
        buf.write("\u0098\7\16\2\2\u0098\u009a\7\"\2\2\u0099\u0097\3\2\2")
        buf.write("\2\u009a\u009d\3\2\2\2\u009b\u009c\3\2\2\2\u009b\u0099")
        buf.write("\3\2\2\2\u009c\u009e\3\2\2\2\u009d\u009b\3\2\2\2\u009e")
        buf.write("\u00a1\7\4\2\2\u009f\u00a1\t\4\2\2\u00a0\u008e\3\2\2\2")
        buf.write("\u00a0\u0091\3\2\2\2\u00a0\u0095\3\2\2\2\u00a0\u009f\3")
        buf.write("\2\2\2\u00a1\u00b3\3\2\2\2\u00a2\u00a3\f\n\2\2\u00a3\u00a4")
        buf.write("\t\5\2\2\u00a4\u00b2\5\34\17\13\u00a5\u00a6\f\t\2\2\u00a6")
        buf.write("\u00a7\t\6\2\2\u00a7\u00b2\5\34\17\n\u00a8\u00a9\f\b\2")
        buf.write("\2\u00a9\u00aa\t\7\2\2\u00aa\u00b2\5\34\17\t\u00ab\u00ac")
        buf.write("\f\7\2\2\u00ac\u00ad\7\33\2\2\u00ad\u00b2\5\34\17\b\u00ae")
        buf.write("\u00af\f\6\2\2\u00af\u00b0\7\34\2\2\u00b0\u00b2\5\34\17")
        buf.write("\7\u00b1\u00a2\3\2\2\2\u00b1\u00a5\3\2\2\2\u00b1\u00a8")
        buf.write("\3\2\2\2\u00b1\u00ab\3\2\2\2\u00b1\u00ae\3\2\2\2\u00b2")
        buf.write("\u00b5\3\2\2\2\u00b3\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2")
        buf.write("\u00b4\35\3\2\2\2\u00b5\u00b3\3\2\2\2\22#)/\62:ILUZbm")
        buf.write("q\u009b\u00a0\u00b1\u00b3")
        return buf.getvalue()


class SpecLangParser ( Parser ):

    grammarFileName = "SpecLang.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'['", "']'", "'custom'", "':'", "'='", 
                     "'@'", "'('", "')'", "';'", "'=='", "'!='", "','", 
                     "'->'", "'while'", "'enter'", "'exits'", "'move'", 
                     "'to'", "'do'", "'if'", "'elif'", "'else'", "'scene'", 
                     "'global'", "'and'", "'or'", "'not'", "'*'", "'/'", 
                     "'+'", "'-'", "<INVALID>", "'True'", "'False'", "'None'", 
                     "'fadein'", "'fadeout'" ]

    symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "NEXT", "WHILE", "ENTER", "EXITS", "MOVE", 
                      "TO", "DO", "IF", "ELIF", "ELSE", "SCENE", "GLOBAL", 
                      "AND", "OR", "NOT", "MUL", "DIV", "ADD", "SUB", "STRING", 
                      "TRUE", "FALSE", "NONE", "FADEIN", "FADEOUT", "ID", 
                      "NUMBER", "NEWLINE", "WS", "INDENT", "DEDENT" ]

    RULE_program = 0
    RULE_block = 1
    RULE_simple_statement = 2
    RULE_stage_direction = 3
    RULE_assignment = 4
    RULE_dialog = 5
    RULE_emotion = 6
    RULE_complex_statement = 7
    RULE_ifstatement = 8
    RULE_else_if_statement = 9
    RULE_else_statement = 10
    RULE_whileLoop = 11
    RULE_scene_statement = 12
    RULE_expression = 13

    ruleNames =  [ "program", "block", "simple_statement", "stage_direction", 
                   "assignment", "dialog", "emotion", "complex_statement", 
                   "ifstatement", "else_if_statement", "else_statement", 
                   "whileLoop", "scene_statement", "expression" ]

    EOF = Token.EOF
    T__0=1
    T__1=2
    T__2=3
    T__3=4
    T__4=5
    T__5=6
    T__6=7
    T__7=8
    T__8=9
    T__9=10
    T__10=11
    T__11=12
    NEXT=13
    WHILE=14
    ENTER=15
    EXITS=16
    MOVE=17
    TO=18
    DO=19
    IF=20
    ELIF=21
    ELSE=22
    SCENE=23
    GLOBAL=24
    AND=25
    OR=26
    NOT=27
    MUL=28
    DIV=29
    ADD=30
    SUB=31
    STRING=32
    TRUE=33
    FALSE=34
    NONE=35
    FADEIN=36
    FADEOUT=37
    ID=38
    NUMBER=39
    NEWLINE=40
    WS=41
    INDENT=42
    DEDENT=43

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




    class ProgramContext(ParserRuleContext):

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

        def assignment(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SpecLangParser.AssignmentContext)
            else:
                return self.getTypedRuleContext(SpecLangParser.AssignmentContext,i)


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

        def scene_statement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SpecLangParser.Scene_statementContext)
            else:
                return self.getTypedRuleContext(SpecLangParser.Scene_statementContext,i)


        def getRuleIndex(self):
            return SpecLangParser.RULE_program

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

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

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




    def program(self):

        localctx = SpecLangParser.ProgramContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_program)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 33
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==SpecLangParser.GLOBAL or _la==SpecLangParser.ID:
                self.state = 28
                self.assignment()
                self.state = 29
                self.match(SpecLangParser.NEWLINE)
                self.state = 35
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 37 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 36
                self.scene_statement()
                self.state = 39 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==SpecLangParser.SCENE):
                    break

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


    class BlockContext(ParserRuleContext):

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

        def simple_statement(self):
            return self.getTypedRuleContext(SpecLangParser.Simple_statementContext,0)


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

        def complex_statement(self):
            return self.getTypedRuleContext(SpecLangParser.Complex_statementContext,0)


        def block(self):
            return self.getTypedRuleContext(SpecLangParser.BlockContext,0)


        def getRuleIndex(self):
            return SpecLangParser.RULE_block

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

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

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




    def block(self):

        localctx = SpecLangParser.BlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_block)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 45
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SpecLangParser.T__0, SpecLangParser.T__5, SpecLangParser.GLOBAL, SpecLangParser.ID]:
                self.state = 41
                self.simple_statement()
                self.state = 42
                self.match(SpecLangParser.NEWLINE)
                pass
            elif token in [SpecLangParser.WHILE, SpecLangParser.IF]:
                self.state = 44
                self.complex_statement()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 48
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SpecLangParser.T__0) | (1 << SpecLangParser.T__5) | (1 << SpecLangParser.WHILE) | (1 << SpecLangParser.IF) | (1 << SpecLangParser.GLOBAL) | (1 << SpecLangParser.ID))) != 0):
                self.state = 47
                self.block()


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


    class Simple_statementContext(ParserRuleContext):

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

        def dialog(self):
            return self.getTypedRuleContext(SpecLangParser.DialogContext,0)


        def assignment(self):
            return self.getTypedRuleContext(SpecLangParser.AssignmentContext,0)


        def stage_direction(self):
            return self.getTypedRuleContext(SpecLangParser.Stage_directionContext,0)


        def getRuleIndex(self):
            return SpecLangParser.RULE_simple_statement

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

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

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




    def simple_statement(self):

        localctx = SpecLangParser.Simple_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_simple_statement)
        try:
            self.state = 56
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SpecLangParser.T__5]:
                self.enterOuterAlt(localctx, 1)
                self.state = 50
                self.dialog()
                pass
            elif token in [SpecLangParser.GLOBAL, SpecLangParser.ID]:
                self.enterOuterAlt(localctx, 2)
                self.state = 51
                self.assignment()
                pass
            elif token in [SpecLangParser.T__0]:
                self.enterOuterAlt(localctx, 3)
                self.state = 52
                self.match(SpecLangParser.T__0)
                self.state = 53
                self.stage_direction()
                self.state = 54
                self.match(SpecLangParser.T__1)
                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 Stage_directionContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return SpecLangParser.RULE_stage_direction

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



    class ExitContext(Stage_directionContext):

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

        def EXITS(self):
            return self.getToken(SpecLangParser.EXITS, 0)
        def ID(self):
            return self.getToken(SpecLangParser.ID, 0)
        def STRING(self):
            return self.getToken(SpecLangParser.STRING, 0)

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

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

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


    class MoveContext(Stage_directionContext):

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

        def MOVE(self):
            return self.getToken(SpecLangParser.MOVE, 0)
        def TO(self):
            return self.getToken(SpecLangParser.TO, 0)
        def ID(self, i:int=None):
            if i is None:
                return self.getTokens(SpecLangParser.ID)
            else:
                return self.getToken(SpecLangParser.ID, i)
        def STRING(self, i:int=None):
            if i is None:
                return self.getTokens(SpecLangParser.STRING)
            else:
                return self.getToken(SpecLangParser.STRING, i)

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

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

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


    class FadeOutContext(Stage_directionContext):

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

        def FADEOUT(self):
            return self.getToken(SpecLangParser.FADEOUT, 0)

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

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

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


    class FadeInContext(Stage_directionContext):

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

        def FADEIN(self):
            return self.getToken(SpecLangParser.FADEIN, 0)

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

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

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


    class EnterContext(Stage_directionContext):

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

        def ENTER(self):
            return self.getToken(SpecLangParser.ENTER, 0)
        def ID(self):
            return self.getToken(SpecLangParser.ID, 0)
        def STRING(self):
            return self.getToken(SpecLangParser.STRING, 0)

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

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

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


    class CustomDirectionContext(Stage_directionContext):

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

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

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

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

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



    def stage_direction(self):

        localctx = SpecLangParser.Stage_directionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_stage_direction)
        self._la = 0 # Token type
        try:
            self.state = 71
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SpecLangParser.ENTER]:
                localctx = SpecLangParser.EnterContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 58
                self.match(SpecLangParser.ENTER)
                self.state = 59
                _la = self._input.LA(1)
                if not(_la==SpecLangParser.STRING or _la==SpecLangParser.ID):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                pass
            elif token in [SpecLangParser.STRING, SpecLangParser.ID]:
                localctx = SpecLangParser.ExitContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 60
                _la = self._input.LA(1)
                if not(_la==SpecLangParser.STRING or _la==SpecLangParser.ID):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 61
                self.match(SpecLangParser.EXITS)
                pass
            elif token in [SpecLangParser.MOVE]:
                localctx = SpecLangParser.MoveContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 62
                self.match(SpecLangParser.MOVE)
                self.state = 63
                _la = self._input.LA(1)
                if not(_la==SpecLangParser.STRING or _la==SpecLangParser.ID):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 64
                self.match(SpecLangParser.TO)
                self.state = 65
                _la = self._input.LA(1)
                if not(_la==SpecLangParser.STRING or _la==SpecLangParser.ID):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                pass
            elif token in [SpecLangParser.FADEIN]:
                localctx = SpecLangParser.FadeInContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 66
                self.match(SpecLangParser.FADEIN)
                pass
            elif token in [SpecLangParser.FADEOUT]:
                localctx = SpecLangParser.FadeOutContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 67
                self.match(SpecLangParser.FADEOUT)
                pass
            elif token in [SpecLangParser.T__2]:
                localctx = SpecLangParser.CustomDirectionContext(self, localctx)
                self.enterOuterAlt(localctx, 6)
                self.state = 68
                self.match(SpecLangParser.T__2)
                self.state = 69
                self.match(SpecLangParser.T__3)
                self.state = 70
                self.match(SpecLangParser.STRING)
                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 AssignmentContext(ParserRuleContext):

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

        def ID(self):
            return self.getToken(SpecLangParser.ID, 0)

        def expression(self):
            return self.getTypedRuleContext(SpecLangParser.ExpressionContext,0)


        def GLOBAL(self):
            return self.getToken(SpecLangParser.GLOBAL, 0)

        def getRuleIndex(self):
            return SpecLangParser.RULE_assignment

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

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

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




    def assignment(self):

        localctx = SpecLangParser.AssignmentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_assignment)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 74
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SpecLangParser.GLOBAL:
                self.state = 73
                self.match(SpecLangParser.GLOBAL)


            self.state = 76
            self.match(SpecLangParser.ID)
            self.state = 77
            self.match(SpecLangParser.T__4)
            self.state = 78
            self.expression(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DialogContext(ParserRuleContext):

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

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

        def ID(self):
            return self.getToken(SpecLangParser.ID, 0)

        def emotion(self):
            return self.getTypedRuleContext(SpecLangParser.EmotionContext,0)


        def NEXT(self):
            return self.getToken(SpecLangParser.NEXT, 0)

        def getRuleIndex(self):
            return SpecLangParser.RULE_dialog

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

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

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




    def dialog(self):

        localctx = SpecLangParser.DialogContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_dialog)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 80
            self.match(SpecLangParser.T__5)
            self.state = 81
            _la = self._input.LA(1)
            if not(_la==SpecLangParser.STRING or _la==SpecLangParser.ID):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 83
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SpecLangParser.T__6:
                self.state = 82
                self.emotion()


            self.state = 85
            self.match(SpecLangParser.T__3)
            self.state = 86
            self.match(SpecLangParser.STRING)
            self.state = 88
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SpecLangParser.NEXT:
                self.state = 87
                self.match(SpecLangParser.NEXT)


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


    class EmotionContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return SpecLangParser.RULE_emotion

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

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

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




    def emotion(self):

        localctx = SpecLangParser.EmotionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_emotion)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 90
            self.match(SpecLangParser.T__6)
            self.state = 91
            self.match(SpecLangParser.STRING)
            self.state = 92
            self.match(SpecLangParser.T__7)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Complex_statementContext(ParserRuleContext):

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

        def ifstatement(self):
            return self.getTypedRuleContext(SpecLangParser.IfstatementContext,0)


        def whileLoop(self):
            return self.getTypedRuleContext(SpecLangParser.WhileLoopContext,0)


        def getRuleIndex(self):
            return SpecLangParser.RULE_complex_statement

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

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

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




    def complex_statement(self):

        localctx = SpecLangParser.Complex_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_complex_statement)
        try:
            self.state = 96
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SpecLangParser.IF]:
                self.enterOuterAlt(localctx, 1)
                self.state = 94
                self.ifstatement()
                pass
            elif token in [SpecLangParser.WHILE]:
                self.enterOuterAlt(localctx, 2)
                self.state = 95
                self.whileLoop()
                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 IfstatementContext(ParserRuleContext):

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

        def IF(self):
            return self.getToken(SpecLangParser.IF, 0)

        def expression(self):
            return self.getTypedRuleContext(SpecLangParser.ExpressionContext,0)


        def INDENT(self):
            return self.getToken(SpecLangParser.INDENT, 0)

        def block(self):
            return self.getTypedRuleContext(SpecLangParser.BlockContext,0)


        def DEDENT(self):
            return self.getToken(SpecLangParser.DEDENT, 0)

        def else_if_statement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SpecLangParser.Else_if_statementContext)
            else:
                return self.getTypedRuleContext(SpecLangParser.Else_if_statementContext,i)


        def else_statement(self):
            return self.getTypedRuleContext(SpecLangParser.Else_statementContext,0)


        def getRuleIndex(self):
            return SpecLangParser.RULE_ifstatement

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

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

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




    def ifstatement(self):

        localctx = SpecLangParser.IfstatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_ifstatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 98
            self.match(SpecLangParser.IF)
            self.state = 99
            self.expression(0)
            self.state = 100
            self.match(SpecLangParser.T__8)
            self.state = 101
            self.match(SpecLangParser.INDENT)
            self.state = 102
            self.block()
            self.state = 103
            self.match(SpecLangParser.DEDENT)
            self.state = 107
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,10,self._ctx)
            while _alt!=1 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1+1:
                    self.state = 104
                    self.else_if_statement() 
                self.state = 109
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,10,self._ctx)

            self.state = 111
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SpecLangParser.ELSE:
                self.state = 110
                self.else_statement()


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


    class Else_if_statementContext(ParserRuleContext):

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

        def ELIF(self):
            return self.getToken(SpecLangParser.ELIF, 0)

        def expression(self):
            return self.getTypedRuleContext(SpecLangParser.ExpressionContext,0)


        def INDENT(self):
            return self.getToken(SpecLangParser.INDENT, 0)

        def block(self):
            return self.getTypedRuleContext(SpecLangParser.BlockContext,0)


        def DEDENT(self):
            return self.getToken(SpecLangParser.DEDENT, 0)

        def getRuleIndex(self):
            return SpecLangParser.RULE_else_if_statement

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

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

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




    def else_if_statement(self):

        localctx = SpecLangParser.Else_if_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_else_if_statement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self.match(SpecLangParser.ELIF)
            self.state = 114
            self.expression(0)
            self.state = 115
            self.match(SpecLangParser.T__8)
            self.state = 116
            self.match(SpecLangParser.INDENT)
            self.state = 117
            self.block()
            self.state = 118
            self.match(SpecLangParser.DEDENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Else_statementContext(ParserRuleContext):

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

        def ELSE(self):
            return self.getToken(SpecLangParser.ELSE, 0)

        def INDENT(self):
            return self.getToken(SpecLangParser.INDENT, 0)

        def block(self):
            return self.getTypedRuleContext(SpecLangParser.BlockContext,0)


        def DEDENT(self):
            return self.getToken(SpecLangParser.DEDENT, 0)

        def getRuleIndex(self):
            return SpecLangParser.RULE_else_statement

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

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

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




    def else_statement(self):

        localctx = SpecLangParser.Else_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_else_statement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 120
            self.match(SpecLangParser.ELSE)
            self.state = 121
            self.match(SpecLangParser.T__8)
            self.state = 122
            self.match(SpecLangParser.INDENT)
            self.state = 123
            self.block()
            self.state = 124
            self.match(SpecLangParser.DEDENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class WhileLoopContext(ParserRuleContext):

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

        def WHILE(self):
            return self.getToken(SpecLangParser.WHILE, 0)

        def expression(self):
            return self.getTypedRuleContext(SpecLangParser.ExpressionContext,0)


        def INDENT(self):
            return self.getToken(SpecLangParser.INDENT, 0)

        def block(self):
            return self.getTypedRuleContext(SpecLangParser.BlockContext,0)


        def DEDENT(self):
            return self.getToken(SpecLangParser.DEDENT, 0)

        def getRuleIndex(self):
            return SpecLangParser.RULE_whileLoop

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

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

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




    def whileLoop(self):

        localctx = SpecLangParser.WhileLoopContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_whileLoop)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 126
            self.match(SpecLangParser.WHILE)
            self.state = 127
            self.expression(0)
            self.state = 128
            self.match(SpecLangParser.T__8)
            self.state = 129
            self.match(SpecLangParser.INDENT)
            self.state = 130
            self.block()
            self.state = 131
            self.match(SpecLangParser.DEDENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Scene_statementContext(ParserRuleContext):

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

        def SCENE(self):
            return self.getToken(SpecLangParser.SCENE, 0)

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

        def INDENT(self):
            return self.getToken(SpecLangParser.INDENT, 0)

        def block(self):
            return self.getTypedRuleContext(SpecLangParser.BlockContext,0)


        def DEDENT(self):
            return self.getToken(SpecLangParser.DEDENT, 0)

        def getRuleIndex(self):
            return SpecLangParser.RULE_scene_statement

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

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

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




    def scene_statement(self):

        localctx = SpecLangParser.Scene_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_scene_statement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 133
            self.match(SpecLangParser.SCENE)
            self.state = 134
            self.match(SpecLangParser.STRING)
            self.state = 135
            self.match(SpecLangParser.T__8)
            self.state = 136
            self.match(SpecLangParser.INDENT)
            self.state = 137
            self.block()
            self.state = 138
            self.match(SpecLangParser.DEDENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExpressionContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return SpecLangParser.RULE_expression

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


    class AddContext(ExpressionContext):

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

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

        def ADD(self):
            return self.getToken(SpecLangParser.ADD, 0)
        def SUB(self):
            return self.getToken(SpecLangParser.SUB, 0)

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

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

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


    class EqualContext(ExpressionContext):

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

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


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

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

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


    class ParenContext(ExpressionContext):

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

        def expression(self):
            return self.getTypedRuleContext(SpecLangParser.ExpressionContext,0)


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

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

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


    class MultContext(ExpressionContext):

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

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

        def MUL(self):
            return self.getToken(SpecLangParser.MUL, 0)
        def DIV(self):
            return self.getToken(SpecLangParser.DIV, 0)

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

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

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


    class OrContext(ExpressionContext):

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

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

        def OR(self):
            return self.getToken(SpecLangParser.OR, 0)

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

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

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


    class AndContext(ExpressionContext):

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

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

        def AND(self):
            return self.getToken(SpecLangParser.AND, 0)

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

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

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


    class TermContext(ExpressionContext):

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

        def NONE(self):
            return self.getToken(SpecLangParser.NONE, 0)
        def TRUE(self):
            return self.getToken(SpecLangParser.TRUE, 0)
        def FALSE(self):
            return self.getToken(SpecLangParser.FALSE, 0)
        def ID(self):
            return self.getToken(SpecLangParser.ID, 0)
        def STRING(self):
            return self.getToken(SpecLangParser.STRING, 0)
        def NUMBER(self):
            return self.getToken(SpecLangParser.NUMBER, 0)

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

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

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


    class UnaryContext(ExpressionContext):

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

        def expression(self):
            return self.getTypedRuleContext(SpecLangParser.ExpressionContext,0)

        def NOT(self):
            return self.getToken(SpecLangParser.NOT, 0)
        def SUB(self):
            return self.getToken(SpecLangParser.SUB, 0)

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

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

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


    class ChoiceContext(ExpressionContext):

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

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

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

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

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



    def expression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = SpecLangParser.ExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 26
        self.enterRecursionRule(localctx, 26, self.RULE_expression, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 158
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SpecLangParser.NOT, SpecLangParser.SUB]:
                localctx = SpecLangParser.UnaryContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 141
                _la = self._input.LA(1)
                if not(_la==SpecLangParser.NOT or _la==SpecLangParser.SUB):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 142
                self.expression(9)
                pass
            elif token in [SpecLangParser.T__6]:
                localctx = SpecLangParser.ParenContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 143
                self.match(SpecLangParser.T__6)
                self.state = 144
                self.expression(0)
                self.state = 145
                self.match(SpecLangParser.T__7)
                pass
            elif token in [SpecLangParser.T__0]:
                localctx = SpecLangParser.ChoiceContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 147
                self.match(SpecLangParser.T__0)
                self.state = 148
                self.match(SpecLangParser.STRING)
                self.state = 153
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,12,self._ctx)
                while _alt!=1 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1+1:
                        self.state = 149
                        self.match(SpecLangParser.T__11)
                        self.state = 150
                        self.match(SpecLangParser.STRING) 
                    self.state = 155
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,12,self._ctx)

                self.state = 156
                self.match(SpecLangParser.T__1)
                pass
            elif token in [SpecLangParser.STRING, SpecLangParser.TRUE, SpecLangParser.FALSE, SpecLangParser.NONE, SpecLangParser.ID, SpecLangParser.NUMBER]:
                localctx = SpecLangParser.TermContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 157
                _la = self._input.LA(1)
                if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SpecLangParser.STRING) | (1 << SpecLangParser.TRUE) | (1 << SpecLangParser.FALSE) | (1 << SpecLangParser.NONE) | (1 << SpecLangParser.ID) | (1 << SpecLangParser.NUMBER))) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                pass
            else:
                raise NoViableAltException(self)

            self._ctx.stop = self._input.LT(-1)
            self.state = 177
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,15,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 = 175
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,14,self._ctx)
                    if la_ == 1:
                        localctx = SpecLangParser.MultContext(self, SpecLangParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 160
                        if not self.precpred(self._ctx, 8):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 8)")
                        self.state = 161
                        _la = self._input.LA(1)
                        if not(_la==SpecLangParser.MUL or _la==SpecLangParser.DIV):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 162
                        self.expression(9)
                        pass

                    elif la_ == 2:
                        localctx = SpecLangParser.AddContext(self, SpecLangParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 163
                        if not self.precpred(self._ctx, 7):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 7)")
                        self.state = 164
                        _la = self._input.LA(1)
                        if not(_la==SpecLangParser.ADD or _la==SpecLangParser.SUB):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 165
                        self.expression(8)
                        pass

                    elif la_ == 3:
                        localctx = SpecLangParser.EqualContext(self, SpecLangParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 166
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 167
                        _la = self._input.LA(1)
                        if not(_la==SpecLangParser.T__9 or _la==SpecLangParser.T__10):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 168
                        self.expression(7)
                        pass

                    elif la_ == 4:
                        localctx = SpecLangParser.AndContext(self, SpecLangParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 169
                        if not self.precpred(self._ctx, 5):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 5)")
                        self.state = 170
                        self.match(SpecLangParser.AND)
                        self.state = 171
                        self.expression(6)
                        pass

                    elif la_ == 5:
                        localctx = SpecLangParser.OrContext(self, SpecLangParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 172
                        if not self.precpred(self._ctx, 4):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 4)")
                        self.state = 173
                        self.match(SpecLangParser.OR)
                        self.state = 174
                        self.expression(5)
                        pass

             
                self.state = 179
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,15,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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[13] = self.expression_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 expression_sempred(self, localctx:ExpressionContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 8)
         

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

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

            if predIndex == 3:
                return self.precpred(self._ctx, 5)
         

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




