Using processor classes

The LexicalProcessor and ParserProcessor are designed to be used in a pipeline structure. These processor used class, which implemented the LexicalHandler and ParserHandler interfaces, to transfer the the produced events.

LexicalProcessor processor = new LexicalProcessor();


LexicalHandler after = new LexicalHandler() 
  public void handleStartDocument() { [...] }

  public void handleLexeme(String symbol, String text) { [...] }

  public void handleEndDocument() { [...] }

So the handler received all produced Events. The LexicalProcessor self implements the interface TextHandler, and receives events from a text producer. The ParserProcessor is similar used.

ParserProcessor processor = new ParserProcessor();


ParserHandler after = new ParserHandler() 
  public void handleStartDocument() { [...] }

  public void handleShiftToken(String symbol, String text) { [...] }

  public void handleReduceProduction(String symbol) { [...] }

  public void handleEndDocument() { [...] }

Similar to the LexicalHandler, the ParserHandler receives all events from the ParserProcessor. And ParserProcessor implements the LexicalHandler interface, so you can just plug the ParserProcessor into the LexicalProcessor.

There also exists a third processor for matching against a pattern. This implementation differ from the others.

PatternProcessor matcher = new PatternProcessor();

char[] text = "bla bla blub bla".toCharArray();

if (

This last processor is equivalent to an regex pattern matcher.

by Stephan Michels