# Generated from gsl_protocol/grammar/HedgehogProtocol.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\33")
        buf.write("\u00c2\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\3\2\7\2$\n\2\f\2\16")
        buf.write("\2\'\13\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\5\3\61\n\3\3")
        buf.write("\3\3\3\7\3\65\n\3\f\3\16\38\13\3\3\3\7\3;\n\3\f\3\16\3")
        buf.write(">\13\3\3\3\3\3\3\4\5\4C\n\4\3\4\5\4F\n\4\3\4\3\4\3\4\3")
        buf.write("\4\3\4\3\4\3\5\3\5\3\5\3\5\7\5R\n\5\f\5\16\5U\13\5\3\5")
        buf.write("\3\5\3\6\3\6\3\6\3\6\3\6\3\6\5\6_\n\6\3\6\3\6\3\7\3\7")
        buf.write("\3\7\7\7f\n\7\f\7\16\7i\13\7\3\7\3\7\5\7m\n\7\3\7\3\7")
        buf.write("\3\7\3\7\3\7\7\7t\n\7\f\7\16\7w\13\7\3\7\3\7\5\7{\n\7")
        buf.write("\3\7\3\7\3\7\3\7\3\7\3\7\7\7\u0083\n\7\f\7\16\7\u0086")
        buf.write("\13\7\3\7\3\7\5\7\u008a\n\7\3\7\3\7\3\7\3\7\7\7\u0090")
        buf.write("\n\7\f\7\16\7\u0093\13\7\3\7\3\7\3\7\5\7\u0098\n\7\3\b")
        buf.write("\3\b\3\t\3\t\3\t\3\n\3\n\3\n\7\n\u00a2\n\n\f\n\16\n\u00a5")
        buf.write("\13\n\3\13\3\13\3\13\5\13\u00aa\n\13\3\13\3\13\3\13\3")
        buf.write("\13\3\f\3\f\3\f\7\f\u00b3\n\f\f\f\16\f\u00b6\13\f\3\r")
        buf.write("\3\r\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\21\2\2")
        buf.write("\22\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \2\3\3\2\17")
        buf.write("\21\2\u00c7\2%\3\2\2\2\4*\3\2\2\2\6B\3\2\2\2\bM\3\2\2")
        buf.write("\2\nX\3\2\2\2\f\u0097\3\2\2\2\16\u0099\3\2\2\2\20\u009b")
        buf.write("\3\2\2\2\22\u009e\3\2\2\2\24\u00a9\3\2\2\2\26\u00af\3")
        buf.write("\2\2\2\30\u00b7\3\2\2\2\32\u00b9\3\2\2\2\34\u00bb\3\2")
        buf.write("\2\2\36\u00bd\3\2\2\2 \u00bf\3\2\2\2\"$\5\4\3\2#\"\3\2")
        buf.write("\2\2$\'\3\2\2\2%#\3\2\2\2%&\3\2\2\2&(\3\2\2\2\'%\3\2\2")
        buf.write("\2()\7\2\2\3)\3\3\2\2\2*+\5\24\13\2+,\5\30\r\2,-\7\r\2")
        buf.write("\2-.\5\32\16\2.\60\7\26\2\2/\61\5\34\17\2\60/\3\2\2\2")
        buf.write("\60\61\3\2\2\2\61\66\3\2\2\2\62\65\5\6\4\2\63\65\5\b\5")
        buf.write("\2\64\62\3\2\2\2\64\63\3\2\2\2\658\3\2\2\2\66\64\3\2\2")
        buf.write("\2\66\67\3\2\2\2\67<\3\2\2\28\66\3\2\2\29;\5\n\6\2:9\3")
        buf.write("\2\2\2;>\3\2\2\2<:\3\2\2\2<=\3\2\2\2=?\3\2\2\2><\3\2\2")
        buf.write("\2?@\7\27\2\2@\5\3\2\2\2AC\7\3\2\2BA\3\2\2\2BC\3\2\2\2")
        buf.write("CE\3\2\2\2DF\7\4\2\2ED\3\2\2\2EF\3\2\2\2FG\3\2\2\2GH\5")
        buf.write("\30\r\2HI\5\30\r\2IJ\7\r\2\2JK\5\32\16\2KL\7\13\2\2L\7")
        buf.write("\3\2\2\2MN\7\5\2\2NO\5\30\r\2OS\7\26\2\2PR\5\6\4\2QP\3")
        buf.write("\2\2\2RU\3\2\2\2SQ\3\2\2\2ST\3\2\2\2TV\3\2\2\2US\3\2\2")
        buf.write("\2VW\7\27\2\2W\t\3\2\2\2XY\5 \21\2YZ\5\24\13\2Z[\7\22")
        buf.write("\2\2[\\\5\f\7\2\\^\7\23\2\2]_\5\34\17\2^]\3\2\2\2^_\3")
        buf.write("\2\2\2_`\3\2\2\2`a\7\13\2\2a\13\3\2\2\2bg\5\16\b\2cd\7")
        buf.write("\t\2\2df\5\16\b\2ec\3\2\2\2fi\3\2\2\2ge\3\2\2\2gh\3\2")
        buf.write("\2\2hl\3\2\2\2ig\3\2\2\2jk\7\t\2\2km\5\20\t\2lj\3\2\2")
        buf.write("\2lm\3\2\2\2mz\3\2\2\2no\7\t\2\2op\7\24\2\2pu\5\22\n\2")
        buf.write("qr\7\t\2\2rt\5\22\n\2sq\3\2\2\2tw\3\2\2\2us\3\2\2\2uv")
        buf.write("\3\2\2\2vx\3\2\2\2wu\3\2\2\2xy\7\25\2\2y{\3\2\2\2zn\3")
        buf.write("\2\2\2z{\3\2\2\2{\u0098\3\2\2\2|\u0089\5\20\t\2}~\7\t")
        buf.write("\2\2~\177\7\24\2\2\177\u0084\5\22\n\2\u0080\u0081\7\t")
        buf.write("\2\2\u0081\u0083\5\22\n\2\u0082\u0080\3\2\2\2\u0083\u0086")
        buf.write("\3\2\2\2\u0084\u0082\3\2\2\2\u0084\u0085\3\2\2\2\u0085")
        buf.write("\u0087\3\2\2\2\u0086\u0084\3\2\2\2\u0087\u0088\7\25\2")
        buf.write("\2\u0088\u008a\3\2\2\2\u0089}\3\2\2\2\u0089\u008a\3\2")
        buf.write("\2\2\u008a\u0098\3\2\2\2\u008b\u008c\7\24\2\2\u008c\u0091")
        buf.write("\5\22\n\2\u008d\u008e\7\t\2\2\u008e\u0090\5\22\n\2\u008f")
        buf.write("\u008d\3\2\2\2\u0090\u0093\3\2\2\2\u0091\u008f\3\2\2\2")
        buf.write("\u0091\u0092\3\2\2\2\u0092\u0094\3\2\2\2\u0093\u0091\3")
        buf.write("\2\2\2\u0094\u0095\7\25\2\2\u0095\u0098\3\2\2\2\u0096")
        buf.write("\u0098\3\2\2\2\u0097b\3\2\2\2\u0097|\3\2\2\2\u0097\u008b")
        buf.write("\3\2\2\2\u0097\u0096\3\2\2\2\u0098\r\3\2\2\2\u0099\u009a")
        buf.write("\5\30\r\2\u009a\17\3\2\2\2\u009b\u009c\7\16\2\2\u009c")
        buf.write("\u009d\5\30\r\2\u009d\21\3\2\2\2\u009e\u00a3\5\30\r\2")
        buf.write("\u009f\u00a0\7\f\2\2\u00a0\u00a2\5\30\r\2\u00a1\u009f")
        buf.write("\3\2\2\2\u00a2\u00a5\3\2\2\2\u00a3\u00a1\3\2\2\2\u00a3")
        buf.write("\u00a4\3\2\2\2\u00a4\23\3\2\2\2\u00a5\u00a3\3\2\2\2\u00a6")
        buf.write("\u00a7\5\26\f\2\u00a7\u00a8\7\b\2\2\u00a8\u00aa\3\2\2")
        buf.write("\2\u00a9\u00a6\3\2\2\2\u00a9\u00aa\3\2\2\2\u00aa\u00ab")
        buf.write("\3\2\2\2\u00ab\u00ac\5\30\r\2\u00ac\u00ad\7\b\2\2\u00ad")
        buf.write("\u00ae\5\30\r\2\u00ae\25\3\2\2\2\u00af\u00b4\5\30\r\2")
        buf.write("\u00b0\u00b1\7\b\2\2\u00b1\u00b3\5\30\r\2\u00b2\u00b0")
        buf.write("\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4\u00b2\3\2\2\2\u00b4")
        buf.write("\u00b5\3\2\2\2\u00b5\27\3\2\2\2\u00b6\u00b4\3\2\2\2\u00b7")
        buf.write("\u00b8\7\30\2\2\u00b8\31\3\2\2\2\u00b9\u00ba\7\31\2\2")
        buf.write("\u00ba\33\3\2\2\2\u00bb\u00bc\7\6\2\2\u00bc\35\3\2\2\2")
        buf.write("\u00bd\u00be\7\7\2\2\u00be\37\3\2\2\2\u00bf\u00c0\t\2")
        buf.write("\2\2\u00c0!\3\2\2\2\26%\60\64\66<BES^gluz\u0084\u0089")
        buf.write("\u0091\u0097\u00a3\u00a9\u00b4")
        return buf.getvalue()


class HedgehogProtocolParser ( Parser ):

    grammarFileName = "HedgehogProtocol.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'nested'", "'repeated'", "'oneof'", "<INVALID>", 
                     "<INVALID>", "'.'", "','", "':'", "';'", "'/'", "'='", 
                     "'*'", "'=>'", "'<='", "'<-'", "'('", "')'", "'['", 
                     "']'", "'{'", "'}'" ]

    symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "DOCSTRING", "STRING", "DOT", "COMMA", "COLON", "SEMI", 
                      "SLASH", "EQUALS", "STAR", "REQ", "REP", "UPD", "LPAREN", 
                      "RPAREN", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", 
                      "IDENTIFIER", "NUMBER", "COMMENT", "WS" ]

    RULE_model = 0
    RULE_message = 1
    RULE_field = 2
    RULE_oneof = 3
    RULE_messageClass = 4
    RULE_paramList = 5
    RULE_mandatoryParam = 6
    RULE_repeatedParam = 7
    RULE_optionalParam = 8
    RULE_qualifiedName = 9
    RULE_qualifiedIdentifier = 10
    RULE_identifier = 11
    RULE_number = 12
    RULE_docstring = 13
    RULE_string = 14
    RULE_direction = 15

    ruleNames =  [ "model", "message", "field", "oneof", "messageClass", 
                   "paramList", "mandatoryParam", "repeatedParam", "optionalParam", 
                   "qualifiedName", "qualifiedIdentifier", "identifier", 
                   "number", "docstring", "string", "direction" ]

    EOF = Token.EOF
    T__0=1
    T__1=2
    T__2=3
    DOCSTRING=4
    STRING=5
    DOT=6
    COMMA=7
    COLON=8
    SEMI=9
    SLASH=10
    EQUALS=11
    STAR=12
    REQ=13
    REP=14
    UPD=15
    LPAREN=16
    RPAREN=17
    LBRACKET=18
    RBRACKET=19
    LBRACE=20
    RBRACE=21
    IDENTIFIER=22
    NUMBER=23
    COMMENT=24
    WS=25

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

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

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

        def message(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.MessageContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.MessageContext,i)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_model

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




    def model(self):

        localctx = HedgehogProtocolParser.ModelContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_model)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 35
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==HedgehogProtocolParser.IDENTIFIER:
                self.state = 32
                self.message()
                self.state = 37
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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

    class MessageContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.discriminator = None # IdentifierContext
            self.label = None # NumberContext

        def qualifiedName(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.QualifiedNameContext,0)


        def EQUALS(self):
            return self.getToken(HedgehogProtocolParser.EQUALS, 0)

        def LBRACE(self):
            return self.getToken(HedgehogProtocolParser.LBRACE, 0)

        def RBRACE(self):
            return self.getToken(HedgehogProtocolParser.RBRACE, 0)

        def identifier(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,0)


        def number(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.NumberContext,0)


        def docstring(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.DocstringContext,0)


        def field(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.FieldContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.FieldContext,i)


        def oneof(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.OneofContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.OneofContext,i)


        def messageClass(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.MessageClassContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.MessageClassContext,i)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_message

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




    def message(self):

        localctx = HedgehogProtocolParser.MessageContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_message)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 40
            self.qualifiedName()
            self.state = 41
            localctx.discriminator = self.identifier()
            self.state = 42
            self.match(HedgehogProtocolParser.EQUALS)
            self.state = 43
            localctx.label = self.number()
            self.state = 44
            self.match(HedgehogProtocolParser.LBRACE)
            self.state = 46
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==HedgehogProtocolParser.DOCSTRING:
                self.state = 45
                self.docstring()


            self.state = 52
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << HedgehogProtocolParser.T__0) | (1 << HedgehogProtocolParser.T__1) | (1 << HedgehogProtocolParser.T__2) | (1 << HedgehogProtocolParser.IDENTIFIER))) != 0):
                self.state = 50
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [HedgehogProtocolParser.T__0, HedgehogProtocolParser.T__1, HedgehogProtocolParser.IDENTIFIER]:
                    self.state = 48
                    self.field()
                    pass
                elif token in [HedgehogProtocolParser.T__2]:
                    self.state = 49
                    self.oneof()
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 58
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << HedgehogProtocolParser.REQ) | (1 << HedgehogProtocolParser.REP) | (1 << HedgehogProtocolParser.UPD))) != 0):
                self.state = 55
                self.messageClass()
                self.state = 60
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 61
            self.match(HedgehogProtocolParser.RBRACE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FieldContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.nested = None # Token
            self.rep = None # Token
            self.fieldType = None # IdentifierContext
            self.name = None # IdentifierContext
            self.label = None # NumberContext

        def EQUALS(self):
            return self.getToken(HedgehogProtocolParser.EQUALS, 0)

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

        def identifier(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.IdentifierContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,i)


        def number(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.NumberContext,0)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_field

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




    def field(self):

        localctx = HedgehogProtocolParser.FieldContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_field)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 64
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==HedgehogProtocolParser.T__0:
                self.state = 63
                localctx.nested = self.match(HedgehogProtocolParser.T__0)


            self.state = 67
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==HedgehogProtocolParser.T__1:
                self.state = 66
                localctx.rep = self.match(HedgehogProtocolParser.T__1)


            self.state = 69
            localctx.fieldType = self.identifier()
            self.state = 70
            localctx.name = self.identifier()
            self.state = 71
            self.match(HedgehogProtocolParser.EQUALS)
            self.state = 72
            localctx.label = self.number()
            self.state = 73
            self.match(HedgehogProtocolParser.SEMI)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class OneofContext(ParserRuleContext):

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

        def LBRACE(self):
            return self.getToken(HedgehogProtocolParser.LBRACE, 0)

        def RBRACE(self):
            return self.getToken(HedgehogProtocolParser.RBRACE, 0)

        def identifier(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,0)


        def field(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.FieldContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.FieldContext,i)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_oneof

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




    def oneof(self):

        localctx = HedgehogProtocolParser.OneofContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_oneof)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 75
            self.match(HedgehogProtocolParser.T__2)
            self.state = 76
            localctx.name = self.identifier()
            self.state = 77
            self.match(HedgehogProtocolParser.LBRACE)
            self.state = 81
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << HedgehogProtocolParser.T__0) | (1 << HedgehogProtocolParser.T__1) | (1 << HedgehogProtocolParser.IDENTIFIER))) != 0):
                self.state = 78
                self.field()
                self.state = 83
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 84
            self.match(HedgehogProtocolParser.RBRACE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class MessageClassContext(ParserRuleContext):

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

        def direction(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.DirectionContext,0)


        def qualifiedName(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.QualifiedNameContext,0)


        def LPAREN(self):
            return self.getToken(HedgehogProtocolParser.LPAREN, 0)

        def paramList(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.ParamListContext,0)


        def RPAREN(self):
            return self.getToken(HedgehogProtocolParser.RPAREN, 0)

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

        def docstring(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.DocstringContext,0)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_messageClass

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




    def messageClass(self):

        localctx = HedgehogProtocolParser.MessageClassContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_messageClass)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 86
            self.direction()
            self.state = 87
            self.qualifiedName()
            self.state = 88
            self.match(HedgehogProtocolParser.LPAREN)
            self.state = 89
            self.paramList()
            self.state = 90
            self.match(HedgehogProtocolParser.RPAREN)
            self.state = 92
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==HedgehogProtocolParser.DOCSTRING:
                self.state = 91
                self.docstring()


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

    class ParamListContext(ParserRuleContext):

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

        def mandatoryParam(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.MandatoryParamContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.MandatoryParamContext,i)


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

        def repeatedParam(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.RepeatedParamContext,0)


        def LBRACKET(self):
            return self.getToken(HedgehogProtocolParser.LBRACKET, 0)

        def optionalParam(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.OptionalParamContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.OptionalParamContext,i)


        def RBRACKET(self):
            return self.getToken(HedgehogProtocolParser.RBRACKET, 0)

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_paramList

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




    def paramList(self):

        localctx = HedgehogProtocolParser.ParamListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_paramList)
        self._la = 0 # Token type
        try:
            self.state = 149
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [HedgehogProtocolParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 1)
                self.state = 96
                self.mandatoryParam()
                self.state = 101
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,9,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 97
                        self.match(HedgehogProtocolParser.COMMA)
                        self.state = 98
                        self.mandatoryParam() 
                    self.state = 103
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,9,self._ctx)

                self.state = 106
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,10,self._ctx)
                if la_ == 1:
                    self.state = 104
                    self.match(HedgehogProtocolParser.COMMA)
                    self.state = 105
                    self.repeatedParam()


                self.state = 120
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==HedgehogProtocolParser.COMMA:
                    self.state = 108
                    self.match(HedgehogProtocolParser.COMMA)
                    self.state = 109
                    self.match(HedgehogProtocolParser.LBRACKET)
                    self.state = 110
                    self.optionalParam()
                    self.state = 115
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    while _la==HedgehogProtocolParser.COMMA:
                        self.state = 111
                        self.match(HedgehogProtocolParser.COMMA)
                        self.state = 112
                        self.optionalParam()
                        self.state = 117
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)

                    self.state = 118
                    self.match(HedgehogProtocolParser.RBRACKET)


                pass
            elif token in [HedgehogProtocolParser.STAR]:
                self.enterOuterAlt(localctx, 2)
                self.state = 122
                self.repeatedParam()
                self.state = 135
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==HedgehogProtocolParser.COMMA:
                    self.state = 123
                    self.match(HedgehogProtocolParser.COMMA)
                    self.state = 124
                    self.match(HedgehogProtocolParser.LBRACKET)
                    self.state = 125
                    self.optionalParam()
                    self.state = 130
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    while _la==HedgehogProtocolParser.COMMA:
                        self.state = 126
                        self.match(HedgehogProtocolParser.COMMA)
                        self.state = 127
                        self.optionalParam()
                        self.state = 132
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)

                    self.state = 133
                    self.match(HedgehogProtocolParser.RBRACKET)


                pass
            elif token in [HedgehogProtocolParser.LBRACKET]:
                self.enterOuterAlt(localctx, 3)
                self.state = 137
                self.match(HedgehogProtocolParser.LBRACKET)
                self.state = 138
                self.optionalParam()
                self.state = 143
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==HedgehogProtocolParser.COMMA:
                    self.state = 139
                    self.match(HedgehogProtocolParser.COMMA)
                    self.state = 140
                    self.optionalParam()
                    self.state = 145
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 146
                self.match(HedgehogProtocolParser.RBRACKET)
                pass
            elif token in [HedgehogProtocolParser.RPAREN]:
                self.enterOuterAlt(localctx, 4)

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

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

        def identifier(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,0)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_mandatoryParam

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




    def mandatoryParam(self):

        localctx = HedgehogProtocolParser.MandatoryParamContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_mandatoryParam)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 151
            self.identifier()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class RepeatedParamContext(ParserRuleContext):

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

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

        def identifier(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,0)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_repeatedParam

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




    def repeatedParam(self):

        localctx = HedgehogProtocolParser.RepeatedParamContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_repeatedParam)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 153
            self.match(HedgehogProtocolParser.STAR)
            self.state = 154
            self.identifier()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class OptionalParamContext(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.getTypedRuleContexts(HedgehogProtocolParser.IdentifierContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,i)


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

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_optionalParam

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




    def optionalParam(self):

        localctx = HedgehogProtocolParser.OptionalParamContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_optionalParam)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 156
            self.identifier()
            self.state = 161
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==HedgehogProtocolParser.SLASH:
                self.state = 157
                self.match(HedgehogProtocolParser.SLASH)
                self.state = 158
                self.identifier()
                self.state = 163
                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 QualifiedNameContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.path = None # QualifiedIdentifierContext
            self.fileName = None # IdentifierContext
            self.name = None # IdentifierContext

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

        def identifier(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(HedgehogProtocolParser.IdentifierContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,i)


        def qualifiedIdentifier(self):
            return self.getTypedRuleContext(HedgehogProtocolParser.QualifiedIdentifierContext,0)


        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_qualifiedName

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




    def qualifiedName(self):

        localctx = HedgehogProtocolParser.QualifiedNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_qualifiedName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 167
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
            if la_ == 1:
                self.state = 164
                localctx.path = self.qualifiedIdentifier()
                self.state = 165
                self.match(HedgehogProtocolParser.DOT)


            self.state = 169
            localctx.fileName = self.identifier()
            self.state = 170
            self.match(HedgehogProtocolParser.DOT)
            self.state = 171
            localctx.name = self.identifier()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QualifiedIdentifierContext(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.getTypedRuleContexts(HedgehogProtocolParser.IdentifierContext)
            else:
                return self.getTypedRuleContext(HedgehogProtocolParser.IdentifierContext,i)


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

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_qualifiedIdentifier

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




    def qualifiedIdentifier(self):

        localctx = HedgehogProtocolParser.QualifiedIdentifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_qualifiedIdentifier)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 173
            self.identifier()
            self.state = 178
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,19,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 174
                    self.match(HedgehogProtocolParser.DOT)
                    self.state = 175
                    self.identifier() 
                self.state = 180
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,19,self._ctx)

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

    class IdentifierContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_identifier

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




    def identifier(self):

        localctx = HedgehogProtocolParser.IdentifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_identifier)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 181
            self.match(HedgehogProtocolParser.IDENTIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class NumberContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_number

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




    def number(self):

        localctx = HedgehogProtocolParser.NumberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_number)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 183
            self.match(HedgehogProtocolParser.NUMBER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DocstringContext(ParserRuleContext):

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

        def DOCSTRING(self):
            return self.getToken(HedgehogProtocolParser.DOCSTRING, 0)

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_docstring

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




    def docstring(self):

        localctx = HedgehogProtocolParser.DocstringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_docstring)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 185
            self.match(HedgehogProtocolParser.DOCSTRING)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StringContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_string

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




    def string(self):

        localctx = HedgehogProtocolParser.StringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_string)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 187
            self.match(HedgehogProtocolParser.STRING)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DirectionContext(ParserRuleContext):

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

        def REQ(self):
            return self.getToken(HedgehogProtocolParser.REQ, 0)

        def REP(self):
            return self.getToken(HedgehogProtocolParser.REP, 0)

        def UPD(self):
            return self.getToken(HedgehogProtocolParser.UPD, 0)

        def getRuleIndex(self):
            return HedgehogProtocolParser.RULE_direction

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




    def direction(self):

        localctx = HedgehogProtocolParser.DirectionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_direction)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 189
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << HedgehogProtocolParser.REQ) | (1 << HedgehogProtocolParser.REP) | (1 << HedgehogProtocolParser.UPD))) != 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





