private Form Build(AntlrInputStream input) { var lexer = new QLLexer(input); var tokenStream = new CommonTokenStream(lexer); var parser = new QLParser(tokenStream); var visitor = new AstBuilderVisitor(); var root = parser.form().Accept(visitor); return(root as Form); }
public QuestionForm ParseQLStream(TextReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } var inputStream = new AntlrInputStream(reader); var lexer = new QLLexer(inputStream); var tokens = new CommonTokenStream(lexer); var parser = new QLParser(tokens); var visitor = new QuestionFormBuilder(); return visitor.Visit(parser.form()); }
public ParsingTask Process(ParsingTask input) { if (string.IsNullOrEmpty(input.ParsingInput)) { input.Errors.Add("Input string is empty"); _canContinue = false; return(input); } QLParser parser = SetupParser(input.ParsingInput); var errorListener = new ErrorListener(); parser.AddErrorListener(errorListener); var visitor = new ParseTreeVisitor(new OperatorFactory(new ValueFactory())); input.Ast = visitor.Visit(parser.form()); errorListener.Errors.ForEach(x => input.Errors.Add(x)); _canContinue = !errorListener.Errors.Any(); return(input); }