# Generated from Dynabuffers.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%")
        buf.write("\u009c\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\3\2\3\2\3\2\3\2\7\2#\n\2\f\2\16\2&\13")
        buf.write("\2\3\2\3\2\3\3\3\3\3\3\3\3\6\3.\n\3\r\3\16\3/\3\3\3\3")
        buf.write("\3\4\3\4\3\4\5\4\67\n\4\3\4\3\4\6\4;\n\4\r\4\16\4<\3\4")
        buf.write("\3\4\3\5\3\5\3\5\5\5D\n\5\3\5\3\5\6\5H\n\5\r\5\16\5I\3")
        buf.write("\5\3\5\3\6\7\6O\n\6\f\6\16\6R\13\6\3\6\3\6\3\6\3\6\3\6")
        buf.write("\5\6Y\n\6\3\6\5\6\\\n\6\3\6\3\6\5\6`\n\6\3\7\3\7\3\b\3")
        buf.write("\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\5\tn\n\t\3\n\3\n\3")
        buf.write("\n\3\n\3\n\3\n\3\n\7\nw\n\n\f\n\16\nz\13\n\3\n\3\n\3\13")
        buf.write("\3\13\6\13\u0080\n\13\r\13\16\13\u0081\3\13\3\13\3\f\3")
        buf.write("\f\6\f\u0088\n\f\r\f\16\f\u0089\3\f\3\f\3\r\3\r\3\r\3")
        buf.write("\r\3\16\3\16\3\16\3\16\3\16\3\16\5\16\u0098\n\16\3\17")
        buf.write("\3\17\3\17\2\2\20\2\4\6\b\n\f\16\20\22\24\26\30\32\34")
        buf.write("\2\6\4\2\n\21\36\36\3\2\36\37\3\2\27\31\4\2\34\36 \"\2")
        buf.write("\u00a3\2$\3\2\2\2\4)\3\2\2\2\6\63\3\2\2\2\b@\3\2\2\2\n")
        buf.write("P\3\2\2\2\fa\3\2\2\2\16c\3\2\2\2\20m\3\2\2\2\22o\3\2\2")
        buf.write("\2\24}\3\2\2\2\26\u0085\3\2\2\2\30\u008d\3\2\2\2\32\u0091")
        buf.write("\3\2\2\2\34\u0099\3\2\2\2\36#\5\4\3\2\37#\5\6\4\2 #\5")
        buf.write("\b\5\2!#\5\22\n\2\"\36\3\2\2\2\"\37\3\2\2\2\" \3\2\2\2")
        buf.write("\"!\3\2\2\2#&\3\2\2\2$\"\3\2\2\2$%\3\2\2\2%\'\3\2\2\2")
        buf.write("&$\3\2\2\2\'(\7\2\2\3(\3\3\2\2\2)*\7\3\2\2*+\7\36\2\2")
        buf.write("+-\7\4\2\2,.\7\36\2\2-,\3\2\2\2./\3\2\2\2/-\3\2\2\2/\60")
        buf.write("\3\2\2\2\60\61\3\2\2\2\61\62\7\5\2\2\62\5\3\2\2\2\63\64")
        buf.write("\7\6\2\2\64\66\7\36\2\2\65\67\5\24\13\2\66\65\3\2\2\2")
        buf.write("\66\67\3\2\2\2\678\3\2\2\28:\7\4\2\29;\5\n\6\2:9\3\2\2")
        buf.write("\2;<\3\2\2\2<:\3\2\2\2<=\3\2\2\2=>\3\2\2\2>?\7\5\2\2?")
        buf.write("\7\3\2\2\2@A\7\7\2\2AC\7\36\2\2BD\5\26\f\2CB\3\2\2\2C")
        buf.write("D\3\2\2\2DE\3\2\2\2EG\7\4\2\2FH\7\36\2\2GF\3\2\2\2HI\3")
        buf.write("\2\2\2IG\3\2\2\2IJ\3\2\2\2JK\3\2\2\2KL\7\5\2\2L\t\3\2")
        buf.write("\2\2MO\5\32\16\2NM\3\2\2\2OR\3\2\2\2PN\3\2\2\2PQ\3\2\2")
        buf.write("\2QS\3\2\2\2RP\3\2\2\2ST\7\36\2\2TX\7\b\2\2UY\5\f\7\2")
        buf.write("VY\5\16\b\2WY\5\20\t\2XU\3\2\2\2XV\3\2\2\2XW\3\2\2\2Y")
        buf.write("[\3\2\2\2Z\\\5\30\r\2[Z\3\2\2\2[\\\3\2\2\2\\_\3\2\2\2")
        buf.write("]^\7\t\2\2^`\5\34\17\2_]\3\2\2\2_`\3\2\2\2`\13\3\2\2\2")
        buf.write("ab\t\2\2\2b\r\3\2\2\2cd\7\22\2\2de\5\f\7\2ef\7\23\2\2")
        buf.write("f\17\3\2\2\2gh\5\f\7\2hi\7\24\2\2in\3\2\2\2jk\5\16\b\2")
        buf.write("kl\7\24\2\2ln\3\2\2\2mg\3\2\2\2mj\3\2\2\2n\21\3\2\2\2")
        buf.write("op\7\25\2\2pq\t\3\2\2qx\7\4\2\2rw\5\4\3\2sw\5\6\4\2tw")
        buf.write("\5\b\5\2uw\5\22\n\2vr\3\2\2\2vs\3\2\2\2vt\3\2\2\2vu\3")
        buf.write("\2\2\2wz\3\2\2\2xv\3\2\2\2xy\3\2\2\2y{\3\2\2\2zx\3\2\2")
        buf.write("\2{|\7\5\2\2|\23\3\2\2\2}\177\7\26\2\2~\u0080\t\4\2\2")
        buf.write("\177~\3\2\2\2\u0080\u0081\3\2\2\2\u0081\177\3\2\2\2\u0081")
        buf.write("\u0082\3\2\2\2\u0082\u0083\3\2\2\2\u0083\u0084\7\32\2")
        buf.write("\2\u0084\25\3\2\2\2\u0085\u0087\7\26\2\2\u0086\u0088\t")
        buf.write("\4\2\2\u0087\u0086\3\2\2\2\u0088\u0089\3\2\2\2\u0089\u0087")
        buf.write("\3\2\2\2\u0089\u008a\3\2\2\2\u008a\u008b\3\2\2\2\u008b")
        buf.write("\u008c\7\32\2\2\u008c\27\3\2\2\2\u008d\u008e\7\26\2\2")
        buf.write("\u008e\u008f\7\30\2\2\u008f\u0090\7\32\2\2\u0090\31\3")
        buf.write("\2\2\2\u0091\u0092\7\33\2\2\u0092\u0097\7\36\2\2\u0093")
        buf.write("\u0094\7\26\2\2\u0094\u0095\5\34\17\2\u0095\u0096\7\32")
        buf.write("\2\2\u0096\u0098\3\2\2\2\u0097\u0093\3\2\2\2\u0097\u0098")
        buf.write("\3\2\2\2\u0098\33\3\2\2\2\u0099\u009a\t\5\2\2\u009a\35")
        buf.write("\3\2\2\2\23\"$/\66<CIPX[_mvx\u0081\u0089\u0097")
        return buf.getvalue()


class DynabuffersParser ( Parser ):

    grammarFileName = "Dynabuffers.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'enum'", "'{'", "'}'", "'class'", "'union'", 
                     "':'", "'='", "'string'", "'short'", "'boolean'", "'byte'", 
                     "'float'", "'long'", "'int'", "'map'", "'['", "']'", 
                     "'?'", "'namespace'", "'('", "'primary'", "'deprecated'", 
                     "'implicit'", "')'", "'@'", "'[]'", "'[:]'", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "';'" ]

    symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "IDENTIFIER", "IDENTIFIER_LITERAL", "STRING", "NUMBER", 
                      "BOOLEAN", "WHITESPACE", "LINE_COMMENT", "SEMICOLON" ]

    RULE_compilation = 0
    RULE_enumType = 1
    RULE_classType = 2
    RULE_unionType = 3
    RULE_fieldType = 4
    RULE_dataType = 5
    RULE_arrayType = 6
    RULE_optionType = 7
    RULE_namespaceType = 8
    RULE_classOptions = 9
    RULE_unionOptions = 10
    RULE_fieldOptions = 11
    RULE_annotation = 12
    RULE_value = 13

    ruleNames =  [ "compilation", "enumType", "classType", "unionType", 
                   "fieldType", "dataType", "arrayType", "optionType", "namespaceType", 
                   "classOptions", "unionOptions", "fieldOptions", "annotation", 
                   "value" ]

    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
    T__22=23
    T__23=24
    T__24=25
    T__25=26
    T__26=27
    IDENTIFIER=28
    IDENTIFIER_LITERAL=29
    STRING=30
    NUMBER=31
    BOOLEAN=32
    WHITESPACE=33
    LINE_COMMENT=34
    SEMICOLON=35

    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 CompilationContext(ParserRuleContext):

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

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

        def enumType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.EnumTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.EnumTypeContext,i)


        def classType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.ClassTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.ClassTypeContext,i)


        def unionType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.UnionTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.UnionTypeContext,i)


        def namespaceType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.NamespaceTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.NamespaceTypeContext,i)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_compilation

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

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

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




    def compilation(self):

        localctx = DynabuffersParser.CompilationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_compilation)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 34
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__0) | (1 << DynabuffersParser.T__3) | (1 << DynabuffersParser.T__4) | (1 << DynabuffersParser.T__18))) != 0):
                self.state = 32
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [DynabuffersParser.T__0]:
                    self.state = 28
                    self.enumType()
                    pass
                elif token in [DynabuffersParser.T__3]:
                    self.state = 29
                    self.classType()
                    pass
                elif token in [DynabuffersParser.T__4]:
                    self.state = 30
                    self.unionType()
                    pass
                elif token in [DynabuffersParser.T__18]:
                    self.state = 31
                    self.namespaceType()
                    pass
                else:
                    raise NoViableAltException(self)

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

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

    class EnumTypeContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return DynabuffersParser.RULE_enumType

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

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

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




    def enumType(self):

        localctx = DynabuffersParser.EnumTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_enumType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 39
            self.match(DynabuffersParser.T__0)
            self.state = 40
            self.match(DynabuffersParser.IDENTIFIER)
            self.state = 41
            self.match(DynabuffersParser.T__1)
            self.state = 43 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 42
                self.match(DynabuffersParser.IDENTIFIER)
                self.state = 45 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==DynabuffersParser.IDENTIFIER):
                    break

            self.state = 47
            self.match(DynabuffersParser.T__2)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ClassTypeContext(ParserRuleContext):

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

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

        def classOptions(self):
            return self.getTypedRuleContext(DynabuffersParser.ClassOptionsContext,0)


        def fieldType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.FieldTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.FieldTypeContext,i)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_classType

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

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

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




    def classType(self):

        localctx = DynabuffersParser.ClassTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_classType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 49
            self.match(DynabuffersParser.T__3)
            self.state = 50
            self.match(DynabuffersParser.IDENTIFIER)
            self.state = 52
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DynabuffersParser.T__19:
                self.state = 51
                self.classOptions()


            self.state = 54
            self.match(DynabuffersParser.T__1)
            self.state = 56 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 55
                self.fieldType()
                self.state = 58 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==DynabuffersParser.T__24 or _la==DynabuffersParser.IDENTIFIER):
                    break

            self.state = 60
            self.match(DynabuffersParser.T__2)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class UnionTypeContext(ParserRuleContext):

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

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

        def unionOptions(self):
            return self.getTypedRuleContext(DynabuffersParser.UnionOptionsContext,0)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_unionType

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

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

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




    def unionType(self):

        localctx = DynabuffersParser.UnionTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_unionType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 62
            self.match(DynabuffersParser.T__4)
            self.state = 63
            self.match(DynabuffersParser.IDENTIFIER)
            self.state = 65
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DynabuffersParser.T__19:
                self.state = 64
                self.unionOptions()


            self.state = 67
            self.match(DynabuffersParser.T__1)
            self.state = 69 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 68
                self.match(DynabuffersParser.IDENTIFIER)
                self.state = 71 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==DynabuffersParser.IDENTIFIER):
                    break

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

    class FieldTypeContext(ParserRuleContext):

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

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

        def dataType(self):
            return self.getTypedRuleContext(DynabuffersParser.DataTypeContext,0)


        def arrayType(self):
            return self.getTypedRuleContext(DynabuffersParser.ArrayTypeContext,0)


        def optionType(self):
            return self.getTypedRuleContext(DynabuffersParser.OptionTypeContext,0)


        def annotation(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.AnnotationContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.AnnotationContext,i)


        def fieldOptions(self):
            return self.getTypedRuleContext(DynabuffersParser.FieldOptionsContext,0)


        def value(self):
            return self.getTypedRuleContext(DynabuffersParser.ValueContext,0)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_fieldType

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

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

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




    def fieldType(self):

        localctx = DynabuffersParser.FieldTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_fieldType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 78
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==DynabuffersParser.T__24:
                self.state = 75
                self.annotation()
                self.state = 80
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 81
            self.match(DynabuffersParser.IDENTIFIER)
            self.state = 82
            self.match(DynabuffersParser.T__5)
            self.state = 86
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,8,self._ctx)
            if la_ == 1:
                self.state = 83
                self.dataType()
                pass

            elif la_ == 2:
                self.state = 84
                self.arrayType()
                pass

            elif la_ == 3:
                self.state = 85
                self.optionType()
                pass


            self.state = 89
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DynabuffersParser.T__19:
                self.state = 88
                self.fieldOptions()


            self.state = 93
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DynabuffersParser.T__6:
                self.state = 91
                self.match(DynabuffersParser.T__6)
                self.state = 92
                self.value()


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

    class DataTypeContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return DynabuffersParser.RULE_dataType

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

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

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




    def dataType(self):

        localctx = DynabuffersParser.DataTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_dataType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 95
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__7) | (1 << DynabuffersParser.T__8) | (1 << DynabuffersParser.T__9) | (1 << DynabuffersParser.T__10) | (1 << DynabuffersParser.T__11) | (1 << DynabuffersParser.T__12) | (1 << DynabuffersParser.T__13) | (1 << DynabuffersParser.T__14) | (1 << DynabuffersParser.IDENTIFIER))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ArrayTypeContext(ParserRuleContext):

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

        def dataType(self):
            return self.getTypedRuleContext(DynabuffersParser.DataTypeContext,0)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_arrayType

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

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

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




    def arrayType(self):

        localctx = DynabuffersParser.ArrayTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_arrayType)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 97
            self.match(DynabuffersParser.T__15)
            self.state = 98
            self.dataType()
            self.state = 99
            self.match(DynabuffersParser.T__16)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class OptionTypeContext(ParserRuleContext):

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

        def dataType(self):
            return self.getTypedRuleContext(DynabuffersParser.DataTypeContext,0)


        def arrayType(self):
            return self.getTypedRuleContext(DynabuffersParser.ArrayTypeContext,0)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_optionType

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

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

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




    def optionType(self):

        localctx = DynabuffersParser.OptionTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_optionType)
        try:
            self.state = 107
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [DynabuffersParser.T__7, DynabuffersParser.T__8, DynabuffersParser.T__9, DynabuffersParser.T__10, DynabuffersParser.T__11, DynabuffersParser.T__12, DynabuffersParser.T__13, DynabuffersParser.T__14, DynabuffersParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 1)
                self.state = 101
                self.dataType()
                self.state = 102
                self.match(DynabuffersParser.T__17)
                pass
            elif token in [DynabuffersParser.T__15]:
                self.enterOuterAlt(localctx, 2)
                self.state = 104
                self.arrayType()
                self.state = 105
                self.match(DynabuffersParser.T__17)
                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 NamespaceTypeContext(ParserRuleContext):

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

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

        def IDENTIFIER_LITERAL(self):
            return self.getToken(DynabuffersParser.IDENTIFIER_LITERAL, 0)

        def enumType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.EnumTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.EnumTypeContext,i)


        def classType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.ClassTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.ClassTypeContext,i)


        def unionType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.UnionTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.UnionTypeContext,i)


        def namespaceType(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DynabuffersParser.NamespaceTypeContext)
            else:
                return self.getTypedRuleContext(DynabuffersParser.NamespaceTypeContext,i)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_namespaceType

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

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

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




    def namespaceType(self):

        localctx = DynabuffersParser.NamespaceTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_namespaceType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 109
            self.match(DynabuffersParser.T__18)
            self.state = 110
            _la = self._input.LA(1)
            if not(_la==DynabuffersParser.IDENTIFIER or _la==DynabuffersParser.IDENTIFIER_LITERAL):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 111
            self.match(DynabuffersParser.T__1)
            self.state = 118
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__0) | (1 << DynabuffersParser.T__3) | (1 << DynabuffersParser.T__4) | (1 << DynabuffersParser.T__18))) != 0):
                self.state = 116
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [DynabuffersParser.T__0]:
                    self.state = 112
                    self.enumType()
                    pass
                elif token in [DynabuffersParser.T__3]:
                    self.state = 113
                    self.classType()
                    pass
                elif token in [DynabuffersParser.T__4]:
                    self.state = 114
                    self.unionType()
                    pass
                elif token in [DynabuffersParser.T__18]:
                    self.state = 115
                    self.namespaceType()
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 121
            self.match(DynabuffersParser.T__2)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ClassOptionsContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return DynabuffersParser.RULE_classOptions

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

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

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




    def classOptions(self):

        localctx = DynabuffersParser.ClassOptionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_classOptions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 123
            self.match(DynabuffersParser.T__19)
            self.state = 125 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 124
                _la = self._input.LA(1)
                if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__20) | (1 << DynabuffersParser.T__21) | (1 << DynabuffersParser.T__22))) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 127 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__20) | (1 << DynabuffersParser.T__21) | (1 << DynabuffersParser.T__22))) != 0)):
                    break

            self.state = 129
            self.match(DynabuffersParser.T__23)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class UnionOptionsContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return DynabuffersParser.RULE_unionOptions

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

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

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




    def unionOptions(self):

        localctx = DynabuffersParser.UnionOptionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_unionOptions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 131
            self.match(DynabuffersParser.T__19)
            self.state = 133 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 132
                _la = self._input.LA(1)
                if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__20) | (1 << DynabuffersParser.T__21) | (1 << DynabuffersParser.T__22))) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 135 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__20) | (1 << DynabuffersParser.T__21) | (1 << DynabuffersParser.T__22))) != 0)):
                    break

            self.state = 137
            self.match(DynabuffersParser.T__23)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FieldOptionsContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return DynabuffersParser.RULE_fieldOptions

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

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

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




    def fieldOptions(self):

        localctx = DynabuffersParser.FieldOptionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_fieldOptions)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 139
            self.match(DynabuffersParser.T__19)
            self.state = 140
            self.match(DynabuffersParser.T__21)
            self.state = 141
            self.match(DynabuffersParser.T__23)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class AnnotationContext(ParserRuleContext):

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

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

        def value(self):
            return self.getTypedRuleContext(DynabuffersParser.ValueContext,0)


        def getRuleIndex(self):
            return DynabuffersParser.RULE_annotation

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

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

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




    def annotation(self):

        localctx = DynabuffersParser.AnnotationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_annotation)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 143
            self.match(DynabuffersParser.T__24)
            self.state = 144
            self.match(DynabuffersParser.IDENTIFIER)
            self.state = 149
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DynabuffersParser.T__19:
                self.state = 145
                self.match(DynabuffersParser.T__19)
                self.state = 146
                self.value()
                self.state = 147
                self.match(DynabuffersParser.T__23)


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

    class ValueContext(ParserRuleContext):

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

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

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

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

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

        def getRuleIndex(self):
            return DynabuffersParser.RULE_value

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

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

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




    def value(self):

        localctx = DynabuffersParser.ValueContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_value)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 151
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DynabuffersParser.T__25) | (1 << DynabuffersParser.T__26) | (1 << DynabuffersParser.IDENTIFIER) | (1 << DynabuffersParser.STRING) | (1 << DynabuffersParser.NUMBER) | (1 << DynabuffersParser.BOOLEAN))) != 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





