Exemple #1
0
        public static string Parse(IPDDLDataCollection actions, string spdOutput, bool two_stageParsing)
        {
            CommonTokenStream tokens = new CommonTokenStream(new SPDGrammarLexer(CharStreams.fromstring(spdOutput)));
            SPDGrammarParser  parser = new SPDGrammarParser(tokens);
            SPDGrammarBaseVisitorImplementation visitor = new SPDGrammarBaseVisitorImplementation(actions);

            if (!two_stageParsing)
            {
                visitor.Visit(parser.json());

                return(visitor.errors);
            }

            parser.Interpreter.PredictionMode = PredictionMode.SLL;

            parser.RemoveErrorListeners();

            parser.ErrorHandler = new BailErrorStrategy();

            try
            {
                visitor.Visit(parser.json());
            }
            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.json());
                }
            }

            return(visitor.errors);
        }
Exemple #2
0
 private SPDGrammarBaseVisitorImplementation(IPDDLDataCollection actions)
 {
     this.actions = actions;
 }
 public static string ParseSolverPlanningDomains(IPDDLDataCollection actions, string spdOutput, bool two_stageParsing)
 {
     return(SPDGrammarBaseVisitorImplementation.Parse(actions, spdOutput, two_stageParsing));
 }