# Generated from /home/hpcc/ppl-course/assignment/assignment2/main/mc/parser/MC.g4 by ANTLR 4.7.1
# encoding: utf-8
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys

def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\63")
        buf.write("\u0135\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23")
        buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31")
        buf.write("\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36")
        buf.write("\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\3\2\6\2H\n\2\r\2")
        buf.write("\16\2I\3\2\3\2\3\3\3\3\5\3P\n\3\3\4\3\4\3\4\3\4\3\5\3")
        buf.write("\5\3\6\3\6\3\6\3\6\3\6\5\6]\n\6\3\7\3\7\3\7\3\7\3\7\5")
        buf.write("\7d\n\7\3\b\3\b\3\b\3\b\5\bj\n\b\3\b\3\b\3\b\3\t\3\t\3")
        buf.write("\t\5\tr\n\t\3\n\3\n\3\n\3\n\3\13\3\13\3\13\7\13{\n\13")
        buf.write("\f\13\16\13~\13\13\3\f\3\f\3\f\3\f\5\f\u0084\n\f\3\r\3")
        buf.write("\r\7\r\u0088\n\r\f\r\16\r\u008b\13\r\3\r\3\r\3\16\3\16")
        buf.write("\5\16\u0091\n\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3")
        buf.write("\17\5\17\u009b\n\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20")
        buf.write("\5\20\u00a4\n\20\3\21\3\21\6\21\u00a8\n\21\r\21\16\21")
        buf.write("\u00a9\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3")
        buf.write("\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\24\3\24\3\24")
        buf.write("\3\25\3\25\5\25\u00c2\n\25\3\25\3\25\3\26\3\26\3\26\3")
        buf.write("\27\3\27\3\27\3\27\3\27\5\27\u00ce\n\27\3\30\3\30\3\30")
        buf.write("\3\30\3\30\3\30\7\30\u00d6\n\30\f\30\16\30\u00d9\13\30")
        buf.write("\3\31\3\31\3\31\3\31\3\31\3\31\7\31\u00e1\n\31\f\31\16")
        buf.write("\31\u00e4\13\31\3\32\3\32\3\32\3\32\3\32\5\32\u00eb\n")
        buf.write("\32\3\33\3\33\3\33\3\33\3\33\5\33\u00f2\n\33\3\34\3\34")
        buf.write("\3\34\3\34\3\34\3\34\7\34\u00fa\n\34\f\34\16\34\u00fd")
        buf.write("\13\34\3\35\3\35\3\35\3\35\3\35\3\35\7\35\u0105\n\35\f")
        buf.write("\35\16\35\u0108\13\35\3\36\3\36\3\36\5\36\u010d\n\36\3")
        buf.write("\37\3\37\3\37\3\37\3\37\3\37\5\37\u0115\n\37\3 \3 \3 ")
        buf.write("\3 \3 \5 \u011c\n \3!\3!\3!\3!\3!\3!\5!\u0124\n!\3\"\3")
        buf.write("\"\3\"\3\"\3\"\3#\3#\3#\7#\u012e\n#\f#\16#\u0131\13#\5")
        buf.write("#\u0133\n#\3#\2\6.\60\668$\2\4\6\b\n\f\16\20\22\24\26")
        buf.write("\30\32\34\36 \"$&(*,.\60\62\64\668:<>@BD\2\b\3\2\7\n\3")
        buf.write("\2\37 \3\2!$\3\2\27\30\3\2\31\33\4\2\30\30\34\34\2\u0138")
        buf.write("\2G\3\2\2\2\4O\3\2\2\2\6Q\3\2\2\2\bU\3\2\2\2\n\\\3\2\2")
        buf.write("\2\fc\3\2\2\2\16e\3\2\2\2\20q\3\2\2\2\22s\3\2\2\2\24w")
        buf.write("\3\2\2\2\26\177\3\2\2\2\30\u0085\3\2\2\2\32\u0090\3\2")
        buf.write("\2\2\34\u009a\3\2\2\2\36\u009c\3\2\2\2 \u00a5\3\2\2\2")
        buf.write("\"\u00af\3\2\2\2$\u00b9\3\2\2\2&\u00bc\3\2\2\2(\u00bf")
        buf.write("\3\2\2\2*\u00c5\3\2\2\2,\u00cd\3\2\2\2.\u00cf\3\2\2\2")
        buf.write("\60\u00da\3\2\2\2\62\u00ea\3\2\2\2\64\u00f1\3\2\2\2\66")
        buf.write("\u00f3\3\2\2\28\u00fe\3\2\2\2:\u010c\3\2\2\2<\u0114\3")
        buf.write("\2\2\2>\u011b\3\2\2\2@\u0123\3\2\2\2B\u0125\3\2\2\2D\u0132")
        buf.write("\3\2\2\2FH\5\4\3\2GF\3\2\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2")
        buf.write("\2\2JK\3\2\2\2KL\7\2\2\3L\3\3\2\2\2MP\5\6\4\2NP\5\16\b")
        buf.write("\2OM\3\2\2\2ON\3\2\2\2P\5\3\2\2\2QR\5\b\5\2RS\5\n\6\2")
        buf.write("ST\7-\2\2T\7\3\2\2\2UV\t\2\2\2V\t\3\2\2\2WX\5\f\7\2XY")
        buf.write("\7,\2\2YZ\5\n\6\2Z]\3\2\2\2[]\5\f\7\2\\W\3\2\2\2\\[\3")
        buf.write("\2\2\2]\13\3\2\2\2^_\7\26\2\2_`\7*\2\2`a\7\3\2\2ad\7+")
        buf.write("\2\2bd\7\26\2\2c^\3\2\2\2cb\3\2\2\2d\r\3\2\2\2ef\5\20")
        buf.write("\t\2fg\7\26\2\2gi\7&\2\2hj\5\24\13\2ih\3\2\2\2ij\3\2\2")
        buf.write("\2jk\3\2\2\2kl\7\'\2\2lm\5\30\r\2m\17\3\2\2\2nr\5\b\5")
        buf.write("\2or\5\22\n\2pr\7\13\2\2qn\3\2\2\2qo\3\2\2\2qp\3\2\2\2")
        buf.write("r\21\3\2\2\2st\5\b\5\2tu\7*\2\2uv\7+\2\2v\23\3\2\2\2w")
        buf.write("|\5\26\f\2xy\7,\2\2y{\5\26\f\2zx\3\2\2\2{~\3\2\2\2|z\3")
        buf.write("\2\2\2|}\3\2\2\2}\25\3\2\2\2~|\3\2\2\2\177\u0080\5\b\5")
        buf.write("\2\u0080\u0083\7\26\2\2\u0081\u0082\7*\2\2\u0082\u0084")
        buf.write("\7+\2\2\u0083\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084")
        buf.write("\27\3\2\2\2\u0085\u0089\7(\2\2\u0086\u0088\5\32\16\2\u0087")
        buf.write("\u0086\3\2\2\2\u0088\u008b\3\2\2\2\u0089\u0087\3\2\2\2")
        buf.write("\u0089\u008a\3\2\2\2\u008a\u008c\3\2\2\2\u008b\u0089\3")
        buf.write("\2\2\2\u008c\u008d\7)\2\2\u008d\31\3\2\2\2\u008e\u0091")
        buf.write("\5\6\4\2\u008f\u0091\5\34\17\2\u0090\u008e\3\2\2\2\u0090")
        buf.write("\u008f\3\2\2\2\u0091\33\3\2\2\2\u0092\u009b\5\30\r\2\u0093")
        buf.write("\u009b\5\36\20\2\u0094\u009b\5 \21\2\u0095\u009b\5\"\22")
        buf.write("\2\u0096\u009b\5$\23\2\u0097\u009b\5&\24\2\u0098\u009b")
        buf.write("\5(\25\2\u0099\u009b\5*\26\2\u009a\u0092\3\2\2\2\u009a")
        buf.write("\u0093\3\2\2\2\u009a\u0094\3\2\2\2\u009a\u0095\3\2\2\2")
        buf.write("\u009a\u0096\3\2\2\2\u009a\u0097\3\2\2\2\u009a\u0098\3")
        buf.write("\2\2\2\u009a\u0099\3\2\2\2\u009b\35\3\2\2\2\u009c\u009d")
        buf.write("\7\21\2\2\u009d\u009e\7&\2\2\u009e\u009f\5,\27\2\u009f")
        buf.write("\u00a0\7\'\2\2\u00a0\u00a3\5\34\17\2\u00a1\u00a2\7\22")
        buf.write("\2\2\u00a2\u00a4\5\34\17\2\u00a3\u00a1\3\2\2\2\u00a3\u00a4")
        buf.write("\3\2\2\2\u00a4\37\3\2\2\2\u00a5\u00a7\7\f\2\2\u00a6\u00a8")
        buf.write("\5\34\17\2\u00a7\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9")
        buf.write("\u00a7\3\2\2\2\u00a9\u00aa\3\2\2\2\u00aa\u00ab\3\2\2\2")
        buf.write("\u00ab\u00ac\7\r\2\2\u00ac\u00ad\5,\27\2\u00ad\u00ae\7")
        buf.write("-\2\2\u00ae!\3\2\2\2\u00af\u00b0\7\16\2\2\u00b0\u00b1")
        buf.write("\7&\2\2\u00b1\u00b2\5,\27\2\u00b2\u00b3\7-\2\2\u00b3\u00b4")
        buf.write("\5,\27\2\u00b4\u00b5\7-\2\2\u00b5\u00b6\5,\27\2\u00b6")
        buf.write("\u00b7\7\'\2\2\u00b7\u00b8\5\34\17\2\u00b8#\3\2\2\2\u00b9")
        buf.write("\u00ba\7\17\2\2\u00ba\u00bb\7-\2\2\u00bb%\3\2\2\2\u00bc")
        buf.write("\u00bd\7\20\2\2\u00bd\u00be\7-\2\2\u00be\'\3\2\2\2\u00bf")
        buf.write("\u00c1\7\23\2\2\u00c0\u00c2\5,\27\2\u00c1\u00c0\3\2\2")
        buf.write("\2\u00c1\u00c2\3\2\2\2\u00c2\u00c3\3\2\2\2\u00c3\u00c4")
        buf.write("\7-\2\2\u00c4)\3\2\2\2\u00c5\u00c6\5,\27\2\u00c6\u00c7")
        buf.write("\7-\2\2\u00c7+\3\2\2\2\u00c8\u00c9\5.\30\2\u00c9\u00ca")
        buf.write("\7%\2\2\u00ca\u00cb\5,\27\2\u00cb\u00ce\3\2\2\2\u00cc")
        buf.write("\u00ce\5.\30\2\u00cd\u00c8\3\2\2\2\u00cd\u00cc\3\2\2\2")
        buf.write("\u00ce-\3\2\2\2\u00cf\u00d0\b\30\1\2\u00d0\u00d1\5\60")
        buf.write("\31\2\u00d1\u00d7\3\2\2\2\u00d2\u00d3\f\4\2\2\u00d3\u00d4")
        buf.write("\7\35\2\2\u00d4\u00d6\5\60\31\2\u00d5\u00d2\3\2\2\2\u00d6")
        buf.write("\u00d9\3\2\2\2\u00d7\u00d5\3\2\2\2\u00d7\u00d8\3\2\2\2")
        buf.write("\u00d8/\3\2\2\2\u00d9\u00d7\3\2\2\2\u00da\u00db\b\31\1")
        buf.write("\2\u00db\u00dc\5\62\32\2\u00dc\u00e2\3\2\2\2\u00dd\u00de")
        buf.write("\f\4\2\2\u00de\u00df\7\36\2\2\u00df\u00e1\5\62\32\2\u00e0")
        buf.write("\u00dd\3\2\2\2\u00e1\u00e4\3\2\2\2\u00e2\u00e0\3\2\2\2")
        buf.write("\u00e2\u00e3\3\2\2\2\u00e3\61\3\2\2\2\u00e4\u00e2\3\2")
        buf.write("\2\2\u00e5\u00e6\5\64\33\2\u00e6\u00e7\t\3\2\2\u00e7\u00e8")
        buf.write("\5\64\33\2\u00e8\u00eb\3\2\2\2\u00e9\u00eb\5\64\33\2\u00ea")
        buf.write("\u00e5\3\2\2\2\u00ea\u00e9\3\2\2\2\u00eb\63\3\2\2\2\u00ec")
        buf.write("\u00ed\5\66\34\2\u00ed\u00ee\t\4\2\2\u00ee\u00ef\5\66")
        buf.write("\34\2\u00ef\u00f2\3\2\2\2\u00f0\u00f2\5\66\34\2\u00f1")
        buf.write("\u00ec\3\2\2\2\u00f1\u00f0\3\2\2\2\u00f2\65\3\2\2\2\u00f3")
        buf.write("\u00f4\b\34\1\2\u00f4\u00f5\58\35\2\u00f5\u00fb\3\2\2")
        buf.write("\2\u00f6\u00f7\f\4\2\2\u00f7\u00f8\t\5\2\2\u00f8\u00fa")
        buf.write("\58\35\2\u00f9\u00f6\3\2\2\2\u00fa\u00fd\3\2\2\2\u00fb")
        buf.write("\u00f9\3\2\2\2\u00fb\u00fc\3\2\2\2\u00fc\67\3\2\2\2\u00fd")
        buf.write("\u00fb\3\2\2\2\u00fe\u00ff\b\35\1\2\u00ff\u0100\5:\36")
        buf.write("\2\u0100\u0106\3\2\2\2\u0101\u0102\f\4\2\2\u0102\u0103")
        buf.write("\t\6\2\2\u0103\u0105\5:\36\2\u0104\u0101\3\2\2\2\u0105")
        buf.write("\u0108\3\2\2\2\u0106\u0104\3\2\2\2\u0106\u0107\3\2\2\2")
        buf.write("\u01079\3\2\2\2\u0108\u0106\3\2\2\2\u0109\u010a\t\7\2")
        buf.write("\2\u010a\u010d\5:\36\2\u010b\u010d\5<\37\2\u010c\u0109")
        buf.write("\3\2\2\2\u010c\u010b\3\2\2\2\u010d;\3\2\2\2\u010e\u010f")
        buf.write("\5> \2\u010f\u0110\7*\2\2\u0110\u0111\5,\27\2\u0111\u0112")
        buf.write("\7+\2\2\u0112\u0115\3\2\2\2\u0113\u0115\5> \2\u0114\u010e")
        buf.write("\3\2\2\2\u0114\u0113\3\2\2\2\u0115=\3\2\2\2\u0116\u0117")
        buf.write("\7&\2\2\u0117\u0118\5,\27\2\u0118\u0119\7\'\2\2\u0119")
        buf.write("\u011c\3\2\2\2\u011a\u011c\5@!\2\u011b\u0116\3\2\2\2\u011b")
        buf.write("\u011a\3\2\2\2\u011c?\3\2\2\2\u011d\u0124\7\3\2\2\u011e")
        buf.write("\u0124\7\5\2\2\u011f\u0124\7\26\2\2\u0120\u0124\7\4\2")
        buf.write("\2\u0121\u0124\7\6\2\2\u0122\u0124\5B\"\2\u0123\u011d")
        buf.write("\3\2\2\2\u0123\u011e\3\2\2\2\u0123\u011f\3\2\2\2\u0123")
        buf.write("\u0120\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0122\3\2\2\2")
        buf.write("\u0124A\3\2\2\2\u0125\u0126\7\26\2\2\u0126\u0127\7&\2")
        buf.write("\2\u0127\u0128\5D#\2\u0128\u0129\7\'\2\2\u0129C\3\2\2")
        buf.write("\2\u012a\u012f\5,\27\2\u012b\u012c\7,\2\2\u012c\u012e")
        buf.write("\5,\27\2\u012d\u012b\3\2\2\2\u012e\u0131\3\2\2\2\u012f")
        buf.write("\u012d\3\2\2\2\u012f\u0130\3\2\2\2\u0130\u0133\3\2\2\2")
        buf.write("\u0131\u012f\3\2\2\2\u0132\u012a\3\2\2\2\u0132\u0133\3")
        buf.write("\2\2\2\u0133E\3\2\2\2\35IO\\ciq|\u0083\u0089\u0090\u009a")
        buf.write("\u00a3\u00a9\u00c1\u00cd\u00d7\u00e2\u00ea\u00f1\u00fb")
        buf.write("\u0106\u010c\u0114\u011b\u0123\u012f\u0132")
        return buf.getvalue()


class MCParser ( Parser ):

    grammarFileName = "MC.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "'boolean'", "'int'", "'float'", "'string'", 
                     "'void'", "'do'", "'while'", "'for'", "'break'", "'continue'", 
                     "'if'", "'else'", "'return'", "'true'", "'false'", 
                     "<INVALID>", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", 
                     "'||'", "'&&'", "'=='", "'!='", "'<'", "'>'", "'<='", 
                     "'>='", "'='", "'('", "')'", "'{'", "'}'", "'['", "']'", 
                     "','", "';'" ]

    symbolicNames = [ "<INVALID>", "INTLIT", "FLOATLIT", "BOOLEANLIT", "STRINGLIT", 
                      "BOOLEANTYPE", "INTTYPE", "FLOATTYPE", "STRINGTYPE", 
                      "VOIDTYPE", "DO", "WHILE", "FOR", "BREAK", "CONTINUE", 
                      "IF", "ELSE", "RETURN", "TRUE", "FALSE", "ID", "ADD", 
                      "SUB", "MUL", "DIV", "MOD", "NOT", "OR", "AND", "EQ", 
                      "NE", "LT", "GT", "LE", "GE", "ASSIGN", "LB", "RB", 
                      "LP", "RP", "LSB", "RSB", "COMA", "SEMI", "CMTLINE", 
                      "CMTBLOCK", "WS", "UNCLOSE_STRING", "ILLEGAL_ESCAPE", 
                      "ERROR_CHAR" ]

    RULE_program = 0
    RULE_declaration = 1
    RULE_vardecl = 2
    RULE_primtype = 3
    RULE_varlist = 4
    RULE_var = 5
    RULE_funcdecl = 6
    RULE_functype = 7
    RULE_arraytype = 8
    RULE_paralist = 9
    RULE_paradecl = 10
    RULE_blockstmt = 11
    RULE_instruction = 12
    RULE_stmt = 13
    RULE_ifstmt = 14
    RULE_whilestmt = 15
    RULE_forstmt = 16
    RULE_breakstmt = 17
    RULE_continuestmt = 18
    RULE_returnstmt = 19
    RULE_exprstmt = 20
    RULE_expr0 = 21
    RULE_expr1 = 22
    RULE_expr2 = 23
    RULE_expr3 = 24
    RULE_expr4 = 25
    RULE_expr5 = 26
    RULE_expr6 = 27
    RULE_expr7 = 28
    RULE_expr8 = 29
    RULE_expr9 = 30
    RULE_operand = 31
    RULE_calfunc = 32
    RULE_arglist = 33

    ruleNames =  [ "program", "declaration", "vardecl", "primtype", "varlist", 
                   "var", "funcdecl", "functype", "arraytype", "paralist", 
                   "paradecl", "blockstmt", "instruction", "stmt", "ifstmt", 
                   "whilestmt", "forstmt", "breakstmt", "continuestmt", 
                   "returnstmt", "exprstmt", "expr0", "expr1", "expr2", 
                   "expr3", "expr4", "expr5", "expr6", "expr7", "expr8", 
                   "expr9", "operand", "calfunc", "arglist" ]

    EOF = Token.EOF
    INTLIT=1
    FLOATLIT=2
    BOOLEANLIT=3
    STRINGLIT=4
    BOOLEANTYPE=5
    INTTYPE=6
    FLOATTYPE=7
    STRINGTYPE=8
    VOIDTYPE=9
    DO=10
    WHILE=11
    FOR=12
    BREAK=13
    CONTINUE=14
    IF=15
    ELSE=16
    RETURN=17
    TRUE=18
    FALSE=19
    ID=20
    ADD=21
    SUB=22
    MUL=23
    DIV=24
    MOD=25
    NOT=26
    OR=27
    AND=28
    EQ=29
    NE=30
    LT=31
    GT=32
    LE=33
    GE=34
    ASSIGN=35
    LB=36
    RB=37
    LP=38
    RP=39
    LSB=40
    RSB=41
    COMA=42
    SEMI=43
    CMTLINE=44
    CMTBLOCK=45
    WS=46
    UNCLOSE_STRING=47
    ILLEGAL_ESCAPE=48
    ERROR_CHAR=49

    def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
        super().__init__(input, output)
        self.checkVersion("4.7.1")
        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 EOF(self):
            return self.getToken(MCParser.EOF, 0)

        def declaration(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.DeclarationContext)
            else:
                return self.getTypedRuleContext(MCParser.DeclarationContext,i)


        def getRuleIndex(self):
            return MCParser.RULE_program




    def program(self):

        localctx = MCParser.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 = 69 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 68
                self.declaration()
                self.state = 71 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE) | (1 << MCParser.VOIDTYPE))) != 0)):
                    break

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

    class DeclarationContext(ParserRuleContext):

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

        def vardecl(self):
            return self.getTypedRuleContext(MCParser.VardeclContext,0)


        def funcdecl(self):
            return self.getTypedRuleContext(MCParser.FuncdeclContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_declaration




    def declaration(self):

        localctx = MCParser.DeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_declaration)
        try:
            self.state = 77
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,1,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 75
                self.vardecl()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 76
                self.funcdecl()
                pass


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

    class VardeclContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


        def varlist(self):
            return self.getTypedRuleContext(MCParser.VarlistContext,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_vardecl




    def vardecl(self):

        localctx = MCParser.VardeclContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_vardecl)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 79
            self.primtype()
            self.state = 80
            self.varlist()
            self.state = 81
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class PrimtypeContext(ParserRuleContext):

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

        def BOOLEANTYPE(self):
            return self.getToken(MCParser.BOOLEANTYPE, 0)

        def INTTYPE(self):
            return self.getToken(MCParser.INTTYPE, 0)

        def FLOATTYPE(self):
            return self.getToken(MCParser.FLOATTYPE, 0)

        def STRINGTYPE(self):
            return self.getToken(MCParser.STRINGTYPE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_primtype




    def primtype(self):

        localctx = MCParser.PrimtypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_primtype)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 83
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class VarlistContext(ParserRuleContext):

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

        def var(self):
            return self.getTypedRuleContext(MCParser.VarContext,0)


        def COMA(self):
            return self.getToken(MCParser.COMA, 0)

        def varlist(self):
            return self.getTypedRuleContext(MCParser.VarlistContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_varlist




    def varlist(self):

        localctx = MCParser.VarlistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_varlist)
        try:
            self.state = 90
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 85
                self.var()
                self.state = 86
                self.match(MCParser.COMA)
                self.state = 87
                self.varlist()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 89
                self.var()
                pass


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

    class VarContext(ParserRuleContext):

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

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

        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

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

        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_var




    def var(self):

        localctx = MCParser.VarContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_var)
        try:
            self.state = 97
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,3,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 92
                self.match(MCParser.ID)
                self.state = 93
                self.match(MCParser.LSB)
                self.state = 94
                self.match(MCParser.INTLIT)
                self.state = 95
                self.match(MCParser.RSB)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 96
                self.match(MCParser.ID)
                pass


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

    class FuncdeclContext(ParserRuleContext):

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

        def functype(self):
            return self.getTypedRuleContext(MCParser.FunctypeContext,0)


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

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

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

        def blockstmt(self):
            return self.getTypedRuleContext(MCParser.BlockstmtContext,0)


        def paralist(self):
            return self.getTypedRuleContext(MCParser.ParalistContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_funcdecl




    def funcdecl(self):

        localctx = MCParser.FuncdeclContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_funcdecl)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 99
            self.functype()
            self.state = 100
            self.match(MCParser.ID)
            self.state = 101
            self.match(MCParser.LB)
            self.state = 103
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE))) != 0):
                self.state = 102
                self.paralist()


            self.state = 105
            self.match(MCParser.RB)
            self.state = 106
            self.blockstmt()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FunctypeContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


        def arraytype(self):
            return self.getTypedRuleContext(MCParser.ArraytypeContext,0)


        def VOIDTYPE(self):
            return self.getToken(MCParser.VOIDTYPE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_functype




    def functype(self):

        localctx = MCParser.FunctypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_functype)
        try:
            self.state = 111
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 108
                self.primtype()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 109
                self.arraytype()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 110
                self.match(MCParser.VOIDTYPE)
                pass


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

    class ArraytypeContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_arraytype




    def arraytype(self):

        localctx = MCParser.ArraytypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_arraytype)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self.primtype()
            self.state = 114
            self.match(MCParser.LSB)
            self.state = 115
            self.match(MCParser.RSB)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ParalistContext(ParserRuleContext):

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

        def paradecl(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.ParadeclContext)
            else:
                return self.getTypedRuleContext(MCParser.ParadeclContext,i)


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

        def getRuleIndex(self):
            return MCParser.RULE_paralist




    def paralist(self):

        localctx = MCParser.ParalistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_paralist)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 117
            self.paradecl()
            self.state = 122
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==MCParser.COMA:
                self.state = 118
                self.match(MCParser.COMA)
                self.state = 119
                self.paradecl()
                self.state = 124
                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 ParadeclContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


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

        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_paradecl




    def paradecl(self):

        localctx = MCParser.ParadeclContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_paradecl)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 125
            self.primtype()
            self.state = 126
            self.match(MCParser.ID)
            self.state = 129
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==MCParser.LSB:
                self.state = 127
                self.match(MCParser.LSB)
                self.state = 128
                self.match(MCParser.RSB)


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

    class BlockstmtContext(ParserRuleContext):

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

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

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

        def instruction(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.InstructionContext)
            else:
                return self.getTypedRuleContext(MCParser.InstructionContext,i)


        def getRuleIndex(self):
            return MCParser.RULE_blockstmt




    def blockstmt(self):

        localctx = MCParser.BlockstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_blockstmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 131
            self.match(MCParser.LP)
            self.state = 135
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE) | (1 << MCParser.DO) | (1 << MCParser.FOR) | (1 << MCParser.BREAK) | (1 << MCParser.CONTINUE) | (1 << MCParser.IF) | (1 << MCParser.RETURN) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB) | (1 << MCParser.LP))) != 0):
                self.state = 132
                self.instruction()
                self.state = 137
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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

    class InstructionContext(ParserRuleContext):

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

        def vardecl(self):
            return self.getTypedRuleContext(MCParser.VardeclContext,0)


        def stmt(self):
            return self.getTypedRuleContext(MCParser.StmtContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_instruction




    def instruction(self):

        localctx = MCParser.InstructionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_instruction)
        try:
            self.state = 142
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.BOOLEANTYPE, MCParser.INTTYPE, MCParser.FLOATTYPE, MCParser.STRINGTYPE]:
                self.enterOuterAlt(localctx, 1)
                self.state = 140
                self.vardecl()
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.DO, MCParser.FOR, MCParser.BREAK, MCParser.CONTINUE, MCParser.IF, MCParser.RETURN, MCParser.ID, MCParser.SUB, MCParser.NOT, MCParser.LB, MCParser.LP]:
                self.enterOuterAlt(localctx, 2)
                self.state = 141
                self.stmt()
                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 StmtContext(ParserRuleContext):

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

        def blockstmt(self):
            return self.getTypedRuleContext(MCParser.BlockstmtContext,0)


        def ifstmt(self):
            return self.getTypedRuleContext(MCParser.IfstmtContext,0)


        def whilestmt(self):
            return self.getTypedRuleContext(MCParser.WhilestmtContext,0)


        def forstmt(self):
            return self.getTypedRuleContext(MCParser.ForstmtContext,0)


        def breakstmt(self):
            return self.getTypedRuleContext(MCParser.BreakstmtContext,0)


        def continuestmt(self):
            return self.getTypedRuleContext(MCParser.ContinuestmtContext,0)


        def returnstmt(self):
            return self.getTypedRuleContext(MCParser.ReturnstmtContext,0)


        def exprstmt(self):
            return self.getTypedRuleContext(MCParser.ExprstmtContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_stmt




    def stmt(self):

        localctx = MCParser.StmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_stmt)
        try:
            self.state = 152
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.LP]:
                self.enterOuterAlt(localctx, 1)
                self.state = 144
                self.blockstmt()
                pass
            elif token in [MCParser.IF]:
                self.enterOuterAlt(localctx, 2)
                self.state = 145
                self.ifstmt()
                pass
            elif token in [MCParser.DO]:
                self.enterOuterAlt(localctx, 3)
                self.state = 146
                self.whilestmt()
                pass
            elif token in [MCParser.FOR]:
                self.enterOuterAlt(localctx, 4)
                self.state = 147
                self.forstmt()
                pass
            elif token in [MCParser.BREAK]:
                self.enterOuterAlt(localctx, 5)
                self.state = 148
                self.breakstmt()
                pass
            elif token in [MCParser.CONTINUE]:
                self.enterOuterAlt(localctx, 6)
                self.state = 149
                self.continuestmt()
                pass
            elif token in [MCParser.RETURN]:
                self.enterOuterAlt(localctx, 7)
                self.state = 150
                self.returnstmt()
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.ID, MCParser.SUB, MCParser.NOT, MCParser.LB]:
                self.enterOuterAlt(localctx, 8)
                self.state = 151
                self.exprstmt()
                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 IfstmtContext(ParserRuleContext):

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

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

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def stmt(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.StmtContext)
            else:
                return self.getTypedRuleContext(MCParser.StmtContext,i)


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

        def getRuleIndex(self):
            return MCParser.RULE_ifstmt




    def ifstmt(self):

        localctx = MCParser.IfstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_ifstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 154
            self.match(MCParser.IF)
            self.state = 155
            self.match(MCParser.LB)
            self.state = 156
            self.expr0()
            self.state = 157
            self.match(MCParser.RB)
            self.state = 158
            self.stmt()
            self.state = 161
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
            if la_ == 1:
                self.state = 159
                self.match(MCParser.ELSE)
                self.state = 160
                self.stmt()


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

    class WhilestmtContext(ParserRuleContext):

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

        def DO(self):
            return self.getToken(MCParser.DO, 0)

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def stmt(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.StmtContext)
            else:
                return self.getTypedRuleContext(MCParser.StmtContext,i)


        def getRuleIndex(self):
            return MCParser.RULE_whilestmt




    def whilestmt(self):

        localctx = MCParser.WhilestmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_whilestmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 163
            self.match(MCParser.DO)
            self.state = 165 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 164
                self.stmt()
                self.state = 167 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.DO) | (1 << MCParser.FOR) | (1 << MCParser.BREAK) | (1 << MCParser.CONTINUE) | (1 << MCParser.IF) | (1 << MCParser.RETURN) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB) | (1 << MCParser.LP))) != 0)):
                    break

            self.state = 169
            self.match(MCParser.WHILE)
            self.state = 170
            self.expr0()
            self.state = 171
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ForstmtContext(ParserRuleContext):

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

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

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

        def expr0(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr0Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr0Context,i)


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

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

        def stmt(self):
            return self.getTypedRuleContext(MCParser.StmtContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_forstmt




    def forstmt(self):

        localctx = MCParser.ForstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_forstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 173
            self.match(MCParser.FOR)
            self.state = 174
            self.match(MCParser.LB)
            self.state = 175
            self.expr0()
            self.state = 176
            self.match(MCParser.SEMI)
            self.state = 177
            self.expr0()
            self.state = 178
            self.match(MCParser.SEMI)
            self.state = 179
            self.expr0()
            self.state = 180
            self.match(MCParser.RB)
            self.state = 181
            self.stmt()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BreakstmtContext(ParserRuleContext):

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

        def BREAK(self):
            return self.getToken(MCParser.BREAK, 0)

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

        def getRuleIndex(self):
            return MCParser.RULE_breakstmt




    def breakstmt(self):

        localctx = MCParser.BreakstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_breakstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 183
            self.match(MCParser.BREAK)
            self.state = 184
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ContinuestmtContext(ParserRuleContext):

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

        def CONTINUE(self):
            return self.getToken(MCParser.CONTINUE, 0)

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

        def getRuleIndex(self):
            return MCParser.RULE_continuestmt




    def continuestmt(self):

        localctx = MCParser.ContinuestmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_continuestmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 186
            self.match(MCParser.CONTINUE)
            self.state = 187
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ReturnstmtContext(ParserRuleContext):

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

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

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


        def getRuleIndex(self):
            return MCParser.RULE_returnstmt




    def returnstmt(self):

        localctx = MCParser.ReturnstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_returnstmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 189
            self.match(MCParser.RETURN)
            self.state = 191
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB))) != 0):
                self.state = 190
                self.expr0()


            self.state = 193
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExprstmtContext(ParserRuleContext):

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_exprstmt




    def exprstmt(self):

        localctx = MCParser.ExprstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_exprstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.expr0()
            self.state = 196
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Expr0Context(ParserRuleContext):

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

        def expr1(self):
            return self.getTypedRuleContext(MCParser.Expr1Context,0)


        def ASSIGN(self):
            return self.getToken(MCParser.ASSIGN, 0)

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


        def getRuleIndex(self):
            return MCParser.RULE_expr0




    def expr0(self):

        localctx = MCParser.Expr0Context(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_expr0)
        try:
            self.state = 203
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,14,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 198
                self.expr1(0)
                self.state = 199
                self.match(MCParser.ASSIGN)
                self.state = 200
                self.expr0()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 202
                self.expr1(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 Expr1Context(ParserRuleContext):

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

        def expr2(self):
            return self.getTypedRuleContext(MCParser.Expr2Context,0)


        def expr1(self):
            return self.getTypedRuleContext(MCParser.Expr1Context,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_expr1



    def expr1(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr1Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 44
        self.enterRecursionRule(localctx, 44, self.RULE_expr1, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 206
            self.expr2(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 213
            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
                    localctx = MCParser.Expr1Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr1)
                    self.state = 208
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 209
                    self.match(MCParser.OR)
                    self.state = 210
                    self.expr2(0) 
                self.state = 215
                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

    class Expr2Context(ParserRuleContext):

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

        def expr3(self):
            return self.getTypedRuleContext(MCParser.Expr3Context,0)


        def expr2(self):
            return self.getTypedRuleContext(MCParser.Expr2Context,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_expr2



    def expr2(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr2Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 46
        self.enterRecursionRule(localctx, 46, self.RULE_expr2, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 217
            self.expr3()
            self._ctx.stop = self._input.LT(-1)
            self.state = 224
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,16,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 = MCParser.Expr2Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr2)
                    self.state = 219
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 220
                    self.match(MCParser.AND)
                    self.state = 221
                    self.expr3() 
                self.state = 226
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,16,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 Expr3Context(ParserRuleContext):

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

        def expr4(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr4Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr4Context,i)


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

        def NE(self):
            return self.getToken(MCParser.NE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr3




    def expr3(self):

        localctx = MCParser.Expr3Context(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_expr3)
        self._la = 0 # Token type
        try:
            self.state = 232
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,17,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 227
                self.expr4()
                self.state = 228
                _la = self._input.LA(1)
                if not(_la==MCParser.EQ or _la==MCParser.NE):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 229
                self.expr4()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 231
                self.expr4()
                pass


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

    class Expr4Context(ParserRuleContext):

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

        def expr5(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr5Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr5Context,i)


        def LT(self):
            return self.getToken(MCParser.LT, 0)

        def LE(self):
            return self.getToken(MCParser.LE, 0)

        def GT(self):
            return self.getToken(MCParser.GT, 0)

        def GE(self):
            return self.getToken(MCParser.GE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr4




    def expr4(self):

        localctx = MCParser.Expr4Context(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_expr4)
        self._la = 0 # Token type
        try:
            self.state = 239
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 234
                self.expr5(0)
                self.state = 235
                _la = self._input.LA(1)
                if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.LT) | (1 << MCParser.GT) | (1 << MCParser.LE) | (1 << MCParser.GE))) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 236
                self.expr5(0)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 238
                self.expr5(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 Expr5Context(ParserRuleContext):

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

        def expr6(self):
            return self.getTypedRuleContext(MCParser.Expr6Context,0)


        def expr5(self):
            return self.getTypedRuleContext(MCParser.Expr5Context,0)


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

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

        def getRuleIndex(self):
            return MCParser.RULE_expr5



    def expr5(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr5Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 52
        self.enterRecursionRule(localctx, 52, self.RULE_expr5, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 242
            self.expr6(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 249
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,19,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 = MCParser.Expr5Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr5)
                    self.state = 244
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 245
                    _la = self._input.LA(1)
                    if not(_la==MCParser.ADD or _la==MCParser.SUB):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 246
                    self.expr6(0) 
                self.state = 251
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,19,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 Expr6Context(ParserRuleContext):

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

        def expr7(self):
            return self.getTypedRuleContext(MCParser.Expr7Context,0)


        def expr6(self):
            return self.getTypedRuleContext(MCParser.Expr6Context,0)


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

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

        def MOD(self):
            return self.getToken(MCParser.MOD, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr6



    def expr6(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr6Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 54
        self.enterRecursionRule(localctx, 54, self.RULE_expr6, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 253
            self.expr7()
            self._ctx.stop = self._input.LT(-1)
            self.state = 260
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,20,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 = MCParser.Expr6Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr6)
                    self.state = 255
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 256
                    _la = self._input.LA(1)
                    if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.MUL) | (1 << MCParser.DIV) | (1 << MCParser.MOD))) != 0)):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 257
                    self.expr7() 
                self.state = 262
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,20,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 Expr7Context(ParserRuleContext):

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

        def expr7(self):
            return self.getTypedRuleContext(MCParser.Expr7Context,0)


        def NOT(self):
            return self.getToken(MCParser.NOT, 0)

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

        def expr8(self):
            return self.getTypedRuleContext(MCParser.Expr8Context,0)


        def getRuleIndex(self):
            return MCParser.RULE_expr7




    def expr7(self):

        localctx = MCParser.Expr7Context(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_expr7)
        self._la = 0 # Token type
        try:
            self.state = 266
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.SUB, MCParser.NOT]:
                self.enterOuterAlt(localctx, 1)
                self.state = 263
                _la = self._input.LA(1)
                if not(_la==MCParser.SUB or _la==MCParser.NOT):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 264
                self.expr7()
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.ID, MCParser.LB]:
                self.enterOuterAlt(localctx, 2)
                self.state = 265
                self.expr8()
                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 Expr8Context(ParserRuleContext):

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

        def expr9(self):
            return self.getTypedRuleContext(MCParser.Expr9Context,0)


        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr8




    def expr8(self):

        localctx = MCParser.Expr8Context(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_expr8)
        try:
            self.state = 274
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,22,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 268
                self.expr9()
                self.state = 269
                self.match(MCParser.LSB)
                self.state = 270
                self.expr0()
                self.state = 271
                self.match(MCParser.RSB)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 273
                self.expr9()
                pass


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

    class Expr9Context(ParserRuleContext):

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

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def operand(self):
            return self.getTypedRuleContext(MCParser.OperandContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_expr9




    def expr9(self):

        localctx = MCParser.Expr9Context(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_expr9)
        try:
            self.state = 281
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.LB]:
                self.enterOuterAlt(localctx, 1)
                self.state = 276
                self.match(MCParser.LB)
                self.state = 277
                self.expr0()
                self.state = 278
                self.match(MCParser.RB)
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.ID]:
                self.enterOuterAlt(localctx, 2)
                self.state = 280
                self.operand()
                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 OperandContext(ParserRuleContext):

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

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

        def BOOLEANLIT(self):
            return self.getToken(MCParser.BOOLEANLIT, 0)

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

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

        def STRINGLIT(self):
            return self.getToken(MCParser.STRINGLIT, 0)

        def calfunc(self):
            return self.getTypedRuleContext(MCParser.CalfuncContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_operand




    def operand(self):

        localctx = MCParser.OperandContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_operand)
        try:
            self.state = 289
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,24,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 283
                self.match(MCParser.INTLIT)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 284
                self.match(MCParser.BOOLEANLIT)
                pass

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

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 286
                self.match(MCParser.FLOATLIT)
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 287
                self.match(MCParser.STRINGLIT)
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 288
                self.calfunc()
                pass


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

    class CalfuncContext(ParserRuleContext):

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

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

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

        def arglist(self):
            return self.getTypedRuleContext(MCParser.ArglistContext,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_calfunc




    def calfunc(self):

        localctx = MCParser.CalfuncContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_calfunc)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 291
            self.match(MCParser.ID)
            self.state = 292
            self.match(MCParser.LB)
            self.state = 293
            self.arglist()
            self.state = 294
            self.match(MCParser.RB)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ArglistContext(ParserRuleContext):

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

        def expr0(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr0Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr0Context,i)


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

        def getRuleIndex(self):
            return MCParser.RULE_arglist




    def arglist(self):

        localctx = MCParser.ArglistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_arglist)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 304
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB))) != 0):
                self.state = 296
                self.expr0()
                self.state = 301
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==MCParser.COMA:
                    self.state = 297
                    self.match(MCParser.COMA)
                    self.state = 298
                    self.expr0()
                    self.state = 303
                    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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[22] = self.expr1_sempred
        self._predicates[23] = self.expr2_sempred
        self._predicates[26] = self.expr5_sempred
        self._predicates[27] = self.expr6_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 expr1_sempred(self, localctx:Expr1Context, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 2)
         

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

    def expr5_sempred(self, localctx:Expr5Context, predIndex:int):
            if predIndex == 2:
                return self.precpred(self._ctx, 2)
         

    def expr6_sempred(self, localctx:Expr6Context, predIndex:int):
            if predIndex == 3:
                return self.precpred(self._ctx, 2)
         





# Generated from /home/hpcc/ppl-course/assignment/assignment2/main/mc/parser/MC.g4 by ANTLR 4.7.1
# encoding: utf-8
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys

def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\63")
        buf.write("\u0135\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23")
        buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31")
        buf.write("\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36")
        buf.write("\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\3\2\6\2H\n\2\r\2")
        buf.write("\16\2I\3\2\3\2\3\3\3\3\5\3P\n\3\3\4\3\4\3\4\3\4\3\5\3")
        buf.write("\5\3\6\3\6\3\6\3\6\3\6\5\6]\n\6\3\7\3\7\3\7\3\7\3\7\5")
        buf.write("\7d\n\7\3\b\3\b\3\b\3\b\5\bj\n\b\3\b\3\b\3\b\3\t\3\t\3")
        buf.write("\t\5\tr\n\t\3\n\3\n\3\n\3\n\3\13\3\13\3\13\7\13{\n\13")
        buf.write("\f\13\16\13~\13\13\3\f\3\f\3\f\3\f\5\f\u0084\n\f\3\r\3")
        buf.write("\r\7\r\u0088\n\r\f\r\16\r\u008b\13\r\3\r\3\r\3\16\3\16")
        buf.write("\5\16\u0091\n\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3")
        buf.write("\17\5\17\u009b\n\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20")
        buf.write("\5\20\u00a4\n\20\3\21\3\21\6\21\u00a8\n\21\r\21\16\21")
        buf.write("\u00a9\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3")
        buf.write("\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\24\3\24\3\24")
        buf.write("\3\25\3\25\5\25\u00c2\n\25\3\25\3\25\3\26\3\26\3\26\3")
        buf.write("\27\3\27\3\27\3\27\3\27\5\27\u00ce\n\27\3\30\3\30\3\30")
        buf.write("\3\30\3\30\3\30\7\30\u00d6\n\30\f\30\16\30\u00d9\13\30")
        buf.write("\3\31\3\31\3\31\3\31\3\31\3\31\7\31\u00e1\n\31\f\31\16")
        buf.write("\31\u00e4\13\31\3\32\3\32\3\32\3\32\3\32\5\32\u00eb\n")
        buf.write("\32\3\33\3\33\3\33\3\33\3\33\5\33\u00f2\n\33\3\34\3\34")
        buf.write("\3\34\3\34\3\34\3\34\7\34\u00fa\n\34\f\34\16\34\u00fd")
        buf.write("\13\34\3\35\3\35\3\35\3\35\3\35\3\35\7\35\u0105\n\35\f")
        buf.write("\35\16\35\u0108\13\35\3\36\3\36\3\36\5\36\u010d\n\36\3")
        buf.write("\37\3\37\3\37\3\37\3\37\3\37\5\37\u0115\n\37\3 \3 \3 ")
        buf.write("\3 \3 \5 \u011c\n \3!\3!\3!\3!\3!\3!\5!\u0124\n!\3\"\3")
        buf.write("\"\3\"\3\"\3\"\3#\3#\3#\7#\u012e\n#\f#\16#\u0131\13#\5")
        buf.write("#\u0133\n#\3#\2\6.\60\668$\2\4\6\b\n\f\16\20\22\24\26")
        buf.write("\30\32\34\36 \"$&(*,.\60\62\64\668:<>@BD\2\b\3\2\7\n\3")
        buf.write("\2\37 \3\2!$\3\2\27\30\3\2\31\33\4\2\30\30\34\34\2\u0138")
        buf.write("\2G\3\2\2\2\4O\3\2\2\2\6Q\3\2\2\2\bU\3\2\2\2\n\\\3\2\2")
        buf.write("\2\fc\3\2\2\2\16e\3\2\2\2\20q\3\2\2\2\22s\3\2\2\2\24w")
        buf.write("\3\2\2\2\26\177\3\2\2\2\30\u0085\3\2\2\2\32\u0090\3\2")
        buf.write("\2\2\34\u009a\3\2\2\2\36\u009c\3\2\2\2 \u00a5\3\2\2\2")
        buf.write("\"\u00af\3\2\2\2$\u00b9\3\2\2\2&\u00bc\3\2\2\2(\u00bf")
        buf.write("\3\2\2\2*\u00c5\3\2\2\2,\u00cd\3\2\2\2.\u00cf\3\2\2\2")
        buf.write("\60\u00da\3\2\2\2\62\u00ea\3\2\2\2\64\u00f1\3\2\2\2\66")
        buf.write("\u00f3\3\2\2\28\u00fe\3\2\2\2:\u010c\3\2\2\2<\u0114\3")
        buf.write("\2\2\2>\u011b\3\2\2\2@\u0123\3\2\2\2B\u0125\3\2\2\2D\u0132")
        buf.write("\3\2\2\2FH\5\4\3\2GF\3\2\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2")
        buf.write("\2\2JK\3\2\2\2KL\7\2\2\3L\3\3\2\2\2MP\5\6\4\2NP\5\16\b")
        buf.write("\2OM\3\2\2\2ON\3\2\2\2P\5\3\2\2\2QR\5\b\5\2RS\5\n\6\2")
        buf.write("ST\7-\2\2T\7\3\2\2\2UV\t\2\2\2V\t\3\2\2\2WX\5\f\7\2XY")
        buf.write("\7,\2\2YZ\5\n\6\2Z]\3\2\2\2[]\5\f\7\2\\W\3\2\2\2\\[\3")
        buf.write("\2\2\2]\13\3\2\2\2^_\7\26\2\2_`\7*\2\2`a\7\3\2\2ad\7+")
        buf.write("\2\2bd\7\26\2\2c^\3\2\2\2cb\3\2\2\2d\r\3\2\2\2ef\5\20")
        buf.write("\t\2fg\7\26\2\2gi\7&\2\2hj\5\24\13\2ih\3\2\2\2ij\3\2\2")
        buf.write("\2jk\3\2\2\2kl\7\'\2\2lm\5\30\r\2m\17\3\2\2\2nr\5\b\5")
        buf.write("\2or\5\22\n\2pr\7\13\2\2qn\3\2\2\2qo\3\2\2\2qp\3\2\2\2")
        buf.write("r\21\3\2\2\2st\5\b\5\2tu\7*\2\2uv\7+\2\2v\23\3\2\2\2w")
        buf.write("|\5\26\f\2xy\7,\2\2y{\5\26\f\2zx\3\2\2\2{~\3\2\2\2|z\3")
        buf.write("\2\2\2|}\3\2\2\2}\25\3\2\2\2~|\3\2\2\2\177\u0080\5\b\5")
        buf.write("\2\u0080\u0083\7\26\2\2\u0081\u0082\7*\2\2\u0082\u0084")
        buf.write("\7+\2\2\u0083\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084")
        buf.write("\27\3\2\2\2\u0085\u0089\7(\2\2\u0086\u0088\5\32\16\2\u0087")
        buf.write("\u0086\3\2\2\2\u0088\u008b\3\2\2\2\u0089\u0087\3\2\2\2")
        buf.write("\u0089\u008a\3\2\2\2\u008a\u008c\3\2\2\2\u008b\u0089\3")
        buf.write("\2\2\2\u008c\u008d\7)\2\2\u008d\31\3\2\2\2\u008e\u0091")
        buf.write("\5\6\4\2\u008f\u0091\5\34\17\2\u0090\u008e\3\2\2\2\u0090")
        buf.write("\u008f\3\2\2\2\u0091\33\3\2\2\2\u0092\u009b\5\30\r\2\u0093")
        buf.write("\u009b\5\36\20\2\u0094\u009b\5 \21\2\u0095\u009b\5\"\22")
        buf.write("\2\u0096\u009b\5$\23\2\u0097\u009b\5&\24\2\u0098\u009b")
        buf.write("\5(\25\2\u0099\u009b\5*\26\2\u009a\u0092\3\2\2\2\u009a")
        buf.write("\u0093\3\2\2\2\u009a\u0094\3\2\2\2\u009a\u0095\3\2\2\2")
        buf.write("\u009a\u0096\3\2\2\2\u009a\u0097\3\2\2\2\u009a\u0098\3")
        buf.write("\2\2\2\u009a\u0099\3\2\2\2\u009b\35\3\2\2\2\u009c\u009d")
        buf.write("\7\21\2\2\u009d\u009e\7&\2\2\u009e\u009f\5,\27\2\u009f")
        buf.write("\u00a0\7\'\2\2\u00a0\u00a3\5\34\17\2\u00a1\u00a2\7\22")
        buf.write("\2\2\u00a2\u00a4\5\34\17\2\u00a3\u00a1\3\2\2\2\u00a3\u00a4")
        buf.write("\3\2\2\2\u00a4\37\3\2\2\2\u00a5\u00a7\7\f\2\2\u00a6\u00a8")
        buf.write("\5\34\17\2\u00a7\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9")
        buf.write("\u00a7\3\2\2\2\u00a9\u00aa\3\2\2\2\u00aa\u00ab\3\2\2\2")
        buf.write("\u00ab\u00ac\7\r\2\2\u00ac\u00ad\5,\27\2\u00ad\u00ae\7")
        buf.write("-\2\2\u00ae!\3\2\2\2\u00af\u00b0\7\16\2\2\u00b0\u00b1")
        buf.write("\7&\2\2\u00b1\u00b2\5,\27\2\u00b2\u00b3\7-\2\2\u00b3\u00b4")
        buf.write("\5,\27\2\u00b4\u00b5\7-\2\2\u00b5\u00b6\5,\27\2\u00b6")
        buf.write("\u00b7\7\'\2\2\u00b7\u00b8\5\34\17\2\u00b8#\3\2\2\2\u00b9")
        buf.write("\u00ba\7\17\2\2\u00ba\u00bb\7-\2\2\u00bb%\3\2\2\2\u00bc")
        buf.write("\u00bd\7\20\2\2\u00bd\u00be\7-\2\2\u00be\'\3\2\2\2\u00bf")
        buf.write("\u00c1\7\23\2\2\u00c0\u00c2\5,\27\2\u00c1\u00c0\3\2\2")
        buf.write("\2\u00c1\u00c2\3\2\2\2\u00c2\u00c3\3\2\2\2\u00c3\u00c4")
        buf.write("\7-\2\2\u00c4)\3\2\2\2\u00c5\u00c6\5,\27\2\u00c6\u00c7")
        buf.write("\7-\2\2\u00c7+\3\2\2\2\u00c8\u00c9\5.\30\2\u00c9\u00ca")
        buf.write("\7%\2\2\u00ca\u00cb\5,\27\2\u00cb\u00ce\3\2\2\2\u00cc")
        buf.write("\u00ce\5.\30\2\u00cd\u00c8\3\2\2\2\u00cd\u00cc\3\2\2\2")
        buf.write("\u00ce-\3\2\2\2\u00cf\u00d0\b\30\1\2\u00d0\u00d1\5\60")
        buf.write("\31\2\u00d1\u00d7\3\2\2\2\u00d2\u00d3\f\4\2\2\u00d3\u00d4")
        buf.write("\7\35\2\2\u00d4\u00d6\5\60\31\2\u00d5\u00d2\3\2\2\2\u00d6")
        buf.write("\u00d9\3\2\2\2\u00d7\u00d5\3\2\2\2\u00d7\u00d8\3\2\2\2")
        buf.write("\u00d8/\3\2\2\2\u00d9\u00d7\3\2\2\2\u00da\u00db\b\31\1")
        buf.write("\2\u00db\u00dc\5\62\32\2\u00dc\u00e2\3\2\2\2\u00dd\u00de")
        buf.write("\f\4\2\2\u00de\u00df\7\36\2\2\u00df\u00e1\5\62\32\2\u00e0")
        buf.write("\u00dd\3\2\2\2\u00e1\u00e4\3\2\2\2\u00e2\u00e0\3\2\2\2")
        buf.write("\u00e2\u00e3\3\2\2\2\u00e3\61\3\2\2\2\u00e4\u00e2\3\2")
        buf.write("\2\2\u00e5\u00e6\5\64\33\2\u00e6\u00e7\t\3\2\2\u00e7\u00e8")
        buf.write("\5\64\33\2\u00e8\u00eb\3\2\2\2\u00e9\u00eb\5\64\33\2\u00ea")
        buf.write("\u00e5\3\2\2\2\u00ea\u00e9\3\2\2\2\u00eb\63\3\2\2\2\u00ec")
        buf.write("\u00ed\5\66\34\2\u00ed\u00ee\t\4\2\2\u00ee\u00ef\5\66")
        buf.write("\34\2\u00ef\u00f2\3\2\2\2\u00f0\u00f2\5\66\34\2\u00f1")
        buf.write("\u00ec\3\2\2\2\u00f1\u00f0\3\2\2\2\u00f2\65\3\2\2\2\u00f3")
        buf.write("\u00f4\b\34\1\2\u00f4\u00f5\58\35\2\u00f5\u00fb\3\2\2")
        buf.write("\2\u00f6\u00f7\f\4\2\2\u00f7\u00f8\t\5\2\2\u00f8\u00fa")
        buf.write("\58\35\2\u00f9\u00f6\3\2\2\2\u00fa\u00fd\3\2\2\2\u00fb")
        buf.write("\u00f9\3\2\2\2\u00fb\u00fc\3\2\2\2\u00fc\67\3\2\2\2\u00fd")
        buf.write("\u00fb\3\2\2\2\u00fe\u00ff\b\35\1\2\u00ff\u0100\5:\36")
        buf.write("\2\u0100\u0106\3\2\2\2\u0101\u0102\f\4\2\2\u0102\u0103")
        buf.write("\t\6\2\2\u0103\u0105\5:\36\2\u0104\u0101\3\2\2\2\u0105")
        buf.write("\u0108\3\2\2\2\u0106\u0104\3\2\2\2\u0106\u0107\3\2\2\2")
        buf.write("\u01079\3\2\2\2\u0108\u0106\3\2\2\2\u0109\u010a\t\7\2")
        buf.write("\2\u010a\u010d\5:\36\2\u010b\u010d\5<\37\2\u010c\u0109")
        buf.write("\3\2\2\2\u010c\u010b\3\2\2\2\u010d;\3\2\2\2\u010e\u010f")
        buf.write("\5> \2\u010f\u0110\7*\2\2\u0110\u0111\5,\27\2\u0111\u0112")
        buf.write("\7+\2\2\u0112\u0115\3\2\2\2\u0113\u0115\5> \2\u0114\u010e")
        buf.write("\3\2\2\2\u0114\u0113\3\2\2\2\u0115=\3\2\2\2\u0116\u0117")
        buf.write("\7&\2\2\u0117\u0118\5,\27\2\u0118\u0119\7\'\2\2\u0119")
        buf.write("\u011c\3\2\2\2\u011a\u011c\5@!\2\u011b\u0116\3\2\2\2\u011b")
        buf.write("\u011a\3\2\2\2\u011c?\3\2\2\2\u011d\u0124\7\3\2\2\u011e")
        buf.write("\u0124\7\5\2\2\u011f\u0124\7\26\2\2\u0120\u0124\7\4\2")
        buf.write("\2\u0121\u0124\7\6\2\2\u0122\u0124\5B\"\2\u0123\u011d")
        buf.write("\3\2\2\2\u0123\u011e\3\2\2\2\u0123\u011f\3\2\2\2\u0123")
        buf.write("\u0120\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0122\3\2\2\2")
        buf.write("\u0124A\3\2\2\2\u0125\u0126\7\26\2\2\u0126\u0127\7&\2")
        buf.write("\2\u0127\u0128\5D#\2\u0128\u0129\7\'\2\2\u0129C\3\2\2")
        buf.write("\2\u012a\u012f\5,\27\2\u012b\u012c\7,\2\2\u012c\u012e")
        buf.write("\5,\27\2\u012d\u012b\3\2\2\2\u012e\u0131\3\2\2\2\u012f")
        buf.write("\u012d\3\2\2\2\u012f\u0130\3\2\2\2\u0130\u0133\3\2\2\2")
        buf.write("\u0131\u012f\3\2\2\2\u0132\u012a\3\2\2\2\u0132\u0133\3")
        buf.write("\2\2\2\u0133E\3\2\2\2\35IO\\ciq|\u0083\u0089\u0090\u009a")
        buf.write("\u00a3\u00a9\u00c1\u00cd\u00d7\u00e2\u00ea\u00f1\u00fb")
        buf.write("\u0106\u010c\u0114\u011b\u0123\u012f\u0132")
        return buf.getvalue()


class MCParser ( Parser ):

    grammarFileName = "MC.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "'boolean'", "'int'", "'float'", "'string'", 
                     "'void'", "'do'", "'while'", "'for'", "'break'", "'continue'", 
                     "'if'", "'else'", "'return'", "'true'", "'false'", 
                     "<INVALID>", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", 
                     "'||'", "'&&'", "'=='", "'!='", "'<'", "'>'", "'<='", 
                     "'>='", "'='", "'('", "')'", "'{'", "'}'", "'['", "']'", 
                     "','", "';'" ]

    symbolicNames = [ "<INVALID>", "INTLIT", "FLOATLIT", "BOOLEANLIT", "STRINGLIT", 
                      "BOOLEANTYPE", "INTTYPE", "FLOATTYPE", "STRINGTYPE", 
                      "VOIDTYPE", "DO", "WHILE", "FOR", "BREAK", "CONTINUE", 
                      "IF", "ELSE", "RETURN", "TRUE", "FALSE", "ID", "ADD", 
                      "SUB", "MUL", "DIV", "MOD", "NOT", "OR", "AND", "EQ", 
                      "NE", "LT", "GT", "LE", "GE", "ASSIGN", "LB", "RB", 
                      "LP", "RP", "LSB", "RSB", "COMA", "SEMI", "CMTLINE", 
                      "CMTBLOCK", "WS", "UNCLOSE_STRING", "ILLEGAL_ESCAPE", 
                      "ERROR_CHAR" ]

    RULE_program = 0
    RULE_declaration = 1
    RULE_vardecl = 2
    RULE_primtype = 3
    RULE_varlist = 4
    RULE_var = 5
    RULE_funcdecl = 6
    RULE_functype = 7
    RULE_arraytype = 8
    RULE_paralist = 9
    RULE_paradecl = 10
    RULE_blockstmt = 11
    RULE_instruction = 12
    RULE_stmt = 13
    RULE_ifstmt = 14
    RULE_whilestmt = 15
    RULE_forstmt = 16
    RULE_breakstmt = 17
    RULE_continuestmt = 18
    RULE_returnstmt = 19
    RULE_exprstmt = 20
    RULE_expr0 = 21
    RULE_expr1 = 22
    RULE_expr2 = 23
    RULE_expr3 = 24
    RULE_expr4 = 25
    RULE_expr5 = 26
    RULE_expr6 = 27
    RULE_expr7 = 28
    RULE_expr8 = 29
    RULE_expr9 = 30
    RULE_operand = 31
    RULE_calfunc = 32
    RULE_arglist = 33

    ruleNames =  [ "program", "declaration", "vardecl", "primtype", "varlist", 
                   "var", "funcdecl", "functype", "arraytype", "paralist", 
                   "paradecl", "blockstmt", "instruction", "stmt", "ifstmt", 
                   "whilestmt", "forstmt", "breakstmt", "continuestmt", 
                   "returnstmt", "exprstmt", "expr0", "expr1", "expr2", 
                   "expr3", "expr4", "expr5", "expr6", "expr7", "expr8", 
                   "expr9", "operand", "calfunc", "arglist" ]

    EOF = Token.EOF
    INTLIT=1
    FLOATLIT=2
    BOOLEANLIT=3
    STRINGLIT=4
    BOOLEANTYPE=5
    INTTYPE=6
    FLOATTYPE=7
    STRINGTYPE=8
    VOIDTYPE=9
    DO=10
    WHILE=11
    FOR=12
    BREAK=13
    CONTINUE=14
    IF=15
    ELSE=16
    RETURN=17
    TRUE=18
    FALSE=19
    ID=20
    ADD=21
    SUB=22
    MUL=23
    DIV=24
    MOD=25
    NOT=26
    OR=27
    AND=28
    EQ=29
    NE=30
    LT=31
    GT=32
    LE=33
    GE=34
    ASSIGN=35
    LB=36
    RB=37
    LP=38
    RP=39
    LSB=40
    RSB=41
    COMA=42
    SEMI=43
    CMTLINE=44
    CMTBLOCK=45
    WS=46
    UNCLOSE_STRING=47
    ILLEGAL_ESCAPE=48
    ERROR_CHAR=49

    def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
        super().__init__(input, output)
        self.checkVersion("4.7.1")
        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 EOF(self):
            return self.getToken(MCParser.EOF, 0)

        def declaration(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.DeclarationContext)
            else:
                return self.getTypedRuleContext(MCParser.DeclarationContext,i)


        def getRuleIndex(self):
            return MCParser.RULE_program




    def program(self):

        localctx = MCParser.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 = 69 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 68
                self.declaration()
                self.state = 71 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE) | (1 << MCParser.VOIDTYPE))) != 0)):
                    break

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

    class DeclarationContext(ParserRuleContext):

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

        def vardecl(self):
            return self.getTypedRuleContext(MCParser.VardeclContext,0)


        def funcdecl(self):
            return self.getTypedRuleContext(MCParser.FuncdeclContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_declaration




    def declaration(self):

        localctx = MCParser.DeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_declaration)
        try:
            self.state = 77
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,1,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 75
                self.vardecl()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 76
                self.funcdecl()
                pass


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

    class VardeclContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


        def varlist(self):
            return self.getTypedRuleContext(MCParser.VarlistContext,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_vardecl




    def vardecl(self):

        localctx = MCParser.VardeclContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_vardecl)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 79
            self.primtype()
            self.state = 80
            self.varlist()
            self.state = 81
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class PrimtypeContext(ParserRuleContext):

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

        def BOOLEANTYPE(self):
            return self.getToken(MCParser.BOOLEANTYPE, 0)

        def INTTYPE(self):
            return self.getToken(MCParser.INTTYPE, 0)

        def FLOATTYPE(self):
            return self.getToken(MCParser.FLOATTYPE, 0)

        def STRINGTYPE(self):
            return self.getToken(MCParser.STRINGTYPE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_primtype




    def primtype(self):

        localctx = MCParser.PrimtypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_primtype)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 83
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class VarlistContext(ParserRuleContext):

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

        def var(self):
            return self.getTypedRuleContext(MCParser.VarContext,0)


        def COMA(self):
            return self.getToken(MCParser.COMA, 0)

        def varlist(self):
            return self.getTypedRuleContext(MCParser.VarlistContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_varlist




    def varlist(self):

        localctx = MCParser.VarlistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_varlist)
        try:
            self.state = 90
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 85
                self.var()
                self.state = 86
                self.match(MCParser.COMA)
                self.state = 87
                self.varlist()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 89
                self.var()
                pass


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

    class VarContext(ParserRuleContext):

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

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

        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

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

        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_var




    def var(self):

        localctx = MCParser.VarContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_var)
        try:
            self.state = 97
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,3,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 92
                self.match(MCParser.ID)
                self.state = 93
                self.match(MCParser.LSB)
                self.state = 94
                self.match(MCParser.INTLIT)
                self.state = 95
                self.match(MCParser.RSB)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 96
                self.match(MCParser.ID)
                pass


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

    class FuncdeclContext(ParserRuleContext):

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

        def functype(self):
            return self.getTypedRuleContext(MCParser.FunctypeContext,0)


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

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

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

        def blockstmt(self):
            return self.getTypedRuleContext(MCParser.BlockstmtContext,0)


        def paralist(self):
            return self.getTypedRuleContext(MCParser.ParalistContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_funcdecl




    def funcdecl(self):

        localctx = MCParser.FuncdeclContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_funcdecl)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 99
            self.functype()
            self.state = 100
            self.match(MCParser.ID)
            self.state = 101
            self.match(MCParser.LB)
            self.state = 103
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE))) != 0):
                self.state = 102
                self.paralist()


            self.state = 105
            self.match(MCParser.RB)
            self.state = 106
            self.blockstmt()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FunctypeContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


        def arraytype(self):
            return self.getTypedRuleContext(MCParser.ArraytypeContext,0)


        def VOIDTYPE(self):
            return self.getToken(MCParser.VOIDTYPE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_functype




    def functype(self):

        localctx = MCParser.FunctypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_functype)
        try:
            self.state = 111
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 108
                self.primtype()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 109
                self.arraytype()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 110
                self.match(MCParser.VOIDTYPE)
                pass


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

    class ArraytypeContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_arraytype




    def arraytype(self):

        localctx = MCParser.ArraytypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_arraytype)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self.primtype()
            self.state = 114
            self.match(MCParser.LSB)
            self.state = 115
            self.match(MCParser.RSB)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ParalistContext(ParserRuleContext):

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

        def paradecl(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.ParadeclContext)
            else:
                return self.getTypedRuleContext(MCParser.ParadeclContext,i)


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

        def getRuleIndex(self):
            return MCParser.RULE_paralist




    def paralist(self):

        localctx = MCParser.ParalistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_paralist)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 117
            self.paradecl()
            self.state = 122
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==MCParser.COMA:
                self.state = 118
                self.match(MCParser.COMA)
                self.state = 119
                self.paradecl()
                self.state = 124
                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 ParadeclContext(ParserRuleContext):

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

        def primtype(self):
            return self.getTypedRuleContext(MCParser.PrimtypeContext,0)


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

        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_paradecl




    def paradecl(self):

        localctx = MCParser.ParadeclContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_paradecl)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 125
            self.primtype()
            self.state = 126
            self.match(MCParser.ID)
            self.state = 129
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==MCParser.LSB:
                self.state = 127
                self.match(MCParser.LSB)
                self.state = 128
                self.match(MCParser.RSB)


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

    class BlockstmtContext(ParserRuleContext):

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

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

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

        def instruction(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.InstructionContext)
            else:
                return self.getTypedRuleContext(MCParser.InstructionContext,i)


        def getRuleIndex(self):
            return MCParser.RULE_blockstmt




    def blockstmt(self):

        localctx = MCParser.BlockstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_blockstmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 131
            self.match(MCParser.LP)
            self.state = 135
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.BOOLEANTYPE) | (1 << MCParser.INTTYPE) | (1 << MCParser.FLOATTYPE) | (1 << MCParser.STRINGTYPE) | (1 << MCParser.DO) | (1 << MCParser.FOR) | (1 << MCParser.BREAK) | (1 << MCParser.CONTINUE) | (1 << MCParser.IF) | (1 << MCParser.RETURN) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB) | (1 << MCParser.LP))) != 0):
                self.state = 132
                self.instruction()
                self.state = 137
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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

    class InstructionContext(ParserRuleContext):

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

        def vardecl(self):
            return self.getTypedRuleContext(MCParser.VardeclContext,0)


        def stmt(self):
            return self.getTypedRuleContext(MCParser.StmtContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_instruction




    def instruction(self):

        localctx = MCParser.InstructionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_instruction)
        try:
            self.state = 142
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.BOOLEANTYPE, MCParser.INTTYPE, MCParser.FLOATTYPE, MCParser.STRINGTYPE]:
                self.enterOuterAlt(localctx, 1)
                self.state = 140
                self.vardecl()
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.DO, MCParser.FOR, MCParser.BREAK, MCParser.CONTINUE, MCParser.IF, MCParser.RETURN, MCParser.ID, MCParser.SUB, MCParser.NOT, MCParser.LB, MCParser.LP]:
                self.enterOuterAlt(localctx, 2)
                self.state = 141
                self.stmt()
                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 StmtContext(ParserRuleContext):

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

        def blockstmt(self):
            return self.getTypedRuleContext(MCParser.BlockstmtContext,0)


        def ifstmt(self):
            return self.getTypedRuleContext(MCParser.IfstmtContext,0)


        def whilestmt(self):
            return self.getTypedRuleContext(MCParser.WhilestmtContext,0)


        def forstmt(self):
            return self.getTypedRuleContext(MCParser.ForstmtContext,0)


        def breakstmt(self):
            return self.getTypedRuleContext(MCParser.BreakstmtContext,0)


        def continuestmt(self):
            return self.getTypedRuleContext(MCParser.ContinuestmtContext,0)


        def returnstmt(self):
            return self.getTypedRuleContext(MCParser.ReturnstmtContext,0)


        def exprstmt(self):
            return self.getTypedRuleContext(MCParser.ExprstmtContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_stmt




    def stmt(self):

        localctx = MCParser.StmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_stmt)
        try:
            self.state = 152
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.LP]:
                self.enterOuterAlt(localctx, 1)
                self.state = 144
                self.blockstmt()
                pass
            elif token in [MCParser.IF]:
                self.enterOuterAlt(localctx, 2)
                self.state = 145
                self.ifstmt()
                pass
            elif token in [MCParser.DO]:
                self.enterOuterAlt(localctx, 3)
                self.state = 146
                self.whilestmt()
                pass
            elif token in [MCParser.FOR]:
                self.enterOuterAlt(localctx, 4)
                self.state = 147
                self.forstmt()
                pass
            elif token in [MCParser.BREAK]:
                self.enterOuterAlt(localctx, 5)
                self.state = 148
                self.breakstmt()
                pass
            elif token in [MCParser.CONTINUE]:
                self.enterOuterAlt(localctx, 6)
                self.state = 149
                self.continuestmt()
                pass
            elif token in [MCParser.RETURN]:
                self.enterOuterAlt(localctx, 7)
                self.state = 150
                self.returnstmt()
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.ID, MCParser.SUB, MCParser.NOT, MCParser.LB]:
                self.enterOuterAlt(localctx, 8)
                self.state = 151
                self.exprstmt()
                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 IfstmtContext(ParserRuleContext):

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

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

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def stmt(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.StmtContext)
            else:
                return self.getTypedRuleContext(MCParser.StmtContext,i)


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

        def getRuleIndex(self):
            return MCParser.RULE_ifstmt




    def ifstmt(self):

        localctx = MCParser.IfstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_ifstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 154
            self.match(MCParser.IF)
            self.state = 155
            self.match(MCParser.LB)
            self.state = 156
            self.expr0()
            self.state = 157
            self.match(MCParser.RB)
            self.state = 158
            self.stmt()
            self.state = 161
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
            if la_ == 1:
                self.state = 159
                self.match(MCParser.ELSE)
                self.state = 160
                self.stmt()


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

    class WhilestmtContext(ParserRuleContext):

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

        def DO(self):
            return self.getToken(MCParser.DO, 0)

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def stmt(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.StmtContext)
            else:
                return self.getTypedRuleContext(MCParser.StmtContext,i)


        def getRuleIndex(self):
            return MCParser.RULE_whilestmt




    def whilestmt(self):

        localctx = MCParser.WhilestmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_whilestmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 163
            self.match(MCParser.DO)
            self.state = 165 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 164
                self.stmt()
                self.state = 167 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.DO) | (1 << MCParser.FOR) | (1 << MCParser.BREAK) | (1 << MCParser.CONTINUE) | (1 << MCParser.IF) | (1 << MCParser.RETURN) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB) | (1 << MCParser.LP))) != 0)):
                    break

            self.state = 169
            self.match(MCParser.WHILE)
            self.state = 170
            self.expr0()
            self.state = 171
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ForstmtContext(ParserRuleContext):

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

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

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

        def expr0(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr0Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr0Context,i)


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

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

        def stmt(self):
            return self.getTypedRuleContext(MCParser.StmtContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_forstmt




    def forstmt(self):

        localctx = MCParser.ForstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_forstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 173
            self.match(MCParser.FOR)
            self.state = 174
            self.match(MCParser.LB)
            self.state = 175
            self.expr0()
            self.state = 176
            self.match(MCParser.SEMI)
            self.state = 177
            self.expr0()
            self.state = 178
            self.match(MCParser.SEMI)
            self.state = 179
            self.expr0()
            self.state = 180
            self.match(MCParser.RB)
            self.state = 181
            self.stmt()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BreakstmtContext(ParserRuleContext):

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

        def BREAK(self):
            return self.getToken(MCParser.BREAK, 0)

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

        def getRuleIndex(self):
            return MCParser.RULE_breakstmt




    def breakstmt(self):

        localctx = MCParser.BreakstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_breakstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 183
            self.match(MCParser.BREAK)
            self.state = 184
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ContinuestmtContext(ParserRuleContext):

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

        def CONTINUE(self):
            return self.getToken(MCParser.CONTINUE, 0)

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

        def getRuleIndex(self):
            return MCParser.RULE_continuestmt




    def continuestmt(self):

        localctx = MCParser.ContinuestmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_continuestmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 186
            self.match(MCParser.CONTINUE)
            self.state = 187
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ReturnstmtContext(ParserRuleContext):

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

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

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


        def getRuleIndex(self):
            return MCParser.RULE_returnstmt




    def returnstmt(self):

        localctx = MCParser.ReturnstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_returnstmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 189
            self.match(MCParser.RETURN)
            self.state = 191
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB))) != 0):
                self.state = 190
                self.expr0()


            self.state = 193
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExprstmtContext(ParserRuleContext):

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_exprstmt




    def exprstmt(self):

        localctx = MCParser.ExprstmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_exprstmt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.expr0()
            self.state = 196
            self.match(MCParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Expr0Context(ParserRuleContext):

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

        def expr1(self):
            return self.getTypedRuleContext(MCParser.Expr1Context,0)


        def ASSIGN(self):
            return self.getToken(MCParser.ASSIGN, 0)

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


        def getRuleIndex(self):
            return MCParser.RULE_expr0




    def expr0(self):

        localctx = MCParser.Expr0Context(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_expr0)
        try:
            self.state = 203
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,14,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 198
                self.expr1(0)
                self.state = 199
                self.match(MCParser.ASSIGN)
                self.state = 200
                self.expr0()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 202
                self.expr1(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 Expr1Context(ParserRuleContext):

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

        def expr2(self):
            return self.getTypedRuleContext(MCParser.Expr2Context,0)


        def expr1(self):
            return self.getTypedRuleContext(MCParser.Expr1Context,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_expr1



    def expr1(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr1Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 44
        self.enterRecursionRule(localctx, 44, self.RULE_expr1, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 206
            self.expr2(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 213
            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
                    localctx = MCParser.Expr1Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr1)
                    self.state = 208
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 209
                    self.match(MCParser.OR)
                    self.state = 210
                    self.expr2(0) 
                self.state = 215
                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

    class Expr2Context(ParserRuleContext):

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

        def expr3(self):
            return self.getTypedRuleContext(MCParser.Expr3Context,0)


        def expr2(self):
            return self.getTypedRuleContext(MCParser.Expr2Context,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_expr2



    def expr2(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr2Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 46
        self.enterRecursionRule(localctx, 46, self.RULE_expr2, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 217
            self.expr3()
            self._ctx.stop = self._input.LT(-1)
            self.state = 224
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,16,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 = MCParser.Expr2Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr2)
                    self.state = 219
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 220
                    self.match(MCParser.AND)
                    self.state = 221
                    self.expr3() 
                self.state = 226
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,16,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 Expr3Context(ParserRuleContext):

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

        def expr4(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr4Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr4Context,i)


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

        def NE(self):
            return self.getToken(MCParser.NE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr3




    def expr3(self):

        localctx = MCParser.Expr3Context(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_expr3)
        self._la = 0 # Token type
        try:
            self.state = 232
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,17,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 227
                self.expr4()
                self.state = 228
                _la = self._input.LA(1)
                if not(_la==MCParser.EQ or _la==MCParser.NE):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 229
                self.expr4()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 231
                self.expr4()
                pass


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

    class Expr4Context(ParserRuleContext):

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

        def expr5(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr5Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr5Context,i)


        def LT(self):
            return self.getToken(MCParser.LT, 0)

        def LE(self):
            return self.getToken(MCParser.LE, 0)

        def GT(self):
            return self.getToken(MCParser.GT, 0)

        def GE(self):
            return self.getToken(MCParser.GE, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr4




    def expr4(self):

        localctx = MCParser.Expr4Context(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_expr4)
        self._la = 0 # Token type
        try:
            self.state = 239
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 234
                self.expr5(0)
                self.state = 235
                _la = self._input.LA(1)
                if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.LT) | (1 << MCParser.GT) | (1 << MCParser.LE) | (1 << MCParser.GE))) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 236
                self.expr5(0)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 238
                self.expr5(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 Expr5Context(ParserRuleContext):

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

        def expr6(self):
            return self.getTypedRuleContext(MCParser.Expr6Context,0)


        def expr5(self):
            return self.getTypedRuleContext(MCParser.Expr5Context,0)


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

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

        def getRuleIndex(self):
            return MCParser.RULE_expr5



    def expr5(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr5Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 52
        self.enterRecursionRule(localctx, 52, self.RULE_expr5, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 242
            self.expr6(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 249
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,19,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 = MCParser.Expr5Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr5)
                    self.state = 244
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 245
                    _la = self._input.LA(1)
                    if not(_la==MCParser.ADD or _la==MCParser.SUB):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 246
                    self.expr6(0) 
                self.state = 251
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,19,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 Expr6Context(ParserRuleContext):

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

        def expr7(self):
            return self.getTypedRuleContext(MCParser.Expr7Context,0)


        def expr6(self):
            return self.getTypedRuleContext(MCParser.Expr6Context,0)


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

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

        def MOD(self):
            return self.getToken(MCParser.MOD, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr6



    def expr6(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MCParser.Expr6Context(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 54
        self.enterRecursionRule(localctx, 54, self.RULE_expr6, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 253
            self.expr7()
            self._ctx.stop = self._input.LT(-1)
            self.state = 260
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,20,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 = MCParser.Expr6Context(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expr6)
                    self.state = 255
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 256
                    _la = self._input.LA(1)
                    if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.MUL) | (1 << MCParser.DIV) | (1 << MCParser.MOD))) != 0)):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 257
                    self.expr7() 
                self.state = 262
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,20,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 Expr7Context(ParserRuleContext):

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

        def expr7(self):
            return self.getTypedRuleContext(MCParser.Expr7Context,0)


        def NOT(self):
            return self.getToken(MCParser.NOT, 0)

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

        def expr8(self):
            return self.getTypedRuleContext(MCParser.Expr8Context,0)


        def getRuleIndex(self):
            return MCParser.RULE_expr7




    def expr7(self):

        localctx = MCParser.Expr7Context(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_expr7)
        self._la = 0 # Token type
        try:
            self.state = 266
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.SUB, MCParser.NOT]:
                self.enterOuterAlt(localctx, 1)
                self.state = 263
                _la = self._input.LA(1)
                if not(_la==MCParser.SUB or _la==MCParser.NOT):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 264
                self.expr7()
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.ID, MCParser.LB]:
                self.enterOuterAlt(localctx, 2)
                self.state = 265
                self.expr8()
                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 Expr8Context(ParserRuleContext):

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

        def expr9(self):
            return self.getTypedRuleContext(MCParser.Expr9Context,0)


        def LSB(self):
            return self.getToken(MCParser.LSB, 0)

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


        def RSB(self):
            return self.getToken(MCParser.RSB, 0)

        def getRuleIndex(self):
            return MCParser.RULE_expr8




    def expr8(self):

        localctx = MCParser.Expr8Context(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_expr8)
        try:
            self.state = 274
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,22,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 268
                self.expr9()
                self.state = 269
                self.match(MCParser.LSB)
                self.state = 270
                self.expr0()
                self.state = 271
                self.match(MCParser.RSB)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 273
                self.expr9()
                pass


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

    class Expr9Context(ParserRuleContext):

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

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

        def expr0(self):
            return self.getTypedRuleContext(MCParser.Expr0Context,0)


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

        def operand(self):
            return self.getTypedRuleContext(MCParser.OperandContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_expr9




    def expr9(self):

        localctx = MCParser.Expr9Context(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_expr9)
        try:
            self.state = 281
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [MCParser.LB]:
                self.enterOuterAlt(localctx, 1)
                self.state = 276
                self.match(MCParser.LB)
                self.state = 277
                self.expr0()
                self.state = 278
                self.match(MCParser.RB)
                pass
            elif token in [MCParser.INTLIT, MCParser.FLOATLIT, MCParser.BOOLEANLIT, MCParser.STRINGLIT, MCParser.ID]:
                self.enterOuterAlt(localctx, 2)
                self.state = 280
                self.operand()
                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 OperandContext(ParserRuleContext):

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

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

        def BOOLEANLIT(self):
            return self.getToken(MCParser.BOOLEANLIT, 0)

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

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

        def STRINGLIT(self):
            return self.getToken(MCParser.STRINGLIT, 0)

        def calfunc(self):
            return self.getTypedRuleContext(MCParser.CalfuncContext,0)


        def getRuleIndex(self):
            return MCParser.RULE_operand




    def operand(self):

        localctx = MCParser.OperandContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_operand)
        try:
            self.state = 289
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,24,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 283
                self.match(MCParser.INTLIT)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 284
                self.match(MCParser.BOOLEANLIT)
                pass

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

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 286
                self.match(MCParser.FLOATLIT)
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 287
                self.match(MCParser.STRINGLIT)
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 288
                self.calfunc()
                pass


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

    class CalfuncContext(ParserRuleContext):

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

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

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

        def arglist(self):
            return self.getTypedRuleContext(MCParser.ArglistContext,0)


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

        def getRuleIndex(self):
            return MCParser.RULE_calfunc




    def calfunc(self):

        localctx = MCParser.CalfuncContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_calfunc)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 291
            self.match(MCParser.ID)
            self.state = 292
            self.match(MCParser.LB)
            self.state = 293
            self.arglist()
            self.state = 294
            self.match(MCParser.RB)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ArglistContext(ParserRuleContext):

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

        def expr0(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MCParser.Expr0Context)
            else:
                return self.getTypedRuleContext(MCParser.Expr0Context,i)


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

        def getRuleIndex(self):
            return MCParser.RULE_arglist




    def arglist(self):

        localctx = MCParser.ArglistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_arglist)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 304
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << MCParser.INTLIT) | (1 << MCParser.FLOATLIT) | (1 << MCParser.BOOLEANLIT) | (1 << MCParser.STRINGLIT) | (1 << MCParser.ID) | (1 << MCParser.SUB) | (1 << MCParser.NOT) | (1 << MCParser.LB))) != 0):
                self.state = 296
                self.expr0()
                self.state = 301
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==MCParser.COMA:
                    self.state = 297
                    self.match(MCParser.COMA)
                    self.state = 298
                    self.expr0()
                    self.state = 303
                    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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[22] = self.expr1_sempred
        self._predicates[23] = self.expr2_sempred
        self._predicates[26] = self.expr5_sempred
        self._predicates[27] = self.expr6_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 expr1_sempred(self, localctx:Expr1Context, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 2)
         

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

    def expr5_sempred(self, localctx:Expr5Context, predIndex:int):
            if predIndex == 2:
                return self.precpred(self._ctx, 2)
         

    def expr6_sempred(self, localctx:Expr6Context, predIndex:int):
            if predIndex == 3:
                return self.precpred(self._ctx, 2)
         





# Generated from /home/hpcc/ppl-course/assignment/assignment2/main/mc/parser/MC.g4 by ANTLR 4.7.1 # encoding: utf-8 #\t#\3\2\6\2H\n\2\r\2") #\3#\3#\7#\u012e\n#\f#\16#\u0131\13#\5") #\3#\2\6.\60\668$\2\4\6\b\n\f\16\20\22\24\26") #\3\2\2\2\u00b9") #\2\u0128\u0129\7\'\2\2\u0129C\3\2\2") # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type # Token type