fr.umlv.tatoo.runtime.lexer
Class Lexer<B extends LexerBuffer>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.lexer.Lexer<B>
Type Parameters:
B - type of the buffer.
All Implemented Interfaces:
SimpleLexer
Direct Known Subclasses:
Lexer.LexerImpl

public abstract class Lexer<B extends LexerBuffer>
extends Object
implements SimpleLexer

A Lexer represents a lexer process.

Author:
Julien Cervelle
See Also:
LexerBuilder

Nested Class Summary
static class Lexer.LexerImpl<R,B extends LexerBuffer>
           
 
Method Summary
static
<R,B extends LexerBuffer>
Lexer<B>
createLexer(LexerTable<R> lexerTable, B buffer, LexerListener<? super R,? super B> listener, RuleActivator<R> activator, LifecycleHandler<B> lifecycleHandler, LexerErrorRecoveryPolicy<R,B> policy)
          Creates a new lexer process.
abstract  RuleActivator<?> getActivator()
          returns the RuleActivator used by this Lexer
 B getBuffer()
          returns the Buffer used by this Lexer
abstract  LexerErrorRecoveryPolicy<?,?> getLexerErrorRecoveryPolicy()
          Returns the LexerErrorRecoveryPolicy used by this lexer
abstract  LexerListener<?,?> getLexerListener()
          Returns the LexerListener this lexer notifies events to
 LifecycleHandler<B> getLifecycleHandler()
          Returns the LifecycleHandler for this lexer
abstract  void reset(B buffer)
          Reset the lexer to perform a new analysis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.umlv.tatoo.runtime.lexer.SimpleLexer
close, run, step
 

Method Detail

createLexer

public static <R,B extends LexerBuffer> Lexer<B> createLexer(LexerTable<R> lexerTable,
                                                             B buffer,
                                                             LexerListener<? super R,? super B> listener,
                                                             RuleActivator<R> activator,
                                                             LifecycleHandler<B> lifecycleHandler,
                                                             LexerErrorRecoveryPolicy<R,B> policy)
Creates a new lexer process.

Type Parameters:
R - type of rules.
B - type of buffer.
Parameters:
lexerTable - table representing automata used by the lexer.
buffer - character buffer the lexer has to process
listener - the token listener called after each token recognition
activator - the rule activator called before each token recognition start to determine the set of active rules
lifecycleHandler - handler called when reset or close the lexer.
Returns:
a new lexer.

getBuffer

public B getBuffer()
returns the Buffer used by this Lexer

Returns:
the Buffer used by this Lexer

getLifecycleHandler

public LifecycleHandler<B> getLifecycleHandler()
Returns the LifecycleHandler for this lexer

Returns:
the LifecycleHandler for this lexer

reset

public abstract void reset(B buffer)
Reset the lexer to perform a new analysis. All current states are discarded. The new buffer is the buffer supplied. This implementation calls LifecycleHandler.handleReset(Lexer) after the reset of the lexer.


getActivator

public abstract RuleActivator<?> getActivator()
returns the RuleActivator used by this Lexer

Returns:
the RuleActivator used by this Lexer

getLexerListener

public abstract LexerListener<?,?> getLexerListener()
Returns the LexerListener this lexer notifies events to

Returns:
the LexerListener this lexer notifies events to

getLexerErrorRecoveryPolicy

public abstract LexerErrorRecoveryPolicy<?,?> getLexerErrorRecoveryPolicy()
Returns the LexerErrorRecoveryPolicy used by this lexer

Returns:
the LexerErrorRecoveryPolicy used by this lexer