EmbASP-Java
DLV2Parser.java
1 package it.unical.mat.parsers.asp.dlv2;
2 
3 import org.antlr.v4.runtime.atn.*;
4 import org.antlr.v4.runtime.dfa.DFA;
5 import org.antlr.v4.runtime.*;
6 import org.antlr.v4.runtime.misc.*;
7 import org.antlr.v4.runtime.tree.*;
8 import java.util.List;
9 import java.util.Iterator;
10 import java.util.ArrayList;
11 
12 @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
13 public class DLV2Parser extends Parser {
14  static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
15 
16  protected static final DFA[] _decisionToDFA;
17  protected static final PredictionContextCache _sharedContextCache =
18  new PredictionContextCache();
19  public static final int
20  START=1, COST_LABEL=2, ANY=3, IGNORE=4, AT=5, INTEGER=6, NEW_LINE=7, BLANK_SPACE=8,
21  COMMA=9, INTEGER_CONSTANT=10, IDENTIFIER=11, MODEL_END=12, STRING_CONSTANT=13,
22  TERMS_BEGIN=14, TERMS_END=15, WHITE_SPACE=16;
23  public static final int
24  RULE_answer_set = 0, RULE_cost = 1, RULE_level = 2, RULE_model = 3, RULE_output = 4,
25  RULE_predicate_atom = 5, RULE_term = 6;
26  public static final String[] ruleNames = {
27  "answer_set", "cost", "level", "model", "output", "predicate_atom", "term"
28  };
29 
30  private static final String[] _LITERAL_NAMES = {
31  null, "'{'", null, null, null, "'@'", null, null, null, "','", null, null,
32  "'}'", null, "'('", "')'"
33  };
34  private static final String[] _SYMBOLIC_NAMES = {
35  null, "START", "COST_LABEL", "ANY", "IGNORE", "AT", "INTEGER", "NEW_LINE",
36  "BLANK_SPACE", "COMMA", "INTEGER_CONSTANT", "IDENTIFIER", "MODEL_END",
37  "STRING_CONSTANT", "TERMS_BEGIN", "TERMS_END", "WHITE_SPACE"
38  };
39  public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
40 
44  @Deprecated
45  public static final String[] tokenNames;
46  static {
47  tokenNames = new String[_SYMBOLIC_NAMES.length];
48  for (int i = 0; i < tokenNames.length; i++) {
49  tokenNames[i] = VOCABULARY.getLiteralName(i);
50  if (tokenNames[i] == null) {
51  tokenNames[i] = VOCABULARY.getSymbolicName(i);
52  }
53 
54  if (tokenNames[i] == null) {
55  tokenNames[i] = "<INVALID>";
56  }
57  }
58  }
59 
60  @Override
61  @Deprecated
62  public String[] getTokenNames() {
63  return tokenNames;
64  }
65 
66  @Override
67 
68  public Vocabulary getVocabulary() {
69  return VOCABULARY;
70  }
71 
72  @Override
73  public String getGrammarFileName() { return "DLV2Parser.g4"; }
74 
75  @Override
76  public String[] getRuleNames() { return ruleNames; }
77 
78  @Override
79  public String getSerializedATN() { return _serializedATN; }
80 
81  @Override
82  public ATN getATN() { return _ATN; }
83 
84  public DLV2Parser(TokenStream input) {
85  super(input);
86  _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
87  }
88  public static class Answer_setContext extends ParserRuleContext {
89  public TerminalNode START() { return getToken(DLV2Parser.START, 0); }
90  public ModelContext model() {
91  return getRuleContext(ModelContext.class,0);
92  }
93  public CostContext cost() {
94  return getRuleContext(CostContext.class,0);
95  }
96  public Answer_setContext(ParserRuleContext parent, int invokingState) {
97  super(parent, invokingState);
98  }
99  @Override public int getRuleIndex() { return RULE_answer_set; }
100  @Override
101  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
102  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitAnswer_set(this);
103  else return visitor.visitChildren(this);
104  }
105  }
106 
107  public final Answer_setContext answer_set() throws RecognitionException {
108  Answer_setContext _localctx = new Answer_setContext(_ctx, getState());
109  enterRule(_localctx, 0, RULE_answer_set);
110  int _la;
111  try {
112  enterOuterAlt(_localctx, 1);
113  {
114  setState(14);
115  match(START);
116  setState(15);
117  model();
118  setState(17);
119  _errHandler.sync(this);
120  _la = _input.LA(1);
121  if (_la==COST_LABEL) {
122  {
123  setState(16);
124  cost();
125  }
126  }
127 
128  }
129  }
130  catch (RecognitionException re) {
131  _localctx.exception = re;
132  _errHandler.reportError(this, re);
133  _errHandler.recover(this, re);
134  }
135  finally {
136  exitRule();
137  }
138  return _localctx;
139  }
140 
141  public static class CostContext extends ParserRuleContext {
142  public TerminalNode COST_LABEL() { return getToken(DLV2Parser.COST_LABEL, 0); }
143  public TerminalNode NEW_LINE() { return getToken(DLV2Parser.NEW_LINE, 0); }
144  public List<LevelContext> level() {
145  return getRuleContexts(LevelContext.class);
146  }
147  public LevelContext level(int i) {
148  return getRuleContext(LevelContext.class,i);
149  }
150  public CostContext(ParserRuleContext parent, int invokingState) {
151  super(parent, invokingState);
152  }
153  @Override public int getRuleIndex() { return RULE_cost; }
154  @Override
155  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
156  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitCost(this);
157  else return visitor.visitChildren(this);
158  }
159  }
160 
161  public final CostContext cost() throws RecognitionException {
162  CostContext _localctx = new CostContext(_ctx, getState());
163  enterRule(_localctx, 2, RULE_cost);
164  int _la;
165  try {
166  enterOuterAlt(_localctx, 1);
167  {
168  setState(19);
169  match(COST_LABEL);
170  setState(23);
171  _errHandler.sync(this);
172  _la = _input.LA(1);
173  while (_la==INTEGER) {
174  {
175  {
176  setState(20);
177  level();
178  }
179  }
180  setState(25);
181  _errHandler.sync(this);
182  _la = _input.LA(1);
183  }
184  setState(26);
185  match(NEW_LINE);
186  }
187  }
188  catch (RecognitionException re) {
189  _localctx.exception = re;
190  _errHandler.reportError(this, re);
191  _errHandler.recover(this, re);
192  }
193  finally {
194  exitRule();
195  }
196  return _localctx;
197  }
198 
199  public static class LevelContext extends ParserRuleContext {
200  public List<TerminalNode> INTEGER() { return getTokens(DLV2Parser.INTEGER); }
201  public TerminalNode INTEGER(int i) {
202  return getToken(DLV2Parser.INTEGER, i);
203  }
204  public TerminalNode AT() { return getToken(DLV2Parser.AT, 0); }
205  public LevelContext(ParserRuleContext parent, int invokingState) {
206  super(parent, invokingState);
207  }
208  @Override public int getRuleIndex() { return RULE_level; }
209  @Override
210  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
211  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitLevel(this);
212  else return visitor.visitChildren(this);
213  }
214  }
215 
216  public final LevelContext level() throws RecognitionException {
217  LevelContext _localctx = new LevelContext(_ctx, getState());
218  enterRule(_localctx, 4, RULE_level);
219  try {
220  enterOuterAlt(_localctx, 1);
221  {
222  setState(28);
223  match(INTEGER);
224  setState(29);
225  match(AT);
226  setState(30);
227  match(INTEGER);
228  }
229  }
230  catch (RecognitionException re) {
231  _localctx.exception = re;
232  _errHandler.reportError(this, re);
233  _errHandler.recover(this, re);
234  }
235  finally {
236  exitRule();
237  }
238  return _localctx;
239  }
240 
241  public static class ModelContext extends ParserRuleContext {
242  public TerminalNode MODEL_END() { return getToken(DLV2Parser.MODEL_END, 0); }
243  public List<Predicate_atomContext> predicate_atom() {
244  return getRuleContexts(Predicate_atomContext.class);
245  }
246  public Predicate_atomContext predicate_atom(int i) {
247  return getRuleContext(Predicate_atomContext.class,i);
248  }
249  public List<TerminalNode> COMMA() { return getTokens(DLV2Parser.COMMA); }
250  public TerminalNode COMMA(int i) {
251  return getToken(DLV2Parser.COMMA, i);
252  }
253  public ModelContext(ParserRuleContext parent, int invokingState) {
254  super(parent, invokingState);
255  }
256  @Override public int getRuleIndex() { return RULE_model; }
257  @Override
258  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
259  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitModel(this);
260  else return visitor.visitChildren(this);
261  }
262  }
263 
264  public final ModelContext model() throws RecognitionException {
265  ModelContext _localctx = new ModelContext(_ctx, getState());
266  enterRule(_localctx, 6, RULE_model);
267  int _la;
268  try {
269  enterOuterAlt(_localctx, 1);
270  {
271  setState(40);
272  _errHandler.sync(this);
273  _la = _input.LA(1);
274  if (_la==IDENTIFIER) {
275  {
276  setState(32);
277  predicate_atom();
278  setState(37);
279  _errHandler.sync(this);
280  _la = _input.LA(1);
281  while (_la==COMMA) {
282  {
283  {
284  setState(33);
285  match(COMMA);
286  setState(34);
287  predicate_atom();
288  }
289  }
290  setState(39);
291  _errHandler.sync(this);
292  _la = _input.LA(1);
293  }
294  }
295  }
296 
297  setState(42);
298  match(MODEL_END);
299  }
300  }
301  catch (RecognitionException re) {
302  _localctx.exception = re;
303  _errHandler.reportError(this, re);
304  _errHandler.recover(this, re);
305  }
306  finally {
307  exitRule();
308  }
309  return _localctx;
310  }
311 
312  public static class OutputContext extends ParserRuleContext {
313  public List<Answer_setContext> answer_set() {
314  return getRuleContexts(Answer_setContext.class);
315  }
316  public Answer_setContext answer_set(int i) {
317  return getRuleContext(Answer_setContext.class,i);
318  }
319  public OutputContext(ParserRuleContext parent, int invokingState) {
320  super(parent, invokingState);
321  }
322  @Override public int getRuleIndex() { return RULE_output; }
323  @Override
324  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
325  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitOutput(this);
326  else return visitor.visitChildren(this);
327  }
328  }
329 
330  public final OutputContext output() throws RecognitionException {
331  OutputContext _localctx = new OutputContext(_ctx, getState());
332  enterRule(_localctx, 8, RULE_output);
333  int _la;
334  try {
335  enterOuterAlt(_localctx, 1);
336  {
337  setState(47);
338  _errHandler.sync(this);
339  _la = _input.LA(1);
340  while (_la==START) {
341  {
342  {
343  setState(44);
344  answer_set();
345  }
346  }
347  setState(49);
348  _errHandler.sync(this);
349  _la = _input.LA(1);
350  }
351  }
352  }
353  catch (RecognitionException re) {
354  _localctx.exception = re;
355  _errHandler.reportError(this, re);
356  _errHandler.recover(this, re);
357  }
358  finally {
359  exitRule();
360  }
361  return _localctx;
362  }
363 
364  public static class Predicate_atomContext extends ParserRuleContext {
365  public TerminalNode IDENTIFIER() { return getToken(DLV2Parser.IDENTIFIER, 0); }
366  public TerminalNode TERMS_BEGIN() { return getToken(DLV2Parser.TERMS_BEGIN, 0); }
367  public List<TermContext> term() {
368  return getRuleContexts(TermContext.class);
369  }
370  public TermContext term(int i) {
371  return getRuleContext(TermContext.class,i);
372  }
373  public TerminalNode TERMS_END() { return getToken(DLV2Parser.TERMS_END, 0); }
374  public List<TerminalNode> COMMA() { return getTokens(DLV2Parser.COMMA); }
375  public TerminalNode COMMA(int i) {
376  return getToken(DLV2Parser.COMMA, i);
377  }
378  public Predicate_atomContext(ParserRuleContext parent, int invokingState) {
379  super(parent, invokingState);
380  }
381  @Override public int getRuleIndex() { return RULE_predicate_atom; }
382  @Override
383  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
384  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitPredicate_atom(this);
385  else return visitor.visitChildren(this);
386  }
387  }
388 
389  public final Predicate_atomContext predicate_atom() throws RecognitionException {
390  Predicate_atomContext _localctx = new Predicate_atomContext(_ctx, getState());
391  enterRule(_localctx, 10, RULE_predicate_atom);
392  int _la;
393  try {
394  enterOuterAlt(_localctx, 1);
395  {
396  setState(50);
397  match(IDENTIFIER);
398  setState(62);
399  _errHandler.sync(this);
400  _la = _input.LA(1);
401  if (_la==TERMS_BEGIN) {
402  {
403  setState(51);
404  match(TERMS_BEGIN);
405  setState(52);
406  term();
407  setState(57);
408  _errHandler.sync(this);
409  _la = _input.LA(1);
410  while (_la==COMMA) {
411  {
412  {
413  setState(53);
414  match(COMMA);
415  setState(54);
416  term();
417  }
418  }
419  setState(59);
420  _errHandler.sync(this);
421  _la = _input.LA(1);
422  }
423  setState(60);
424  match(TERMS_END);
425  }
426  }
427 
428  }
429  }
430  catch (RecognitionException re) {
431  _localctx.exception = re;
432  _errHandler.reportError(this, re);
433  _errHandler.recover(this, re);
434  }
435  finally {
436  exitRule();
437  }
438  return _localctx;
439  }
440 
441  public static class TermContext extends ParserRuleContext {
442  public TerminalNode IDENTIFIER() { return getToken(DLV2Parser.IDENTIFIER, 0); }
443  public TerminalNode INTEGER_CONSTANT() { return getToken(DLV2Parser.INTEGER_CONSTANT, 0); }
444  public Predicate_atomContext predicate_atom() {
445  return getRuleContext(Predicate_atomContext.class,0);
446  }
447  public TerminalNode STRING_CONSTANT() { return getToken(DLV2Parser.STRING_CONSTANT, 0); }
448  public TermContext(ParserRuleContext parent, int invokingState) {
449  super(parent, invokingState);
450  }
451  @Override public int getRuleIndex() { return RULE_term; }
452  @Override
453  public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
454  if ( visitor instanceof DLV2ParserVisitor ) return ((DLV2ParserVisitor<? extends T>)visitor).visitTerm(this);
455  else return visitor.visitChildren(this);
456  }
457  }
458 
459  public final TermContext term() throws RecognitionException {
460  TermContext _localctx = new TermContext(_ctx, getState());
461  enterRule(_localctx, 12, RULE_term);
462  try {
463  setState(68);
464  _errHandler.sync(this);
465  switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) {
466  case 1:
467  enterOuterAlt(_localctx, 1);
468  {
469  setState(64);
470  match(IDENTIFIER);
471  }
472  break;
473  case 2:
474  enterOuterAlt(_localctx, 2);
475  {
476  setState(65);
477  match(INTEGER_CONSTANT);
478  }
479  break;
480  case 3:
481  enterOuterAlt(_localctx, 3);
482  {
483  setState(66);
484  predicate_atom();
485  }
486  break;
487  case 4:
488  enterOuterAlt(_localctx, 4);
489  {
490  setState(67);
491  match(STRING_CONSTANT);
492  }
493  break;
494  }
495  }
496  catch (RecognitionException re) {
497  _localctx.exception = re;
498  _errHandler.reportError(this, re);
499  _errHandler.recover(this, re);
500  }
501  finally {
502  exitRule();
503  }
504  return _localctx;
505  }
506 
507  public static final String _serializedATN =
508  "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\22I\4\2\t\2\4\3\t"+
509  "\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\3\2\3\2\3\2\5\2\24\n\2\3\3"+
510  "\3\3\7\3\30\n\3\f\3\16\3\33\13\3\3\3\3\3\3\4\3\4\3\4\3\4\3\5\3\5\3\5\7"+
511  "\5&\n\5\f\5\16\5)\13\5\5\5+\n\5\3\5\3\5\3\6\7\6\60\n\6\f\6\16\6\63\13"+
512  "\6\3\7\3\7\3\7\3\7\3\7\7\7:\n\7\f\7\16\7=\13\7\3\7\3\7\5\7A\n\7\3\b\3"+
513  "\b\3\b\3\b\5\bG\n\b\3\b\2\2\t\2\4\6\b\n\f\16\2\2\2K\2\20\3\2\2\2\4\25"+
514  "\3\2\2\2\6\36\3\2\2\2\b*\3\2\2\2\n\61\3\2\2\2\f\64\3\2\2\2\16F\3\2\2\2"+
515  "\20\21\7\3\2\2\21\23\5\b\5\2\22\24\5\4\3\2\23\22\3\2\2\2\23\24\3\2\2\2"+
516  "\24\3\3\2\2\2\25\31\7\4\2\2\26\30\5\6\4\2\27\26\3\2\2\2\30\33\3\2\2\2"+
517  "\31\27\3\2\2\2\31\32\3\2\2\2\32\34\3\2\2\2\33\31\3\2\2\2\34\35\7\t\2\2"+
518  "\35\5\3\2\2\2\36\37\7\b\2\2\37 \7\7\2\2 !\7\b\2\2!\7\3\2\2\2\"\'\5\f\7"+
519  "\2#$\7\13\2\2$&\5\f\7\2%#\3\2\2\2&)\3\2\2\2\'%\3\2\2\2\'(\3\2\2\2(+\3"+
520  "\2\2\2)\'\3\2\2\2*\"\3\2\2\2*+\3\2\2\2+,\3\2\2\2,-\7\16\2\2-\t\3\2\2\2"+
521  ".\60\5\2\2\2/.\3\2\2\2\60\63\3\2\2\2\61/\3\2\2\2\61\62\3\2\2\2\62\13\3"+
522  "\2\2\2\63\61\3\2\2\2\64@\7\r\2\2\65\66\7\20\2\2\66;\5\16\b\2\678\7\13"+
523  "\2\28:\5\16\b\29\67\3\2\2\2:=\3\2\2\2;9\3\2\2\2;<\3\2\2\2<>\3\2\2\2=;"+
524  "\3\2\2\2>?\7\21\2\2?A\3\2\2\2@\65\3\2\2\2@A\3\2\2\2A\r\3\2\2\2BG\7\r\2"+
525  "\2CG\7\f\2\2DG\5\f\7\2EG\7\17\2\2FB\3\2\2\2FC\3\2\2\2FD\3\2\2\2FE\3\2"+
526  "\2\2G\17\3\2\2\2\n\23\31\'*\61;@F";
527  public static final ATN _ATN =
528  new ATNDeserializer().deserialize(_serializedATN.toCharArray());
529  static {
530  _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
531  for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
532  _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
533  }
534  }
535 }
it.unical.mat.parsers.asp.dlv2.DLV2Parser
Definition: DLV2Parser.java:13
it.unical.mat.parsers.asp.dlv2.DLV2Parser.tokenNames
static final String[] tokenNames
Definition: DLV2Parser.java:45