14 #pragma warning disable 0162
16 #pragma warning disable 0219
18 #pragma warning disable 1591
20 #pragma warning disable 419
25 using System.Diagnostics;
26 using System.Collections.Generic;
28 using Antlr4.Runtime.Atn;
29 using Antlr4.Runtime.Misc;
30 using Antlr4.Runtime.Tree;
31 using DFA = Antlr4.Runtime.Dfa.DFA;
33 [System.CodeDom.Compiler.GeneratedCode(
"ANTLR",
"4.7")]
34 [System.CLSCompliant(
false)]
35 public partial class DLV2Parser : Parser {
36 protected static DFA[] decisionToDFA;
37 protected static PredictionContextCache sharedContextCache =
new PredictionContextCache();
39 START=1, COST_LABEL=2, ANY=3, IGNORE=4, AT=5, INTEGER=6, NEW_LINE=7, BLANK_SPACE=8,
40 COMMA=9, INTEGER_CONSTANT=10, IDENTIFIER=11, MODEL_END=12, STRING_CONSTANT=13,
41 TERMS_BEGIN=14, TERMS_END=15, WHITE_SPACE=16;
43 RULE_answer_set = 0, RULE_cost = 1, RULE_level = 2, RULE_model = 3, RULE_output = 4,
44 RULE_predicate_atom = 5, RULE_term = 6;
45 public static readonly
string[] ruleNames = {
46 "answer_set",
"cost",
"level",
"model",
"output",
"predicate_atom",
"term"
49 private static readonly
string[] _LiteralNames = {
50 null,
"'{'",
null,
null,
null,
"'@'",
null,
null,
null,
"','",
null,
null,
51 "'}'",
null,
"'('",
"')'"
53 private static readonly
string[] _SymbolicNames = {
54 null,
"START",
"COST_LABEL",
"ANY",
"IGNORE",
"AT",
"INTEGER",
"NEW_LINE",
55 "BLANK_SPACE",
"COMMA",
"INTEGER_CONSTANT",
"IDENTIFIER",
"MODEL_END",
56 "STRING_CONSTANT",
"TERMS_BEGIN",
"TERMS_END",
"WHITE_SPACE"
58 public static readonly IVocabulary DefaultVocabulary =
new Vocabulary(_LiteralNames, _SymbolicNames);
61 public override IVocabulary Vocabulary
65 return DefaultVocabulary;
69 public override string GrammarFileName {
get {
return "DLV2Parser.g4"; } }
71 public override string[] RuleNames {
get {
return ruleNames; } }
73 public override string SerializedAtn {
get {
return new string(_serializedATN); } }
76 decisionToDFA =
new DFA[_ATN.NumberOfDecisions];
77 for (
int i = 0; i < _ATN.NumberOfDecisions; i++) {
78 decisionToDFA[i] =
new DFA(_ATN.GetDecisionState(i), i);
82 public DLV2Parser(ITokenStream input) : this(input, Console.Out, Console.Error) { }
84 public DLV2Parser(ITokenStream input, TextWriter output, TextWriter errorOutput)
85 :
base(input, output, errorOutput)
87 Interpreter =
new ParserATNSimulator(
this, _ATN, decisionToDFA, sharedContextCache);
89 public partial class Answer_setContext : ParserRuleContext {
90 public ITerminalNode START() {
return GetToken(DLV2Parser.START, 0); }
91 public ModelContext model() {
92 return GetRuleContext<ModelContext>(0);
94 public CostContext cost() {
95 return GetRuleContext<CostContext>(0);
97 public Answer_setContext(ParserRuleContext parent,
int invokingState)
98 :
base(parent, invokingState)
101 public override int RuleIndex {
get {
return RULE_answer_set; } }
102 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
105 else return visitor.VisitChildren(
this);
110 public Answer_setContext answer_set() {
111 Answer_setContext _localctx =
new Answer_setContext(Context, State);
112 EnterRule(_localctx, 0, RULE_answer_set);
115 EnterOuterAlt(_localctx, 1);
117 State = 14; Match(START);
120 ErrorHandler.Sync(
this);
121 _la = TokenStream.LA(1);
122 if (_la==COST_LABEL) {
130 catch (RecognitionException re) {
131 _localctx.exception = re;
132 ErrorHandler.ReportError(
this, re);
133 ErrorHandler.Recover(
this, re);
141 public partial class CostContext : ParserRuleContext {
142 public ITerminalNode COST_LABEL() {
return GetToken(DLV2Parser.COST_LABEL, 0); }
143 public ITerminalNode NEW_LINE() {
return GetToken(DLV2Parser.NEW_LINE, 0); }
144 public LevelContext[] level() {
145 return GetRuleContexts<LevelContext>();
147 public LevelContext level(
int i) {
148 return GetRuleContext<LevelContext>(i);
150 public CostContext(ParserRuleContext parent,
int invokingState)
151 :
base(parent, invokingState)
154 public override int RuleIndex {
get {
return RULE_cost; } }
155 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
157 if (typedVisitor !=
null)
return typedVisitor.
VisitCost(
this);
158 else return visitor.VisitChildren(
this);
163 public CostContext cost() {
164 CostContext _localctx =
new CostContext(Context, State);
165 EnterRule(_localctx, 2, RULE_cost);
168 EnterOuterAlt(_localctx, 1);
170 State = 19; Match(COST_LABEL);
172 ErrorHandler.Sync(
this);
173 _la = TokenStream.LA(1);
174 while (_la==INTEGER) {
181 ErrorHandler.Sync(
this);
182 _la = TokenStream.LA(1);
184 State = 26; Match(NEW_LINE);
187 catch (RecognitionException re) {
188 _localctx.exception = re;
189 ErrorHandler.ReportError(
this, re);
190 ErrorHandler.Recover(
this, re);
198 public partial class LevelContext : ParserRuleContext {
199 public ITerminalNode[] INTEGER() {
return GetTokens(DLV2Parser.INTEGER); }
200 public ITerminalNode INTEGER(
int i) {
201 return GetToken(DLV2Parser.INTEGER, i);
203 public ITerminalNode AT() {
return GetToken(DLV2Parser.AT, 0); }
204 public LevelContext(ParserRuleContext parent,
int invokingState)
205 :
base(parent, invokingState)
208 public override int RuleIndex {
get {
return RULE_level; } }
209 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
211 if (typedVisitor !=
null)
return typedVisitor.
VisitLevel(
this);
212 else return visitor.VisitChildren(
this);
217 public LevelContext level() {
218 LevelContext _localctx =
new LevelContext(Context, State);
219 EnterRule(_localctx, 4, RULE_level);
221 EnterOuterAlt(_localctx, 1);
223 State = 28; Match(INTEGER);
224 State = 29; Match(AT);
225 State = 30; Match(INTEGER);
228 catch (RecognitionException re) {
229 _localctx.exception = re;
230 ErrorHandler.ReportError(
this, re);
231 ErrorHandler.Recover(
this, re);
239 public partial class ModelContext : ParserRuleContext {
240 public ITerminalNode MODEL_END() {
return GetToken(DLV2Parser.MODEL_END, 0); }
241 public Predicate_atomContext[] predicate_atom() {
242 return GetRuleContexts<Predicate_atomContext>();
244 public Predicate_atomContext predicate_atom(
int i) {
245 return GetRuleContext<Predicate_atomContext>(i);
247 public ITerminalNode[] COMMA() {
return GetTokens(DLV2Parser.COMMA); }
248 public ITerminalNode COMMA(
int i) {
249 return GetToken(DLV2Parser.COMMA, i);
251 public ModelContext(ParserRuleContext parent,
int invokingState)
252 :
base(parent, invokingState)
255 public override int RuleIndex {
get {
return RULE_model; } }
256 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
258 if (typedVisitor !=
null)
return typedVisitor.
VisitModel(
this);
259 else return visitor.VisitChildren(
this);
264 public ModelContext model() {
265 ModelContext _localctx =
new ModelContext(Context, State);
266 EnterRule(_localctx, 6, RULE_model);
269 EnterOuterAlt(_localctx, 1);
272 ErrorHandler.Sync(
this);
273 _la = TokenStream.LA(1);
274 if (_la==IDENTIFIER) {
276 State = 32; predicate_atom();
278 ErrorHandler.Sync(
this);
279 _la = TokenStream.LA(1);
283 State = 33; Match(COMMA);
284 State = 34; predicate_atom();
288 ErrorHandler.Sync(
this);
289 _la = TokenStream.LA(1);
294 State = 42; Match(MODEL_END);
297 catch (RecognitionException re) {
298 _localctx.exception = re;
299 ErrorHandler.ReportError(
this, re);
300 ErrorHandler.Recover(
this, re);
308 public partial class OutputContext : ParserRuleContext {
309 public Answer_setContext[] answer_set() {
310 return GetRuleContexts<Answer_setContext>();
312 public Answer_setContext answer_set(
int i) {
313 return GetRuleContext<Answer_setContext>(i);
315 public OutputContext(ParserRuleContext parent,
int invokingState)
316 :
base(parent, invokingState)
319 public override int RuleIndex {
get {
return RULE_output; } }
320 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
322 if (typedVisitor !=
null)
return typedVisitor.
VisitOutput(
this);
323 else return visitor.VisitChildren(
this);
328 public OutputContext output() {
329 OutputContext _localctx =
new OutputContext(Context, State);
330 EnterRule(_localctx, 8, RULE_output);
333 EnterOuterAlt(_localctx, 1);
336 ErrorHandler.Sync(
this);
337 _la = TokenStream.LA(1);
341 State = 44; answer_set();
345 ErrorHandler.Sync(
this);
346 _la = TokenStream.LA(1);
350 catch (RecognitionException re) {
351 _localctx.exception = re;
352 ErrorHandler.ReportError(
this, re);
353 ErrorHandler.Recover(
this, re);
361 public partial class Predicate_atomContext : ParserRuleContext {
362 public ITerminalNode IDENTIFIER() {
return GetToken(DLV2Parser.IDENTIFIER, 0); }
363 public ITerminalNode TERMS_BEGIN() {
return GetToken(DLV2Parser.TERMS_BEGIN, 0); }
364 public TermContext[] term() {
365 return GetRuleContexts<TermContext>();
367 public TermContext term(
int i) {
368 return GetRuleContext<TermContext>(i);
370 public ITerminalNode TERMS_END() {
return GetToken(DLV2Parser.TERMS_END, 0); }
371 public ITerminalNode[] COMMA() {
return GetTokens(DLV2Parser.COMMA); }
372 public ITerminalNode COMMA(
int i) {
373 return GetToken(DLV2Parser.COMMA, i);
375 public Predicate_atomContext(ParserRuleContext parent,
int invokingState)
376 :
base(parent, invokingState)
379 public override int RuleIndex {
get {
return RULE_predicate_atom; } }
380 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
383 else return visitor.VisitChildren(
this);
388 public Predicate_atomContext predicate_atom() {
389 Predicate_atomContext _localctx =
new Predicate_atomContext(Context, State);
390 EnterRule(_localctx, 10, RULE_predicate_atom);
393 EnterOuterAlt(_localctx, 1);
395 State = 50; Match(IDENTIFIER);
397 ErrorHandler.Sync(
this);
398 _la = TokenStream.LA(1);
399 if (_la==TERMS_BEGIN) {
401 State = 51; Match(TERMS_BEGIN);
404 ErrorHandler.Sync(
this);
405 _la = TokenStream.LA(1);
409 State = 53; Match(COMMA);
414 ErrorHandler.Sync(
this);
415 _la = TokenStream.LA(1);
417 State = 60; Match(TERMS_END);
423 catch (RecognitionException re) {
424 _localctx.exception = re;
425 ErrorHandler.ReportError(
this, re);
426 ErrorHandler.Recover(
this, re);
434 public partial class TermContext : ParserRuleContext {
435 public ITerminalNode IDENTIFIER() {
return GetToken(DLV2Parser.IDENTIFIER, 0); }
436 public ITerminalNode INTEGER_CONSTANT() {
return GetToken(DLV2Parser.INTEGER_CONSTANT, 0); }
437 public Predicate_atomContext predicate_atom() {
438 return GetRuleContext<Predicate_atomContext>(0);
440 public ITerminalNode STRING_CONSTANT() {
return GetToken(DLV2Parser.STRING_CONSTANT, 0); }
441 public TermContext(ParserRuleContext parent,
int invokingState)
442 :
base(parent, invokingState)
445 public override int RuleIndex {
get {
return RULE_term; } }
446 public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
448 if (typedVisitor !=
null)
return typedVisitor.
VisitTerm(
this);
449 else return visitor.VisitChildren(
this);
454 public TermContext term() {
455 TermContext _localctx =
new TermContext(Context, State);
456 EnterRule(_localctx, 12, RULE_term);
459 ErrorHandler.Sync(
this);
460 switch ( Interpreter.AdaptivePredict(TokenStream,7,Context) ) {
462 EnterOuterAlt(_localctx, 1);
464 State = 64; Match(IDENTIFIER);
468 EnterOuterAlt(_localctx, 2);
470 State = 65; Match(INTEGER_CONSTANT);
474 EnterOuterAlt(_localctx, 3);
476 State = 66; predicate_atom();
480 EnterOuterAlt(_localctx, 4);
482 State = 67; Match(STRING_CONSTANT);
487 catch (RecognitionException re) {
488 _localctx.exception = re;
489 ErrorHandler.ReportError(
this, re);
490 ErrorHandler.Recover(
this, re);
498 private static char[] _serializedATN = {
499 '\x3',
'\x608B',
'\xA72A',
'\x8133',
'\xB9ED',
'\x417C',
'\x3BE7',
'\x7786',
500 '\x5964',
'\x3',
'\x12',
'I',
'\x4',
'\x2',
'\t',
'\x2',
'\x4',
'\x3',
501 '\t',
'\x3',
'\x4',
'\x4',
'\t',
'\x4',
'\x4',
'\x5',
'\t',
'\x5',
'\x4',
502 '\x6',
'\t',
'\x6',
'\x4',
'\a',
'\t',
'\a',
'\x4',
'\b',
'\t',
'\b',
503 '\x3',
'\x2',
'\x3',
'\x2',
'\x3',
'\x2',
'\x5',
'\x2',
'\x14',
'\n',
504 '\x2',
'\x3',
'\x3',
'\x3',
'\x3',
'\a',
'\x3',
'\x18',
'\n',
'\x3',
'\f',
505 '\x3',
'\xE',
'\x3',
'\x1B',
'\v',
'\x3',
'\x3',
'\x3',
'\x3',
'\x3',
506 '\x3',
'\x4',
'\x3',
'\x4',
'\x3',
'\x4',
'\x3',
'\x4',
'\x3',
'\x5',
507 '\x3',
'\x5',
'\x3',
'\x5',
'\a',
'\x5',
'&',
'\n',
'\x5',
'\f',
'\x5',
508 '\xE',
'\x5',
')',
'\v',
'\x5',
'\x5',
'\x5',
'+',
'\n',
'\x5',
'\x3',
509 '\x5',
'\x3',
'\x5',
'\x3',
'\x6',
'\a',
'\x6',
'\x30',
'\n',
'\x6',
'\f',
510 '\x6',
'\xE',
'\x6',
'\x33',
'\v',
'\x6',
'\x3',
'\a',
'\x3',
'\a',
'\x3',
511 '\a',
'\x3',
'\a',
'\x3',
'\a',
'\a',
'\a',
':',
'\n',
'\a',
'\f',
'\a',
512 '\xE',
'\a',
'=',
'\v',
'\a',
'\x3',
'\a',
'\x3',
'\a',
'\x5',
'\a',
'\x41',
513 '\n',
'\a',
'\x3',
'\b',
'\x3',
'\b',
'\x3',
'\b',
'\x3',
'\b',
'\x5',
514 '\b',
'G',
'\n',
'\b',
'\x3',
'\b',
'\x2',
'\x2',
'\t',
'\x2',
'\x4',
515 '\x6',
'\b',
'\n',
'\f',
'\xE',
'\x2',
'\x2',
'\x2',
'K',
'\x2',
'\x10',
516 '\x3',
'\x2',
'\x2',
'\x2',
'\x4',
'\x15',
'\x3',
'\x2',
'\x2',
'\x2',
517 '\x6',
'\x1E',
'\x3',
'\x2',
'\x2',
'\x2',
'\b',
'*',
'\x3',
'\x2',
'\x2',
518 '\x2',
'\n',
'\x31',
'\x3',
'\x2',
'\x2',
'\x2',
'\f',
'\x34',
'\x3',
519 '\x2',
'\x2',
'\x2',
'\xE',
'\x46',
'\x3',
'\x2',
'\x2',
'\x2',
'\x10',
520 '\x11',
'\a',
'\x3',
'\x2',
'\x2',
'\x11',
'\x13',
'\x5',
'\b',
'\x5',
521 '\x2',
'\x12',
'\x14',
'\x5',
'\x4',
'\x3',
'\x2',
'\x13',
'\x12',
'\x3',
522 '\x2',
'\x2',
'\x2',
'\x13',
'\x14',
'\x3',
'\x2',
'\x2',
'\x2',
'\x14',
523 '\x3',
'\x3',
'\x2',
'\x2',
'\x2',
'\x15',
'\x19',
'\a',
'\x4',
'\x2',
524 '\x2',
'\x16',
'\x18',
'\x5',
'\x6',
'\x4',
'\x2',
'\x17',
'\x16',
'\x3',
525 '\x2',
'\x2',
'\x2',
'\x18',
'\x1B',
'\x3',
'\x2',
'\x2',
'\x2',
'\x19',
526 '\x17',
'\x3',
'\x2',
'\x2',
'\x2',
'\x19',
'\x1A',
'\x3',
'\x2',
'\x2',
527 '\x2',
'\x1A',
'\x1C',
'\x3',
'\x2',
'\x2',
'\x2',
'\x1B',
'\x19',
'\x3',
528 '\x2',
'\x2',
'\x2',
'\x1C',
'\x1D',
'\a',
'\t',
'\x2',
'\x2',
'\x1D',
529 '\x5',
'\x3',
'\x2',
'\x2',
'\x2',
'\x1E',
'\x1F',
'\a',
'\b',
'\x2',
530 '\x2',
'\x1F',
' ',
'\a',
'\a',
'\x2',
'\x2',
' ',
'!',
'\a',
'\b',
'\x2',
531 '\x2',
'!',
'\a',
'\x3',
'\x2',
'\x2',
'\x2',
'\"',
'\'',
'\x5',
'\f',
532 '\a',
'\x2',
'#',
'$',
'\a',
'\v',
'\x2',
'\x2',
'$',
'&',
'\x5',
'\f',
533 '\a',
'\x2',
'%',
'#',
'\x3',
'\x2',
'\x2',
'\x2',
'&',
')',
'\x3',
'\x2',
534 '\x2',
'\x2',
'\'',
'%',
'\x3',
'\x2',
'\x2',
'\x2',
'\'',
'(',
'\x3',
535 '\x2',
'\x2',
'\x2',
'(',
'+',
'\x3',
'\x2',
'\x2',
'\x2',
')',
'\'',
536 '\x3',
'\x2',
'\x2',
'\x2',
'*',
'\"',
'\x3',
'\x2',
'\x2',
'\x2',
'*',
537 '+',
'\x3',
'\x2',
'\x2',
'\x2',
'+',
',',
'\x3',
'\x2',
'\x2',
'\x2',
538 ',',
'-',
'\a',
'\xE',
'\x2',
'\x2',
'-',
'\t',
'\x3',
'\x2',
'\x2',
'\x2',
539 '.',
'\x30',
'\x5',
'\x2',
'\x2',
'\x2',
'/',
'.',
'\x3',
'\x2',
'\x2',
540 '\x2',
'\x30',
'\x33',
'\x3',
'\x2',
'\x2',
'\x2',
'\x31',
'/',
'\x3',
541 '\x2',
'\x2',
'\x2',
'\x31',
'\x32',
'\x3',
'\x2',
'\x2',
'\x2',
'\x32',
542 '\v',
'\x3',
'\x2',
'\x2',
'\x2',
'\x33',
'\x31',
'\x3',
'\x2',
'\x2',
543 '\x2',
'\x34',
'@',
'\a',
'\r',
'\x2',
'\x2',
'\x35',
'\x36',
'\a',
'\x10',
544 '\x2',
'\x2',
'\x36',
';',
'\x5',
'\xE',
'\b',
'\x2',
'\x37',
'\x38',
545 '\a',
'\v',
'\x2',
'\x2',
'\x38',
':',
'\x5',
'\xE',
'\b',
'\x2',
'\x39',
546 '\x37',
'\x3',
'\x2',
'\x2',
'\x2',
':',
'=',
'\x3',
'\x2',
'\x2',
'\x2',
547 ';',
'\x39',
'\x3',
'\x2',
'\x2',
'\x2',
';',
'<',
'\x3',
'\x2',
'\x2',
548 '\x2',
'<',
'>',
'\x3',
'\x2',
'\x2',
'\x2',
'=',
';',
'\x3',
'\x2',
'\x2',
549 '\x2',
'>',
'?',
'\a',
'\x11',
'\x2',
'\x2',
'?',
'\x41',
'\x3',
'\x2',
550 '\x2',
'\x2',
'@',
'\x35',
'\x3',
'\x2',
'\x2',
'\x2',
'@',
'\x41',
'\x3',
551 '\x2',
'\x2',
'\x2',
'\x41',
'\r',
'\x3',
'\x2',
'\x2',
'\x2',
'\x42',
552 'G',
'\a',
'\r',
'\x2',
'\x2',
'\x43',
'G',
'\a',
'\f',
'\x2',
'\x2',
553 '\x44',
'G',
'\x5',
'\f',
'\a',
'\x2',
'\x45',
'G',
'\a',
'\xF',
'\x2',
554 '\x2',
'\x46',
'\x42',
'\x3',
'\x2',
'\x2',
'\x2',
'\x46',
'\x43',
'\x3',
555 '\x2',
'\x2',
'\x2',
'\x46',
'\x44',
'\x3',
'\x2',
'\x2',
'\x2',
'\x46',
556 '\x45',
'\x3',
'\x2',
'\x2',
'\x2',
'G',
'\xF',
'\x3',
'\x2',
'\x2',
'\x2',
557 '\n',
'\x13',
'\x19',
'\'',
'*',
'\x31',
';',
'@',
'\x46',
560 public static readonly ATN _ATN =
561 new ATNDeserializer().Deserialize(_serializedATN);