public static void Parse(IASPDataCollection answerSets, string atomsList, bool two_stageParsing) { CommonTokenStream tokens = new CommonTokenStream(new DLV2Lexer(CharStreams.fromstring(atomsList))); DLV2Parser parser = new DLV2Parser(tokens); DLV2ParserBaseVisitorImplementation visitor = new DLV2ParserBaseVisitorImplementation(answerSets); if (!two_stageParsing) { visitor.Visit(parser.output()); return; } parser.Interpreter.PredictionMode = PredictionMode.SLL; parser.RemoveErrorListeners(); parser.ErrorHandler = new BailErrorStrategy(); try { visitor.Visit(parser.output()); } catch (SystemException exception) { if (exception.GetBaseException() is RecognitionException) { tokens.Seek(0); parser.AddErrorListener(ConsoleErrorListener <object> .Instance); parser.ErrorHandler = new DefaultErrorStrategy(); parser.Interpreter.PredictionMode = PredictionMode.LL; visitor.Visit(parser.output()); } } }
private DLV2ParserBaseVisitorImplementation(IASPDataCollection answerSets) { this.answerSets = answerSets; }
public static void ParseClingo(IASPDataCollection answerSets, string atomsList, bool two_stageParsing) { ClingoParserBaseVisitorImplementation.Parse(answerSets, atomsList, two_stageParsing); }