fr.umlv.tatoo.runtime.lexer
Class Lexer<R extends Rule,B extends CharacterBuffer>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.lexer.Lexer<R,B>
Type Parameters:
R - type of rules.
B - type of the buffer.

public final class Lexer<R extends Rule,B extends CharacterBuffer>
extends Object

A Lexer represents a lexer process.

Author:
julien

Method Summary
 void close()
           
static
<R extends Rule,B extends CharacterBuffer>
Lexer<R,B>
createLexer(B buffer, LexerListener<R,? super B> listener, R[] rules, ErrorHandler<? super B> errorHandler)
          Creates a new lexer process with a fix set of active rules.
static
<R extends Rule,B extends CharacterBuffer & ErrorContextBuffer<?>>
Lexer<R,B>
createLexer(B buffer, LexerListener<R,? super B> listener, RuleActivator<R> activator)
          Creates a new lexer process with default error handling.
static
<R extends Rule,B extends CharacterBuffer>
Lexer<R,B>
createLexer(B buffer, LexerListener<R,? super B> listener, RuleActivator<R> activator, ErrorHandler<? super B> errorHandler)
          Creates a new lexer process.
static
<R extends Rule,E extends CharacterBuffer & ErrorContextBuffer<?>>
Lexer<R,E>
createLexer(E buffer, LexerListener<R,? super E> listener, R[] rules)
          Creates a new lexer process with a fix set of active rules and a default error handler.
 void reset(B buffer)
          Resets the lexer processs with a new character buffer to process.
 void step()
          Processes next character of the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createLexer

public static <R extends Rule,B extends CharacterBuffer> Lexer<R,B> createLexer(B buffer,
                                                                                LexerListener<R,? super B> listener,
                                                                                RuleActivator<R> activator,
                                                                                ErrorHandler<? super B> errorHandler)
Creates a new lexer process.

Type Parameters:
R - type of rules.
B - type of the buffer.
Parameters:
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
errorHandler - the error handler to be used
Returns:
a new lexer.

createLexer

public static <R extends Rule,B extends CharacterBuffer> Lexer<R,B> createLexer(B buffer,
                                                                                LexerListener<R,? super B> listener,
                                                                                R[] rules,
                                                                                ErrorHandler<? super B> errorHandler)
Creates a new lexer process with a fix set of active rules.

Type Parameters:
R - type of rules.
B - type of the buffer.
Parameters:
buffer - character buffer the lexer has to process
listener - the token listener called after each token recognition
rules - set of rules
errorHandler - the error handler to be used
Returns:
a new lexer.

createLexer

public static <R extends Rule,B extends CharacterBuffer & ErrorContextBuffer<?>> Lexer<R,B> createLexer(B buffer,
                                                                                                       LexerListener<R,? super B> listener,
                                                                                                       RuleActivator<R> activator)
Creates a new lexer process with default error handling.

Type Parameters:
R - type of rules.
B - type of the huffer.
Parameters:
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
Returns:
the newly created lexer.

createLexer

public static <R extends Rule,E extends CharacterBuffer & ErrorContextBuffer<?>> Lexer<R,E> createLexer(E buffer,
                                                                                                       LexerListener<R,? super E> listener,
                                                                                                       R[] rules)
Creates a new lexer process with a fix set of active rules and a default error handler.

Type Parameters:
R - type of rules.
E - type of the buffer with an error handling macanism.
Parameters:
buffer - character buffer the lexer has to process
listener - the token listener called after each token recognition
rules - set of rules
Returns:
a new lexer.

reset

public void reset(B buffer)
Resets the lexer processs with a new character buffer to process.

Parameters:
buffer - the new character buffer to process

step

public void step()
Processes next character of the input stream. If a token has been recognized, the method ruleVerifed() of the TokenListener is called.

Throws:
LexingException - if the lexer encounters an unexpected character or end of file before a token has been unambiguously recognized

close

public void close()