# Generated from main/bkit/parser/BKIT.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\30")
        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\3\2\3\2\7\2+\n\2\f\2\16\2.\13\2\3\3\3\3\3\3")
        buf.write("\3\3\7\3\64\n\3\f\3\16\3\67\13\3\3\3\3\3\3\4\3\4\3\4\3")
        buf.write("\4\3\4\3\5\3\5\3\5\7\5C\n\5\f\5\16\5F\13\5\3\5\3\5\3\6")
        buf.write("\3\6\5\6L\n\6\3\6\3\6\3\7\3\7\3\7\3\7\7\7T\n\7\f\7\16")
        buf.write("\7W\13\7\3\b\3\b\3\b\7\b\\\n\b\f\b\16\b_\13\b\3\t\3\t")
        buf.write("\3\t\3\t\3\t\5\tf\n\t\3\n\3\n\3\n\3\n\3\n\3\n\7\nn\n\n")
        buf.write("\f\n\16\nq\13\n\3\13\3\13\3\13\3\13\3\13\3\13\7\13y\n")
        buf.write("\13\f\13\16\13|\13\13\3\f\3\f\3\f\3\f\3\f\5\f\u0083\n")
        buf.write("\f\3\r\3\r\3\r\3\r\5\r\u0089\n\r\3\16\3\16\3\16\5\16\u008e")
        buf.write("\n\16\3\17\3\17\3\17\7\17\u0093\n\17\f\17\16\17\u0096")
        buf.write("\13\17\3\20\3\20\3\20\5\20\u009b\n\20\3\20\3\20\3\21\3")
        buf.write("\21\3\21\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23")
        buf.write("\3\24\3\24\3\24\2\4\22\24\25\2\4\6\b\n\f\16\20\22\24\26")
        buf.write("\30\32\34\36 \"$&\2\4\3\2\17\20\3\2\3\4\2\u00ac\2,\3\2")
        buf.write("\2\2\4/\3\2\2\2\6:\3\2\2\2\b?\3\2\2\2\nI\3\2\2\2\fO\3")
        buf.write("\2\2\2\16X\3\2\2\2\20e\3\2\2\2\22g\3\2\2\2\24r\3\2\2\2")
        buf.write("\26\u0082\3\2\2\2\30\u0088\3\2\2\2\32\u008d\3\2\2\2\34")
        buf.write("\u008f\3\2\2\2\36\u0097\3\2\2\2 \u009e\3\2\2\2\"\u00a1")
        buf.write("\3\2\2\2$\u00a6\3\2\2\2&\u00aa\3\2\2\2(+\5\4\3\2)+\5\6")
        buf.write("\4\2*(\3\2\2\2*)\3\2\2\2+.\3\2\2\2,*\3\2\2\2,-\3\2\2\2")
        buf.write("-\3\3\2\2\2.,\3\2\2\2/\60\5&\24\2\60\65\7\21\2\2\61\62")
        buf.write("\7\t\2\2\62\64\7\21\2\2\63\61\3\2\2\2\64\67\3\2\2\2\65")
        buf.write("\63\3\2\2\2\65\66\3\2\2\2\668\3\2\2\2\67\65\3\2\2\289")
        buf.write("\7\b\2\29\5\3\2\2\2:;\5&\24\2;<\7\21\2\2<=\5\n\6\2=>\5")
        buf.write("\b\5\2>\7\3\2\2\2?D\7\6\2\2@C\5\4\3\2AC\5\32\16\2B@\3")
        buf.write("\2\2\2BA\3\2\2\2CF\3\2\2\2DB\3\2\2\2DE\3\2\2\2EG\3\2\2")
        buf.write("\2FD\3\2\2\2GH\7\7\2\2H\t\3\2\2\2IK\7\13\2\2JL\5\16\b")
        buf.write("\2KJ\3\2\2\2KL\3\2\2\2LM\3\2\2\2MN\7\f\2\2N\13\3\2\2\2")
        buf.write("OP\5&\24\2PU\7\21\2\2QR\7\t\2\2RT\7\21\2\2SQ\3\2\2\2T")
        buf.write("W\3\2\2\2US\3\2\2\2UV\3\2\2\2V\r\3\2\2\2WU\3\2\2\2X]\5")
        buf.write("\f\7\2YZ\7\b\2\2Z\\\5\f\7\2[Y\3\2\2\2\\_\3\2\2\2][\3\2")
        buf.write("\2\2]^\3\2\2\2^\17\3\2\2\2_]\3\2\2\2`a\5\22\n\2ab\7\r")
        buf.write("\2\2bc\5\20\t\2cf\3\2\2\2df\5\22\n\2e`\3\2\2\2ed\3\2\2")
        buf.write("\2f\21\3\2\2\2gh\b\n\1\2hi\5\24\13\2io\3\2\2\2jk\f\4\2")
        buf.write("\2kl\7\16\2\2ln\5\24\13\2mj\3\2\2\2nq\3\2\2\2om\3\2\2")
        buf.write("\2op\3\2\2\2p\23\3\2\2\2qo\3\2\2\2rs\b\13\1\2st\5\26\f")
        buf.write("\2tz\3\2\2\2uv\f\4\2\2vw\t\2\2\2wy\5\26\f\2xu\3\2\2\2")
        buf.write("y|\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\25\3\2\2\2|z\3\2\2\2}")
        buf.write("~\7\13\2\2~\177\5\20\t\2\177\u0080\7\f\2\2\u0080\u0083")
        buf.write("\3\2\2\2\u0081\u0083\5\30\r\2\u0082}\3\2\2\2\u0082\u0081")
        buf.write("\3\2\2\2\u0083\27\3\2\2\2\u0084\u0089\7\22\2\2\u0085\u0089")
        buf.write("\7\23\2\2\u0086\u0089\7\21\2\2\u0087\u0089\5\36\20\2\u0088")
        buf.write("\u0084\3\2\2\2\u0088\u0085\3\2\2\2\u0088\u0086\3\2\2\2")
        buf.write("\u0088\u0087\3\2\2\2\u0089\31\3\2\2\2\u008a\u008e\5\"")
        buf.write("\22\2\u008b\u008e\5 \21\2\u008c\u008e\5$\23\2\u008d\u008a")
        buf.write("\3\2\2\2\u008d\u008b\3\2\2\2\u008d\u008c\3\2\2\2\u008e")
        buf.write("\33\3\2\2\2\u008f\u0094\5\20\t\2\u0090\u0091\7\t\2\2\u0091")
        buf.write("\u0093\5\20\t\2\u0092\u0090\3\2\2\2\u0093\u0096\3\2\2")
        buf.write("\2\u0094\u0092\3\2\2\2\u0094\u0095\3\2\2\2\u0095\35\3")
        buf.write("\2\2\2\u0096\u0094\3\2\2\2\u0097\u0098\7\21\2\2\u0098")
        buf.write("\u009a\7\13\2\2\u0099\u009b\5\34\17\2\u009a\u0099\3\2")
        buf.write("\2\2\u009a\u009b\3\2\2\2\u009b\u009c\3\2\2\2\u009c\u009d")
        buf.write("\7\f\2\2\u009d\37\3\2\2\2\u009e\u009f\5\36\20\2\u009f")
        buf.write("\u00a0\7\b\2\2\u00a0!\3\2\2\2\u00a1\u00a2\7\21\2\2\u00a2")
        buf.write("\u00a3\7\n\2\2\u00a3\u00a4\5\20\t\2\u00a4\u00a5\7\b\2")
        buf.write("\2\u00a5#\3\2\2\2\u00a6\u00a7\7\5\2\2\u00a7\u00a8\5\20")
        buf.write("\t\2\u00a8\u00a9\7\b\2\2\u00a9%\3\2\2\2\u00aa\u00ab\t")
        buf.write("\3\2\2\u00ab\'\3\2\2\2\22*,\65BDKU]eoz\u0082\u0088\u008d")
        buf.write("\u0094\u009a")
        return buf.getvalue()


class BKITParser ( Parser ):

    grammarFileName = "BKIT.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'int'", "'float'", "'return'", "'{'", 
                     "'}'", "';'", "','", "'='", "'('", "')'", "'+'", "'-'", 
                     "'*'", "'/'" ]

    symbolicNames = [ "<INVALID>", "INT", "FLOAT", "RETURN", "LB", "RB", 
                      "SM", "CM", "EQ", "LP", "RP", "ADD", "SUB", "MUL", 
                      "DIV", "ID", "INTLIT", "FLOATLIT", "WS", "ERROR_CHAR", 
                      "UNCLOSE_STRING", "ILLEGAL_ESCAPE", "UNTERMINATED_COMMENT" ]

    RULE_program = 0
    RULE_variable_declaration = 1
    RULE_function_declaration = 2
    RULE_function_body = 3
    RULE_parameter_declaration = 4
    RULE_variable_parameter = 5
    RULE_parameter_list = 6
    RULE_expression = 7
    RULE_exp1 = 8
    RULE_exp2 = 9
    RULE_exp3 = 10
    RULE_operands = 11
    RULE_statement = 12
    RULE_in_parameters = 13
    RULE_call_function = 14
    RULE_call_statement = 15
    RULE_assignment = 16
    RULE_return_statement = 17
    RULE_data_type = 18

    ruleNames =  [ "program", "variable_declaration", "function_declaration", 
                   "function_body", "parameter_declaration", "variable_parameter", 
                   "parameter_list", "expression", "exp1", "exp2", "exp3", 
                   "operands", "statement", "in_parameters", "call_function", 
                   "call_statement", "assignment", "return_statement", "data_type" ]

    EOF = Token.EOF
    INT=1
    FLOAT=2
    RETURN=3
    LB=4
    RB=5
    SM=6
    CM=7
    EQ=8
    LP=9
    RP=10
    ADD=11
    SUB=12
    MUL=13
    DIV=14
    ID=15
    INTLIT=16
    FLOATLIT=17
    WS=18
    ERROR_CHAR=19
    UNCLOSE_STRING=20
    ILLEGAL_ESCAPE=21
    UNTERMINATED_COMMENT=22

    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 variable_declaration(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(BKITParser.Variable_declarationContext)
            else:
                return self.getTypedRuleContext(BKITParser.Variable_declarationContext,i)


        def function_declaration(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(BKITParser.Function_declarationContext)
            else:
                return self.getTypedRuleContext(BKITParser.Function_declarationContext,i)


        def getRuleIndex(self):
            return BKITParser.RULE_program

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




    def program(self):

        localctx = BKITParser.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 = 42
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==BKITParser.INT or _la==BKITParser.FLOAT:
                self.state = 40
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,0,self._ctx)
                if la_ == 1:
                    self.state = 38
                    self.variable_declaration()
                    pass

                elif la_ == 2:
                    self.state = 39
                    self.function_declaration()
                    pass


                self.state = 44
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class Variable_declarationContext(ParserRuleContext):

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

        def data_type(self):
            return self.getTypedRuleContext(BKITParser.Data_typeContext,0)


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

        def SM(self):
            return self.getToken(BKITParser.SM, 0)

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

        def getRuleIndex(self):
            return BKITParser.RULE_variable_declaration

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




    def variable_declaration(self):

        localctx = BKITParser.Variable_declarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_variable_declaration)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 45
            self.data_type()
            self.state = 46
            self.match(BKITParser.ID)
            self.state = 51
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==BKITParser.CM:
                self.state = 47
                self.match(BKITParser.CM)
                self.state = 48
                self.match(BKITParser.ID)
                self.state = 53
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 54
            self.match(BKITParser.SM)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Function_declarationContext(ParserRuleContext):

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

        def data_type(self):
            return self.getTypedRuleContext(BKITParser.Data_typeContext,0)


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

        def parameter_declaration(self):
            return self.getTypedRuleContext(BKITParser.Parameter_declarationContext,0)


        def function_body(self):
            return self.getTypedRuleContext(BKITParser.Function_bodyContext,0)


        def getRuleIndex(self):
            return BKITParser.RULE_function_declaration

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




    def function_declaration(self):

        localctx = BKITParser.Function_declarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_function_declaration)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 56
            self.data_type()
            self.state = 57
            self.match(BKITParser.ID)
            self.state = 58
            self.parameter_declaration()
            self.state = 59
            self.function_body()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Function_bodyContext(ParserRuleContext):

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

        def LB(self):
            return self.getToken(BKITParser.LB, 0)

        def RB(self):
            return self.getToken(BKITParser.RB, 0)

        def variable_declaration(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(BKITParser.Variable_declarationContext)
            else:
                return self.getTypedRuleContext(BKITParser.Variable_declarationContext,i)


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


        def getRuleIndex(self):
            return BKITParser.RULE_function_body

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




    def function_body(self):

        localctx = BKITParser.Function_bodyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_function_body)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 61
            self.match(BKITParser.LB)
            self.state = 66
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << BKITParser.INT) | (1 << BKITParser.FLOAT) | (1 << BKITParser.RETURN) | (1 << BKITParser.ID))) != 0):
                self.state = 64
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [BKITParser.INT, BKITParser.FLOAT]:
                    self.state = 62
                    self.variable_declaration()
                    pass
                elif token in [BKITParser.RETURN, BKITParser.ID]:
                    self.state = 63
                    self.statement()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 68
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 69
            self.match(BKITParser.RB)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Parameter_declarationContext(ParserRuleContext):

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

        def LP(self):
            return self.getToken(BKITParser.LP, 0)

        def RP(self):
            return self.getToken(BKITParser.RP, 0)

        def parameter_list(self):
            return self.getTypedRuleContext(BKITParser.Parameter_listContext,0)


        def getRuleIndex(self):
            return BKITParser.RULE_parameter_declaration

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




    def parameter_declaration(self):

        localctx = BKITParser.Parameter_declarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_parameter_declaration)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 71
            self.match(BKITParser.LP)
            self.state = 73
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==BKITParser.INT or _la==BKITParser.FLOAT:
                self.state = 72
                self.parameter_list()


            self.state = 75
            self.match(BKITParser.RP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Variable_parameterContext(ParserRuleContext):

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

        def data_type(self):
            return self.getTypedRuleContext(BKITParser.Data_typeContext,0)


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

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

        def getRuleIndex(self):
            return BKITParser.RULE_variable_parameter

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




    def variable_parameter(self):

        localctx = BKITParser.Variable_parameterContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_variable_parameter)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 77
            self.data_type()
            self.state = 78
            self.match(BKITParser.ID)
            self.state = 83
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==BKITParser.CM:
                self.state = 79
                self.match(BKITParser.CM)
                self.state = 80
                self.match(BKITParser.ID)
                self.state = 85
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class Parameter_listContext(ParserRuleContext):

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

        def variable_parameter(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(BKITParser.Variable_parameterContext)
            else:
                return self.getTypedRuleContext(BKITParser.Variable_parameterContext,i)


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

        def getRuleIndex(self):
            return BKITParser.RULE_parameter_list

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




    def parameter_list(self):

        localctx = BKITParser.Parameter_listContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_parameter_list)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 86
            self.variable_parameter()
            self.state = 91
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==BKITParser.SM:
                self.state = 87
                self.match(BKITParser.SM)
                self.state = 88
                self.variable_parameter()
                self.state = 93
                self._errHandler.sync(self)
                _la = self._input.LA(1)

        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 exp1(self):
            return self.getTypedRuleContext(BKITParser.Exp1Context,0)


        def ADD(self):
            return self.getToken(BKITParser.ADD, 0)

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


        def getRuleIndex(self):
            return BKITParser.RULE_expression

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




    def expression(self):

        localctx = BKITParser.ExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_expression)
        try:
            self.state = 99
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,8,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 94
                self.exp1(0)
                self.state = 95
                self.match(BKITParser.ADD)
                self.state = 96
                self.expression()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 98
                self.exp1(0)
                pass


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


    class Exp1Context(ParserRuleContext):

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

        def exp2(self):
            return self.getTypedRuleContext(BKITParser.Exp2Context,0)


        def exp1(self):
            return self.getTypedRuleContext(BKITParser.Exp1Context,0)


        def SUB(self):
            return self.getToken(BKITParser.SUB, 0)

        def getRuleIndex(self):
            return BKITParser.RULE_exp1

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



    def exp1(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = BKITParser.Exp1Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 16
        self.enterRecursionRule(localctx, 16, self.RULE_exp1, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 102
            self.exp2(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 109
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,9,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = BKITParser.Exp1Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_exp1)
                    self.state = 104
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 105
                    self.match(BKITParser.SUB)
                    self.state = 106
                    self.exp2(0) 
                self.state = 111
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,9,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 Exp2Context(ParserRuleContext):

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

        def exp3(self):
            return self.getTypedRuleContext(BKITParser.Exp3Context,0)


        def exp2(self):
            return self.getTypedRuleContext(BKITParser.Exp2Context,0)


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

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

        def getRuleIndex(self):
            return BKITParser.RULE_exp2

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



    def exp2(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = BKITParser.Exp2Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 18
        self.enterRecursionRule(localctx, 18, self.RULE_exp2, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self.exp3()
            self._ctx.stop = self._input.LT(-1)
            self.state = 120
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,10,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = BKITParser.Exp2Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_exp2)
                    self.state = 115
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 116
                    _la = self._input.LA(1)
                    if not(_la==BKITParser.MUL or _la==BKITParser.DIV):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 117
                    self.exp3() 
                self.state = 122
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,10,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 Exp3Context(ParserRuleContext):

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

        def LP(self):
            return self.getToken(BKITParser.LP, 0)

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


        def RP(self):
            return self.getToken(BKITParser.RP, 0)

        def operands(self):
            return self.getTypedRuleContext(BKITParser.OperandsContext,0)


        def getRuleIndex(self):
            return BKITParser.RULE_exp3

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




    def exp3(self):

        localctx = BKITParser.Exp3Context(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_exp3)
        try:
            self.state = 128
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [BKITParser.LP]:
                self.enterOuterAlt(localctx, 1)
                self.state = 123
                self.match(BKITParser.LP)
                self.state = 124
                self.expression()
                self.state = 125
                self.match(BKITParser.RP)
                pass
            elif token in [BKITParser.ID, BKITParser.INTLIT, BKITParser.FLOATLIT]:
                self.enterOuterAlt(localctx, 2)
                self.state = 127
                self.operands()
                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 OperandsContext(ParserRuleContext):

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

        def INTLIT(self):
            return self.getToken(BKITParser.INTLIT, 0)

        def FLOATLIT(self):
            return self.getToken(BKITParser.FLOATLIT, 0)

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

        def call_function(self):
            return self.getTypedRuleContext(BKITParser.Call_functionContext,0)


        def getRuleIndex(self):
            return BKITParser.RULE_operands

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




    def operands(self):

        localctx = BKITParser.OperandsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_operands)
        try:
            self.state = 134
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 130
                self.match(BKITParser.INTLIT)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 131
                self.match(BKITParser.FLOATLIT)
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 132
                self.match(BKITParser.ID)
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 133
                self.call_function()
                pass


        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 assignment(self):
            return self.getTypedRuleContext(BKITParser.AssignmentContext,0)


        def call_statement(self):
            return self.getTypedRuleContext(BKITParser.Call_statementContext,0)


        def return_statement(self):
            return self.getTypedRuleContext(BKITParser.Return_statementContext,0)


        def getRuleIndex(self):
            return BKITParser.RULE_statement

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




    def statement(self):

        localctx = BKITParser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_statement)
        try:
            self.state = 139
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 136
                self.assignment()
                pass

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

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


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


    class In_parametersContext(ParserRuleContext):

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

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


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

        def getRuleIndex(self):
            return BKITParser.RULE_in_parameters

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




    def in_parameters(self):

        localctx = BKITParser.In_parametersContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_in_parameters)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 141
            self.expression()
            self.state = 146
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==BKITParser.CM:
                self.state = 142
                self.match(BKITParser.CM)
                self.state = 143
                self.expression()
                self.state = 148
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class Call_functionContext(ParserRuleContext):

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

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

        def LP(self):
            return self.getToken(BKITParser.LP, 0)

        def RP(self):
            return self.getToken(BKITParser.RP, 0)

        def in_parameters(self):
            return self.getTypedRuleContext(BKITParser.In_parametersContext,0)


        def getRuleIndex(self):
            return BKITParser.RULE_call_function

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




    def call_function(self):

        localctx = BKITParser.Call_functionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_call_function)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 149
            self.match(BKITParser.ID)
            self.state = 150
            self.match(BKITParser.LP)
            self.state = 152
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << BKITParser.LP) | (1 << BKITParser.ID) | (1 << BKITParser.INTLIT) | (1 << BKITParser.FLOATLIT))) != 0):
                self.state = 151
                self.in_parameters()


            self.state = 154
            self.match(BKITParser.RP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Call_statementContext(ParserRuleContext):

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

        def call_function(self):
            return self.getTypedRuleContext(BKITParser.Call_functionContext,0)


        def SM(self):
            return self.getToken(BKITParser.SM, 0)

        def getRuleIndex(self):
            return BKITParser.RULE_call_statement

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




    def call_statement(self):

        localctx = BKITParser.Call_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_call_statement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 156
            self.call_function()
            self.state = 157
            self.match(BKITParser.SM)
        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(BKITParser.ID, 0)

        def EQ(self):
            return self.getToken(BKITParser.EQ, 0)

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


        def SM(self):
            return self.getToken(BKITParser.SM, 0)

        def getRuleIndex(self):
            return BKITParser.RULE_assignment

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




    def assignment(self):

        localctx = BKITParser.AssignmentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_assignment)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 159
            self.match(BKITParser.ID)
            self.state = 160
            self.match(BKITParser.EQ)
            self.state = 161
            self.expression()
            self.state = 162
            self.match(BKITParser.SM)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Return_statementContext(ParserRuleContext):

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

        def RETURN(self):
            return self.getToken(BKITParser.RETURN, 0)

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


        def SM(self):
            return self.getToken(BKITParser.SM, 0)

        def getRuleIndex(self):
            return BKITParser.RULE_return_statement

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




    def return_statement(self):

        localctx = BKITParser.Return_statementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_return_statement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 164
            self.match(BKITParser.RETURN)
            self.state = 165
            self.expression()
            self.state = 166
            self.match(BKITParser.SM)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class Data_typeContext(ParserRuleContext):

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

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

        def FLOAT(self):
            return self.getToken(BKITParser.FLOAT, 0)

        def getRuleIndex(self):
            return BKITParser.RULE_data_type

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




    def data_type(self):

        localctx = BKITParser.Data_typeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_data_type)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 168
            _la = self._input.LA(1)
            if not(_la==BKITParser.INT or _la==BKITParser.FLOAT):
                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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[8] = self.exp1_sempred
        self._predicates[9] = self.exp2_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 exp1_sempred(self, localctx:Exp1Context, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 2)
         

    def exp2_sempred(self, localctx:Exp2Context, predIndex:int):
            if predIndex == 1:
                return self.precpred(self._ctx, 2)
         




