return super.newStrategy();
}
};
// override the Parser builder to install the new Lexer implementation
SerializedParser builder = new SerializedParser() {
protected SerializedLexer newSerializedLexer() // override SerializedLexer factory method
throws Exception
{
return new SerializedLexer() {
protected LexerBuilder newLexerBuilder(Syntax syntax, List ignoredSymbols) // override LexerBuilder factory method
throws LexerException, SyntaxException
{
return new LexerBuilder(syntax, ignoredSymbols) {
public Lexer getLexer() { // override Lexer factory method
return new OverrideLexer(ignoredSymbols, charConsumers);
}
};
}
};
}
};
String [][] syntaxInput = {
{ "Start", "\"Hello\"", "\"World\"" },
{ Token.IGNORED, "`whitespaces`" },
};
Parser parser = builder.get(syntaxInput);
boolean ok = parser.parse("Hello World");
System.err.println("Parsing was "+ok);
}