fr.umlv.tatoo.runtime.lexer
Interface LexerListener<R,B>

Type Parameters:
R - type of rules.
B - type of buffers.

public interface LexerListener<R,B>

Interface defining an observer registered on a lexer that receive notifications of rule recognized.

Author:
Remi Forax
See Also:
Lexer.createLexer(LexerTable, fr.umlv.tatoo.runtime.buffer.LexerBuffer, LexerListener, RuleActivator, LifecycleHandler, LexerErrorRecoveryPolicy)

Method Summary
 void ruleVerified(R rule, int lastTokenLength, B buffer)
          This method is called each time a token is recognized by the lexer.
 

Method Detail

ruleVerified

void ruleVerified(R rule,
                  int lastTokenLength,
                  B buffer)
This method is called each time a token is recognized by the lexer. The way to extract the token value depends of the kind of buffer used by the lexer. If it's a the token buffer (TokenBuffer) the token can be get using method TokenBuffer.view(). Otherwise, the way to extract the token value depends on the buffer implementation. If the token is accepted by this listener, it should be discarded using the methods TokenBuffer.discard() or LexerBuffer.discard() otherwise the next token value will be concatenate with the current one.

Parameters:
rule - the rule verified
lastTokenLength - the length of the token recognized by the rule
buffer - the buffer containing the token to extract
Throws:
RuntimeException - the implementor of this interface could throw a runtime exception to signal an error.