public string RunParser(String VTLrule)
        {
            // Get our lexer
            AntlrInputStream  inputStream       = new AntlrInputStream(VTLrule);
            ValidationMlLexer ValidationMlLexer = new ValidationMlLexer(inputStream);


            // Get a list of matched tokens
            CommonTokenStream commonTokenStream = new CommonTokenStream(ValidationMlLexer);

            // Pass the tokens to the parser
            ValidationMlParser ValidationMlParser = new ValidationMlParser(commonTokenStream);

            //var pp = Combined1Parser.AndContext.GetChildContext(null, 23);
            // Specify our entry point

            ValidationMlParser.StartContext rContext = ValidationMlParser.start();

            //Combined1Parser.BooleanExprContext rC = (Combined1Parser.BooleanExprContext)rContext.children[0];

            ////// Walk it and attach our listener
            ParseTreeWalker walker = new ParseTreeWalker();

            ValidationMlBaseListener listener = new ValidationMlBaseListener();

            String str_error = "";

            str_error = walker.Walk(listener, rContext);


            if (!String.IsNullOrEmpty(str_error))
            {
                str_error = "Syntax error: " + str_error;
            }
            else
            {
                str_error = "Success";
            }

            return(str_error);
        }
Exemple #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="ValidationMlParser.start"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitStart([NotNull] ValidationMlParser.StartContext context)
 {
     return(VisitChildren(context));
 }