3 using Antlr4.Runtime.Atn;
13 this.answerSets = answerSets;
16 public override object VisitModel(DLVHEXParser.ModelContext context)
18 answerSets.AddAnswerSet();
20 return VisitChildren(context);
23 public override object VisitLevel(DLVHEXParser.LevelContext context)
25 answerSets.StoreCost(Int32.Parse(context.INTEGER()[1].GetText()), Int32.Parse(context.INTEGER()[0].GetText()));
32 answerSets.StoreAtom(context.GetText());
37 public override object VisitWitness(DLVHEXParser.WitnessContext context)
39 answerSets.AddAnswerSet();
41 return VisitChildren(context);
44 public static void Parse(
IASPDataCollection answerSets,
string atomsList,
bool two_stageParsing)
46 CommonTokenStream tokens =
new CommonTokenStream(
new DLVHEXLexer(CharStreams.fromstring(atomsList)));
47 DLVHEXParser parser =
new DLVHEXParser(tokens);
50 if (!two_stageParsing)
52 visitor.Visit(parser.output());
57 parser.Interpreter.PredictionMode = PredictionMode.SLL;
59 parser.RemoveErrorListeners();
61 parser.ErrorHandler =
new BailErrorStrategy();
65 visitor.Visit(parser.output());
67 catch (SystemException exception)
69 if (exception.GetBaseException() is RecognitionException)
72 parser.AddErrorListener(ConsoleErrorListener<object>.Instance);
74 parser.ErrorHandler =
new DefaultErrorStrategy();
75 parser.Interpreter.PredictionMode = PredictionMode.LL;
77 visitor.Visit(parser.output());