2 using System.Collections.Generic;
4 using Antlr4.Runtime.Atn;
10 private readonly List<string> parameters =
new List<string>();
17 public static ASPParser Parse(
string atom)
19 CommonTokenStream tokens =
new CommonTokenStream(
new ASPGrammarLexer(CharStreams.fromstring(atom)));
20 ASPGrammarParser parser =
new ASPGrammarParser(tokens);
22 parser.Interpreter.PredictionMode = PredictionMode.SLL;
24 parser.RemoveErrorListeners();
26 parser.ErrorHandler =
new BailErrorStrategy();
30 visitor.Visit(parser.output());
32 catch (SystemException exception)
34 if (exception.GetBaseException() is RecognitionException)
37 parser.AddErrorListener(ConsoleErrorListener<object>.Instance);
39 parser.ErrorHandler =
new DefaultErrorStrategy();
40 parser.Interpreter.PredictionMode = PredictionMode.LL;
42 visitor.Visit(parser.output());
49 public string[] GetParameters()
51 return parameters.ToArray();
54 public override object VisitTerm(ASPGrammarParser.TermContext context)
56 parameters.Add(context.GetText());