The universal bottom-up parser algorithm. Runs with a Lexer (containing the input), ParserTables (containing the syntax), and a Semantic (optional).
private static final String [][] syntax = { { "Start", "\"Hello\"", "\"World\"" }, { Token.IGNORED, "`whitespaces`" }, }; SyntaxSeparation separation = new SyntaxSeparation(new Syntax(syntax)); LexerBuilder builder = new LexerBuilder(separation.getLexerSyntax(), separation.getIgnoredSymbols()); Lexer lexer = builder.getLexer(); lexer.setInput("\tHello \r\n\tWorld\n"); ParserTables parserTables = new SLRParserTables(separation.getParserSyntax()); Parser parser = new Parser(parserTables); parser.parse(lexer, new PrintSemantic());
TODO: implement error recovery: method recover()
@author (c) 2000, Fritz Ritzberger