Example #1
0
        public void RunTests()
        {
            foreach (Test test in Tests)
            {
                P4ParserErrorListener p4ParserErrorListener = new P4ParserErrorListener(test.Name);
                P4Parser parser = new P4Parser(test.Content, p4ParserErrorListener);

                p4ParserErrorListener.HandleErrors();
            }
        }
Example #2
0
        public P4Parser(string input, P4ParserErrorListener errorListener)
        {
            ICharStream stream = CharStreams.fromString(input);

            Lexer = new p4Lexer(stream);
            Lexer.RemoveErrorListeners();
            Lexer.AddErrorListener(errorListener);

            ITokenStream tokens = new CommonTokenStream(Lexer);

            Parser = new p4Parser(tokens);
            Parser.RemoveErrorListeners();
            Parser.AddErrorListener(errorListener);
            Parser.BuildParseTree = true;

            Parser.s(); // Run parser on rule s (start rule)
        }