EmbASP-CSharp
ClingoParser.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by a tool.
4 // ANTLR Version: 4.7
5 //
6 // Changes to this file may cause incorrect behavior and will be lost if
7 // the code is regenerated.
8 // </auto-generated>
9 //------------------------------------------------------------------------------
10 
11 // Generated from ClingoParser.g4 by ANTLR 4.7
12 
13 // Unreachable code detected
14 #pragma warning disable 0162
15 // The variable '...' is assigned but its value is never used
16 #pragma warning disable 0219
17 // Missing XML comment for publicly visible type or member '...'
18 #pragma warning disable 1591
19 // Ambiguous reference in cref attribute
20 #pragma warning disable 419
21 
22 using System;
23 using System.IO;
24 using System.Text;
25 using System.Diagnostics;
26 using System.Collections.Generic;
27 using Antlr4.Runtime;
28 using Antlr4.Runtime.Atn;
29 using Antlr4.Runtime.Misc;
30 using Antlr4.Runtime.Tree;
31 using DFA = Antlr4.Runtime.Dfa.DFA;
32 
33 [System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.7")]
34 [System.CLSCompliant(false)]
35 public partial class ClingoParser : Parser {
36  protected static DFA[] decisionToDFA;
37  protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
38  public const int
39  START=1, ANY=2, COMMA=3, INTEGER_CONSTANT=4, NEW_LINE=5, IDENTIFIER=6,
40  STRING_CONSTANT=7, TERMS_BEGIN=8, TERMS_END=9, WHITE_SPACE=10;
41  public const int
42  RULE_answer_set = 0, RULE_model = 1, RULE_output = 2, RULE_predicate_atom = 3,
43  RULE_term = 4;
44  public static readonly string[] ruleNames = {
45  "answer_set", "model", "output", "predicate_atom", "term"
46  };
47 
48  private static readonly string[] _LiteralNames = {
49  null, null, null, "','", null, null, null, null, "'('", "')'"
50  };
51  private static readonly string[] _SymbolicNames = {
52  null, "START", "ANY", "COMMA", "INTEGER_CONSTANT", "NEW_LINE", "IDENTIFIER",
53  "STRING_CONSTANT", "TERMS_BEGIN", "TERMS_END", "WHITE_SPACE"
54  };
55  public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
56 
57  [NotNull]
58  public override IVocabulary Vocabulary
59  {
60  get
61  {
62  return DefaultVocabulary;
63  }
64  }
65 
66  public override string GrammarFileName { get { return "ClingoParser.g4"; } }
67 
68  public override string[] RuleNames { get { return ruleNames; } }
69 
70  public override string SerializedAtn { get { return new string(_serializedATN); } }
71 
72  static ClingoParser() {
73  decisionToDFA = new DFA[_ATN.NumberOfDecisions];
74  for (int i = 0; i < _ATN.NumberOfDecisions; i++) {
75  decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i);
76  }
77  }
78 
79  public ClingoParser(ITokenStream input) : this(input, Console.Out, Console.Error) { }
80 
81  public ClingoParser(ITokenStream input, TextWriter output, TextWriter errorOutput)
82  : base(input, output, errorOutput)
83  {
84  Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache);
85  }
86  public partial class Answer_setContext : ParserRuleContext {
87  public ITerminalNode START() { return GetToken(ClingoParser.START, 0); }
88  public ModelContext model() {
89  return GetRuleContext<ModelContext>(0);
90  }
91  public Answer_setContext(ParserRuleContext parent, int invokingState)
92  : base(parent, invokingState)
93  {
94  }
95  public override int RuleIndex { get { return RULE_answer_set; } }
96  public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
98  if (typedVisitor != null) return typedVisitor.VisitAnswer_set(this);
99  else return visitor.VisitChildren(this);
100  }
101  }
102 
103  [RuleVersion(0)]
104  public Answer_setContext answer_set() {
105  Answer_setContext _localctx = new Answer_setContext(Context, State);
106  EnterRule(_localctx, 0, RULE_answer_set);
107  try {
108  EnterOuterAlt(_localctx, 1);
109  {
110  State = 10; Match(START);
111  State = 11; model();
112  }
113  }
114  catch (RecognitionException re) {
115  _localctx.exception = re;
116  ErrorHandler.ReportError(this, re);
117  ErrorHandler.Recover(this, re);
118  }
119  finally {
120  ExitRule();
121  }
122  return _localctx;
123  }
124 
125  public partial class ModelContext : ParserRuleContext {
126  public ITerminalNode NEW_LINE() { return GetToken(ClingoParser.NEW_LINE, 0); }
127  public Predicate_atomContext[] predicate_atom() {
128  return GetRuleContexts<Predicate_atomContext>();
129  }
130  public Predicate_atomContext predicate_atom(int i) {
131  return GetRuleContext<Predicate_atomContext>(i);
132  }
133  public ModelContext(ParserRuleContext parent, int invokingState)
134  : base(parent, invokingState)
135  {
136  }
137  public override int RuleIndex { get { return RULE_model; } }
138  public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
140  if (typedVisitor != null) return typedVisitor.VisitModel(this);
141  else return visitor.VisitChildren(this);
142  }
143  }
144 
145  [RuleVersion(0)]
146  public ModelContext model() {
147  ModelContext _localctx = new ModelContext(Context, State);
148  EnterRule(_localctx, 2, RULE_model);
149  int _la;
150  try {
151  EnterOuterAlt(_localctx, 1);
152  {
153  State = 16;
154  ErrorHandler.Sync(this);
155  _la = TokenStream.LA(1);
156  while (_la==IDENTIFIER) {
157  {
158  {
159  State = 13; predicate_atom();
160  }
161  }
162  State = 18;
163  ErrorHandler.Sync(this);
164  _la = TokenStream.LA(1);
165  }
166  State = 19; Match(NEW_LINE);
167  }
168  }
169  catch (RecognitionException re) {
170  _localctx.exception = re;
171  ErrorHandler.ReportError(this, re);
172  ErrorHandler.Recover(this, re);
173  }
174  finally {
175  ExitRule();
176  }
177  return _localctx;
178  }
179 
180  public partial class OutputContext : ParserRuleContext {
181  public Answer_setContext[] answer_set() {
182  return GetRuleContexts<Answer_setContext>();
183  }
184  public Answer_setContext answer_set(int i) {
185  return GetRuleContext<Answer_setContext>(i);
186  }
187  public OutputContext(ParserRuleContext parent, int invokingState)
188  : base(parent, invokingState)
189  {
190  }
191  public override int RuleIndex { get { return RULE_output; } }
192  public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
194  if (typedVisitor != null) return typedVisitor.VisitOutput(this);
195  else return visitor.VisitChildren(this);
196  }
197  }
198 
199  [RuleVersion(0)]
200  public OutputContext output() {
201  OutputContext _localctx = new OutputContext(Context, State);
202  EnterRule(_localctx, 4, RULE_output);
203  int _la;
204  try {
205  EnterOuterAlt(_localctx, 1);
206  {
207  State = 24;
208  ErrorHandler.Sync(this);
209  _la = TokenStream.LA(1);
210  while (_la==START) {
211  {
212  {
213  State = 21; answer_set();
214  }
215  }
216  State = 26;
217  ErrorHandler.Sync(this);
218  _la = TokenStream.LA(1);
219  }
220  }
221  }
222  catch (RecognitionException re) {
223  _localctx.exception = re;
224  ErrorHandler.ReportError(this, re);
225  ErrorHandler.Recover(this, re);
226  }
227  finally {
228  ExitRule();
229  }
230  return _localctx;
231  }
232 
233  public partial class Predicate_atomContext : ParserRuleContext {
234  public ITerminalNode IDENTIFIER() { return GetToken(ClingoParser.IDENTIFIER, 0); }
235  public ITerminalNode TERMS_BEGIN() { return GetToken(ClingoParser.TERMS_BEGIN, 0); }
236  public TermContext[] term() {
237  return GetRuleContexts<TermContext>();
238  }
239  public TermContext term(int i) {
240  return GetRuleContext<TermContext>(i);
241  }
242  public ITerminalNode TERMS_END() { return GetToken(ClingoParser.TERMS_END, 0); }
243  public ITerminalNode[] COMMA() { return GetTokens(ClingoParser.COMMA); }
244  public ITerminalNode COMMA(int i) {
245  return GetToken(ClingoParser.COMMA, i);
246  }
247  public Predicate_atomContext(ParserRuleContext parent, int invokingState)
248  : base(parent, invokingState)
249  {
250  }
251  public override int RuleIndex { get { return RULE_predicate_atom; } }
252  public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
254  if (typedVisitor != null) return typedVisitor.VisitPredicate_atom(this);
255  else return visitor.VisitChildren(this);
256  }
257  }
258 
259  [RuleVersion(0)]
260  public Predicate_atomContext predicate_atom() {
261  Predicate_atomContext _localctx = new Predicate_atomContext(Context, State);
262  EnterRule(_localctx, 6, RULE_predicate_atom);
263  int _la;
264  try {
265  EnterOuterAlt(_localctx, 1);
266  {
267  State = 27; Match(IDENTIFIER);
268  State = 39;
269  ErrorHandler.Sync(this);
270  _la = TokenStream.LA(1);
271  if (_la==TERMS_BEGIN) {
272  {
273  State = 28; Match(TERMS_BEGIN);
274  State = 29; term();
275  State = 34;
276  ErrorHandler.Sync(this);
277  _la = TokenStream.LA(1);
278  while (_la==COMMA) {
279  {
280  {
281  State = 30; Match(COMMA);
282  State = 31; term();
283  }
284  }
285  State = 36;
286  ErrorHandler.Sync(this);
287  _la = TokenStream.LA(1);
288  }
289  State = 37; Match(TERMS_END);
290  }
291  }
292 
293  }
294  }
295  catch (RecognitionException re) {
296  _localctx.exception = re;
297  ErrorHandler.ReportError(this, re);
298  ErrorHandler.Recover(this, re);
299  }
300  finally {
301  ExitRule();
302  }
303  return _localctx;
304  }
305 
306  public partial class TermContext : ParserRuleContext {
307  public ITerminalNode IDENTIFIER() { return GetToken(ClingoParser.IDENTIFIER, 0); }
308  public ITerminalNode INTEGER_CONSTANT() { return GetToken(ClingoParser.INTEGER_CONSTANT, 0); }
309  public Predicate_atomContext predicate_atom() {
310  return GetRuleContext<Predicate_atomContext>(0);
311  }
312  public ITerminalNode STRING_CONSTANT() { return GetToken(ClingoParser.STRING_CONSTANT, 0); }
313  public TermContext(ParserRuleContext parent, int invokingState)
314  : base(parent, invokingState)
315  {
316  }
317  public override int RuleIndex { get { return RULE_term; } }
318  public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
320  if (typedVisitor != null) return typedVisitor.VisitTerm(this);
321  else return visitor.VisitChildren(this);
322  }
323  }
324 
325  [RuleVersion(0)]
326  public TermContext term() {
327  TermContext _localctx = new TermContext(Context, State);
328  EnterRule(_localctx, 8, RULE_term);
329  try {
330  State = 45;
331  ErrorHandler.Sync(this);
332  switch ( Interpreter.AdaptivePredict(TokenStream,4,Context) ) {
333  case 1:
334  EnterOuterAlt(_localctx, 1);
335  {
336  State = 41; Match(IDENTIFIER);
337  }
338  break;
339  case 2:
340  EnterOuterAlt(_localctx, 2);
341  {
342  State = 42; Match(INTEGER_CONSTANT);
343  }
344  break;
345  case 3:
346  EnterOuterAlt(_localctx, 3);
347  {
348  State = 43; predicate_atom();
349  }
350  break;
351  case 4:
352  EnterOuterAlt(_localctx, 4);
353  {
354  State = 44; Match(STRING_CONSTANT);
355  }
356  break;
357  }
358  }
359  catch (RecognitionException re) {
360  _localctx.exception = re;
361  ErrorHandler.ReportError(this, re);
362  ErrorHandler.Recover(this, re);
363  }
364  finally {
365  ExitRule();
366  }
367  return _localctx;
368  }
369 
370  private static char[] _serializedATN = {
371  '\x3', '\x608B', '\xA72A', '\x8133', '\xB9ED', '\x417C', '\x3BE7', '\x7786',
372  '\x5964', '\x3', '\f', '\x32', '\x4', '\x2', '\t', '\x2', '\x4', '\x3',
373  '\t', '\x3', '\x4', '\x4', '\t', '\x4', '\x4', '\x5', '\t', '\x5', '\x4',
374  '\x6', '\t', '\x6', '\x3', '\x2', '\x3', '\x2', '\x3', '\x2', '\x3', '\x3',
375  '\a', '\x3', '\x11', '\n', '\x3', '\f', '\x3', '\xE', '\x3', '\x14', '\v',
376  '\x3', '\x3', '\x3', '\x3', '\x3', '\x3', '\x4', '\a', '\x4', '\x19',
377  '\n', '\x4', '\f', '\x4', '\xE', '\x4', '\x1C', '\v', '\x4', '\x3', '\x5',
378  '\x3', '\x5', '\x3', '\x5', '\x3', '\x5', '\x3', '\x5', '\a', '\x5', '#',
379  '\n', '\x5', '\f', '\x5', '\xE', '\x5', '&', '\v', '\x5', '\x3', '\x5',
380  '\x3', '\x5', '\x5', '\x5', '*', '\n', '\x5', '\x3', '\x6', '\x3', '\x6',
381  '\x3', '\x6', '\x3', '\x6', '\x5', '\x6', '\x30', '\n', '\x6', '\x3',
382  '\x6', '\x2', '\x2', '\a', '\x2', '\x4', '\x6', '\b', '\n', '\x2', '\x2',
383  '\x2', '\x33', '\x2', '\f', '\x3', '\x2', '\x2', '\x2', '\x4', '\x12',
384  '\x3', '\x2', '\x2', '\x2', '\x6', '\x1A', '\x3', '\x2', '\x2', '\x2',
385  '\b', '\x1D', '\x3', '\x2', '\x2', '\x2', '\n', '/', '\x3', '\x2', '\x2',
386  '\x2', '\f', '\r', '\a', '\x3', '\x2', '\x2', '\r', '\xE', '\x5', '\x4',
387  '\x3', '\x2', '\xE', '\x3', '\x3', '\x2', '\x2', '\x2', '\xF', '\x11',
388  '\x5', '\b', '\x5', '\x2', '\x10', '\xF', '\x3', '\x2', '\x2', '\x2',
389  '\x11', '\x14', '\x3', '\x2', '\x2', '\x2', '\x12', '\x10', '\x3', '\x2',
390  '\x2', '\x2', '\x12', '\x13', '\x3', '\x2', '\x2', '\x2', '\x13', '\x15',
391  '\x3', '\x2', '\x2', '\x2', '\x14', '\x12', '\x3', '\x2', '\x2', '\x2',
392  '\x15', '\x16', '\a', '\a', '\x2', '\x2', '\x16', '\x5', '\x3', '\x2',
393  '\x2', '\x2', '\x17', '\x19', '\x5', '\x2', '\x2', '\x2', '\x18', '\x17',
394  '\x3', '\x2', '\x2', '\x2', '\x19', '\x1C', '\x3', '\x2', '\x2', '\x2',
395  '\x1A', '\x18', '\x3', '\x2', '\x2', '\x2', '\x1A', '\x1B', '\x3', '\x2',
396  '\x2', '\x2', '\x1B', '\a', '\x3', '\x2', '\x2', '\x2', '\x1C', '\x1A',
397  '\x3', '\x2', '\x2', '\x2', '\x1D', ')', '\a', '\b', '\x2', '\x2', '\x1E',
398  '\x1F', '\a', '\n', '\x2', '\x2', '\x1F', '$', '\x5', '\n', '\x6', '\x2',
399  ' ', '!', '\a', '\x5', '\x2', '\x2', '!', '#', '\x5', '\n', '\x6', '\x2',
400  '\"', ' ', '\x3', '\x2', '\x2', '\x2', '#', '&', '\x3', '\x2', '\x2',
401  '\x2', '$', '\"', '\x3', '\x2', '\x2', '\x2', '$', '%', '\x3', '\x2',
402  '\x2', '\x2', '%', '\'', '\x3', '\x2', '\x2', '\x2', '&', '$', '\x3',
403  '\x2', '\x2', '\x2', '\'', '(', '\a', '\v', '\x2', '\x2', '(', '*', '\x3',
404  '\x2', '\x2', '\x2', ')', '\x1E', '\x3', '\x2', '\x2', '\x2', ')', '*',
405  '\x3', '\x2', '\x2', '\x2', '*', '\t', '\x3', '\x2', '\x2', '\x2', '+',
406  '\x30', '\a', '\b', '\x2', '\x2', ',', '\x30', '\a', '\x6', '\x2', '\x2',
407  '-', '\x30', '\x5', '\b', '\x5', '\x2', '.', '\x30', '\a', '\t', '\x2',
408  '\x2', '/', '+', '\x3', '\x2', '\x2', '\x2', '/', ',', '\x3', '\x2', '\x2',
409  '\x2', '/', '-', '\x3', '\x2', '\x2', '\x2', '/', '.', '\x3', '\x2', '\x2',
410  '\x2', '\x30', '\v', '\x3', '\x2', '\x2', '\x2', '\a', '\x12', '\x1A',
411  '$', ')', '/',
412  };
413 
414  public static readonly ATN _ATN =
415  new ATNDeserializer().Deserialize(_serializedATN);
416 
417 
418 }
IClingoParserVisitor.VisitModel
Result VisitModel([NotNull] ClingoParser.ModelContext context)
Visit a parse tree produced by ClingoParser.model.
base
Definition: Callback.cs:1
IClingoParserVisitor.VisitAnswer_set
Result VisitAnswer_set([NotNull] ClingoParser.Answer_setContext context)
Visit a parse tree produced by ClingoParser.answer_set.
IClingoParserVisitor
This interface defines a complete generic visitor for a parse tree produced by ClingoParser.
Definition: ClingoParserVisitor.cs:33
IClingoParserVisitor.VisitTerm
Result VisitTerm([NotNull] ClingoParser.TermContext context)
Visit a parse tree produced by ClingoParser.term.
IClingoParserVisitor.VisitPredicate_atom
Result VisitPredicate_atom([NotNull] ClingoParser.Predicate_atomContext context)
Visit a parse tree produced by ClingoParser.predicate_atom.
IClingoParserVisitor.VisitOutput
Result VisitOutput([NotNull] ClingoParser.OutputContext context)
Visit a parse tree produced by ClingoParser.output.