# Generated from TypeLang.g4 by ANTLR 4.13.2
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
	from typing import TextIO
else:
	from typing.io import TextIO

def serializedATN():
    return [
        4,1,30,196,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
        6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
        1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
        3,0,46,8,0,1,1,1,1,1,1,1,1,1,1,5,1,53,8,1,10,1,12,1,56,9,1,1,2,1,
        2,3,2,60,8,2,1,3,5,3,63,8,3,10,3,12,3,66,9,3,1,4,1,4,3,4,70,8,4,
        1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,
        1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,
        1,5,1,5,3,5,106,8,5,1,6,1,6,1,6,1,6,1,6,3,6,113,8,6,1,7,1,7,1,7,
        1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,3,7,126,8,7,1,8,1,8,1,8,1,8,1,8,
        1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,
        1,8,3,8,150,8,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,
        1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,5,8,178,
        8,8,10,8,12,8,181,9,8,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,10,
        1,10,1,10,3,10,194,8,10,1,10,0,2,2,16,11,0,2,4,6,8,10,12,14,16,18,
        20,0,1,0,1,217,0,45,1,0,0,0,2,47,1,0,0,0,4,59,1,0,0,0,6,64,1,0,0,
        0,8,69,1,0,0,0,10,105,1,0,0,0,12,112,1,0,0,0,14,125,1,0,0,0,16,149,
        1,0,0,0,18,182,1,0,0,0,20,193,1,0,0,0,22,23,3,2,1,0,23,24,5,0,0,
        1,24,46,1,0,0,0,25,26,3,2,1,0,26,27,3,4,2,0,27,28,5,0,0,1,28,46,
        1,0,0,0,29,30,3,4,2,0,30,31,5,0,0,1,31,46,1,0,0,0,32,33,3,2,1,0,
        33,34,3,6,3,0,34,35,5,0,0,1,35,46,1,0,0,0,36,37,3,2,1,0,37,38,3,
        4,2,0,38,39,3,6,3,0,39,40,5,0,0,1,40,46,1,0,0,0,41,42,3,4,2,0,42,
        43,3,6,3,0,43,44,5,0,0,1,44,46,1,0,0,0,45,22,1,0,0,0,45,25,1,0,0,
        0,45,29,1,0,0,0,45,32,1,0,0,0,45,36,1,0,0,0,45,41,1,0,0,0,46,1,1,
        0,0,0,47,48,6,1,-1,0,48,49,3,8,4,0,49,54,1,0,0,0,50,51,10,2,0,0,
        51,53,3,8,4,0,52,50,1,0,0,0,53,56,1,0,0,0,54,52,1,0,0,0,54,55,1,
        0,0,0,55,3,1,0,0,0,56,54,1,0,0,0,57,60,3,16,8,0,58,60,3,12,6,0,59,
        57,1,0,0,0,59,58,1,0,0,0,60,5,1,0,0,0,61,63,8,0,0,0,62,61,1,0,0,
        0,63,66,1,0,0,0,64,62,1,0,0,0,64,65,1,0,0,0,65,7,1,0,0,0,66,64,1,
        0,0,0,67,70,3,10,5,0,68,70,3,14,7,0,69,67,1,0,0,0,69,68,1,0,0,0,
        70,9,1,0,0,0,71,72,5,25,0,0,72,73,5,1,0,0,73,106,3,10,5,0,74,75,
        5,25,0,0,75,76,5,1,0,0,76,77,5,2,0,0,77,78,5,3,0,0,78,79,5,4,0,0,
        79,106,3,12,6,0,80,81,5,25,0,0,81,82,5,1,0,0,82,83,5,2,0,0,83,106,
        5,3,0,0,84,85,5,25,0,0,85,86,5,1,0,0,86,87,5,2,0,0,87,88,5,4,0,0,
        88,89,3,12,6,0,89,90,5,5,0,0,90,91,3,12,6,0,91,106,1,0,0,0,92,93,
        5,25,0,0,93,94,5,1,0,0,94,95,5,2,0,0,95,96,5,4,0,0,96,106,3,12,6,
        0,97,98,5,25,0,0,98,99,5,1,0,0,99,100,5,2,0,0,100,101,5,5,0,0,101,
        106,3,12,6,0,102,103,5,25,0,0,103,104,5,1,0,0,104,106,5,2,0,0,105,
        71,1,0,0,0,105,74,1,0,0,0,105,80,1,0,0,0,105,84,1,0,0,0,105,92,1,
        0,0,0,105,97,1,0,0,0,105,102,1,0,0,0,106,11,1,0,0,0,107,113,5,25,
        0,0,108,109,5,6,0,0,109,110,3,10,5,0,110,111,5,7,0,0,111,113,1,0,
        0,0,112,107,1,0,0,0,112,108,1,0,0,0,113,13,1,0,0,0,114,115,5,25,
        0,0,115,116,5,1,0,0,116,117,5,8,0,0,117,118,5,4,0,0,118,126,3,12,
        6,0,119,120,5,25,0,0,120,121,5,1,0,0,121,126,5,8,0,0,122,123,5,25,
        0,0,123,124,5,1,0,0,124,126,3,16,8,0,125,114,1,0,0,0,125,119,1,0,
        0,0,125,122,1,0,0,0,126,15,1,0,0,0,127,128,6,8,-1,0,128,129,5,13,
        0,0,129,130,3,20,10,0,130,131,5,14,0,0,131,150,1,0,0,0,132,133,5,
        15,0,0,133,134,3,20,10,0,134,135,5,16,0,0,135,150,1,0,0,0,136,137,
        5,24,0,0,137,138,5,17,0,0,138,150,3,16,8,9,139,150,3,12,6,0,140,
        141,5,6,0,0,141,142,3,16,8,0,142,143,5,7,0,0,143,150,1,0,0,0,144,
        150,5,23,0,0,145,146,5,21,0,0,146,147,3,16,8,0,147,148,5,7,0,0,148,
        150,1,0,0,0,149,127,1,0,0,0,149,132,1,0,0,0,149,136,1,0,0,0,149,
        139,1,0,0,0,149,140,1,0,0,0,149,144,1,0,0,0,149,145,1,0,0,0,150,
        179,1,0,0,0,151,152,10,15,0,0,152,153,5,9,0,0,153,178,3,16,8,16,
        154,155,10,14,0,0,155,156,5,10,0,0,156,178,3,16,8,15,157,158,10,
        13,0,0,158,159,5,11,0,0,159,178,3,16,8,14,160,161,10,12,0,0,161,
        162,5,12,0,0,162,178,3,16,8,13,163,164,10,8,0,0,164,165,5,17,0,0,
        165,178,3,16,8,9,166,167,10,7,0,0,167,168,5,18,0,0,168,178,3,16,
        8,8,169,170,10,6,0,0,170,171,5,19,0,0,171,172,3,16,8,0,172,173,5,
        20,0,0,173,178,1,0,0,0,174,175,10,1,0,0,175,176,5,4,0,0,176,178,
        3,12,6,0,177,151,1,0,0,0,177,154,1,0,0,0,177,157,1,0,0,0,177,160,
        1,0,0,0,177,163,1,0,0,0,177,166,1,0,0,0,177,169,1,0,0,0,177,174,
        1,0,0,0,178,181,1,0,0,0,179,177,1,0,0,0,179,180,1,0,0,0,180,17,1,
        0,0,0,181,179,1,0,0,0,182,183,5,30,0,0,183,19,1,0,0,0,184,185,5,
        25,0,0,185,186,5,1,0,0,186,194,3,16,8,0,187,188,5,25,0,0,188,189,
        5,1,0,0,189,190,3,16,8,0,190,191,5,22,0,0,191,192,3,20,10,0,192,
        194,1,0,0,0,193,184,1,0,0,0,193,187,1,0,0,0,194,21,1,0,0,0,12,45,
        54,59,64,69,105,112,125,149,177,179,193
    ]

class TypeLangParser ( Parser ):

    grammarFileName = "TypeLang.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "':'", "'atom'", "'explicit'", "'in'", 
                     "'implicitly'", "'('", "')'", "'tbc'", "'&&'", "'&'", 
                     "'+'", "'*'", "'{'", "'}'", "'{{'", "'}}'", "'**'", 
                     "'^'", "'['", "']'", "'*('", "','" ]

    symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "SCHEMA_VAR", 
                      "SEQ_VAR", "NAME", "ALPHA", "DIGIT", "WHITESPACE", 
                      "NEWLINE", "LINE_COMMENT" ]

    RULE_tl_body = 0
    RULE_assignments = 1
    RULE_ret_expr = 2
    RULE_err_if_toks = 3
    RULE_assign = 4
    RULE_assign_atom = 5
    RULE_get = 6
    RULE_assign_expr = 7
    RULE_expr = 8
    RULE_comment = 9
    RULE_fields = 10

    ruleNames =  [ "tl_body", "assignments", "ret_expr", "err_if_toks", 
                   "assign", "assign_atom", "get", "assign_expr", "expr", 
                   "comment", "fields" ]

    EOF = Token.EOF
    T__0=1
    T__1=2
    T__2=3
    T__3=4
    T__4=5
    T__5=6
    T__6=7
    T__7=8
    T__8=9
    T__9=10
    T__10=11
    T__11=12
    T__12=13
    T__13=14
    T__14=15
    T__15=16
    T__16=17
    T__17=18
    T__18=19
    T__19=20
    T__20=21
    T__21=22
    SCHEMA_VAR=23
    SEQ_VAR=24
    NAME=25
    ALPHA=26
    DIGIT=27
    WHITESPACE=28
    NEWLINE=29
    LINE_COMMENT=30

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




    class Tl_bodyContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_tl_body

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



    class Ignored_1dContext(Tl_bodyContext):

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

        def ret_expr(self):
            return self.getTypedRuleContext(TypeLangParser.Ret_exprContext,0)

        def err_if_toks(self):
            return self.getTypedRuleContext(TypeLangParser.Err_if_toksContext,0)

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

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

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


    class Ignored_1cContext(Tl_bodyContext):

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

        def assignments(self):
            return self.getTypedRuleContext(TypeLangParser.AssignmentsContext,0)

        def ret_expr(self):
            return self.getTypedRuleContext(TypeLangParser.Ret_exprContext,0)

        def err_if_toks(self):
            return self.getTypedRuleContext(TypeLangParser.Err_if_toksContext,0)

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

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

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


    class DoneContext(Tl_bodyContext):

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

        def assignments(self):
            return self.getTypedRuleContext(TypeLangParser.AssignmentsContext,0)

        def EOF(self):
            return self.getToken(TypeLangParser.EOF, 0)
        def err_if_toks(self):
            return self.getTypedRuleContext(TypeLangParser.Err_if_toksContext,0)


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

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


    class Ignored_1bContext(Tl_bodyContext):

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

        def ret_expr(self):
            return self.getTypedRuleContext(TypeLangParser.Ret_exprContext,0)

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

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

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


    class Ignored_1aContext(Tl_bodyContext):

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

        def assignments(self):
            return self.getTypedRuleContext(TypeLangParser.AssignmentsContext,0)

        def ret_expr(self):
            return self.getTypedRuleContext(TypeLangParser.Ret_exprContext,0)

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

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

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



    def tl_body(self):

        localctx = TypeLangParser.Tl_bodyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_tl_body)
        try:
            self.state = 45
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,0,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.DoneContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 22
                self.assignments(0)
                self.state = 23
                self.match(TypeLangParser.EOF)
                pass

            elif la_ == 2:
                localctx = TypeLangParser.Ignored_1aContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 25
                self.assignments(0)
                self.state = 26
                self.ret_expr()
                self.state = 27
                self.match(TypeLangParser.EOF)
                pass

            elif la_ == 3:
                localctx = TypeLangParser.Ignored_1bContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 29
                self.ret_expr()
                self.state = 30
                self.match(TypeLangParser.EOF)
                pass

            elif la_ == 4:
                localctx = TypeLangParser.DoneContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 32
                self.assignments(0)
                self.state = 33
                self.err_if_toks()
                self.state = 34
                self.match(TypeLangParser.EOF)
                pass

            elif la_ == 5:
                localctx = TypeLangParser.Ignored_1cContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 36
                self.assignments(0)
                self.state = 37
                self.ret_expr()
                self.state = 38
                self.err_if_toks()
                self.state = 39
                self.match(TypeLangParser.EOF)
                pass

            elif la_ == 6:
                localctx = TypeLangParser.Ignored_1dContext(self, localctx)
                self.enterOuterAlt(localctx, 6)
                self.state = 41
                self.ret_expr()
                self.state = 42
                self.err_if_toks()
                self.state = 43
                self.match(TypeLangParser.EOF)
                pass


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


    class AssignmentsContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_assignments

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


    class Ignored_2bContext(AssignmentsContext):

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

        def assign(self):
            return self.getTypedRuleContext(TypeLangParser.AssignContext,0)


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

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


    class Ignored_2aContext(AssignmentsContext):

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

        def assignments(self):
            return self.getTypedRuleContext(TypeLangParser.AssignmentsContext,0)

        def assign(self):
            return self.getTypedRuleContext(TypeLangParser.AssignContext,0)


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

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



    def assignments(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = TypeLangParser.AssignmentsContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 2
        self.enterRecursionRule(localctx, 2, self.RULE_assignments, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            localctx = TypeLangParser.Ignored_2bContext(self, localctx)
            self._ctx = localctx
            _prevctx = localctx

            self.state = 48
            self.assign()
            self._ctx.stop = self._input.LT(-1)
            self.state = 54
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,1,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 = TypeLangParser.Ignored_2aContext(self, TypeLangParser.AssignmentsContext(self, _parentctx, _parentState))
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_assignments)
                    self.state = 50
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 51
                    self.assign() 
                self.state = 56
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,1,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 Ret_exprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_ret_expr

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



    class Return_namedContext(Ret_exprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Ret_exprContext
            super().__init__(parser)
            self.name_or_atom_ = None # GetContext
            self.copyFrom(ctx)

        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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


    class Return_exprContext(Ret_exprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Ret_exprContext
            super().__init__(parser)
            self.expr_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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



    def ret_expr(self):

        localctx = TypeLangParser.Ret_exprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_ret_expr)
        try:
            self.state = 59
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.Return_exprContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 57
                localctx.expr_ = self.expr(0)
                pass

            elif la_ == 2:
                localctx = TypeLangParser.Return_namedContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 58
                localctx.name_or_atom_ = self.get()
                pass


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


    class Err_if_toksContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def getRuleIndex(self):
            return TypeLangParser.RULE_err_if_toks

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

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




    def err_if_toks(self):

        localctx = TypeLangParser.Err_if_toksContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_err_if_toks)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 64
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 2147483646) != 0):
                self.state = 61
                _la = self._input.LA(1)
                if _la <= 0 or _la==-1:
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 66
                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 AssignContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_assign

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



    class Ignored_3aContext(AssignContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.AssignContext
            super().__init__(parser)
            self.atom_ = None # Assign_atomContext
            self.copyFrom(ctx)

        def assign_atom(self):
            return self.getTypedRuleContext(TypeLangParser.Assign_atomContext,0)


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

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


    class Ignored_3bContext(AssignContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.AssignContext
            super().__init__(parser)
            self.expr_ = None # Assign_exprContext
            self.copyFrom(ctx)

        def assign_expr(self):
            return self.getTypedRuleContext(TypeLangParser.Assign_exprContext,0)


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

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



    def assign(self):

        localctx = TypeLangParser.AssignContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_assign)
        try:
            self.state = 69
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,4,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.Ignored_3aContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 67
                localctx.atom_ = self.assign_atom()
                pass

            elif la_ == 2:
                localctx = TypeLangParser.Ignored_3bContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 68
                localctx.expr_ = self.assign_expr()
                pass


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


    class Assign_atomContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_assign_atom

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



    class Atom_explicit_inContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.atom_ = None # GetContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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


    class Atom_multiContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.rhs_ = None # Assign_atomContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def assign_atom(self):
            return self.getTypedRuleContext(TypeLangParser.Assign_atomContext,0)


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

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


    class Atom_in_implicitlyContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.atom1_ = None # GetContext
            self.atom2_ = None # GetContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def get(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(TypeLangParser.GetContext)
            else:
                return self.getTypedRuleContext(TypeLangParser.GetContext,i)


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

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


    class Atom_implicitlyContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.atom_ = None # GetContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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


    class AtomContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.copyFrom(ctx)

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

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

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


    class Atom_explicitContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.copyFrom(ctx)

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

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

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


    class Atom_inContext(Assign_atomContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_atomContext
            super().__init__(parser)
            self.name_ = None # Token
            self.atom_ = None # GetContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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



    def assign_atom(self):

        localctx = TypeLangParser.Assign_atomContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_assign_atom)
        try:
            self.state = 105
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.Atom_multiContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 71
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 72
                self.match(TypeLangParser.T__0)
                self.state = 73
                localctx.rhs_ = self.assign_atom()
                pass

            elif la_ == 2:
                localctx = TypeLangParser.Atom_explicit_inContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 74
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 75
                self.match(TypeLangParser.T__0)
                self.state = 76
                self.match(TypeLangParser.T__1)
                self.state = 77
                self.match(TypeLangParser.T__2)
                self.state = 78
                self.match(TypeLangParser.T__3)
                self.state = 79
                localctx.atom_ = self.get()
                pass

            elif la_ == 3:
                localctx = TypeLangParser.Atom_explicitContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 80
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 81
                self.match(TypeLangParser.T__0)
                self.state = 82
                self.match(TypeLangParser.T__1)
                self.state = 83
                self.match(TypeLangParser.T__2)
                pass

            elif la_ == 4:
                localctx = TypeLangParser.Atom_in_implicitlyContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 84
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 85
                self.match(TypeLangParser.T__0)
                self.state = 86
                self.match(TypeLangParser.T__1)
                self.state = 87
                self.match(TypeLangParser.T__3)
                self.state = 88
                localctx.atom1_ = self.get()
                self.state = 89
                self.match(TypeLangParser.T__4)
                self.state = 90
                localctx.atom2_ = self.get()
                pass

            elif la_ == 5:
                localctx = TypeLangParser.Atom_inContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 92
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 93
                self.match(TypeLangParser.T__0)
                self.state = 94
                self.match(TypeLangParser.T__1)
                self.state = 95
                self.match(TypeLangParser.T__3)
                self.state = 96
                localctx.atom_ = self.get()
                pass

            elif la_ == 6:
                localctx = TypeLangParser.Atom_implicitlyContext(self, localctx)
                self.enterOuterAlt(localctx, 6)
                self.state = 97
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 98
                self.match(TypeLangParser.T__0)
                self.state = 99
                self.match(TypeLangParser.T__1)
                self.state = 100
                self.match(TypeLangParser.T__4)
                self.state = 101
                localctx.atom_ = self.get()
                pass

            elif la_ == 7:
                localctx = TypeLangParser.AtomContext(self, localctx)
                self.enterOuterAlt(localctx, 7)
                self.state = 102
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 103
                self.match(TypeLangParser.T__0)
                self.state = 104
                self.match(TypeLangParser.T__1)
                pass


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


    class GetContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_get

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



    class NameContext(GetContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.GetContext
            super().__init__(parser)
            self.name_ = None # Token
            self.copyFrom(ctx)

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

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

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


    class Atom_in_parensContext(GetContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.GetContext
            super().__init__(parser)
            self.atom_ = None # Assign_atomContext
            self.copyFrom(ctx)

        def assign_atom(self):
            return self.getTypedRuleContext(TypeLangParser.Assign_atomContext,0)


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

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



    def get(self):

        localctx = TypeLangParser.GetContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_get)
        try:
            self.state = 112
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [25]:
                localctx = TypeLangParser.NameContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 107
                localctx.name_ = self.match(TypeLangParser.NAME)
                pass
            elif token in [6]:
                localctx = TypeLangParser.Atom_in_parensContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 108
                self.match(TypeLangParser.T__5)
                self.state = 109
                localctx.atom_ = self.assign_atom()
                self.state = 110
                self.match(TypeLangParser.T__6)
                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 Assign_exprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_assign_expr

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



    class Prealloc_inContext(Assign_exprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_exprContext
            super().__init__(parser)
            self.name_ = None # Token
            self.atom_ = None # GetContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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


    class Assign_expr_toContext(Assign_exprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_exprContext
            super().__init__(parser)
            self.name_ = None # Token
            self.expr_ = None # ExprContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def expr(self):
            return self.getTypedRuleContext(TypeLangParser.ExprContext,0)


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

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


    class PreallocContext(Assign_exprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.Assign_exprContext
            super().__init__(parser)
            self.name_ = None # Token
            self.copyFrom(ctx)

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

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

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



    def assign_expr(self):

        localctx = TypeLangParser.Assign_exprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_assign_expr)
        try:
            self.state = 125
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,7,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.Prealloc_inContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 114
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 115
                self.match(TypeLangParser.T__0)
                self.state = 116
                self.match(TypeLangParser.T__7)
                self.state = 117
                self.match(TypeLangParser.T__3)
                self.state = 118
                localctx.atom_ = self.get()
                pass

            elif la_ == 2:
                localctx = TypeLangParser.PreallocContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 119
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 120
                self.match(TypeLangParser.T__0)
                self.state = 121
                self.match(TypeLangParser.T__7)
                pass

            elif la_ == 3:
                localctx = TypeLangParser.Assign_expr_toContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 122
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 123
                self.match(TypeLangParser.T__0)
                self.state = 124
                localctx.expr_ = self.expr(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 ExprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_expr

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


    class StructContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.fields_ = None # FieldsContext
            self.copyFrom(ctx)

        def fields(self):
            return self.getTypedRuleContext(TypeLangParser.FieldsContext,0)


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

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


    class Schema_varContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.name_ = None # Token
            self.copyFrom(ctx)

        def SCHEMA_VAR(self):
            return self.getToken(TypeLangParser.SCHEMA_VAR, 0)

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

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


    class Inter_lowContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class InterContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class FnContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class Expr_parensContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.expr_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class UnionContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class Name_or_atomContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.name_or_atom_ = None # GetContext
            self.copyFrom(ctx)

        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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


    class RecContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.fields_ = None # FieldsContext
            self.copyFrom(ctx)

        def fields(self):
            return self.getTypedRuleContext(TypeLangParser.FieldsContext,0)


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

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


    class TupleContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class Expr_inContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.expr_ = None # ExprContext
            self.atom_ = None # GetContext
            self.copyFrom(ctx)

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

        def get(self):
            return self.getTypedRuleContext(TypeLangParser.GetContext,0)


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

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


    class MutableContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.expr_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class Inter_highContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class MapContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # ExprContext
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

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


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

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


    class SeqContext(ExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.ExprContext
            super().__init__(parser)
            self.lhs_ = None # Token
            self.rhs_ = None # ExprContext
            self.copyFrom(ctx)

        def SEQ_VAR(self):
            return self.getToken(TypeLangParser.SEQ_VAR, 0)
        def expr(self):
            return self.getTypedRuleContext(TypeLangParser.ExprContext,0)


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

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



    def expr(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = TypeLangParser.ExprContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 16
        self.enterRecursionRule(localctx, 16, self.RULE_expr, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 149
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,8,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.StructContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 128
                self.match(TypeLangParser.T__12)
                self.state = 129
                localctx.fields_ = self.fields()
                self.state = 130
                self.match(TypeLangParser.T__13)
                pass

            elif la_ == 2:
                localctx = TypeLangParser.RecContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 132
                self.match(TypeLangParser.T__14)
                self.state = 133
                localctx.fields_ = self.fields()
                self.state = 134
                self.match(TypeLangParser.T__15)
                pass

            elif la_ == 3:
                localctx = TypeLangParser.SeqContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 136
                localctx.lhs_ = self.match(TypeLangParser.SEQ_VAR)
                self.state = 137
                self.match(TypeLangParser.T__16)
                self.state = 138
                localctx.rhs_ = self.expr(9)
                pass

            elif la_ == 4:
                localctx = TypeLangParser.Name_or_atomContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 139
                localctx.name_or_atom_ = self.get()
                pass

            elif la_ == 5:
                localctx = TypeLangParser.Expr_parensContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 140
                self.match(TypeLangParser.T__5)
                self.state = 141
                localctx.expr_ = self.expr(0)
                self.state = 142
                self.match(TypeLangParser.T__6)
                pass

            elif la_ == 6:
                localctx = TypeLangParser.Schema_varContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 144
                localctx.name_ = self.match(TypeLangParser.SCHEMA_VAR)
                pass

            elif la_ == 7:
                localctx = TypeLangParser.MutableContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 145
                self.match(TypeLangParser.T__20)
                self.state = 146
                localctx.expr_ = self.expr(0)
                self.state = 147
                self.match(TypeLangParser.T__6)
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 179
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,10,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 177
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,9,self._ctx)
                    if la_ == 1:
                        localctx = TypeLangParser.Inter_highContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 151
                        if not self.precpred(self._ctx, 15):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 15)")
                        self.state = 152
                        self.match(TypeLangParser.T__8)
                        self.state = 153
                        localctx.rhs_ = self.expr(16)
                        pass

                    elif la_ == 2:
                        localctx = TypeLangParser.InterContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 154
                        if not self.precpred(self._ctx, 14):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 14)")
                        self.state = 155
                        self.match(TypeLangParser.T__9)
                        self.state = 156
                        localctx.rhs_ = self.expr(15)
                        pass

                    elif la_ == 3:
                        localctx = TypeLangParser.UnionContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 157
                        if not self.precpred(self._ctx, 13):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 13)")
                        self.state = 158
                        self.match(TypeLangParser.T__10)
                        self.state = 159
                        localctx.rhs_ = self.expr(14)
                        pass

                    elif la_ == 4:
                        localctx = TypeLangParser.TupleContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 160
                        if not self.precpred(self._ctx, 12):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 12)")
                        self.state = 161
                        self.match(TypeLangParser.T__11)
                        self.state = 162
                        localctx.rhs_ = self.expr(13)
                        pass

                    elif la_ == 5:
                        localctx = TypeLangParser.MapContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 163
                        if not self.precpred(self._ctx, 8):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 8)")
                        self.state = 164
                        self.match(TypeLangParser.T__16)
                        self.state = 165
                        localctx.rhs_ = self.expr(9)
                        pass

                    elif la_ == 6:
                        localctx = TypeLangParser.FnContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 166
                        if not self.precpred(self._ctx, 7):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 7)")
                        self.state = 167
                        self.match(TypeLangParser.T__17)
                        self.state = 168
                        localctx.rhs_ = self.expr(8)
                        pass

                    elif la_ == 7:
                        localctx = TypeLangParser.Inter_lowContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.lhs_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 169
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 170
                        self.match(TypeLangParser.T__18)
                        self.state = 171
                        localctx.rhs_ = self.expr(0)
                        self.state = 172
                        self.match(TypeLangParser.T__19)
                        pass

                    elif la_ == 8:
                        localctx = TypeLangParser.Expr_inContext(self, TypeLangParser.ExprContext(self, _parentctx, _parentState))
                        localctx.expr_ = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
                        self.state = 174
                        if not self.precpred(self._ctx, 1):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                        self.state = 175
                        self.match(TypeLangParser.T__3)
                        self.state = 176
                        localctx.atom_ = self.get()
                        pass

             
                self.state = 181
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,10,self._ctx)

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


    class CommentContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def LINE_COMMENT(self):
            return self.getToken(TypeLangParser.LINE_COMMENT, 0)

        def getRuleIndex(self):
            return TypeLangParser.RULE_comment

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

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




    def comment(self):

        localctx = TypeLangParser.CommentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_comment)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 182
            localctx.comment_ = self.match(TypeLangParser.LINE_COMMENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldsContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return TypeLangParser.RULE_fields

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



    class Ignored_4bContext(FieldsContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.FieldsContext
            super().__init__(parser)
            self.name_ = None # Token
            self.type_ = None # ExprContext
            self.rhs_ = None # FieldsContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def expr(self):
            return self.getTypedRuleContext(TypeLangParser.ExprContext,0)

        def fields(self):
            return self.getTypedRuleContext(TypeLangParser.FieldsContext,0)


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

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


    class Ignored_4aContext(FieldsContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a TypeLangParser.FieldsContext
            super().__init__(parser)
            self.name_ = None # Token
            self.type_ = None # ExprContext
            self.copyFrom(ctx)

        def NAME(self):
            return self.getToken(TypeLangParser.NAME, 0)
        def expr(self):
            return self.getTypedRuleContext(TypeLangParser.ExprContext,0)


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

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



    def fields(self):

        localctx = TypeLangParser.FieldsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_fields)
        try:
            self.state = 193
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
            if la_ == 1:
                localctx = TypeLangParser.Ignored_4aContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 184
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 185
                self.match(TypeLangParser.T__0)
                self.state = 186
                localctx.type_ = self.expr(0)
                pass

            elif la_ == 2:
                localctx = TypeLangParser.Ignored_4bContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 187
                localctx.name_ = self.match(TypeLangParser.NAME)
                self.state = 188
                self.match(TypeLangParser.T__0)
                self.state = 189
                localctx.type_ = self.expr(0)
                self.state = 190
                self.match(TypeLangParser.T__21)
                self.state = 191
                localctx.rhs_ = self.fields()
                pass


        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[1] = self.assignments_sempred
        self._predicates[8] = self.expr_sempred
        pred = self._predicates.get(ruleIndex, None)
        if pred is None:
            raise Exception("No predicate with index:" + str(ruleIndex))
        else:
            return pred(localctx, predIndex)

    def assignments_sempred(self, localctx:AssignmentsContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 2)
         

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

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

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

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

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

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

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

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




