# Generated from Zish.g4 by ANTLR 4.7
# 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\26")
        buf.write("\u00d7\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\3\2\7\2\24\n\2\f\2\16\2\27\13\2\3\2\3")
        buf.write("\2\6\2\33\n\2\r\2\16\2\34\3\2\3\2\7\2!\n\2\f\2\16\2$\13")
        buf.write("\2\3\2\7\2\'\n\2\f\2\16\2*\13\2\3\2\3\2\3\3\3\3\5\3\60")
        buf.write("\n\3\3\4\3\4\7\4\64\n\4\f\4\16\4\67\13\4\3\4\3\4\7\4;")
        buf.write("\n\4\f\4\16\4>\13\4\3\4\3\4\7\4B\n\4\f\4\16\4E\13\4\3")
        buf.write("\4\7\4H\n\4\f\4\16\4K\13\4\3\4\7\4N\n\4\f\4\16\4Q\13\4")
        buf.write("\3\4\3\4\3\4\3\4\7\4W\n\4\f\4\16\4Z\13\4\3\4\5\4]\n\4")
        buf.write("\3\5\3\5\7\5a\n\5\f\5\16\5d\13\5\3\5\3\5\7\5h\n\5\f\5")
        buf.write("\16\5k\13\5\3\5\3\5\7\5o\n\5\f\5\16\5r\13\5\3\5\7\5u\n")
        buf.write("\5\f\5\16\5x\13\5\3\5\7\5{\n\5\f\5\16\5~\13\5\3\5\3\5")
        buf.write("\3\5\3\5\7\5\u0084\n\5\f\5\16\5\u0087\13\5\3\5\5\5\u008a")
        buf.write("\n\5\3\6\3\6\7\6\u008e\n\6\f\6\16\6\u0091\13\6\3\6\3\6")
        buf.write("\7\6\u0095\n\6\f\6\16\6\u0098\13\6\3\6\3\6\7\6\u009c\n")
        buf.write("\6\f\6\16\6\u009f\13\6\3\6\7\6\u00a2\n\6\f\6\16\6\u00a5")
        buf.write("\13\6\3\6\7\6\u00a8\n\6\f\6\16\6\u00ab\13\6\3\6\3\6\3")
        buf.write("\6\3\6\7\6\u00b1\n\6\f\6\16\6\u00b4\13\6\3\6\5\6\u00b7")
        buf.write("\n\6\3\7\3\7\7\7\u00bb\n\7\f\7\16\7\u00be\13\7\3\7\3\7")
        buf.write("\7\7\u00c2\n\7\f\7\16\7\u00c5\13\7\3\7\3\7\3\b\3\b\3\b")
        buf.write("\3\b\3\b\3\b\3\b\3\b\3\b\3\b\5\b\u00d3\n\b\3\t\3\t\3\t")
        buf.write("\2\2\n\2\4\6\b\n\f\16\20\2\3\3\2\13\r\2\u00f3\2\25\3\2")
        buf.write("\2\2\4/\3\2\2\2\6\\\3\2\2\2\b\u0089\3\2\2\2\n\u00b6\3")
        buf.write("\2\2\2\f\u00b8\3\2\2\2\16\u00d2\3\2\2\2\20\u00d4\3\2\2")
        buf.write("\2\22\24\5\20\t\2\23\22\3\2\2\2\24\27\3\2\2\2\25\23\3")
        buf.write("\2\2\2\25\26\3\2\2\2\26\30\3\2\2\2\27\25\3\2\2\2\30\"")
        buf.write("\5\4\3\2\31\33\5\20\t\2\32\31\3\2\2\2\33\34\3\2\2\2\34")
        buf.write("\32\3\2\2\2\34\35\3\2\2\2\35\36\3\2\2\2\36\37\5\4\3\2")
        buf.write("\37!\3\2\2\2 \32\3\2\2\2!$\3\2\2\2\" \3\2\2\2\"#\3\2\2")
        buf.write("\2#(\3\2\2\2$\"\3\2\2\2%\'\5\20\t\2&%\3\2\2\2\'*\3\2\2")
        buf.write("\2(&\3\2\2\2()\3\2\2\2)+\3\2\2\2*(\3\2\2\2+,\7\2\2\3,")
        buf.write("\3\3\2\2\2-\60\5\16\b\2.\60\5\n\6\2/-\3\2\2\2/.\3\2\2")
        buf.write("\2\60\5\3\2\2\2\61\65\7\3\2\2\62\64\5\20\t\2\63\62\3\2")
        buf.write("\2\2\64\67\3\2\2\2\65\63\3\2\2\2\65\66\3\2\2\2\668\3\2")
        buf.write("\2\2\67\65\3\2\2\28I\5\4\3\29;\5\20\t\2:9\3\2\2\2;>\3")
        buf.write("\2\2\2<:\3\2\2\2<=\3\2\2\2=?\3\2\2\2><\3\2\2\2?C\7\7\2")
        buf.write("\2@B\5\20\t\2A@\3\2\2\2BE\3\2\2\2CA\3\2\2\2CD\3\2\2\2")
        buf.write("DF\3\2\2\2EC\3\2\2\2FH\5\4\3\2G<\3\2\2\2HK\3\2\2\2IG\3")
        buf.write("\2\2\2IJ\3\2\2\2JO\3\2\2\2KI\3\2\2\2LN\5\20\t\2ML\3\2")
        buf.write("\2\2NQ\3\2\2\2OM\3\2\2\2OP\3\2\2\2PR\3\2\2\2QO\3\2\2\2")
        buf.write("RS\7\4\2\2S]\3\2\2\2TX\7\3\2\2UW\5\20\t\2VU\3\2\2\2WZ")
        buf.write("\3\2\2\2XV\3\2\2\2XY\3\2\2\2Y[\3\2\2\2ZX\3\2\2\2[]\7\4")
        buf.write("\2\2\\\61\3\2\2\2\\T\3\2\2\2]\7\3\2\2\2^b\7\5\2\2_a\5")
        buf.write("\20\t\2`_\3\2\2\2ad\3\2\2\2b`\3\2\2\2bc\3\2\2\2ce\3\2")
        buf.write("\2\2db\3\2\2\2ev\5\16\b\2fh\5\20\t\2gf\3\2\2\2hk\3\2\2")
        buf.write("\2ig\3\2\2\2ij\3\2\2\2jl\3\2\2\2ki\3\2\2\2lp\7\7\2\2m")
        buf.write("o\5\20\t\2nm\3\2\2\2or\3\2\2\2pn\3\2\2\2pq\3\2\2\2qs\3")
        buf.write("\2\2\2rp\3\2\2\2su\5\16\b\2ti\3\2\2\2ux\3\2\2\2vt\3\2")
        buf.write("\2\2vw\3\2\2\2w|\3\2\2\2xv\3\2\2\2y{\5\20\t\2zy\3\2\2")
        buf.write("\2{~\3\2\2\2|z\3\2\2\2|}\3\2\2\2}\177\3\2\2\2~|\3\2\2")
        buf.write("\2\177\u0080\7\6\2\2\u0080\u008a\3\2\2\2\u0081\u0085\7")
        buf.write("\5\2\2\u0082\u0084\5\20\t\2\u0083\u0082\3\2\2\2\u0084")
        buf.write("\u0087\3\2\2\2\u0085\u0083\3\2\2\2\u0085\u0086\3\2\2\2")
        buf.write("\u0086\u0088\3\2\2\2\u0087\u0085\3\2\2\2\u0088\u008a\7")
        buf.write("\6\2\2\u0089^\3\2\2\2\u0089\u0081\3\2\2\2\u008a\t\3\2")
        buf.write("\2\2\u008b\u008f\7\b\2\2\u008c\u008e\5\20\t\2\u008d\u008c")
        buf.write("\3\2\2\2\u008e\u0091\3\2\2\2\u008f\u008d\3\2\2\2\u008f")
        buf.write("\u0090\3\2\2\2\u0090\u0092\3\2\2\2\u0091\u008f\3\2\2\2")
        buf.write("\u0092\u00a3\5\f\7\2\u0093\u0095\5\20\t\2\u0094\u0093")
        buf.write("\3\2\2\2\u0095\u0098\3\2\2\2\u0096\u0094\3\2\2\2\u0096")
        buf.write("\u0097\3\2\2\2\u0097\u0099\3\2\2\2\u0098\u0096\3\2\2\2")
        buf.write("\u0099\u009d\7\7\2\2\u009a\u009c\5\20\t\2\u009b\u009a")
        buf.write("\3\2\2\2\u009c\u009f\3\2\2\2\u009d\u009b\3\2\2\2\u009d")
        buf.write("\u009e\3\2\2\2\u009e\u00a0\3\2\2\2\u009f\u009d\3\2\2\2")
        buf.write("\u00a0\u00a2\5\f\7\2\u00a1\u0096\3\2\2\2\u00a2\u00a5\3")
        buf.write("\2\2\2\u00a3\u00a1\3\2\2\2\u00a3\u00a4\3\2\2\2\u00a4\u00a9")
        buf.write("\3\2\2\2\u00a5\u00a3\3\2\2\2\u00a6\u00a8\5\20\t\2\u00a7")
        buf.write("\u00a6\3\2\2\2\u00a8\u00ab\3\2\2\2\u00a9\u00a7\3\2\2\2")
        buf.write("\u00a9\u00aa\3\2\2\2\u00aa\u00ac\3\2\2\2\u00ab\u00a9\3")
        buf.write("\2\2\2\u00ac\u00ad\7\t\2\2\u00ad\u00b7\3\2\2\2\u00ae\u00b2")
        buf.write("\7\b\2\2\u00af\u00b1\5\20\t\2\u00b0\u00af\3\2\2\2\u00b1")
        buf.write("\u00b4\3\2\2\2\u00b2\u00b0\3\2\2\2\u00b2\u00b3\3\2\2\2")
        buf.write("\u00b3\u00b5\3\2\2\2\u00b4\u00b2\3\2\2\2\u00b5\u00b7\7")
        buf.write("\t\2\2\u00b6\u008b\3\2\2\2\u00b6\u00ae\3\2\2\2\u00b7\13")
        buf.write("\3\2\2\2\u00b8\u00bc\5\16\b\2\u00b9\u00bb\5\20\t\2\u00ba")
        buf.write("\u00b9\3\2\2\2\u00bb\u00be\3\2\2\2\u00bc\u00ba\3\2\2\2")
        buf.write("\u00bc\u00bd\3\2\2\2\u00bd\u00bf\3\2\2\2\u00be\u00bc\3")
        buf.write("\2\2\2\u00bf\u00c3\7\n\2\2\u00c0\u00c2\5\20\t\2\u00c1")
        buf.write("\u00c0\3\2\2\2\u00c2\u00c5\3\2\2\2\u00c3\u00c1\3\2\2\2")
        buf.write("\u00c3\u00c4\3\2\2\2\u00c4\u00c6\3\2\2\2\u00c5\u00c3\3")
        buf.write("\2\2\2\u00c6\u00c7\5\4\3\2\u00c7\r\3\2\2\2\u00c8\u00d3")
        buf.write("\7\17\2\2\u00c9\u00d3\7\16\2\2\u00ca\u00d3\7\20\2\2\u00cb")
        buf.write("\u00d3\7\21\2\2\u00cc\u00d3\7\23\2\2\u00cd\u00d3\7\24")
        buf.write("\2\2\u00ce\u00d3\7\25\2\2\u00cf\u00d3\7\26\2\2\u00d0\u00d3")
        buf.write("\5\6\4\2\u00d1\u00d3\5\b\5\2\u00d2\u00c8\3\2\2\2\u00d2")
        buf.write("\u00c9\3\2\2\2\u00d2\u00ca\3\2\2\2\u00d2\u00cb\3\2\2\2")
        buf.write("\u00d2\u00cc\3\2\2\2\u00d2\u00cd\3\2\2\2\u00d2\u00ce\3")
        buf.write("\2\2\2\u00d2\u00cf\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d2\u00d1")
        buf.write("\3\2\2\2\u00d3\17\3\2\2\2\u00d4\u00d5\t\2\2\2\u00d5\21")
        buf.write("\3\2\2\2\37\25\34\"(/\65<CIOX\\bipv|\u0085\u0089\u008f")
        buf.write("\u0096\u009d\u00a3\u00a9\u00b2\u00b6\u00bc\u00c3\u00d2")
        return buf.getvalue()


class ZishParser ( Parser ):

    grammarFileName = "Zish.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'['", "']'", "'('", "')'", "','", "'{'", 
                     "'}'", "':'", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "'null'" ]

    symbolicNames = [ "<INVALID>", "LIST_START", "LIST_FINISH", "SET_START", 
                      "SET_FINISH", "COMMA", "MAP_START", "MAP_FINISH", 
                      "COLON", "WHITESPACE", "INLINE_COMMENT", "BLOCK_COMMENT", 
                      "NULL", "BOOL", "TIMESTAMP", "INTEGER", "UNSIGNED_INTEGER", 
                      "FLOAT", "DECIMAL", "STRING", "BLOB" ]

    RULE_start = 0
    RULE_element = 1
    RULE_list_type = 2
    RULE_set_type = 3
    RULE_map_type = 4
    RULE_pair = 5
    RULE_key = 6
    RULE_ws = 7

    ruleNames =  [ "start", "element", "list_type", "set_type", "map_type", 
                   "pair", "key", "ws" ]

    EOF = Token.EOF
    LIST_START=1
    LIST_FINISH=2
    SET_START=3
    SET_FINISH=4
    COMMA=5
    MAP_START=6
    MAP_FINISH=7
    COLON=8
    WHITESPACE=9
    INLINE_COMMENT=10
    BLOCK_COMMENT=11
    NULL=12
    BOOL=13
    TIMESTAMP=14
    INTEGER=15
    UNSIGNED_INTEGER=16
    FLOAT=17
    DECIMAL=18
    STRING=19
    BLOB=20

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



    class StartContext(ParserRuleContext):

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

        def element(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.ElementContext)
            else:
                return self.getTypedRuleContext(ZishParser.ElementContext,i)


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

        def ws(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.WsContext)
            else:
                return self.getTypedRuleContext(ZishParser.WsContext,i)


        def getRuleIndex(self):
            return ZishParser.RULE_start

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

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




    def start(self):

        localctx = ZishParser.StartContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_start)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 19
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                self.state = 16
                self.ws()
                self.state = 21
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 22
            self.element()
            self.state = 32
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,2,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 24 
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    while True:
                        self.state = 23
                        self.ws()
                        self.state = 26 
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0)):
                            break

                    self.state = 28
                    self.element() 
                self.state = 34
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,2,self._ctx)

            self.state = 38
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                self.state = 35
                self.ws()
                self.state = 40
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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

    class ElementContext(ParserRuleContext):

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

        def key(self):
            return self.getTypedRuleContext(ZishParser.KeyContext,0)


        def map_type(self):
            return self.getTypedRuleContext(ZishParser.Map_typeContext,0)


        def getRuleIndex(self):
            return ZishParser.RULE_element

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

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




    def element(self):

        localctx = ZishParser.ElementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_element)
        try:
            self.state = 45
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [ZishParser.LIST_START, ZishParser.SET_START, ZishParser.NULL, ZishParser.BOOL, ZishParser.TIMESTAMP, ZishParser.INTEGER, ZishParser.FLOAT, ZishParser.DECIMAL, ZishParser.STRING, ZishParser.BLOB]:
                self.enterOuterAlt(localctx, 1)
                self.state = 43
                self.key()
                pass
            elif token in [ZishParser.MAP_START]:
                self.enterOuterAlt(localctx, 2)
                self.state = 44
                self.map_type()
                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 List_typeContext(ParserRuleContext):

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

        def LIST_START(self):
            return self.getToken(ZishParser.LIST_START, 0)

        def element(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.ElementContext)
            else:
                return self.getTypedRuleContext(ZishParser.ElementContext,i)


        def LIST_FINISH(self):
            return self.getToken(ZishParser.LIST_FINISH, 0)

        def ws(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.WsContext)
            else:
                return self.getTypedRuleContext(ZishParser.WsContext,i)


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

        def getRuleIndex(self):
            return ZishParser.RULE_list_type

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

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




    def list_type(self):

        localctx = ZishParser.List_typeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_list_type)
        self._la = 0 # Token type
        try:
            self.state = 90
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 47
                self.match(ZishParser.LIST_START)
                self.state = 51
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 48
                    self.ws()
                    self.state = 53
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 54
                self.element()
                self.state = 71
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,8,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 58
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                            self.state = 55
                            self.ws()
                            self.state = 60
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)

                        self.state = 61
                        self.match(ZishParser.COMMA)
                        self.state = 65
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                            self.state = 62
                            self.ws()
                            self.state = 67
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)

                        self.state = 68
                        self.element() 
                    self.state = 73
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,8,self._ctx)

                self.state = 77
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 74
                    self.ws()
                    self.state = 79
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 80
                self.match(ZishParser.LIST_FINISH)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 82
                self.match(ZishParser.LIST_START)
                self.state = 86
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 83
                    self.ws()
                    self.state = 88
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 89
                self.match(ZishParser.LIST_FINISH)
                pass


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

    class Set_typeContext(ParserRuleContext):

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

        def SET_START(self):
            return self.getToken(ZishParser.SET_START, 0)

        def key(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.KeyContext)
            else:
                return self.getTypedRuleContext(ZishParser.KeyContext,i)


        def SET_FINISH(self):
            return self.getToken(ZishParser.SET_FINISH, 0)

        def ws(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.WsContext)
            else:
                return self.getTypedRuleContext(ZishParser.WsContext,i)


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

        def getRuleIndex(self):
            return ZishParser.RULE_set_type

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

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




    def set_type(self):

        localctx = ZishParser.Set_typeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_set_type)
        self._la = 0 # Token type
        try:
            self.state = 135
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 92
                self.match(ZishParser.SET_START)
                self.state = 96
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 93
                    self.ws()
                    self.state = 98
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 99
                self.key()
                self.state = 116
                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:
                        self.state = 103
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                            self.state = 100
                            self.ws()
                            self.state = 105
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)

                        self.state = 106
                        self.match(ZishParser.COMMA)
                        self.state = 110
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                            self.state = 107
                            self.ws()
                            self.state = 112
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)

                        self.state = 113
                        self.key() 
                    self.state = 118
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,15,self._ctx)

                self.state = 122
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 119
                    self.ws()
                    self.state = 124
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 125
                self.match(ZishParser.SET_FINISH)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 127
                self.match(ZishParser.SET_START)
                self.state = 131
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 128
                    self.ws()
                    self.state = 133
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 134
                self.match(ZishParser.SET_FINISH)
                pass


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

    class Map_typeContext(ParserRuleContext):

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

        def MAP_START(self):
            return self.getToken(ZishParser.MAP_START, 0)

        def pair(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.PairContext)
            else:
                return self.getTypedRuleContext(ZishParser.PairContext,i)


        def MAP_FINISH(self):
            return self.getToken(ZishParser.MAP_FINISH, 0)

        def ws(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.WsContext)
            else:
                return self.getTypedRuleContext(ZishParser.WsContext,i)


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

        def getRuleIndex(self):
            return ZishParser.RULE_map_type

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

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




    def map_type(self):

        localctx = ZishParser.Map_typeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_map_type)
        self._la = 0 # Token type
        try:
            self.state = 180
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,25,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 137
                self.match(ZishParser.MAP_START)
                self.state = 141
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 138
                    self.ws()
                    self.state = 143
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 144
                self.pair()
                self.state = 161
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,22,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 148
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                            self.state = 145
                            self.ws()
                            self.state = 150
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)

                        self.state = 151
                        self.match(ZishParser.COMMA)
                        self.state = 155
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                            self.state = 152
                            self.ws()
                            self.state = 157
                            self._errHandler.sync(self)
                            _la = self._input.LA(1)

                        self.state = 158
                        self.pair() 
                    self.state = 163
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,22,self._ctx)

                self.state = 167
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 164
                    self.ws()
                    self.state = 169
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 170
                self.match(ZishParser.MAP_FINISH)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 172
                self.match(ZishParser.MAP_START)
                self.state = 176
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                    self.state = 173
                    self.ws()
                    self.state = 178
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 179
                self.match(ZishParser.MAP_FINISH)
                pass


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

    class PairContext(ParserRuleContext):

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

        def key(self):
            return self.getTypedRuleContext(ZishParser.KeyContext,0)


        def COLON(self):
            return self.getToken(ZishParser.COLON, 0)

        def element(self):
            return self.getTypedRuleContext(ZishParser.ElementContext,0)


        def ws(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(ZishParser.WsContext)
            else:
                return self.getTypedRuleContext(ZishParser.WsContext,i)


        def getRuleIndex(self):
            return ZishParser.RULE_pair

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

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




    def pair(self):

        localctx = ZishParser.PairContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_pair)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 182
            self.key()
            self.state = 186
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                self.state = 183
                self.ws()
                self.state = 188
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 189
            self.match(ZishParser.COLON)
            self.state = 193
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 0):
                self.state = 190
                self.ws()
                self.state = 195
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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

    class KeyContext(ParserRuleContext):

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

        def BOOL(self):
            return self.getToken(ZishParser.BOOL, 0)

        def NULL(self):
            return self.getToken(ZishParser.NULL, 0)

        def TIMESTAMP(self):
            return self.getToken(ZishParser.TIMESTAMP, 0)

        def INTEGER(self):
            return self.getToken(ZishParser.INTEGER, 0)

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

        def DECIMAL(self):
            return self.getToken(ZishParser.DECIMAL, 0)

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

        def BLOB(self):
            return self.getToken(ZishParser.BLOB, 0)

        def list_type(self):
            return self.getTypedRuleContext(ZishParser.List_typeContext,0)


        def set_type(self):
            return self.getTypedRuleContext(ZishParser.Set_typeContext,0)


        def getRuleIndex(self):
            return ZishParser.RULE_key

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

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




    def key(self):

        localctx = ZishParser.KeyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_key)
        try:
            self.state = 208
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [ZishParser.BOOL]:
                self.enterOuterAlt(localctx, 1)
                self.state = 198
                self.match(ZishParser.BOOL)
                pass
            elif token in [ZishParser.NULL]:
                self.enterOuterAlt(localctx, 2)
                self.state = 199
                self.match(ZishParser.NULL)
                pass
            elif token in [ZishParser.TIMESTAMP]:
                self.enterOuterAlt(localctx, 3)
                self.state = 200
                self.match(ZishParser.TIMESTAMP)
                pass
            elif token in [ZishParser.INTEGER]:
                self.enterOuterAlt(localctx, 4)
                self.state = 201
                self.match(ZishParser.INTEGER)
                pass
            elif token in [ZishParser.FLOAT]:
                self.enterOuterAlt(localctx, 5)
                self.state = 202
                self.match(ZishParser.FLOAT)
                pass
            elif token in [ZishParser.DECIMAL]:
                self.enterOuterAlt(localctx, 6)
                self.state = 203
                self.match(ZishParser.DECIMAL)
                pass
            elif token in [ZishParser.STRING]:
                self.enterOuterAlt(localctx, 7)
                self.state = 204
                self.match(ZishParser.STRING)
                pass
            elif token in [ZishParser.BLOB]:
                self.enterOuterAlt(localctx, 8)
                self.state = 205
                self.match(ZishParser.BLOB)
                pass
            elif token in [ZishParser.LIST_START]:
                self.enterOuterAlt(localctx, 9)
                self.state = 206
                self.list_type()
                pass
            elif token in [ZishParser.SET_START]:
                self.enterOuterAlt(localctx, 10)
                self.state = 207
                self.set_type()
                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 WsContext(ParserRuleContext):

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

        def WHITESPACE(self):
            return self.getToken(ZishParser.WHITESPACE, 0)

        def INLINE_COMMENT(self):
            return self.getToken(ZishParser.INLINE_COMMENT, 0)

        def BLOCK_COMMENT(self):
            return self.getToken(ZishParser.BLOCK_COMMENT, 0)

        def getRuleIndex(self):
            return ZishParser.RULE_ws

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

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




    def ws(self):

        localctx = ZishParser.WsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_ws)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 210
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ZishParser.WHITESPACE) | (1 << ZishParser.INLINE_COMMENT) | (1 << ZishParser.BLOCK_COMMENT))) != 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





