# Generated from gn.g4 by ANTLR 4.7.1
# encoding: utf-8
from __future__ import print_function
from antlr4 import *
from io import StringIO
import sys
def serializedATN():
with StringIO() as buf:
buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3")
buf.write(u"\24\u008e\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7")
buf.write(u"\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t")
buf.write(u"\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\3\2\3\2\3")
buf.write(u"\2\3\3\3\3\3\3\5\3)\n\3\3\4\3\4\3\4\5\4.\n\4\3\5\3\5")
buf.write(u"\3\5\3\5\3\6\3\6\3\6\5\6\67\n\6\3\6\3\6\5\6;\n\6\3\7")
buf.write(u"\3\7\3\7\3\7\3\7\3\7\3\7\3\7\5\7E\n\7\5\7G\n\7\3\b\3")
buf.write(u"\b\3\b\3\b\3\t\3\t\7\tO\n\t\f\t\16\tR\13\t\3\n\3\n\3")
buf.write(u"\n\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3")
buf.write(u"\f\7\fc\n\f\f\f\16\ff\13\f\3\r\3\r\3\r\5\rk\n\r\3\16")
buf.write(u"\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3")
buf.write(u"\16\3\16\3\16\5\16{\n\16\5\16}\n\16\3\16\5\16\u0080\n")
buf.write(u"\16\3\17\3\17\3\17\7\17\u0085\n\17\f\17\16\17\u0088\13")
buf.write(u"\17\3\20\3\20\3\21\3\21\3\21\2\3\26\22\2\4\6\b\n\f\16")
buf.write(u"\20\22\24\26\30\32\34\36 \2\2\2\u0094\2\"\3\2\2\2\4(")
buf.write(u"\3\2\2\2\6-\3\2\2\2\b/\3\2\2\2\n\63\3\2\2\2\f<\3\2\2")
buf.write(u"\2\16H\3\2\2\2\20P\3\2\2\2\22S\3\2\2\2\24X\3\2\2\2\26")
buf.write(u"\\\3\2\2\2\30j\3\2\2\2\32\177\3\2\2\2\34\u0081\3\2\2")
buf.write(u"\2\36\u0089\3\2\2\2 \u008b\3\2\2\2\"#\5\20\t\2#$\7\2")
buf.write(u"\2\3$\3\3\2\2\2%)\5\b\5\2&)\5\n\6\2\')\5\f\7\2(%\3\2")
buf.write(u"\2\2(&\3\2\2\2(\'\3\2\2\2)\5\3\2\2\2*.\7\20\2\2+.\5\22")
buf.write(u"\n\2,.\5\24\13\2-*\3\2\2\2-+\3\2\2\2-,\3\2\2\2.\7\3\2")
buf.write(u"\2\2/\60\5\6\4\2\60\61\7\r\2\2\61\62\5\26\f\2\62\t\3")
buf.write(u"\2\2\2\63\64\7\20\2\2\64\66\7\3\2\2\65\67\5\34\17\2\66")
buf.write(u"\65\3\2\2\2\66\67\3\2\2\2\678\3\2\2\28:\7\4\2\29;\5\16")
buf.write(u"\b\2:9\3\2\2\2:;\3\2\2\2;\13\3\2\2\2<=\7\5\2\2=>\7\3")
buf.write(u"\2\2>?\5\26\f\2?@\7\4\2\2@F\5\16\b\2AD\5\36\20\2BE\5")
buf.write(u"\f\7\2CE\5\16\b\2DB\3\2\2\2DC\3\2\2\2EG\3\2\2\2FA\3\2")
buf.write(u"\2\2FG\3\2\2\2G\r\3\2\2\2HI\7\6\2\2IJ\5\20\t\2JK\7\7")
buf.write(u"\2\2K\17\3\2\2\2LO\5\4\3\2MO\5 \21\2NL\3\2\2\2NM\3\2")
buf.write(u"\2\2OR\3\2\2\2PN\3\2\2\2PQ\3\2\2\2Q\21\3\2\2\2RP\3\2")
buf.write(u"\2\2ST\7\20\2\2TU\7\b\2\2UV\5\26\f\2VW\7\t\2\2W\23\3")
buf.write(u"\2\2\2XY\7\20\2\2YZ\7\n\2\2Z[\7\20\2\2[\25\3\2\2\2\\")
buf.write(u"]\b\f\1\2]^\5\30\r\2^d\3\2\2\2_`\f\3\2\2`a\7\17\2\2a")
buf.write(u"c\5\26\f\4b_\3\2\2\2cf\3\2\2\2db\3\2\2\2de\3\2\2\2e\27")
buf.write(u"\3\2\2\2fd\3\2\2\2gk\5\32\16\2hi\7\16\2\2ik\5\30\r\2")
buf.write(u"jg\3\2\2\2jh\3\2\2\2k\31\3\2\2\2l\u0080\7\20\2\2m\u0080")
buf.write(u"\7\21\2\2n\u0080\7\22\2\2o\u0080\5\n\6\2p\u0080\5\22")
buf.write(u"\n\2q\u0080\5\24\13\2r\u0080\5\16\b\2st\7\3\2\2tu\5\26")
buf.write(u"\f\2uv\7\4\2\2v\u0080\3\2\2\2w|\7\b\2\2xz\5\34\17\2y")
buf.write(u"{\7\13\2\2zy\3\2\2\2z{\3\2\2\2{}\3\2\2\2|x\3\2\2\2|}")
buf.write(u"\3\2\2\2}~\3\2\2\2~\u0080\7\t\2\2\177l\3\2\2\2\177m\3")
buf.write(u"\2\2\2\177n\3\2\2\2\177o\3\2\2\2\177p\3\2\2\2\177q\3")
buf.write(u"\2\2\2\177r\3\2\2\2\177s\3\2\2\2\177w\3\2\2\2\u0080\33")
buf.write(u"\3\2\2\2\u0081\u0086\5\26\f\2\u0082\u0083\7\13\2\2\u0083")
buf.write(u"\u0085\5\26\f\2\u0084\u0082\3\2\2\2\u0085\u0088\3\2\2")
buf.write(u"\2\u0086\u0084\3\2\2\2\u0086\u0087\3\2\2\2\u0087\35\3")
buf.write(u"\2\2\2\u0088\u0086\3\2\2\2\u0089\u008a\7\f\2\2\u008a")
buf.write(u"\37\3\2\2\2\u008b\u008c\7\23\2\2\u008c!\3\2\2\2\20(-")
buf.write(u"\66:DFNPdjz|\177\u0086")
return buf.getvalue()
class gnParser ( Parser ):
grammarFileName = "gn.g4"
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
sharedContextCache = PredictionContextCache()
literalNames = [ u"<INVALID>", u"'('", u"')'", u"'if'", u"'{'", u"'}'",
u"'['", u"']'", u"'.'", u"','", u"'else'", u"<INVALID>",
u"'!'" ]
symbolicNames = [ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
u"<INVALID>", u"<INVALID>", u"<INVALID>", u"AssignOp",
u"UnaryOp", u"BinaryOp", u"Identifier", u"Integer",
u"String", u"COMMENT", u"WS" ]
RULE_r = 0
RULE_statement = 1
RULE_lvalue = 2
RULE_assignment = 3
RULE_call = 4
RULE_condition = 5
RULE_block = 6
RULE_statementlist = 7
RULE_arrayaccess = 8
RULE_scopeaccess = 9
RULE_expr = 10
RULE_unaryexpr = 11
RULE_primaryexpr = 12
RULE_exprlist = 13
RULE_elsec = 14
RULE_comment = 15
ruleNames = [ u"r", u"statement", u"lvalue", u"assignment", u"call",
u"condition", u"block", u"statementlist", u"arrayaccess",
u"scopeaccess", u"expr", u"unaryexpr", u"primaryexpr",
u"exprlist", u"elsec", u"comment" ]
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
AssignOp=11
UnaryOp=12
BinaryOp=13
Identifier=14
Integer=15
String=16
COMMENT=17
WS=18
def __init__(self, input, output=sys.stdout):
super(gnParser, self).__init__(input, output=output)
self.checkVersion("4.7.1")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None
class RContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.RContext, self).__init__(parent, invokingState)
self.parser = parser
def statementlist(self):
return self.getTypedRuleContext(gnParser.StatementlistContext,0)
def EOF(self):
return self.getToken(gnParser.EOF, 0)
def getRuleIndex(self):
return gnParser.RULE_r
def enterRule(self, listener):
if hasattr(listener, "enterR"):
listener.enterR(self)
def exitRule(self, listener):
if hasattr(listener, "exitR"):
listener.exitR(self)
def r(self):
localctx = gnParser.RContext(self, self._ctx, self.state)
self.enterRule(localctx, 0, self.RULE_r)
try:
self.enterOuterAlt(localctx, 1)
self.state = 32
self.statementlist()
self.state = 33
self.match(gnParser.EOF)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class StatementContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.StatementContext, self).__init__(parent, invokingState)
self.parser = parser
def assignment(self):
return self.getTypedRuleContext(gnParser.AssignmentContext,0)
def call(self):
return self.getTypedRuleContext(gnParser.CallContext,0)
def condition(self):
return self.getTypedRuleContext(gnParser.ConditionContext,0)
def getRuleIndex(self):
return gnParser.RULE_statement
def enterRule(self, listener):
if hasattr(listener, "enterStatement"):
listener.enterStatement(self)
def exitRule(self, listener):
if hasattr(listener, "exitStatement"):
listener.exitStatement(self)
def statement(self):
localctx = gnParser.StatementContext(self, self._ctx, self.state)
self.enterRule(localctx, 2, self.RULE_statement)
try:
self.state = 38
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,0,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 35
self.assignment()
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 36
self.call()
pass
elif la_ == 3:
self.enterOuterAlt(localctx, 3)
self.state = 37
self.condition()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class LvalueContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.LvalueContext, self).__init__(parent, invokingState)
self.parser = parser
def Identifier(self):
return self.getToken(gnParser.Identifier, 0)
def arrayaccess(self):
return self.getTypedRuleContext(gnParser.ArrayaccessContext,0)
def scopeaccess(self):
return self.getTypedRuleContext(gnParser.ScopeaccessContext,0)
def getRuleIndex(self):
return gnParser.RULE_lvalue
def enterRule(self, listener):
if hasattr(listener, "enterLvalue"):
listener.enterLvalue(self)
def exitRule(self, listener):
if hasattr(listener, "exitLvalue"):
listener.exitLvalue(self)
def lvalue(self):
localctx = gnParser.LvalueContext(self, self._ctx, self.state)
self.enterRule(localctx, 4, self.RULE_lvalue)
try:
self.state = 43
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,1,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 40
self.match(gnParser.Identifier)
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 41
self.arrayaccess()
pass
elif la_ == 3:
self.enterOuterAlt(localctx, 3)
self.state = 42
self.scopeaccess()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class AssignmentContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.AssignmentContext, self).__init__(parent, invokingState)
self.parser = parser
def lvalue(self):
return self.getTypedRuleContext(gnParser.LvalueContext,0)
def AssignOp(self):
return self.getToken(gnParser.AssignOp, 0)
def expr(self):
return self.getTypedRuleContext(gnParser.ExprContext,0)
def getRuleIndex(self):
return gnParser.RULE_assignment
def enterRule(self, listener):
if hasattr(listener, "enterAssignment"):
listener.enterAssignment(self)
def exitRule(self, listener):
if hasattr(listener, "exitAssignment"):
listener.exitAssignment(self)
def assignment(self):
localctx = gnParser.AssignmentContext(self, self._ctx, self.state)
self.enterRule(localctx, 6, self.RULE_assignment)
try:
self.enterOuterAlt(localctx, 1)
self.state = 45
self.lvalue()
self.state = 46
self.match(gnParser.AssignOp)
self.state = 47
self.expr(0)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class CallContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.CallContext, self).__init__(parent, invokingState)
self.parser = parser
def Identifier(self):
return self.getToken(gnParser.Identifier, 0)
def exprlist(self):
return self.getTypedRuleContext(gnParser.ExprlistContext,0)
def block(self):
return self.getTypedRuleContext(gnParser.BlockContext,0)
def getRuleIndex(self):
return gnParser.RULE_call
def enterRule(self, listener):
if hasattr(listener, "enterCall"):
listener.enterCall(self)
def exitRule(self, listener):
if hasattr(listener, "exitCall"):
listener.exitCall(self)
def call(self):
localctx = gnParser.CallContext(self, self._ctx, self.state)
self.enterRule(localctx, 8, self.RULE_call)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 49
self.match(gnParser.Identifier)
self.state = 50
self.match(gnParser.T__0)
self.state = 52
self._errHandler.sync(self)
_la = self._input.LA(1)
if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << gnParser.T__0) | (1 << gnParser.T__3) | (1 << gnParser.T__5) | (1 << gnParser.UnaryOp) | (1 << gnParser.Identifier) | (1 << gnParser.Integer) | (1 << gnParser.String))) != 0):
self.state = 51
self.exprlist()
self.state = 54
self.match(gnParser.T__1)
self.state = 56
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,3,self._ctx)
if la_ == 1:
self.state = 55
self.block()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ConditionContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.ConditionContext, self).__init__(parent, invokingState)
self.parser = parser
def expr(self):
return self.getTypedRuleContext(gnParser.ExprContext,0)
def block(self, i=None):
if i is None:
return self.getTypedRuleContexts(gnParser.BlockContext)
else:
return self.getTypedRuleContext(gnParser.BlockContext,i)
def elsec(self):
return self.getTypedRuleContext(gnParser.ElsecContext,0)
def condition(self):
return self.getTypedRuleContext(gnParser.ConditionContext,0)
def getRuleIndex(self):
return gnParser.RULE_condition
def enterRule(self, listener):
if hasattr(listener, "enterCondition"):
listener.enterCondition(self)
def exitRule(self, listener):
if hasattr(listener, "exitCondition"):
listener.exitCondition(self)
def condition(self):
localctx = gnParser.ConditionContext(self, self._ctx, self.state)
self.enterRule(localctx, 10, self.RULE_condition)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 58
self.match(gnParser.T__2)
self.state = 59
self.match(gnParser.T__0)
self.state = 60
self.expr(0)
self.state = 61
self.match(gnParser.T__1)
self.state = 62
self.block()
self.state = 68
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==gnParser.T__9:
self.state = 63
self.elsec()
self.state = 66
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [gnParser.T__2]:
self.state = 64
self.condition()
pass
elif token in [gnParser.T__3]:
self.state = 65
self.block()
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 BlockContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.BlockContext, self).__init__(parent, invokingState)
self.parser = parser
def statementlist(self):
return self.getTypedRuleContext(gnParser.StatementlistContext,0)
def getRuleIndex(self):
return gnParser.RULE_block
def enterRule(self, listener):
if hasattr(listener, "enterBlock"):
listener.enterBlock(self)
def exitRule(self, listener):
if hasattr(listener, "exitBlock"):
listener.exitBlock(self)
def block(self):
localctx = gnParser.BlockContext(self, self._ctx, self.state)
self.enterRule(localctx, 12, self.RULE_block)
try:
self.enterOuterAlt(localctx, 1)
self.state = 70
self.match(gnParser.T__3)
self.state = 71
self.statementlist()
self.state = 72
self.match(gnParser.T__4)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class StatementlistContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.StatementlistContext, self).__init__(parent, invokingState)
self.parser = parser
def statement(self, i=None):
if i is None:
return self.getTypedRuleContexts(gnParser.StatementContext)
else:
return self.getTypedRuleContext(gnParser.StatementContext,i)
def comment(self, i=None):
if i is None:
return self.getTypedRuleContexts(gnParser.CommentContext)
else:
return self.getTypedRuleContext(gnParser.CommentContext,i)
def getRuleIndex(self):
return gnParser.RULE_statementlist
def enterRule(self, listener):
if hasattr(listener, "enterStatementlist"):
listener.enterStatementlist(self)
def exitRule(self, listener):
if hasattr(listener, "exitStatementlist"):
listener.exitStatementlist(self)
def statementlist(self):
localctx = gnParser.StatementlistContext(self, self._ctx, self.state)
self.enterRule(localctx, 14, self.RULE_statementlist)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 78
self._errHandler.sync(self)
_la = self._input.LA(1)
while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << gnParser.T__2) | (1 << gnParser.Identifier) | (1 << gnParser.COMMENT))) != 0):
self.state = 76
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [gnParser.T__2, gnParser.Identifier]:
self.state = 74
self.statement()
pass
elif token in [gnParser.COMMENT]:
self.state = 75
self.comment()
pass
else:
raise NoViableAltException(self)
self.state = 80
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 ArrayaccessContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.ArrayaccessContext, self).__init__(parent, invokingState)
self.parser = parser
def Identifier(self):
return self.getToken(gnParser.Identifier, 0)
def expr(self):
return self.getTypedRuleContext(gnParser.ExprContext,0)
def getRuleIndex(self):
return gnParser.RULE_arrayaccess
def enterRule(self, listener):
if hasattr(listener, "enterArrayaccess"):
listener.enterArrayaccess(self)
def exitRule(self, listener):
if hasattr(listener, "exitArrayaccess"):
listener.exitArrayaccess(self)
def arrayaccess(self):
localctx = gnParser.ArrayaccessContext(self, self._ctx, self.state)
self.enterRule(localctx, 16, self.RULE_arrayaccess)
try:
self.enterOuterAlt(localctx, 1)
self.state = 81
self.match(gnParser.Identifier)
self.state = 82
self.match(gnParser.T__5)
self.state = 83
self.expr(0)
self.state = 84
self.match(gnParser.T__6)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ScopeaccessContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.ScopeaccessContext, self).__init__(parent, invokingState)
self.parser = parser
def Identifier(self, i=None):
if i is None:
return self.getTokens(gnParser.Identifier)
else:
return self.getToken(gnParser.Identifier, i)
def getRuleIndex(self):
return gnParser.RULE_scopeaccess
def enterRule(self, listener):
if hasattr(listener, "enterScopeaccess"):
listener.enterScopeaccess(self)
def exitRule(self, listener):
if hasattr(listener, "exitScopeaccess"):
listener.exitScopeaccess(self)
def scopeaccess(self):
localctx = gnParser.ScopeaccessContext(self, self._ctx, self.state)
self.enterRule(localctx, 18, self.RULE_scopeaccess)
try:
self.enterOuterAlt(localctx, 1)
self.state = 86
self.match(gnParser.Identifier)
self.state = 87
self.match(gnParser.T__7)
self.state = 88
self.match(gnParser.Identifier)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ExprContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.ExprContext, self).__init__(parent, invokingState)
self.parser = parser
def unaryexpr(self):
return self.getTypedRuleContext(gnParser.UnaryexprContext,0)
def expr(self, i=None):
if i is None:
return self.getTypedRuleContexts(gnParser.ExprContext)
else:
return self.getTypedRuleContext(gnParser.ExprContext,i)
def BinaryOp(self):
return self.getToken(gnParser.BinaryOp, 0)
def getRuleIndex(self):
return gnParser.RULE_expr
def enterRule(self, listener):
if hasattr(listener, "enterExpr"):
listener.enterExpr(self)
def exitRule(self, listener):
if hasattr(listener, "exitExpr"):
listener.exitExpr(self)
def expr(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = gnParser.ExprContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 20
self.enterRecursionRule(localctx, 20, self.RULE_expr, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 91
self.unaryexpr()
self._ctx.stop = self._input.LT(-1)
self.state = 98
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:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = gnParser.ExprContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
self.state = 93
if not self.precpred(self._ctx, 1):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
self.state = 94
self.match(gnParser.BinaryOp)
self.state = 95
self.expr(2)
self.state = 100
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,8,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class UnaryexprContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.UnaryexprContext, self).__init__(parent, invokingState)
self.parser = parser
def primaryexpr(self):
return self.getTypedRuleContext(gnParser.PrimaryexprContext,0)
def UnaryOp(self):
return self.getToken(gnParser.UnaryOp, 0)
def unaryexpr(self):
return self.getTypedRuleContext(gnParser.UnaryexprContext,0)
def getRuleIndex(self):
return gnParser.RULE_unaryexpr
def enterRule(self, listener):
if hasattr(listener, "enterUnaryexpr"):
listener.enterUnaryexpr(self)
def exitRule(self, listener):
if hasattr(listener, "exitUnaryexpr"):
listener.exitUnaryexpr(self)
def unaryexpr(self):
localctx = gnParser.UnaryexprContext(self, self._ctx, self.state)
self.enterRule(localctx, 22, self.RULE_unaryexpr)
try:
self.state = 104
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [gnParser.T__0, gnParser.T__3, gnParser.T__5, gnParser.Identifier, gnParser.Integer, gnParser.String]:
self.enterOuterAlt(localctx, 1)
self.state = 101
self.primaryexpr()
pass
elif token in [gnParser.UnaryOp]:
self.enterOuterAlt(localctx, 2)
self.state = 102
self.match(gnParser.UnaryOp)
self.state = 103
self.unaryexpr()
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 PrimaryexprContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.PrimaryexprContext, self).__init__(parent, invokingState)
self.parser = parser
def Identifier(self):
return self.getToken(gnParser.Identifier, 0)
def Integer(self):
return self.getToken(gnParser.Integer, 0)
def String(self):
return self.getToken(gnParser.String, 0)
def call(self):
return self.getTypedRuleContext(gnParser.CallContext,0)
def arrayaccess(self):
return self.getTypedRuleContext(gnParser.ArrayaccessContext,0)
def scopeaccess(self):
return self.getTypedRuleContext(gnParser.ScopeaccessContext,0)
def block(self):
return self.getTypedRuleContext(gnParser.BlockContext,0)
def expr(self):
return self.getTypedRuleContext(gnParser.ExprContext,0)
def exprlist(self):
return self.getTypedRuleContext(gnParser.ExprlistContext,0)
def getRuleIndex(self):
return gnParser.RULE_primaryexpr
def enterRule(self, listener):
if hasattr(listener, "enterPrimaryexpr"):
listener.enterPrimaryexpr(self)
def exitRule(self, listener):
if hasattr(listener, "exitPrimaryexpr"):
listener.exitPrimaryexpr(self)
def primaryexpr(self):
localctx = gnParser.PrimaryexprContext(self, self._ctx, self.state)
self.enterRule(localctx, 24, self.RULE_primaryexpr)
self._la = 0 # Token type
try:
self.state = 125
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 106
self.match(gnParser.Identifier)
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 107
self.match(gnParser.Integer)
pass
elif la_ == 3:
self.enterOuterAlt(localctx, 3)
self.state = 108
self.match(gnParser.String)
pass
elif la_ == 4:
self.enterOuterAlt(localctx, 4)
self.state = 109
self.call()
pass
elif la_ == 5:
self.enterOuterAlt(localctx, 5)
self.state = 110
self.arrayaccess()
pass
elif la_ == 6:
self.enterOuterAlt(localctx, 6)
self.state = 111
self.scopeaccess()
pass
elif la_ == 7:
self.enterOuterAlt(localctx, 7)
self.state = 112
self.block()
pass
elif la_ == 8:
self.enterOuterAlt(localctx, 8)
self.state = 113
self.match(gnParser.T__0)
self.state = 114
self.expr(0)
self.state = 115
self.match(gnParser.T__1)
pass
elif la_ == 9:
self.enterOuterAlt(localctx, 9)
self.state = 117
self.match(gnParser.T__5)
self.state = 122
self._errHandler.sync(self)
_la = self._input.LA(1)
if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << gnParser.T__0) | (1 << gnParser.T__3) | (1 << gnParser.T__5) | (1 << gnParser.UnaryOp) | (1 << gnParser.Identifier) | (1 << gnParser.Integer) | (1 << gnParser.String))) != 0):
self.state = 118
self.exprlist()
self.state = 120
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==gnParser.T__8:
self.state = 119
self.match(gnParser.T__8)
self.state = 124
self.match(gnParser.T__6)
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ExprlistContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.ExprlistContext, self).__init__(parent, invokingState)
self.parser = parser
def expr(self, i=None):
if i is None:
return self.getTypedRuleContexts(gnParser.ExprContext)
else:
return self.getTypedRuleContext(gnParser.ExprContext,i)
def getRuleIndex(self):
return gnParser.RULE_exprlist
def enterRule(self, listener):
if hasattr(listener, "enterExprlist"):
listener.enterExprlist(self)
def exitRule(self, listener):
if hasattr(listener, "exitExprlist"):
listener.exitExprlist(self)
def exprlist(self):
localctx = gnParser.ExprlistContext(self, self._ctx, self.state)
self.enterRule(localctx, 26, self.RULE_exprlist)
try:
self.enterOuterAlt(localctx, 1)
self.state = 127
self.expr(0)
self.state = 132
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,13,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
self.state = 128
self.match(gnParser.T__8)
self.state = 129
self.expr(0)
self.state = 134
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,13,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 ElsecContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.ElsecContext, self).__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return gnParser.RULE_elsec
def enterRule(self, listener):
if hasattr(listener, "enterElsec"):
listener.enterElsec(self)
def exitRule(self, listener):
if hasattr(listener, "exitElsec"):
listener.exitElsec(self)
def elsec(self):
localctx = gnParser.ElsecContext(self, self._ctx, self.state)
self.enterRule(localctx, 28, self.RULE_elsec)
try:
self.enterOuterAlt(localctx, 1)
self.state = 135
self.match(gnParser.T__9)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class CommentContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(gnParser.CommentContext, self).__init__(parent, invokingState)
self.parser = parser
def COMMENT(self):
return self.getToken(gnParser.COMMENT, 0)
def getRuleIndex(self):
return gnParser.RULE_comment
def enterRule(self, listener):
if hasattr(listener, "enterComment"):
listener.enterComment(self)
def exitRule(self, listener):
if hasattr(listener, "exitComment"):
listener.exitComment(self)
def comment(self):
localctx = gnParser.CommentContext(self, self._ctx, self.state)
self.enterRule(localctx, 30, self.RULE_comment)
try:
self.enterOuterAlt(localctx, 1)
self.state = 137
self.match(gnParser.COMMENT)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
def sempred(self, localctx, ruleIndex, predIndex):
if self._predicates == None:
self._predicates = dict()
self._predicates[10] = self.expr_sempred
pred = self._predicates.get(ruleIndex, None)
if pred is None:
raise Exception("No predicate with index:" + str(ruleIndex))
else:
return pred(localctx, predIndex)
def expr_sempred(self, localctx, predIndex):
if predIndex == 0:
return self.precpred(self._ctx, 1)