fr.umlv.tatoo.runtime.lexer.rules
Class ActionProcessor<R>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.lexer.rules.ActionProcessor<R>
Type Parameters:
R - type of rules.

public class ActionProcessor<R>
extends Object

Author:
Julien

Constructor Summary
ActionProcessor(LexerTable<R> lexerTable)
          Creates a new lexer process.
 
Method Summary
 LexerTable<R> getLexerTable()
          Returns the rule tables for this process
 void reset()
          Reset the action processor.
 ProcessReturn step(LexerBuffer buffer, Iterable<? extends R> rules)
          Processes available characters from the input stream.
 ProcessReturn stepClose()
          This method is called after step(fr.umlv.tatoo.runtime.buffer.LexerBuffer, java.lang.Iterable) has returned MORE and end-of-file is reached
 int tokenLength()
          Returns the token length, upon successful analyze.
 R winningRule()
          Returns the rule that matched, upon successful analyze.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionProcessor

public ActionProcessor(LexerTable<R> lexerTable)
Creates a new lexer process.

Parameters:
lexerTable - the rule tables for this process
Method Detail

reset

public void reset()
Reset the action processor.


step

public ProcessReturn step(LexerBuffer buffer,
                          Iterable<? extends R> rules)
Processes available characters from the input stream.

Parameters:
buffer - the lexer buffer.
Returns:
MORE if more characters are needed to perform the match, ERROR, if an error occurred and TOKEN if a new token is spawned.

stepClose

public ProcessReturn stepClose()
This method is called after step(fr.umlv.tatoo.runtime.buffer.LexerBuffer, java.lang.Iterable) has returned MORE and end-of-file is reached

Returns:
NOTHING if no new token is available, ERROR, if an error occurred and TOKEN if a new token is spawned. In this case; if characters are back available in the buffer, step(fr.umlv.tatoo.runtime.buffer.LexerBuffer, java.lang.Iterable) must be called again until it returns MORE, and then this method has to be called again

winningRule

public R winningRule()
Returns the rule that matched, upon successful analyze. This method must be called only after method step(fr.umlv.tatoo.runtime.buffer.LexerBuffer, java.lang.Iterable) or stepClose() has returned ProcessReturn.TOKEN

Returns:
the rule that matched

tokenLength

public int tokenLength()
Returns the token length, upon successful analyze. This method must be called only after method step(fr.umlv.tatoo.runtime.buffer.LexerBuffer, java.lang.Iterable) or stepClose() has returned ProcessReturn.TOKEN

Returns:
the token length

getLexerTable

public LexerTable<R> getLexerTable()
Returns the rule tables for this process

Returns:
the rule tables for this process