# Generated from CX.g4 by ANTLR 4.7.2
# 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:")
        buf.write("\u0120\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\3\2\7\2\60\n")
        buf.write("\2\f\2\16\2\63\13\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3")
        buf.write("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3")
        buf.write("\3\3\5\3L\n\3\3\3\3\3\5\3P\n\3\3\4\3\4\7\4T\n\4\f\4\16")
        buf.write("\4W\13\4\3\4\3\4\3\5\5\5\\\n\5\3\5\3\5\3\6\3\6\3\6\3\6")
        buf.write("\3\6\3\6\3\6\5\6g\n\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7")
        buf.write("\3\7\5\7r\n\7\3\7\3\7\5\7v\n\7\3\7\3\7\5\7z\n\7\3\7\3")
        buf.write("\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7")
        buf.write("\3\7\3\7\3\7\5\7\u008e\n\7\3\b\3\b\3\t\3\t\3\t\3\t\5\t")
        buf.write("\u0096\n\t\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\7\13")
        buf.write("\u00a0\n\13\f\13\16\13\u00a3\13\13\3\f\3\f\3\f\3\f\3\f")
        buf.write("\3\f\7\f\u00ab\n\f\f\f\16\f\u00ae\13\f\3\r\3\r\3\r\3\r")
        buf.write("\3\r\3\r\7\r\u00b6\n\r\f\r\16\r\u00b9\13\r\3\16\3\16\3")
        buf.write("\16\3\16\3\16\3\16\3\16\3\16\3\16\7\16\u00c4\n\16\f\16")
        buf.write("\16\16\u00c7\13\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17")
        buf.write("\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\7\17\u00d8\n")
        buf.write("\17\f\17\16\17\u00db\13\17\3\20\3\20\3\20\3\20\3\20\3")
        buf.write("\20\3\20\3\20\3\20\7\20\u00e6\n\20\f\20\16\20\u00e9\13")
        buf.write("\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21")
        buf.write("\3\21\3\21\7\21\u00f7\n\21\f\21\16\21\u00fa\13\21\3\22")
        buf.write("\3\22\3\22\3\22\3\22\5\22\u0101\n\22\3\23\3\23\3\23\3")
        buf.write("\23\3\23\3\23\3\23\7\23\u010a\n\23\f\23\16\23\u010d\13")
        buf.write("\23\3\24\3\24\3\24\5\24\u0112\n\24\3\25\3\25\3\25\3\25")
        buf.write("\3\25\3\25\5\25\u011a\n\25\3\26\3\26\3\27\3\27\3\27\2")
        buf.write("\n\24\26\30\32\34\36 $\30\2\4\6\b\n\f\16\20\22\24\26\30")
        buf.write("\32\34\36 \"$&(*,\2\6\4\2\t\t99\5\2\31\31\"\"\61\61\4")
        buf.write("\2\25\26-.\4\2\t\n99\2\u0132\2\61\3\2\2\2\4O\3\2\2\2\6")
        buf.write("Q\3\2\2\2\b[\3\2\2\2\n_\3\2\2\2\f\u008d\3\2\2\2\16\u008f")
        buf.write("\3\2\2\2\20\u0095\3\2\2\2\22\u0097\3\2\2\2\24\u0099\3")
        buf.write("\2\2\2\26\u00a4\3\2\2\2\30\u00af\3\2\2\2\32\u00ba\3\2")
        buf.write("\2\2\34\u00c8\3\2\2\2\36\u00dc\3\2\2\2 \u00ea\3\2\2\2")
        buf.write("\"\u0100\3\2\2\2$\u0102\3\2\2\2&\u0111\3\2\2\2(\u0119")
        buf.write("\3\2\2\2*\u011b\3\2\2\2,\u011d\3\2\2\2.\60\5\4\3\2/.\3")
        buf.write("\2\2\2\60\63\3\2\2\2\61/\3\2\2\2\61\62\3\2\2\2\62\3\3")
        buf.write("\2\2\2\63\61\3\2\2\2\64P\5\b\5\2\65P\5\6\4\2\66P\5\n\6")
        buf.write("\2\67P\5\f\7\289\7\65\2\29P\7\r\2\2:;\7\66\2\2;P\7\r\2")
        buf.write("\2<=\7\6\2\2=>\7:\2\2>P\7\r\2\2?@\7\7\2\2@A\5\16\b\2A")
        buf.write("B\7\r\2\2BP\3\2\2\2CD\7\b\2\2DE\5\16\b\2EF\7\r\2\2FP\3")
        buf.write("\2\2\2GH\5,\27\2HK\7:\2\2IJ\7\27\2\2JL\5\16\b\2KI\3\2")
        buf.write("\2\2KL\3\2\2\2LM\3\2\2\2MN\7\r\2\2NP\3\2\2\2O\64\3\2\2")
        buf.write("\2O\65\3\2\2\2O\66\3\2\2\2O\67\3\2\2\2O8\3\2\2\2O:\3\2")
        buf.write("\2\2O<\3\2\2\2O?\3\2\2\2OC\3\2\2\2OG\3\2\2\2P\5\3\2\2")
        buf.write("\2QU\7\13\2\2RT\5\4\3\2SR\3\2\2\2TW\3\2\2\2US\3\2\2\2")
        buf.write("UV\3\2\2\2VX\3\2\2\2WU\3\2\2\2XY\7\f\2\2Y\7\3\2\2\2Z\\")
        buf.write("\5\16\b\2[Z\3\2\2\2[\\\3\2\2\2\\]\3\2\2\2]^\7\r\2\2^\t")
        buf.write("\3\2\2\2_`\7\16\2\2`a\7\20\2\2ab\5\16\b\2bc\7\21\2\2c")
        buf.write("f\5\4\3\2de\7\22\2\2eg\5\4\3\2fd\3\2\2\2fg\3\2\2\2g\13")
        buf.write("\3\2\2\2hi\7\23\2\2ij\7\20\2\2jk\5\16\b\2kl\7\21\2\2l")
        buf.write("m\5\4\3\2m\u008e\3\2\2\2no\7\24\2\2oq\7\20\2\2pr\5\16")
        buf.write("\b\2qp\3\2\2\2qr\3\2\2\2rs\3\2\2\2su\7\r\2\2tv\5\16\b")
        buf.write("\2ut\3\2\2\2uv\3\2\2\2vw\3\2\2\2wy\7\r\2\2xz\5\16\b\2")
        buf.write("yx\3\2\2\2yz\3\2\2\2z{\3\2\2\2{|\7\21\2\2|\u008e\5\4\3")
        buf.write("\2}~\7\17\2\2~\177\5\4\3\2\177\u0080\7\23\2\2\u0080\u0081")
        buf.write("\7\20\2\2\u0081\u0082\5\16\b\2\u0082\u0083\7\21\2\2\u0083")
        buf.write("\u0084\7\r\2\2\u0084\u008e\3\2\2\2\u0085\u0086\7\67\2")
        buf.write("\2\u0086\u0087\5\4\3\2\u0087\u0088\78\2\2\u0088\u0089")
        buf.write("\7\20\2\2\u0089\u008a\5\16\b\2\u008a\u008b\7\21\2\2\u008b")
        buf.write("\u008c\7\r\2\2\u008c\u008e\3\2\2\2\u008dh\3\2\2\2\u008d")
        buf.write("n\3\2\2\2\u008d}\3\2\2\2\u008d\u0085\3\2\2\2\u008e\r\3")
        buf.write("\2\2\2\u008f\u0090\5\20\t\2\u0090\17\3\2\2\2\u0091\u0096")
        buf.write("\5\22\n\2\u0092\u0093\7:\2\2\u0093\u0094\7\27\2\2\u0094")
        buf.write("\u0096\5\16\b\2\u0095\u0091\3\2\2\2\u0095\u0092\3\2\2")
        buf.write("\2\u0096\21\3\2\2\2\u0097\u0098\5\24\13\2\u0098\23\3\2")
        buf.write("\2\2\u0099\u009a\b\13\1\2\u009a\u009b\5\26\f\2\u009b\u00a1")
        buf.write("\3\2\2\2\u009c\u009d\f\3\2\2\u009d\u009e\7$\2\2\u009e")
        buf.write("\u00a0\5\26\f\2\u009f\u009c\3\2\2\2\u00a0\u00a3\3\2\2")
        buf.write("\2\u00a1\u009f\3\2\2\2\u00a1\u00a2\3\2\2\2\u00a2\25\3")
        buf.write("\2\2\2\u00a3\u00a1\3\2\2\2\u00a4\u00a5\b\f\1\2\u00a5\u00a6")
        buf.write("\5\30\r\2\u00a6\u00ac\3\2\2\2\u00a7\u00a8\f\3\2\2\u00a8")
        buf.write("\u00a9\7#\2\2\u00a9\u00ab\5\30\r\2\u00aa\u00a7\3\2\2\2")
        buf.write("\u00ab\u00ae\3\2\2\2\u00ac\u00aa\3\2\2\2\u00ac\u00ad\3")
        buf.write("\2\2\2\u00ad\27\3\2\2\2\u00ae\u00ac\3\2\2\2\u00af\u00b0")
        buf.write("\b\r\1\2\u00b0\u00b1\5\32\16\2\u00b1\u00b7\3\2\2\2\u00b2")
        buf.write("\u00b3\f\3\2\2\u00b3\u00b4\7%\2\2\u00b4\u00b6\5\32\16")
        buf.write("\2\u00b5\u00b2\3\2\2\2\u00b6\u00b9\3\2\2\2\u00b7\u00b5")
        buf.write("\3\2\2\2\u00b7\u00b8\3\2\2\2\u00b8\31\3\2\2\2\u00b9\u00b7")
        buf.write("\3\2\2\2\u00ba\u00bb\b\16\1\2\u00bb\u00bc\5\34\17\2\u00bc")
        buf.write("\u00c5\3\2\2\2\u00bd\u00be\f\4\2\2\u00be\u00bf\7\34\2")
        buf.write("\2\u00bf\u00c4\5\34\17\2\u00c0\u00c1\f\3\2\2\u00c1\u00c2")
        buf.write("\7\35\2\2\u00c2\u00c4\5\34\17\2\u00c3\u00bd\3\2\2\2\u00c3")
        buf.write("\u00c0\3\2\2\2\u00c4\u00c7\3\2\2\2\u00c5\u00c3\3\2\2\2")
        buf.write("\u00c5\u00c6\3\2\2\2\u00c6\33\3\2\2\2\u00c7\u00c5\3\2")
        buf.write("\2\2\u00c8\u00c9\b\17\1\2\u00c9\u00ca\5\36\20\2\u00ca")
        buf.write("\u00d9\3\2\2\2\u00cb\u00cc\f\6\2\2\u00cc\u00cd\7\36\2")
        buf.write("\2\u00cd\u00d8\5\36\20\2\u00ce\u00cf\f\5\2\2\u00cf\u00d0")
        buf.write("\7\37\2\2\u00d0\u00d8\5\36\20\2\u00d1\u00d2\f\4\2\2\u00d2")
        buf.write("\u00d3\7 \2\2\u00d3\u00d8\5\36\20\2\u00d4\u00d5\f\3\2")
        buf.write("\2\u00d5\u00d6\7!\2\2\u00d6\u00d8\5\36\20\2\u00d7\u00cb")
        buf.write("\3\2\2\2\u00d7\u00ce\3\2\2\2\u00d7\u00d1\3\2\2\2\u00d7")
        buf.write("\u00d4\3\2\2\2\u00d8\u00db\3\2\2\2\u00d9\u00d7\3\2\2\2")
        buf.write("\u00d9\u00da\3\2\2\2\u00da\35\3\2\2\2\u00db\u00d9\3\2")
        buf.write("\2\2\u00dc\u00dd\b\20\1\2\u00dd\u00de\5 \21\2\u00de\u00e7")
        buf.write("\3\2\2\2\u00df\u00e0\f\4\2\2\u00e0\u00e1\7\30\2\2\u00e1")
        buf.write("\u00e6\5 \21\2\u00e2\u00e3\f\3\2\2\u00e3\u00e4\7\31\2")
        buf.write("\2\u00e4\u00e6\5 \21\2\u00e5\u00df\3\2\2\2\u00e5\u00e2")
        buf.write("\3\2\2\2\u00e6\u00e9\3\2\2\2\u00e7\u00e5\3\2\2\2\u00e7")
        buf.write("\u00e8\3\2\2\2\u00e8\37\3\2\2\2\u00e9\u00e7\3\2\2\2\u00ea")
        buf.write("\u00eb\b\21\1\2\u00eb\u00ec\5\"\22\2\u00ec\u00f8\3\2\2")
        buf.write("\2\u00ed\u00ee\f\5\2\2\u00ee\u00ef\7\32\2\2\u00ef\u00f7")
        buf.write("\5\"\22\2\u00f0\u00f1\f\4\2\2\u00f1\u00f2\7\33\2\2\u00f2")
        buf.write("\u00f7\5\"\22\2\u00f3\u00f4\f\3\2\2\u00f4\u00f5\7\60\2")
        buf.write("\2\u00f5\u00f7\5\"\22\2\u00f6\u00ed\3\2\2\2\u00f6\u00f0")
        buf.write("\3\2\2\2\u00f6\u00f3\3\2\2\2\u00f7\u00fa\3\2\2\2\u00f8")
        buf.write("\u00f6\3\2\2\2\u00f8\u00f9\3\2\2\2\u00f9!\3\2\2\2\u00fa")
        buf.write("\u00f8\3\2\2\2\u00fb\u0101\5$\23\2\u00fc\u00fd\7\20\2")
        buf.write("\2\u00fd\u00fe\t\2\2\2\u00fe\u00ff\7\21\2\2\u00ff\u0101")
        buf.write("\5(\25\2\u0100\u00fb\3\2\2\2\u0100\u00fc\3\2\2\2\u0101")
        buf.write("#\3\2\2\2\u0102\u0103\b\23\1\2\u0103\u0104\5&\24\2\u0104")
        buf.write("\u010b\3\2\2\2\u0105\u0106\f\4\2\2\u0106\u010a\7\62\2")
        buf.write("\2\u0107\u0108\f\3\2\2\u0108\u010a\7\63\2\2\u0109\u0105")
        buf.write("\3\2\2\2\u0109\u0107\3\2\2\2\u010a\u010d\3\2\2\2\u010b")
        buf.write("\u0109\3\2\2\2\u010b\u010c\3\2\2\2\u010c%\3\2\2\2\u010d")
        buf.write("\u010b\3\2\2\2\u010e\u0112\5(\25\2\u010f\u0110\t\3\2\2")
        buf.write("\u0110\u0112\5&\24\2\u0111\u010e\3\2\2\2\u0111\u010f\3")
        buf.write("\2\2\2\u0112\'\3\2\2\2\u0113\u011a\7:\2\2\u0114\u011a")
        buf.write("\5*\26\2\u0115\u0116\7\20\2\2\u0116\u0117\5\16\b\2\u0117")
        buf.write("\u0118\7\21\2\2\u0118\u011a\3\2\2\2\u0119\u0113\3\2\2")
        buf.write("\2\u0119\u0114\3\2\2\2\u0119\u0115\3\2\2\2\u011a)\3\2")
        buf.write("\2\2\u011b\u011c\t\4\2\2\u011c+\3\2\2\2\u011d\u011e\t")
        buf.write("\5\2\2\u011e-\3\2\2\2\35\61KOU[fquy\u008d\u0095\u00a1")
        buf.write("\u00ac\u00b7\u00c3\u00c5\u00d7\u00d9\u00e5\u00e7\u00f6")
        buf.write("\u00f8\u0100\u0109\u010b\u0111\u0119")
        return buf.getvalue()


class CXParser ( Parser ):

    grammarFileName = "CX.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "'read'", "'write'", "'writeln'", "'int'", "'bool'", 
                     "'{'", "'}'", "';'", "'if'", "'do'", "'('", "')'", 
                     "'else'", "'while'", "'for'", "'true'", "'false'", 
                     "'='", "'+'", "'-'", "'*'", "'/'", "'=='", "'!='", 
                     "'<'", "'>'", "'<='", "'>='", "'!'", "'&&'", "'||'", 
                     "'^'", "'//'", "'/*'", "'*/'", "','", "'<<'", "'>>'", 
                     "'?'", "<INVALID>", "<INVALID>", "':'", "'%'", "'odd'", 
                     "'++'", "'--'", "'const'", "'break'", "'continue'", 
                     "'repeat'", "'until'", "'real'" ]

    symbolicNames = [ "<INVALID>", "COMMENT", "WHITESPACE", "NEWLINE", "READ", 
                      "WRITE", "WRITELN", "INT", "BOOLEAN", "LEFTBRACE", 
                      "RIGHTBRACE", "SEMICOLON", "IF", "DO", "LEFTPARENTHESIS", 
                      "RIGHTPARENTHESIS", "ELSE", "WHILE", "FOR", "TRUE", 
                      "FALSE", "ASSIGN", "PLUS", "MINUS", "STAR", "SLASH", 
                      "EQUAL", "NOTEQUAL", "LESSTHAN", "GREATERTHAN", "LESSTHANOREQUAL", 
                      "GREATERTHANOREQUAL", "NOT", "AND", "OR", "XOR", "BEGININLINECOMMENT", 
                      "BEGINCOMMENT", "ENDCOMMENT", "COMMA", "LEFTSHIFT", 
                      "RIGHTSHIFT", "QUESTIONMARK", "NUMBER", "REALNUMBER", 
                      "COLON", "MOD", "ODD", "PLUSPLUS", "MINUSMINUS", "CONST", 
                      "BREAK", "CONTINUE", "REPEAT", "UNTIL", "REAL", "IDENTIFIER" ]

    RULE_program = 0
    RULE_statement = 1
    RULE_compoundstatement = 2
    RULE_expressionstatement = 3
    RULE_selectionstatement = 4
    RULE_iterationstatement = 5
    RULE_expression = 6
    RULE_assignmentexpression = 7
    RULE_conditionalexpression = 8
    RULE_logicorexpression = 9
    RULE_logicandexpression = 10
    RULE_logicxorexpression = 11
    RULE_equalityexpression = 12
    RULE_comparisonexpression = 13
    RULE_additiveexpression = 14
    RULE_multiplicativeexpression = 15
    RULE_castexpression = 16
    RULE_postfixexpression = 17
    RULE_unaryexpression = 18
    RULE_primaryexpression = 19
    RULE_constant = 20
    RULE_basetype = 21

    ruleNames =  [ "program", "statement", "compoundstatement", "expressionstatement", 
                   "selectionstatement", "iterationstatement", "expression", 
                   "assignmentexpression", "conditionalexpression", "logicorexpression", 
                   "logicandexpression", "logicxorexpression", "equalityexpression", 
                   "comparisonexpression", "additiveexpression", "multiplicativeexpression", 
                   "castexpression", "postfixexpression", "unaryexpression", 
                   "primaryexpression", "constant", "basetype" ]

    EOF = Token.EOF
    COMMENT=1
    WHITESPACE=2
    NEWLINE=3
    READ=4
    WRITE=5
    WRITELN=6
    INT=7
    BOOLEAN=8
    LEFTBRACE=9
    RIGHTBRACE=10
    SEMICOLON=11
    IF=12
    DO=13
    LEFTPARENTHESIS=14
    RIGHTPARENTHESIS=15
    ELSE=16
    WHILE=17
    FOR=18
    TRUE=19
    FALSE=20
    ASSIGN=21
    PLUS=22
    MINUS=23
    STAR=24
    SLASH=25
    EQUAL=26
    NOTEQUAL=27
    LESSTHAN=28
    GREATERTHAN=29
    LESSTHANOREQUAL=30
    GREATERTHANOREQUAL=31
    NOT=32
    AND=33
    OR=34
    XOR=35
    BEGININLINECOMMENT=36
    BEGINCOMMENT=37
    ENDCOMMENT=38
    COMMA=39
    LEFTSHIFT=40
    RIGHTSHIFT=41
    QUESTIONMARK=42
    NUMBER=43
    REALNUMBER=44
    COLON=45
    MOD=46
    ODD=47
    PLUSPLUS=48
    MINUSMINUS=49
    CONST=50
    BREAK=51
    CONTINUE=52
    REPEAT=53
    UNTIL=54
    REAL=55
    IDENTIFIER=56

    def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
        super().__init__(input, output)
        self.checkVersion("4.7.2")
        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 statement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(CXParser.StatementContext)
            else:
                return self.getTypedRuleContext(CXParser.StatementContext,i)


        def getRuleIndex(self):
            return CXParser.RULE_program

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

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




    def program(self):

        localctx = CXParser.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 = 47
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.READ) | (1 << CXParser.WRITE) | (1 << CXParser.WRITELN) | (1 << CXParser.INT) | (1 << CXParser.BOOLEAN) | (1 << CXParser.LEFTBRACE) | (1 << CXParser.SEMICOLON) | (1 << CXParser.IF) | (1 << CXParser.DO) | (1 << CXParser.LEFTPARENTHESIS) | (1 << CXParser.WHILE) | (1 << CXParser.FOR) | (1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER) | (1 << CXParser.ODD) | (1 << CXParser.BREAK) | (1 << CXParser.CONTINUE) | (1 << CXParser.REPEAT) | (1 << CXParser.REAL) | (1 << CXParser.IDENTIFIER))) != 0):
                self.state = 44
                self.statement()
                self.state = 49
                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 StatementContext(ParserRuleContext):

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

        def expressionstatement(self):
            return self.getTypedRuleContext(CXParser.ExpressionstatementContext,0)


        def compoundstatement(self):
            return self.getTypedRuleContext(CXParser.CompoundstatementContext,0)


        def selectionstatement(self):
            return self.getTypedRuleContext(CXParser.SelectionstatementContext,0)


        def iterationstatement(self):
            return self.getTypedRuleContext(CXParser.IterationstatementContext,0)


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

        def SEMICOLON(self):
            return self.getToken(CXParser.SEMICOLON, 0)

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

        def READ(self):
            return self.getToken(CXParser.READ, 0)

        def IDENTIFIER(self):
            return self.getToken(CXParser.IDENTIFIER, 0)

        def WRITE(self):
            return self.getToken(CXParser.WRITE, 0)

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


        def WRITELN(self):
            return self.getToken(CXParser.WRITELN, 0)

        def basetype(self):
            return self.getTypedRuleContext(CXParser.BasetypeContext,0)


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

        def getRuleIndex(self):
            return CXParser.RULE_statement

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

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




    def statement(self):

        localctx = CXParser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_statement)
        self._la = 0 # Token type
        try:
            self.state = 77
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [CXParser.SEMICOLON, CXParser.LEFTPARENTHESIS, CXParser.TRUE, CXParser.FALSE, CXParser.MINUS, CXParser.NOT, CXParser.NUMBER, CXParser.REALNUMBER, CXParser.ODD, CXParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 1)
                self.state = 50
                self.expressionstatement()
                pass
            elif token in [CXParser.LEFTBRACE]:
                self.enterOuterAlt(localctx, 2)
                self.state = 51
                self.compoundstatement()
                pass
            elif token in [CXParser.IF]:
                self.enterOuterAlt(localctx, 3)
                self.state = 52
                self.selectionstatement()
                pass
            elif token in [CXParser.DO, CXParser.WHILE, CXParser.FOR, CXParser.REPEAT]:
                self.enterOuterAlt(localctx, 4)
                self.state = 53
                self.iterationstatement()
                pass
            elif token in [CXParser.BREAK]:
                self.enterOuterAlt(localctx, 5)
                self.state = 54
                self.match(CXParser.BREAK)
                self.state = 55
                self.match(CXParser.SEMICOLON)
                pass
            elif token in [CXParser.CONTINUE]:
                self.enterOuterAlt(localctx, 6)
                self.state = 56
                self.match(CXParser.CONTINUE)
                self.state = 57
                self.match(CXParser.SEMICOLON)
                pass
            elif token in [CXParser.READ]:
                self.enterOuterAlt(localctx, 7)
                self.state = 58
                self.match(CXParser.READ)
                self.state = 59
                self.match(CXParser.IDENTIFIER)
                self.state = 60
                self.match(CXParser.SEMICOLON)
                pass
            elif token in [CXParser.WRITE]:
                self.enterOuterAlt(localctx, 8)
                self.state = 61
                self.match(CXParser.WRITE)
                self.state = 62
                self.expression()
                self.state = 63
                self.match(CXParser.SEMICOLON)
                pass
            elif token in [CXParser.WRITELN]:
                self.enterOuterAlt(localctx, 9)
                self.state = 65
                self.match(CXParser.WRITELN)
                self.state = 66
                self.expression()
                self.state = 67
                self.match(CXParser.SEMICOLON)
                pass
            elif token in [CXParser.INT, CXParser.BOOLEAN, CXParser.REAL]:
                self.enterOuterAlt(localctx, 10)
                self.state = 69
                self.basetype()
                self.state = 70
                self.match(CXParser.IDENTIFIER)
                self.state = 73
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==CXParser.ASSIGN:
                    self.state = 71
                    self.match(CXParser.ASSIGN)
                    self.state = 72
                    self.expression()


                self.state = 75
                self.match(CXParser.SEMICOLON)
                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 CompoundstatementContext(ParserRuleContext):

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

        def LEFTBRACE(self):
            return self.getToken(CXParser.LEFTBRACE, 0)

        def RIGHTBRACE(self):
            return self.getToken(CXParser.RIGHTBRACE, 0)

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


        def getRuleIndex(self):
            return CXParser.RULE_compoundstatement

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

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




    def compoundstatement(self):

        localctx = CXParser.CompoundstatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_compoundstatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 79
            self.match(CXParser.LEFTBRACE)
            self.state = 83
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.READ) | (1 << CXParser.WRITE) | (1 << CXParser.WRITELN) | (1 << CXParser.INT) | (1 << CXParser.BOOLEAN) | (1 << CXParser.LEFTBRACE) | (1 << CXParser.SEMICOLON) | (1 << CXParser.IF) | (1 << CXParser.DO) | (1 << CXParser.LEFTPARENTHESIS) | (1 << CXParser.WHILE) | (1 << CXParser.FOR) | (1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER) | (1 << CXParser.ODD) | (1 << CXParser.BREAK) | (1 << CXParser.CONTINUE) | (1 << CXParser.REPEAT) | (1 << CXParser.REAL) | (1 << CXParser.IDENTIFIER))) != 0):
                self.state = 80
                self.statement()
                self.state = 85
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 86
            self.match(CXParser.RIGHTBRACE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExpressionstatementContext(ParserRuleContext):

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

        def SEMICOLON(self):
            return self.getToken(CXParser.SEMICOLON, 0)

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


        def getRuleIndex(self):
            return CXParser.RULE_expressionstatement

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

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




    def expressionstatement(self):

        localctx = CXParser.ExpressionstatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_expressionstatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 89
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.LEFTPARENTHESIS) | (1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER) | (1 << CXParser.ODD) | (1 << CXParser.IDENTIFIER))) != 0):
                self.state = 88
                self.expression()


            self.state = 91
            self.match(CXParser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SelectionstatementContext(ParserRuleContext):

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

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

        def LEFTPARENTHESIS(self):
            return self.getToken(CXParser.LEFTPARENTHESIS, 0)

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


        def RIGHTPARENTHESIS(self):
            return self.getToken(CXParser.RIGHTPARENTHESIS, 0)

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


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

        def getRuleIndex(self):
            return CXParser.RULE_selectionstatement

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

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




    def selectionstatement(self):

        localctx = CXParser.SelectionstatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_selectionstatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 93
            self.match(CXParser.IF)
            self.state = 94
            self.match(CXParser.LEFTPARENTHESIS)
            self.state = 95
            self.expression()
            self.state = 96
            self.match(CXParser.RIGHTPARENTHESIS)
            self.state = 97
            self.statement()
            self.state = 100
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
            if la_ == 1:
                self.state = 98
                self.match(CXParser.ELSE)
                self.state = 99
                self.statement()


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


    class IterationstatementContext(ParserRuleContext):

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

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

        def LEFTPARENTHESIS(self):
            return self.getToken(CXParser.LEFTPARENTHESIS, 0)

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


        def RIGHTPARENTHESIS(self):
            return self.getToken(CXParser.RIGHTPARENTHESIS, 0)

        def statement(self):
            return self.getTypedRuleContext(CXParser.StatementContext,0)


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

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

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

        def REPEAT(self):
            return self.getToken(CXParser.REPEAT, 0)

        def UNTIL(self):
            return self.getToken(CXParser.UNTIL, 0)

        def getRuleIndex(self):
            return CXParser.RULE_iterationstatement

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

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




    def iterationstatement(self):

        localctx = CXParser.IterationstatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_iterationstatement)
        self._la = 0 # Token type
        try:
            self.state = 139
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [CXParser.WHILE]:
                self.enterOuterAlt(localctx, 1)
                self.state = 102
                self.match(CXParser.WHILE)
                self.state = 103
                self.match(CXParser.LEFTPARENTHESIS)
                self.state = 104
                self.expression()
                self.state = 105
                self.match(CXParser.RIGHTPARENTHESIS)
                self.state = 106
                self.statement()
                pass
            elif token in [CXParser.FOR]:
                self.enterOuterAlt(localctx, 2)
                self.state = 108
                self.match(CXParser.FOR)
                self.state = 109
                self.match(CXParser.LEFTPARENTHESIS)
                self.state = 111
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.LEFTPARENTHESIS) | (1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER) | (1 << CXParser.ODD) | (1 << CXParser.IDENTIFIER))) != 0):
                    self.state = 110
                    self.expression()


                self.state = 113
                self.match(CXParser.SEMICOLON)
                self.state = 115
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.LEFTPARENTHESIS) | (1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER) | (1 << CXParser.ODD) | (1 << CXParser.IDENTIFIER))) != 0):
                    self.state = 114
                    self.expression()


                self.state = 117
                self.match(CXParser.SEMICOLON)
                self.state = 119
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.LEFTPARENTHESIS) | (1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER) | (1 << CXParser.ODD) | (1 << CXParser.IDENTIFIER))) != 0):
                    self.state = 118
                    self.expression()


                self.state = 121
                self.match(CXParser.RIGHTPARENTHESIS)
                self.state = 122
                self.statement()
                pass
            elif token in [CXParser.DO]:
                self.enterOuterAlt(localctx, 3)
                self.state = 123
                self.match(CXParser.DO)
                self.state = 124
                self.statement()
                self.state = 125
                self.match(CXParser.WHILE)
                self.state = 126
                self.match(CXParser.LEFTPARENTHESIS)
                self.state = 127
                self.expression()
                self.state = 128
                self.match(CXParser.RIGHTPARENTHESIS)
                self.state = 129
                self.match(CXParser.SEMICOLON)
                pass
            elif token in [CXParser.REPEAT]:
                self.enterOuterAlt(localctx, 4)
                self.state = 131
                self.match(CXParser.REPEAT)
                self.state = 132
                self.statement()
                self.state = 133
                self.match(CXParser.UNTIL)
                self.state = 134
                self.match(CXParser.LEFTPARENTHESIS)
                self.state = 135
                self.expression()
                self.state = 136
                self.match(CXParser.RIGHTPARENTHESIS)
                self.state = 137
                self.match(CXParser.SEMICOLON)
                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 ExpressionContext(ParserRuleContext):

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

        def assignmentexpression(self):
            return self.getTypedRuleContext(CXParser.AssignmentexpressionContext,0)


        def getRuleIndex(self):
            return CXParser.RULE_expression

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

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




    def expression(self):

        localctx = CXParser.ExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_expression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 141
            self.assignmentexpression()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AssignmentexpressionContext(ParserRuleContext):

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

        def conditionalexpression(self):
            return self.getTypedRuleContext(CXParser.ConditionalexpressionContext,0)


        def IDENTIFIER(self):
            return self.getToken(CXParser.IDENTIFIER, 0)

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

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


        def getRuleIndex(self):
            return CXParser.RULE_assignmentexpression

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

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




    def assignmentexpression(self):

        localctx = CXParser.AssignmentexpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_assignmentexpression)
        try:
            self.state = 147
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,10,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 143
                self.conditionalexpression()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 144
                self.match(CXParser.IDENTIFIER)
                self.state = 145
                self.match(CXParser.ASSIGN)
                self.state = 146
                self.expression()
                pass


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


    class ConditionalexpressionContext(ParserRuleContext):

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

        def logicorexpression(self):
            return self.getTypedRuleContext(CXParser.LogicorexpressionContext,0)


        def getRuleIndex(self):
            return CXParser.RULE_conditionalexpression

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

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




    def conditionalexpression(self):

        localctx = CXParser.ConditionalexpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_conditionalexpression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 149
            self.logicorexpression(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class LogicorexpressionContext(ParserRuleContext):

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

        def logicandexpression(self):
            return self.getTypedRuleContext(CXParser.LogicandexpressionContext,0)


        def logicorexpression(self):
            return self.getTypedRuleContext(CXParser.LogicorexpressionContext,0)


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

        def getRuleIndex(self):
            return CXParser.RULE_logicorexpression

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

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



    def logicorexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.LogicorexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 18
        self.enterRecursionRule(localctx, 18, self.RULE_logicorexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 152
            self.logicandexpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 159
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,11,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 = CXParser.LogicorexpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_logicorexpression)
                    self.state = 154
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 155
                    self.match(CXParser.OR)
                    self.state = 156
                    self.logicandexpression(0) 
                self.state = 161
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,11,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 LogicandexpressionContext(ParserRuleContext):

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

        def logicxorexpression(self):
            return self.getTypedRuleContext(CXParser.LogicxorexpressionContext,0)


        def logicandexpression(self):
            return self.getTypedRuleContext(CXParser.LogicandexpressionContext,0)


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

        def getRuleIndex(self):
            return CXParser.RULE_logicandexpression

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

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



    def logicandexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.LogicandexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 20
        self.enterRecursionRule(localctx, 20, self.RULE_logicandexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 163
            self.logicxorexpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 170
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,12,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 = CXParser.LogicandexpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_logicandexpression)
                    self.state = 165
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 166
                    self.match(CXParser.AND)
                    self.state = 167
                    self.logicxorexpression(0) 
                self.state = 172
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,12,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 LogicxorexpressionContext(ParserRuleContext):

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

        def equalityexpression(self):
            return self.getTypedRuleContext(CXParser.EqualityexpressionContext,0)


        def logicxorexpression(self):
            return self.getTypedRuleContext(CXParser.LogicxorexpressionContext,0)


        def XOR(self):
            return self.getToken(CXParser.XOR, 0)

        def getRuleIndex(self):
            return CXParser.RULE_logicxorexpression

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

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



    def logicxorexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.LogicxorexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 22
        self.enterRecursionRule(localctx, 22, self.RULE_logicxorexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 174
            self.equalityexpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 181
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,13,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 = CXParser.LogicxorexpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_logicxorexpression)
                    self.state = 176
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 177
                    self.match(CXParser.XOR)
                    self.state = 178
                    self.equalityexpression(0) 
                self.state = 183
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,13,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 EqualityexpressionContext(ParserRuleContext):

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

        def comparisonexpression(self):
            return self.getTypedRuleContext(CXParser.ComparisonexpressionContext,0)


        def equalityexpression(self):
            return self.getTypedRuleContext(CXParser.EqualityexpressionContext,0)


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

        def NOTEQUAL(self):
            return self.getToken(CXParser.NOTEQUAL, 0)

        def getRuleIndex(self):
            return CXParser.RULE_equalityexpression

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

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



    def equalityexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.EqualityexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 24
        self.enterRecursionRule(localctx, 24, self.RULE_equalityexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 185
            self.comparisonexpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 195
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,15,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 193
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,14,self._ctx)
                    if la_ == 1:
                        localctx = CXParser.EqualityexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_equalityexpression)
                        self.state = 187
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 188
                        self.match(CXParser.EQUAL)
                        self.state = 189
                        self.comparisonexpression(0)
                        pass

                    elif la_ == 2:
                        localctx = CXParser.EqualityexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_equalityexpression)
                        self.state = 190
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 191
                        self.match(CXParser.NOTEQUAL)
                        self.state = 192
                        self.comparisonexpression(0)
                        pass

             
                self.state = 197
                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 ComparisonexpressionContext(ParserRuleContext):

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

        def additiveexpression(self):
            return self.getTypedRuleContext(CXParser.AdditiveexpressionContext,0)


        def comparisonexpression(self):
            return self.getTypedRuleContext(CXParser.ComparisonexpressionContext,0)


        def LESSTHAN(self):
            return self.getToken(CXParser.LESSTHAN, 0)

        def GREATERTHAN(self):
            return self.getToken(CXParser.GREATERTHAN, 0)

        def LESSTHANOREQUAL(self):
            return self.getToken(CXParser.LESSTHANOREQUAL, 0)

        def GREATERTHANOREQUAL(self):
            return self.getToken(CXParser.GREATERTHANOREQUAL, 0)

        def getRuleIndex(self):
            return CXParser.RULE_comparisonexpression

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

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



    def comparisonexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.ComparisonexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 26
        self.enterRecursionRule(localctx, 26, self.RULE_comparisonexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 199
            self.additiveexpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 215
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 213
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,16,self._ctx)
                    if la_ == 1:
                        localctx = CXParser.ComparisonexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonexpression)
                        self.state = 201
                        if not self.precpred(self._ctx, 4):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 4)")
                        self.state = 202
                        self.match(CXParser.LESSTHAN)
                        self.state = 203
                        self.additiveexpression(0)
                        pass

                    elif la_ == 2:
                        localctx = CXParser.ComparisonexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonexpression)
                        self.state = 204
                        if not self.precpred(self._ctx, 3):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                        self.state = 205
                        self.match(CXParser.GREATERTHAN)
                        self.state = 206
                        self.additiveexpression(0)
                        pass

                    elif la_ == 3:
                        localctx = CXParser.ComparisonexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonexpression)
                        self.state = 207
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 208
                        self.match(CXParser.LESSTHANOREQUAL)
                        self.state = 209
                        self.additiveexpression(0)
                        pass

                    elif la_ == 4:
                        localctx = CXParser.ComparisonexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonexpression)
                        self.state = 210
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 211
                        self.match(CXParser.GREATERTHANOREQUAL)
                        self.state = 212
                        self.additiveexpression(0)
                        pass

             
                self.state = 217
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,17,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 AdditiveexpressionContext(ParserRuleContext):

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

        def multiplicativeexpression(self):
            return self.getTypedRuleContext(CXParser.MultiplicativeexpressionContext,0)


        def additiveexpression(self):
            return self.getTypedRuleContext(CXParser.AdditiveexpressionContext,0)


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

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

        def getRuleIndex(self):
            return CXParser.RULE_additiveexpression

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

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



    def additiveexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.AdditiveexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 28
        self.enterRecursionRule(localctx, 28, self.RULE_additiveexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 219
            self.multiplicativeexpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 229
            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
                    self.state = 227
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
                    if la_ == 1:
                        localctx = CXParser.AdditiveexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_additiveexpression)
                        self.state = 221
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 222
                        self.match(CXParser.PLUS)
                        self.state = 223
                        self.multiplicativeexpression(0)
                        pass

                    elif la_ == 2:
                        localctx = CXParser.AdditiveexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_additiveexpression)
                        self.state = 224
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 225
                        self.match(CXParser.MINUS)
                        self.state = 226
                        self.multiplicativeexpression(0)
                        pass

             
                self.state = 231
                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 MultiplicativeexpressionContext(ParserRuleContext):

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

        def castexpression(self):
            return self.getTypedRuleContext(CXParser.CastexpressionContext,0)


        def multiplicativeexpression(self):
            return self.getTypedRuleContext(CXParser.MultiplicativeexpressionContext,0)


        def STAR(self):
            return self.getToken(CXParser.STAR, 0)

        def SLASH(self):
            return self.getToken(CXParser.SLASH, 0)

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

        def getRuleIndex(self):
            return CXParser.RULE_multiplicativeexpression

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

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



    def multiplicativeexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.MultiplicativeexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 30
        self.enterRecursionRule(localctx, 30, self.RULE_multiplicativeexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 233
            self.castexpression()
            self._ctx.stop = self._input.LT(-1)
            self.state = 246
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,21,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 244
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,20,self._ctx)
                    if la_ == 1:
                        localctx = CXParser.MultiplicativeexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_multiplicativeexpression)
                        self.state = 235
                        if not self.precpred(self._ctx, 3):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                        self.state = 236
                        self.match(CXParser.STAR)
                        self.state = 237
                        self.castexpression()
                        pass

                    elif la_ == 2:
                        localctx = CXParser.MultiplicativeexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_multiplicativeexpression)
                        self.state = 238
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 239
                        self.match(CXParser.SLASH)
                        self.state = 240
                        self.castexpression()
                        pass

                    elif la_ == 3:
                        localctx = CXParser.MultiplicativeexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_multiplicativeexpression)
                        self.state = 241
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 242
                        self.match(CXParser.MOD)
                        self.state = 243
                        self.castexpression()
                        pass

             
                self.state = 248
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,21,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 CastexpressionContext(ParserRuleContext):

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

        def postfixexpression(self):
            return self.getTypedRuleContext(CXParser.PostfixexpressionContext,0)


        def LEFTPARENTHESIS(self):
            return self.getToken(CXParser.LEFTPARENTHESIS, 0)

        def RIGHTPARENTHESIS(self):
            return self.getToken(CXParser.RIGHTPARENTHESIS, 0)

        def primaryexpression(self):
            return self.getTypedRuleContext(CXParser.PrimaryexpressionContext,0)


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

        def REAL(self):
            return self.getToken(CXParser.REAL, 0)

        def getRuleIndex(self):
            return CXParser.RULE_castexpression

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

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




    def castexpression(self):

        localctx = CXParser.CastexpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_castexpression)
        self._la = 0 # Token type
        try:
            self.state = 254
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,22,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 249
                self.postfixexpression(0)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 250
                self.match(CXParser.LEFTPARENTHESIS)
                self.state = 251
                _la = self._input.LA(1)
                if not(_la==CXParser.INT or _la==CXParser.REAL):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 252
                self.match(CXParser.RIGHTPARENTHESIS)
                self.state = 253
                self.primaryexpression()
                pass


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


    class PostfixexpressionContext(ParserRuleContext):

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

        def unaryexpression(self):
            return self.getTypedRuleContext(CXParser.UnaryexpressionContext,0)


        def postfixexpression(self):
            return self.getTypedRuleContext(CXParser.PostfixexpressionContext,0)


        def PLUSPLUS(self):
            return self.getToken(CXParser.PLUSPLUS, 0)

        def MINUSMINUS(self):
            return self.getToken(CXParser.MINUSMINUS, 0)

        def getRuleIndex(self):
            return CXParser.RULE_postfixexpression

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

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



    def postfixexpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = CXParser.PostfixexpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 34
        self.enterRecursionRule(localctx, 34, self.RULE_postfixexpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 257
            self.unaryexpression()
            self._ctx.stop = self._input.LT(-1)
            self.state = 265
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,24,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 263
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,23,self._ctx)
                    if la_ == 1:
                        localctx = CXParser.PostfixexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_postfixexpression)
                        self.state = 259
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 260
                        self.match(CXParser.PLUSPLUS)
                        pass

                    elif la_ == 2:
                        localctx = CXParser.PostfixexpressionContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_postfixexpression)
                        self.state = 261
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 262
                        self.match(CXParser.MINUSMINUS)
                        pass

             
                self.state = 267
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,24,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 UnaryexpressionContext(ParserRuleContext):

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

        def primaryexpression(self):
            return self.getTypedRuleContext(CXParser.PrimaryexpressionContext,0)


        def unaryexpression(self):
            return self.getTypedRuleContext(CXParser.UnaryexpressionContext,0)


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

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

        def ODD(self):
            return self.getToken(CXParser.ODD, 0)

        def getRuleIndex(self):
            return CXParser.RULE_unaryexpression

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

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




    def unaryexpression(self):

        localctx = CXParser.UnaryexpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_unaryexpression)
        self._la = 0 # Token type
        try:
            self.state = 271
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [CXParser.LEFTPARENTHESIS, CXParser.TRUE, CXParser.FALSE, CXParser.NUMBER, CXParser.REALNUMBER, CXParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 1)
                self.state = 268
                self.primaryexpression()
                pass
            elif token in [CXParser.MINUS, CXParser.NOT, CXParser.ODD]:
                self.enterOuterAlt(localctx, 2)
                self.state = 269
                _la = self._input.LA(1)
                if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.MINUS) | (1 << CXParser.NOT) | (1 << CXParser.ODD))) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 270
                self.unaryexpression()
                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 PrimaryexpressionContext(ParserRuleContext):

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

        def IDENTIFIER(self):
            return self.getToken(CXParser.IDENTIFIER, 0)

        def constant(self):
            return self.getTypedRuleContext(CXParser.ConstantContext,0)


        def LEFTPARENTHESIS(self):
            return self.getToken(CXParser.LEFTPARENTHESIS, 0)

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


        def RIGHTPARENTHESIS(self):
            return self.getToken(CXParser.RIGHTPARENTHESIS, 0)

        def getRuleIndex(self):
            return CXParser.RULE_primaryexpression

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

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




    def primaryexpression(self):

        localctx = CXParser.PrimaryexpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_primaryexpression)
        try:
            self.state = 279
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [CXParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 1)
                self.state = 273
                self.match(CXParser.IDENTIFIER)
                pass
            elif token in [CXParser.TRUE, CXParser.FALSE, CXParser.NUMBER, CXParser.REALNUMBER]:
                self.enterOuterAlt(localctx, 2)
                self.state = 274
                self.constant()
                pass
            elif token in [CXParser.LEFTPARENTHESIS]:
                self.enterOuterAlt(localctx, 3)
                self.state = 275
                self.match(CXParser.LEFTPARENTHESIS)
                self.state = 276
                self.expression()
                self.state = 277
                self.match(CXParser.RIGHTPARENTHESIS)
                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 ConstantContext(ParserRuleContext):

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

        def TRUE(self):
            return self.getToken(CXParser.TRUE, 0)

        def FALSE(self):
            return self.getToken(CXParser.FALSE, 0)

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

        def REALNUMBER(self):
            return self.getToken(CXParser.REALNUMBER, 0)

        def getRuleIndex(self):
            return CXParser.RULE_constant

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

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




    def constant(self):

        localctx = CXParser.ConstantContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_constant)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 281
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.TRUE) | (1 << CXParser.FALSE) | (1 << CXParser.NUMBER) | (1 << CXParser.REALNUMBER))) != 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 BasetypeContext(ParserRuleContext):

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

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

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

        def REAL(self):
            return self.getToken(CXParser.REAL, 0)

        def getRuleIndex(self):
            return CXParser.RULE_basetype

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

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




    def basetype(self):

        localctx = CXParser.BasetypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_basetype)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 283
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CXParser.INT) | (1 << CXParser.BOOLEAN) | (1 << CXParser.REAL))) != 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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[9] = self.logicorexpression_sempred
        self._predicates[10] = self.logicandexpression_sempred
        self._predicates[11] = self.logicxorexpression_sempred
        self._predicates[12] = self.equalityexpression_sempred
        self._predicates[13] = self.comparisonexpression_sempred
        self._predicates[14] = self.additiveexpression_sempred
        self._predicates[15] = self.multiplicativeexpression_sempred
        self._predicates[17] = self.postfixexpression_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 logicorexpression_sempred(self, localctx:LogicorexpressionContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 1)
         

    def logicandexpression_sempred(self, localctx:LogicandexpressionContext, predIndex:int):
            if predIndex == 1:
                return self.precpred(self._ctx, 1)
         

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

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

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

    def comparisonexpression_sempred(self, localctx:ComparisonexpressionContext, predIndex:int):
            if predIndex == 5:
                return self.precpred(self._ctx, 4)
         

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

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

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

    def additiveexpression_sempred(self, localctx:AdditiveexpressionContext, predIndex:int):
            if predIndex == 9:
                return self.precpred(self._ctx, 2)
         

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

    def multiplicativeexpression_sempred(self, localctx:MultiplicativeexpressionContext, predIndex:int):
            if predIndex == 11:
                return self.precpred(self._ctx, 3)
         

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

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

    def postfixexpression_sempred(self, localctx:PostfixexpressionContext, predIndex:int):
            if predIndex == 14:
                return self.precpred(self._ctx, 2)
         

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




