Example #1
0
        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());
                }
            }
        }
Example #2
0
 private DLV2ParserBaseVisitorImplementation(IASPDataCollection answerSets)
 {
     this.answerSets = answerSets;
 }
Example #3
0
 public static void ParseClingo(IASPDataCollection answerSets, string atomsList, bool two_stageParsing)
 {
     ClingoParserBaseVisitorImplementation.Parse(answerSets, atomsList, two_stageParsing);
 }