EmbASP-Python
ASPGrammarParser.py
1 # Generated from ASPGrammar.g4 by ANTLR 4.7
2 # encoding: utf-8
3 from __future__ import print_function
4 from antlr4 import *
5 from io import StringIO
6 import sys
7 
8 def serializedATN():
9  with StringIO() as buf:
10  buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3")
11  buf.write(u"\13/\4\2\t\2\4\3\t\3\4\4\t\4\3\2\7\2\n\n\2\f\2\16\2\r")
12  buf.write(u"\13\2\3\3\3\3\3\3\3\3\3\3\7\3\24\n\3\f\3\16\3\27\13\3")
13  buf.write(u"\3\3\3\3\5\3\33\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\7\4$")
14  buf.write(u"\n\4\f\4\16\4\'\13\4\5\4)\n\4\3\4\3\4\5\4-\n\4\3\4\2")
15  buf.write(u"\2\5\2\4\6\2\2\2\64\2\13\3\2\2\2\4\16\3\2\2\2\6,\3\2")
16  buf.write(u"\2\2\b\n\5\4\3\2\t\b\3\2\2\2\n\r\3\2\2\2\13\t\3\2\2\2")
17  buf.write(u"\13\f\3\2\2\2\f\3\3\2\2\2\r\13\3\2\2\2\16\32\7\b\2\2")
18  buf.write(u"\17\20\7\3\2\2\20\25\5\6\4\2\21\22\7\4\2\2\22\24\5\6")
19  buf.write(u"\4\2\23\21\3\2\2\2\24\27\3\2\2\2\25\23\3\2\2\2\25\26")
20  buf.write(u"\3\2\2\2\26\30\3\2\2\2\27\25\3\2\2\2\30\31\7\5\2\2\31")
21  buf.write(u"\33\3\2\2\2\32\17\3\2\2\2\32\33\3\2\2\2\33\5\3\2\2\2")
22  buf.write(u"\34-\7\b\2\2\35-\7\t\2\2\36-\5\4\3\2\37(\7\6\2\2 %\5")
23  buf.write(u"\6\4\2!\"\7\4\2\2\"$\5\6\4\2#!\3\2\2\2$\'\3\2\2\2%#\3")
24  buf.write(u"\2\2\2%&\3\2\2\2&)\3\2\2\2\'%\3\2\2\2( \3\2\2\2()\3\2")
25  buf.write(u"\2\2)*\3\2\2\2*-\7\7\2\2+-\7\n\2\2,\34\3\2\2\2,\35\3")
26  buf.write(u"\2\2\2,\36\3\2\2\2,\37\3\2\2\2,+\3\2\2\2-\7\3\2\2\2\b")
27  buf.write(u"\13\25\32%(,")
28  return buf.getvalue()
29 
30 
31 class ASPGrammarParser ( Parser ):
32 
33  grammarFileName = "ASPGrammar.g4"
34 
35  atn = ATNDeserializer().deserialize(serializedATN())
36 
37  decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
38 
39  sharedContextCache = PredictionContextCache()
40 
41  literalNames = [ u"<INVALID>", u"'('", u"','", u"')'", u"'['", u"']'" ]
42 
43  symbolicNames = [ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
44  u"<INVALID>", u"<INVALID>", u"IDENTIFIER", u"INTEGER",
45  u"STRING", u"WHITESPACE" ]
46 
47  RULE_output = 0
48  RULE_predicate_atom = 1
49  RULE_term = 2
50 
51  ruleNames = [ u"output", u"predicate_atom", u"term" ]
52 
53  EOF = Token.EOF
54  T__0=1
55  T__1=2
56  T__2=3
57  T__3=4
58  T__4=5
59  IDENTIFIER=6
60  INTEGER=7
61  STRING=8
62  WHITESPACE=9
63 
64  def __init__(self, input, output=sys.stdout):
65  super(ASPGrammarParser, self).__init__(input, output=output)
66  self.checkVersion("4.7")
67  self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
68  self._predicates = None
69 
70 
71 
72  class OutputContext(ParserRuleContext):
73 
74  def __init__(self, parser, parent=None, invokingState=-1):
75  super(ASPGrammarParser.OutputContext, self).__init__(parent, invokingState)
76  self.parser = parser
77 
78  def predicate_atom(self, i=None):
79  if i is None:
80  return self.getTypedRuleContexts(ASPGrammarParser.Predicate_atomContext)
81  else:
82  return self.getTypedRuleContext(ASPGrammarParser.Predicate_atomContext,i)
83 
84 
85  def getRuleIndex(self):
86  return ASPGrammarParser.RULE_output
87 
88  def accept(self, visitor):
89  if hasattr(visitor, "visitOutput"):
90  return visitor.visitOutput(self)
91  else:
92  return visitor.visitChildren(self)
93 
94 
95 
96 
97  def output(self):
98 
99  localctx = ASPGrammarParser.OutputContext(self, self._ctx, self.state)
100  self.enterRule(localctx, 0, self.RULE_output)
101  self._la = 0 # Token type
102  try:
103  self.enterOuterAlt(localctx, 1)
104  self.state = 9
105  self._errHandler.sync(self)
106  _la = self._input.LA(1)
107  while _la==ASPGrammarParser.IDENTIFIER:
108  self.state = 6
109  self.predicate_atom()
110  self.state = 11
111  self._errHandler.sync(self)
112  _la = self._input.LA(1)
113 
114  except RecognitionException as re:
115  localctx.exception = re
116  self._errHandler.reportError(self, re)
117  self._errHandler.recover(self, re)
118  finally:
119  self.exitRule()
120  return localctx
121 
122  class Predicate_atomContext(ParserRuleContext):
123 
124  def __init__(self, parser, parent=None, invokingState=-1):
125  super(ASPGrammarParser.Predicate_atomContext, self).__init__(parent, invokingState)
126  self.parser = parser
127 
128  def IDENTIFIER(self):
129  return self.getToken(ASPGrammarParser.IDENTIFIER, 0)
130 
131  def term(self, i=None):
132  if i is None:
133  return self.getTypedRuleContexts(ASPGrammarParser.TermContext)
134  else:
135  return self.getTypedRuleContext(ASPGrammarParser.TermContext,i)
136 
137 
138  def getRuleIndex(self):
139  return ASPGrammarParser.RULE_predicate_atom
140 
141  def accept(self, visitor):
142  if hasattr(visitor, "visitPredicate_atom"):
143  return visitor.visitPredicate_atom(self)
144  else:
145  return visitor.visitChildren(self)
146 
147 
148 
149 
150  def predicate_atom(self):
151 
152  localctx = ASPGrammarParser.Predicate_atomContext(self, self._ctx, self.state)
153  self.enterRule(localctx, 2, self.RULE_predicate_atom)
154  self._la = 0 # Token type
155  try:
156  self.enterOuterAlt(localctx, 1)
157  self.state = 12
158  self.match(ASPGrammarParser.IDENTIFIER)
159  self.state = 24
160  self._errHandler.sync(self)
161  _la = self._input.LA(1)
162  if _la==ASPGrammarParser.T__0:
163  self.state = 13
164  self.match(ASPGrammarParser.T__0)
165  self.state = 14
166  self.term()
167  self.state = 19
168  self._errHandler.sync(self)
169  _la = self._input.LA(1)
170  while _la==ASPGrammarParser.T__1:
171  self.state = 15
172  self.match(ASPGrammarParser.T__1)
173  self.state = 16
174  self.term()
175  self.state = 21
176  self._errHandler.sync(self)
177  _la = self._input.LA(1)
178 
179  self.state = 22
180  self.match(ASPGrammarParser.T__2)
181 
182 
183  except RecognitionException as re:
184  localctx.exception = re
185  self._errHandler.reportError(self, re)
186  self._errHandler.recover(self, re)
187  finally:
188  self.exitRule()
189  return localctx
190 
191  class TermContext(ParserRuleContext):
192 
193  def __init__(self, parser, parent=None, invokingState=-1):
194  super(ASPGrammarParser.TermContext, self).__init__(parent, invokingState)
195  self.parser = parser
196 
197  def IDENTIFIER(self):
198  return self.getToken(ASPGrammarParser.IDENTIFIER, 0)
199 
200  def INTEGER(self):
201  return self.getToken(ASPGrammarParser.INTEGER, 0)
202 
203  def predicate_atom(self):
204  return self.getTypedRuleContext(ASPGrammarParser.Predicate_atomContext,0)
205 
206 
207  def term(self, i=None):
208  if i is None:
209  return self.getTypedRuleContexts(ASPGrammarParser.TermContext)
210  else:
211  return self.getTypedRuleContext(ASPGrammarParser.TermContext,i)
212 
213 
214  def STRING(self):
215  return self.getToken(ASPGrammarParser.STRING, 0)
216 
217  def getRuleIndex(self):
218  return ASPGrammarParser.RULE_term
219 
220  def accept(self, visitor):
221  if hasattr(visitor, "visitTerm"):
222  return visitor.visitTerm(self)
223  else:
224  return visitor.visitChildren(self)
225 
226 
227 
228 
229  def term(self):
230 
231  localctx = ASPGrammarParser.TermContext(self, self._ctx, self.state)
232  self.enterRule(localctx, 4, self.RULE_term)
233  self._la = 0 # Token type
234  try:
235  self.state = 42
236  self._errHandler.sync(self)
237  la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
238  if la_ == 1:
239  self.enterOuterAlt(localctx, 1)
240  self.state = 26
241  self.match(ASPGrammarParser.IDENTIFIER)
242  pass
243 
244  elif la_ == 2:
245  self.enterOuterAlt(localctx, 2)
246  self.state = 27
247  self.match(ASPGrammarParser.INTEGER)
248  pass
249 
250  elif la_ == 3:
251  self.enterOuterAlt(localctx, 3)
252  self.state = 28
253  self.predicate_atom()
254  pass
255 
256  elif la_ == 4:
257  self.enterOuterAlt(localctx, 4)
258  self.state = 29
259  self.match(ASPGrammarParser.T__3)
260  self.state = 38
261  self._errHandler.sync(self)
262  _la = self._input.LA(1)
263  if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ASPGrammarParser.T__3) | (1 << ASPGrammarParser.IDENTIFIER) | (1 << ASPGrammarParser.INTEGER) | (1 << ASPGrammarParser.STRING))) != 0):
264  self.state = 30
265  self.term()
266  self.state = 35
267  self._errHandler.sync(self)
268  _la = self._input.LA(1)
269  while _la==ASPGrammarParser.T__1:
270  self.state = 31
271  self.match(ASPGrammarParser.T__1)
272  self.state = 32
273  self.term()
274  self.state = 37
275  self._errHandler.sync(self)
276  _la = self._input.LA(1)
277 
278 
279 
280  self.state = 40
281  self.match(ASPGrammarParser.T__4)
282  pass
283 
284  elif la_ == 5:
285  self.enterOuterAlt(localctx, 5)
286  self.state = 41
287  self.match(ASPGrammarParser.STRING)
288  pass
289 
290 
291  except RecognitionException as re:
292  localctx.exception = re
293  self._errHandler.reportError(self, re)
294  self._errHandler.recover(self, re)
295  finally:
296  self.exitRule()
297  return localctx
298 
299 
300 
301 
302 
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser._interp
_interp
Definition: ASPGrammarParser.py:67
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser._predicates
_predicates
Definition: ASPGrammarParser.py:68
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.Predicate_atomContext.term
def term(self, i=None)
Definition: ASPGrammarParser.py:131
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.OutputContext.predicate_atom
def predicate_atom(self, i=None)
Definition: ASPGrammarParser.py:78
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.decisionsToDFA
list decisionsToDFA
Definition: ASPGrammarParser.py:37
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.TermContext.parser
parser
Definition: ASPGrammarParser.py:195
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.TermContext.term
def term(self, i=None)
Definition: ASPGrammarParser.py:207
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser
Definition: ASPGrammarParser.py:31
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.sharedContextCache
sharedContextCache
Definition: ASPGrammarParser.py:39
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.TermContext.predicate_atom
def predicate_atom(self)
Definition: ASPGrammarParser.py:203
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.TermContext
Definition: ASPGrammarParser.py:191
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.OutputContext.parser
parser
Definition: ASPGrammarParser.py:76
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.Predicate_atomContext.parser
parser
Definition: ASPGrammarParser.py:126
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.atn
atn
Definition: ASPGrammarParser.py:35
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.OutputContext
Definition: ASPGrammarParser.py:72
parsers.asp.asp_parser_base.ASPGrammarParser.ASPGrammarParser.Predicate_atomContext
Definition: ASPGrammarParser.py:122