icp_agents/ic/parser/DIDParser.py
2024-09-15 15:38:35 +03:00

1587 lines
52 KiB
Python

# Generated from DIDParser.g4 by ANTLR 4.9.3
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
from typing import TextIO
else:
from typing import TextIO
def serializedATN():
with StringIO() as buf:
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\32")
buf.write("\u00b4\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\3\2\7\2\"\n\2\f\2\16\2%\13\2")
buf.write("\3\2\5\2(\n\2\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\5\4\62\n")
buf.write("\4\3\4\3\4\3\4\3\4\5\48\n\4\3\4\3\4\5\4<\n\4\3\5\3\5\3")
buf.write("\5\3\5\7\5B\n\5\f\5\16\5E\13\5\3\5\3\5\3\6\3\6\3\6\5\6")
buf.write("L\n\6\3\7\3\7\5\7P\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b")
buf.write("\3\b\3\b\3\b\3\b\7\b^\n\b\f\b\16\ba\13\b\3\b\5\bd\n\b")
buf.write("\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\7\bp\n\b\f\b")
buf.write("\16\bs\13\b\3\b\5\bv\n\b\3\b\3\b\5\bz\n\b\3\t\3\t\3\t")
buf.write("\3\t\5\t\u0080\n\t\3\n\3\n\3\n\3\n\5\n\u0086\n\n\3\13")
buf.write("\3\13\3\13\3\13\5\13\u008c\n\13\3\f\3\f\3\f\3\f\5\f\u0092")
buf.write("\n\f\3\r\3\r\3\r\3\r\3\r\3\r\5\r\u009a\n\r\3\16\3\16\3")
buf.write("\16\7\16\u009f\n\16\f\16\16\16\u00a2\13\16\3\16\5\16\u00a5")
buf.write("\n\16\3\16\3\16\3\16\5\16\u00aa\n\16\3\17\3\17\5\17\u00ae")
buf.write("\n\17\3\20\3\20\3\20\3\20\3\20\2\2\21\2\4\6\b\n\f\16\20")
buf.write("\22\24\26\30\32\34\36\2\2\2\u00bf\2#\3\2\2\2\4)\3\2\2")
buf.write("\2\6/\3\2\2\2\b=\3\2\2\2\nK\3\2\2\2\fO\3\2\2\2\16y\3\2")
buf.write("\2\2\20\177\3\2\2\2\22\u0085\3\2\2\2\24\u008b\3\2\2\2")
buf.write("\26\u008d\3\2\2\2\30\u0099\3\2\2\2\32\u00a9\3\2\2\2\34")
buf.write("\u00ad\3\2\2\2\36\u00af\3\2\2\2 \"\5\4\3\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&(\5")
buf.write("\6\4\2\'&\3\2\2\2\'(\3\2\2\2(\3\3\2\2\2)*\7\6\2\2*+\7")
buf.write("\21\2\2+,\7\31\2\2,-\5\n\6\2-.\7\30\2\2.\5\3\2\2\2/\61")
buf.write("\7\17\2\2\60\62\7\21\2\2\61\60\3\2\2\2\61\62\3\2\2\2\62")
buf.write("\63\3\2\2\2\63\67\7\27\2\2\64\65\5\30\r\2\65\66\7\26\2")
buf.write("\2\668\3\2\2\2\67\64\3\2\2\2\678\3\2\2\28;\3\2\2\29<\5")
buf.write("\b\5\2:<\7\21\2\2;9\3\2\2\2;:\3\2\2\2<\7\3\2\2\2=C\7\24")
buf.write("\2\2>?\5\36\20\2?@\7\30\2\2@B\3\2\2\2A>\3\2\2\2BE\3\2")
buf.write("\2\2CA\3\2\2\2CD\3\2\2\2DF\3\2\2\2EC\3\2\2\2FG\7\25\2")
buf.write("\2G\t\3\2\2\2HL\7\21\2\2IL\7\t\2\2JL\5\f\7\2KH\3\2\2\2")
buf.write("KI\3\2\2\2KJ\3\2\2\2L\13\3\2\2\2MP\5\16\b\2NP\5\24\13")
buf.write("\2OM\3\2\2\2ON\3\2\2\2P\r\3\2\2\2QR\7\13\2\2Rz\5\n\6\2")
buf.write("ST\7\f\2\2Tz\5\n\6\2UV\7\r\2\2VW\7\24\2\2Wz\7\25\2\2X")
buf.write("Y\7\r\2\2YZ\7\24\2\2Z_\5\20\t\2[\\\7\30\2\2\\^\5\20\t")
buf.write("\2][\3\2\2\2^a\3\2\2\2_]\3\2\2\2_`\3\2\2\2`c\3\2\2\2a")
buf.write("_\3\2\2\2bd\7\30\2\2cb\3\2\2\2cd\3\2\2\2de\3\2\2\2ef\7")
buf.write("\25\2\2fz\3\2\2\2gh\7\16\2\2hi\7\24\2\2iz\7\25\2\2jk\7")
buf.write("\16\2\2kl\7\24\2\2lq\5\22\n\2mn\7\30\2\2np\5\22\n\2om")
buf.write("\3\2\2\2ps\3\2\2\2qo\3\2\2\2qr\3\2\2\2ru\3\2\2\2sq\3\2")
buf.write("\2\2tv\7\30\2\2ut\3\2\2\2uv\3\2\2\2vw\3\2\2\2wx\7\25\2")
buf.write("\2xz\3\2\2\2yQ\3\2\2\2yS\3\2\2\2yU\3\2\2\2yX\3\2\2\2y")
buf.write("g\3\2\2\2yj\3\2\2\2z\17\3\2\2\2{|\7\21\2\2|}\7\27\2\2")
buf.write("}\u0080\5\n\6\2~\u0080\5\n\6\2\177{\3\2\2\2\177~\3\2\2")
buf.write("\2\u0080\21\3\2\2\2\u0081\u0082\7\21\2\2\u0082\u0083\7")
buf.write("\27\2\2\u0083\u0086\5\n\6\2\u0084\u0086\7\21\2\2\u0085")
buf.write("\u0081\3\2\2\2\u0085\u0084\3\2\2\2\u0086\23\3\2\2\2\u0087")
buf.write("\u0088\7\20\2\2\u0088\u008c\5\26\f\2\u0089\u008a\7\17")
buf.write("\2\2\u008a\u008c\5\b\5\2\u008b\u0087\3\2\2\2\u008b\u0089")
buf.write("\3\2\2\2\u008c\25\3\2\2\2\u008d\u008e\5\30\r\2\u008e\u008f")
buf.write("\7\26\2\2\u008f\u0091\5\30\r\2\u0090\u0092\5\34\17\2\u0091")
buf.write("\u0090\3\2\2\2\u0091\u0092\3\2\2\2\u0092\27\3\2\2\2\u0093")
buf.write("\u0094\7\22\2\2\u0094\u009a\7\23\2\2\u0095\u0096\7\22")
buf.write("\2\2\u0096\u0097\5\32\16\2\u0097\u0098\7\23\2\2\u0098")
buf.write("\u009a\3\2\2\2\u0099\u0093\3\2\2\2\u0099\u0095\3\2\2\2")
buf.write("\u009a\31\3\2\2\2\u009b\u00a0\5\n\6\2\u009c\u009d\7\32")
buf.write("\2\2\u009d\u009f\5\n\6\2\u009e\u009c\3\2\2\2\u009f\u00a2")
buf.write("\3\2\2\2\u00a0\u009e\3\2\2\2\u00a0\u00a1\3\2\2\2\u00a1")
buf.write("\u00a4\3\2\2\2\u00a2\u00a0\3\2\2\2\u00a3\u00a5\7\32\2")
buf.write("\2\u00a4\u00a3\3\2\2\2\u00a4\u00a5\3\2\2\2\u00a5\u00aa")
buf.write("\3\2\2\2\u00a6\u00a7\7\21\2\2\u00a7\u00a8\7\27\2\2\u00a8")
buf.write("\u00aa\5\n\6\2\u00a9\u009b\3\2\2\2\u00a9\u00a6\3\2\2\2")
buf.write("\u00aa\33\3\2\2\2\u00ab\u00ae\7\7\2\2\u00ac\u00ae\7\b")
buf.write("\2\2\u00ad\u00ab\3\2\2\2\u00ad\u00ac\3\2\2\2\u00ae\35")
buf.write("\3\2\2\2\u00af\u00b0\7\21\2\2\u00b0\u00b1\7\27\2\2\u00b1")
buf.write("\u00b2\5\26\f\2\u00b2\37\3\2\2\2\30#\'\61\67;CKO_cquy")
buf.write("\177\u0085\u008b\u0091\u0099\u00a0\u00a4\u00a9\u00ad")
return buf.getvalue()
class DIDParser ( Parser ):
grammarFileName = "DIDParser.g4"
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
sharedContextCache = PredictionContextCache()
literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
"'type'", "'query'", "'oneway'", "<INVALID>", "<INVALID>",
"'opt'", "'vec'", "'record'", "'variant'", "'service'",
"'func'", "<INVALID>", "'('", "')'", "'{'", "'}'",
"'->'", "':'", "';'", "'='", "','" ]
symbolicNames = [ "<INVALID>", "BlockComment", "LineComment", "S", "Type",
"Query", "Oneway", "PrimType", "NumType", "OPT", "VEC",
"RECORD", "VARIANT", "Service", "FUNC", "Name", "LeftP",
"RightP", "LeftB", "RightB", "Arrow", "Colon", "Semicolon",
"Eq", "Comma" ]
RULE_program = 0
RULE_defination = 1
RULE_actor = 2
RULE_actortype = 3
RULE_datatype = 4
RULE_comptype = 5
RULE_constype = 6
RULE_recordfield = 7
RULE_variantfield = 8
RULE_reftype = 9
RULE_functype = 10
RULE_tuptype = 11
RULE_argtypes = 12
RULE_funcann = 13
RULE_methodtype = 14
ruleNames = [ "program", "defination", "actor", "actortype", "datatype",
"comptype", "constype", "recordfield", "variantfield",
"reftype", "functype", "tuptype", "argtypes", "funcann",
"methodtype" ]
EOF = Token.EOF
BlockComment=1
LineComment=2
S=3
Type=4
Query=5
Oneway=6
PrimType=7
NumType=8
OPT=9
VEC=10
RECORD=11
VARIANT=12
Service=13
FUNC=14
Name=15
LeftP=16
RightP=17
LeftB=18
RightB=19
Arrow=20
Colon=21
Semicolon=22
Eq=23
Comma=24
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
super().__init__(input, output)
self.checkVersion("4.9.3")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None
class ProgramContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def defination(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(DIDParser.DefinationContext)
else:
return self.getTypedRuleContext(DIDParser.DefinationContext,i)
def actor(self):
return self.getTypedRuleContext(DIDParser.ActorContext,0)
def getRuleIndex(self):
return DIDParser.RULE_program
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterProgram" ):
listener.enterProgram(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitProgram" ):
listener.exitProgram(self)
def program(self):
localctx = DIDParser.ProgramContext(self, self._ctx, self.state)
self.enterRule(localctx, 0, self.RULE_program)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 33
self._errHandler.sync(self)
_la = self._input.LA(1)
while _la==DIDParser.Type:
self.state = 30
self.defination()
self.state = 35
self._errHandler.sync(self)
_la = self._input.LA(1)
self.state = 37
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.Service:
self.state = 36
self.actor()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class DefinationContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def Type(self):
return self.getToken(DIDParser.Type, 0)
def Name(self):
return self.getToken(DIDParser.Name, 0)
def Eq(self):
return self.getToken(DIDParser.Eq, 0)
def datatype(self):
return self.getTypedRuleContext(DIDParser.DatatypeContext,0)
def Semicolon(self):
return self.getToken(DIDParser.Semicolon, 0)
def getRuleIndex(self):
return DIDParser.RULE_defination
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterDefination" ):
listener.enterDefination(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitDefination" ):
listener.exitDefination(self)
def defination(self):
localctx = DIDParser.DefinationContext(self, self._ctx, self.state)
self.enterRule(localctx, 2, self.RULE_defination)
try:
self.enterOuterAlt(localctx, 1)
self.state = 39
self.match(DIDParser.Type)
self.state = 40
self.match(DIDParser.Name)
self.state = 41
self.match(DIDParser.Eq)
self.state = 42
self.datatype()
self.state = 43
self.match(DIDParser.Semicolon)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ActorContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def Service(self):
return self.getToken(DIDParser.Service, 0)
def Colon(self):
return self.getToken(DIDParser.Colon, 0)
def actortype(self):
return self.getTypedRuleContext(DIDParser.ActortypeContext,0)
def Name(self, i:int=None):
if i is None:
return self.getTokens(DIDParser.Name)
else:
return self.getToken(DIDParser.Name, i)
def tuptype(self):
return self.getTypedRuleContext(DIDParser.TuptypeContext,0)
def Arrow(self):
return self.getToken(DIDParser.Arrow, 0)
def getRuleIndex(self):
return DIDParser.RULE_actor
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterActor" ):
listener.enterActor(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitActor" ):
listener.exitActor(self)
def actor(self):
localctx = DIDParser.ActorContext(self, self._ctx, self.state)
self.enterRule(localctx, 4, self.RULE_actor)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 45
self.match(DIDParser.Service)
self.state = 47
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.Name:
self.state = 46
self.match(DIDParser.Name)
self.state = 49
self.match(DIDParser.Colon)
self.state = 53
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.LeftP:
self.state = 50
self.tuptype()
self.state = 51
self.match(DIDParser.Arrow)
self.state = 57
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [DIDParser.LeftB]:
self.state = 55
self.actortype()
pass
elif token in [DIDParser.Name]:
self.state = 56
self.match(DIDParser.Name)
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 ActortypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def LeftB(self):
return self.getToken(DIDParser.LeftB, 0)
def RightB(self):
return self.getToken(DIDParser.RightB, 0)
def methodtype(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(DIDParser.MethodtypeContext)
else:
return self.getTypedRuleContext(DIDParser.MethodtypeContext,i)
def Semicolon(self, i:int=None):
if i is None:
return self.getTokens(DIDParser.Semicolon)
else:
return self.getToken(DIDParser.Semicolon, i)
def getRuleIndex(self):
return DIDParser.RULE_actortype
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterActortype" ):
listener.enterActortype(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitActortype" ):
listener.exitActortype(self)
def actortype(self):
localctx = DIDParser.ActortypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 6, self.RULE_actortype)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 59
self.match(DIDParser.LeftB)
self.state = 65
self._errHandler.sync(self)
_la = self._input.LA(1)
while _la==DIDParser.Name:
self.state = 60
self.methodtype()
self.state = 61
self.match(DIDParser.Semicolon)
self.state = 67
self._errHandler.sync(self)
_la = self._input.LA(1)
self.state = 68
self.match(DIDParser.RightB)
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):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return DIDParser.RULE_datatype
def copyFrom(self, ctx:ParserRuleContext):
super().copyFrom(ctx)
class PrimitiveContext(DatatypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.DatatypeContext
super().__init__(parser)
self.copyFrom(ctx)
def PrimType(self):
return self.getToken(DIDParser.PrimType, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterPrimitive" ):
listener.enterPrimitive(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitPrimitive" ):
listener.exitPrimitive(self)
class ComponentContext(DatatypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.DatatypeContext
super().__init__(parser)
self.copyFrom(ctx)
def comptype(self):
return self.getTypedRuleContext(DIDParser.ComptypeContext,0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterComponent" ):
listener.enterComponent(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitComponent" ):
listener.exitComponent(self)
class NameContext(DatatypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.DatatypeContext
super().__init__(parser)
self.copyFrom(ctx)
def Name(self):
return self.getToken(DIDParser.Name, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterName" ):
listener.enterName(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitName" ):
listener.exitName(self)
def datatype(self):
localctx = DIDParser.DatatypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 8, self.RULE_datatype)
try:
self.state = 73
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [DIDParser.Name]:
localctx = DIDParser.NameContext(self, localctx)
self.enterOuterAlt(localctx, 1)
self.state = 70
self.match(DIDParser.Name)
pass
elif token in [DIDParser.PrimType]:
localctx = DIDParser.PrimitiveContext(self, localctx)
self.enterOuterAlt(localctx, 2)
self.state = 71
self.match(DIDParser.PrimType)
pass
elif token in [DIDParser.OPT, DIDParser.VEC, DIDParser.RECORD, DIDParser.VARIANT, DIDParser.Service, DIDParser.FUNC]:
localctx = DIDParser.ComponentContext(self, localctx)
self.enterOuterAlt(localctx, 3)
self.state = 72
self.comptype()
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 ComptypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def constype(self):
return self.getTypedRuleContext(DIDParser.ConstypeContext,0)
def reftype(self):
return self.getTypedRuleContext(DIDParser.ReftypeContext,0)
def getRuleIndex(self):
return DIDParser.RULE_comptype
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterComptype" ):
listener.enterComptype(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitComptype" ):
listener.exitComptype(self)
def comptype(self):
localctx = DIDParser.ComptypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 10, self.RULE_comptype)
try:
self.state = 77
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [DIDParser.OPT, DIDParser.VEC, DIDParser.RECORD, DIDParser.VARIANT]:
self.enterOuterAlt(localctx, 1)
self.state = 75
self.constype()
pass
elif token in [DIDParser.Service, DIDParser.FUNC]:
self.enterOuterAlt(localctx, 2)
self.state = 76
self.reftype()
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 ConstypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return DIDParser.RULE_constype
def copyFrom(self, ctx:ParserRuleContext):
super().copyFrom(ctx)
class VariantContext(ConstypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.ConstypeContext
super().__init__(parser)
self.copyFrom(ctx)
def VARIANT(self):
return self.getToken(DIDParser.VARIANT, 0)
def LeftB(self):
return self.getToken(DIDParser.LeftB, 0)
def variantfield(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(DIDParser.VariantfieldContext)
else:
return self.getTypedRuleContext(DIDParser.VariantfieldContext,i)
def RightB(self):
return self.getToken(DIDParser.RightB, 0)
def Semicolon(self, i:int=None):
if i is None:
return self.getTokens(DIDParser.Semicolon)
else:
return self.getToken(DIDParser.Semicolon, i)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterVariant" ):
listener.enterVariant(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitVariant" ):
listener.exitVariant(self)
class EmptyRecordContext(ConstypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.ConstypeContext
super().__init__(parser)
self.copyFrom(ctx)
def RECORD(self):
return self.getToken(DIDParser.RECORD, 0)
def LeftB(self):
return self.getToken(DIDParser.LeftB, 0)
def RightB(self):
return self.getToken(DIDParser.RightB, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterEmptyRecord" ):
listener.enterEmptyRecord(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitEmptyRecord" ):
listener.exitEmptyRecord(self)
class EmptyVariantContext(ConstypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.ConstypeContext
super().__init__(parser)
self.copyFrom(ctx)
def VARIANT(self):
return self.getToken(DIDParser.VARIANT, 0)
def LeftB(self):
return self.getToken(DIDParser.LeftB, 0)
def RightB(self):
return self.getToken(DIDParser.RightB, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterEmptyVariant" ):
listener.enterEmptyVariant(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitEmptyVariant" ):
listener.exitEmptyVariant(self)
class OptionContext(ConstypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.ConstypeContext
super().__init__(parser)
self.copyFrom(ctx)
def OPT(self):
return self.getToken(DIDParser.OPT, 0)
def datatype(self):
return self.getTypedRuleContext(DIDParser.DatatypeContext,0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterOption" ):
listener.enterOption(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitOption" ):
listener.exitOption(self)
class RecordContext(ConstypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.ConstypeContext
super().__init__(parser)
self.copyFrom(ctx)
def RECORD(self):
return self.getToken(DIDParser.RECORD, 0)
def LeftB(self):
return self.getToken(DIDParser.LeftB, 0)
def recordfield(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(DIDParser.RecordfieldContext)
else:
return self.getTypedRuleContext(DIDParser.RecordfieldContext,i)
def RightB(self):
return self.getToken(DIDParser.RightB, 0)
def Semicolon(self, i:int=None):
if i is None:
return self.getTokens(DIDParser.Semicolon)
else:
return self.getToken(DIDParser.Semicolon, i)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterRecord" ):
listener.enterRecord(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitRecord" ):
listener.exitRecord(self)
class VectorContext(ConstypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.ConstypeContext
super().__init__(parser)
self.copyFrom(ctx)
def VEC(self):
return self.getToken(DIDParser.VEC, 0)
def datatype(self):
return self.getTypedRuleContext(DIDParser.DatatypeContext,0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterVector" ):
listener.enterVector(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitVector" ):
listener.exitVector(self)
def constype(self):
localctx = DIDParser.ConstypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 12, self.RULE_constype)
self._la = 0 # Token type
try:
self.state = 119
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
if la_ == 1:
localctx = DIDParser.OptionContext(self, localctx)
self.enterOuterAlt(localctx, 1)
self.state = 79
self.match(DIDParser.OPT)
self.state = 80
self.datatype()
pass
elif la_ == 2:
localctx = DIDParser.VectorContext(self, localctx)
self.enterOuterAlt(localctx, 2)
self.state = 81
self.match(DIDParser.VEC)
self.state = 82
self.datatype()
pass
elif la_ == 3:
localctx = DIDParser.EmptyRecordContext(self, localctx)
self.enterOuterAlt(localctx, 3)
self.state = 83
self.match(DIDParser.RECORD)
self.state = 84
self.match(DIDParser.LeftB)
self.state = 85
self.match(DIDParser.RightB)
pass
elif la_ == 4:
localctx = DIDParser.RecordContext(self, localctx)
self.enterOuterAlt(localctx, 4)
self.state = 86
self.match(DIDParser.RECORD)
self.state = 87
self.match(DIDParser.LeftB)
self.state = 88
self.recordfield()
self.state = 93
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 = 89
self.match(DIDParser.Semicolon)
self.state = 90
self.recordfield()
self.state = 95
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,8,self._ctx)
self.state = 97
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.Semicolon:
self.state = 96
self.match(DIDParser.Semicolon)
self.state = 99
self.match(DIDParser.RightB)
pass
elif la_ == 5:
localctx = DIDParser.EmptyVariantContext(self, localctx)
self.enterOuterAlt(localctx, 5)
self.state = 101
self.match(DIDParser.VARIANT)
self.state = 102
self.match(DIDParser.LeftB)
self.state = 103
self.match(DIDParser.RightB)
pass
elif la_ == 6:
localctx = DIDParser.VariantContext(self, localctx)
self.enterOuterAlt(localctx, 6)
self.state = 104
self.match(DIDParser.VARIANT)
self.state = 105
self.match(DIDParser.LeftB)
self.state = 106
self.variantfield()
self.state = 111
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,10,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
self.state = 107
self.match(DIDParser.Semicolon)
self.state = 108
self.variantfield()
self.state = 113
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,10,self._ctx)
self.state = 115
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.Semicolon:
self.state = 114
self.match(DIDParser.Semicolon)
self.state = 117
self.match(DIDParser.RightB)
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class RecordfieldContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return DIDParser.RULE_recordfield
def copyFrom(self, ctx:ParserRuleContext):
super().copyFrom(ctx)
class RecordDataContext(RecordfieldContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.RecordfieldContext
super().__init__(parser)
self.copyFrom(ctx)
def datatype(self):
return self.getTypedRuleContext(DIDParser.DatatypeContext,0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterRecordData" ):
listener.enterRecordData(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitRecordData" ):
listener.exitRecordData(self)
class RecordKVContext(RecordfieldContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.RecordfieldContext
super().__init__(parser)
self.copyFrom(ctx)
def Name(self):
return self.getToken(DIDParser.Name, 0)
def Colon(self):
return self.getToken(DIDParser.Colon, 0)
def datatype(self):
return self.getTypedRuleContext(DIDParser.DatatypeContext,0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterRecordKV" ):
listener.enterRecordKV(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitRecordKV" ):
listener.exitRecordKV(self)
def recordfield(self):
localctx = DIDParser.RecordfieldContext(self, self._ctx, self.state)
self.enterRule(localctx, 14, self.RULE_recordfield)
try:
self.state = 125
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
if la_ == 1:
localctx = DIDParser.RecordKVContext(self, localctx)
self.enterOuterAlt(localctx, 1)
self.state = 121
self.match(DIDParser.Name)
self.state = 122
self.match(DIDParser.Colon)
self.state = 123
self.datatype()
pass
elif la_ == 2:
localctx = DIDParser.RecordDataContext(self, localctx)
self.enterOuterAlt(localctx, 2)
self.state = 124
self.datatype()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class VariantfieldContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return DIDParser.RULE_variantfield
def copyFrom(self, ctx:ParserRuleContext):
super().copyFrom(ctx)
class VariantNameContext(VariantfieldContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.VariantfieldContext
super().__init__(parser)
self.copyFrom(ctx)
def Name(self):
return self.getToken(DIDParser.Name, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterVariantName" ):
listener.enterVariantName(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitVariantName" ):
listener.exitVariantName(self)
class VariantKVContext(VariantfieldContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.VariantfieldContext
super().__init__(parser)
self.copyFrom(ctx)
def Name(self):
return self.getToken(DIDParser.Name, 0)
def Colon(self):
return self.getToken(DIDParser.Colon, 0)
def datatype(self):
return self.getTypedRuleContext(DIDParser.DatatypeContext,0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterVariantKV" ):
listener.enterVariantKV(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitVariantKV" ):
listener.exitVariantKV(self)
def variantfield(self):
localctx = DIDParser.VariantfieldContext(self, self._ctx, self.state)
self.enterRule(localctx, 16, self.RULE_variantfield)
try:
self.state = 131
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,14,self._ctx)
if la_ == 1:
localctx = DIDParser.VariantKVContext(self, localctx)
self.enterOuterAlt(localctx, 1)
self.state = 127
self.match(DIDParser.Name)
self.state = 128
self.match(DIDParser.Colon)
self.state = 129
self.datatype()
pass
elif la_ == 2:
localctx = DIDParser.VariantNameContext(self, localctx)
self.enterOuterAlt(localctx, 2)
self.state = 130
self.match(DIDParser.Name)
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ReftypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def FUNC(self):
return self.getToken(DIDParser.FUNC, 0)
def functype(self):
return self.getTypedRuleContext(DIDParser.FunctypeContext,0)
def Service(self):
return self.getToken(DIDParser.Service, 0)
def actortype(self):
return self.getTypedRuleContext(DIDParser.ActortypeContext,0)
def getRuleIndex(self):
return DIDParser.RULE_reftype
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterReftype" ):
listener.enterReftype(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitReftype" ):
listener.exitReftype(self)
def reftype(self):
localctx = DIDParser.ReftypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 18, self.RULE_reftype)
try:
self.state = 137
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [DIDParser.FUNC]:
self.enterOuterAlt(localctx, 1)
self.state = 133
self.match(DIDParser.FUNC)
self.state = 134
self.functype()
pass
elif token in [DIDParser.Service]:
self.enterOuterAlt(localctx, 2)
self.state = 135
self.match(DIDParser.Service)
self.state = 136
self.actortype()
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 FunctypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def tuptype(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(DIDParser.TuptypeContext)
else:
return self.getTypedRuleContext(DIDParser.TuptypeContext,i)
def Arrow(self):
return self.getToken(DIDParser.Arrow, 0)
def funcann(self):
return self.getTypedRuleContext(DIDParser.FuncannContext,0)
def getRuleIndex(self):
return DIDParser.RULE_functype
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterFunctype" ):
listener.enterFunctype(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitFunctype" ):
listener.exitFunctype(self)
def functype(self):
localctx = DIDParser.FunctypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 20, self.RULE_functype)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 139
self.tuptype()
self.state = 140
self.match(DIDParser.Arrow)
self.state = 141
self.tuptype()
self.state = 143
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.Query or _la==DIDParser.Oneway:
self.state = 142
self.funcann()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class TuptypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return DIDParser.RULE_tuptype
def copyFrom(self, ctx:ParserRuleContext):
super().copyFrom(ctx)
class EmptyTupleContext(TuptypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.TuptypeContext
super().__init__(parser)
self.copyFrom(ctx)
def LeftP(self):
return self.getToken(DIDParser.LeftP, 0)
def RightP(self):
return self.getToken(DIDParser.RightP, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterEmptyTuple" ):
listener.enterEmptyTuple(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitEmptyTuple" ):
listener.exitEmptyTuple(self)
class TupleContext(TuptypeContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.TuptypeContext
super().__init__(parser)
self.copyFrom(ctx)
def LeftP(self):
return self.getToken(DIDParser.LeftP, 0)
def argtypes(self):
return self.getTypedRuleContext(DIDParser.ArgtypesContext,0)
def RightP(self):
return self.getToken(DIDParser.RightP, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterTuple" ):
listener.enterTuple(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitTuple" ):
listener.exitTuple(self)
def tuptype(self):
localctx = DIDParser.TuptypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 22, self.RULE_tuptype)
try:
self.state = 151
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,17,self._ctx)
if la_ == 1:
localctx = DIDParser.EmptyTupleContext(self, localctx)
self.enterOuterAlt(localctx, 1)
self.state = 145
self.match(DIDParser.LeftP)
self.state = 146
self.match(DIDParser.RightP)
pass
elif la_ == 2:
localctx = DIDParser.TupleContext(self, localctx)
self.enterOuterAlt(localctx, 2)
self.state = 147
self.match(DIDParser.LeftP)
self.state = 148
self.argtypes()
self.state = 149
self.match(DIDParser.RightP)
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ArgtypesContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def datatype(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(DIDParser.DatatypeContext)
else:
return self.getTypedRuleContext(DIDParser.DatatypeContext,i)
def Comma(self, i:int=None):
if i is None:
return self.getTokens(DIDParser.Comma)
else:
return self.getToken(DIDParser.Comma, i)
def Name(self):
return self.getToken(DIDParser.Name, 0)
def Colon(self):
return self.getToken(DIDParser.Colon, 0)
def getRuleIndex(self):
return DIDParser.RULE_argtypes
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterArgtypes" ):
listener.enterArgtypes(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitArgtypes" ):
listener.exitArgtypes(self)
def argtypes(self):
localctx = DIDParser.ArgtypesContext(self, self._ctx, self.state)
self.enterRule(localctx, 24, self.RULE_argtypes)
self._la = 0 # Token type
try:
self.state = 167
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,20,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 153
self.datatype()
self.state = 158
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,18,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
self.state = 154
self.match(DIDParser.Comma)
self.state = 155
self.datatype()
self.state = 160
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,18,self._ctx)
self.state = 162
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==DIDParser.Comma:
self.state = 161
self.match(DIDParser.Comma)
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 164
self.match(DIDParser.Name)
self.state = 165
self.match(DIDParser.Colon)
self.state = 166
self.datatype()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class FuncannContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return DIDParser.RULE_funcann
def copyFrom(self, ctx:ParserRuleContext):
super().copyFrom(ctx)
class QueryContext(FuncannContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.FuncannContext
super().__init__(parser)
self.copyFrom(ctx)
def Query(self):
return self.getToken(DIDParser.Query, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterQuery" ):
listener.enterQuery(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitQuery" ):
listener.exitQuery(self)
class OnewayContext(FuncannContext):
def __init__(self, parser, ctx:ParserRuleContext): # actually a DIDParser.FuncannContext
super().__init__(parser)
self.copyFrom(ctx)
def Oneway(self):
return self.getToken(DIDParser.Oneway, 0)
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterOneway" ):
listener.enterOneway(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitOneway" ):
listener.exitOneway(self)
def funcann(self):
localctx = DIDParser.FuncannContext(self, self._ctx, self.state)
self.enterRule(localctx, 26, self.RULE_funcann)
try:
self.state = 171
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [DIDParser.Query]:
localctx = DIDParser.QueryContext(self, localctx)
self.enterOuterAlt(localctx, 1)
self.state = 169
self.match(DIDParser.Query)
pass
elif token in [DIDParser.Oneway]:
localctx = DIDParser.OnewayContext(self, localctx)
self.enterOuterAlt(localctx, 2)
self.state = 170
self.match(DIDParser.Oneway)
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 MethodtypeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def Name(self):
return self.getToken(DIDParser.Name, 0)
def Colon(self):
return self.getToken(DIDParser.Colon, 0)
def functype(self):
return self.getTypedRuleContext(DIDParser.FunctypeContext,0)
def getRuleIndex(self):
return DIDParser.RULE_methodtype
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterMethodtype" ):
listener.enterMethodtype(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitMethodtype" ):
listener.exitMethodtype(self)
def methodtype(self):
localctx = DIDParser.MethodtypeContext(self, self._ctx, self.state)
self.enterRule(localctx, 28, self.RULE_methodtype)
try:
self.enterOuterAlt(localctx, 1)
self.state = 173
self.match(DIDParser.Name)
self.state = 174
self.match(DIDParser.Colon)
self.state = 175
self.functype()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx