fr.umlv.tatoo.runtime.tools
Class ParserForwarder<T,B extends LexerBuffer>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.tools.ParserForwarder<T,B>
All Implemented Interfaces:
LexerErrorForwarder<B>, LifecycleHandler<B>

public class ParserForwarder<T,B extends LexerBuffer>
extends Object
implements LexerErrorForwarder<B>, LifecycleHandler<B>

This class implements a lexer error forwarder and a lexer lifecycle handler. The lexer error forwarder part forwards error to the parser branching mechanism (see SimpleParser.branchOnError(Object, String)) or the error recovery mechanism. The lifecycle handler part forwards the close (resp. reset) event in order to close (resp. reset) the parser.

Author:
Remi Forax

Constructor Summary
ParserForwarder(SimpleParser<T> parser)
          Creates a parser forwarder.
 
Method Summary
 ForwardReturn forwardUnexpectedCharacter(Lexer<B> lexer)
          Forwards unexpected character found during the lexing process.
 void forwardUnexpectedEndOfFile(Lexer<B> lexer)
          Forwards unexpected end of file during the lexing process.
 void lexerClosed(Lexer<B> lexer)
          Called after the lexer is closed.
 void lexerReset(Lexer<B> lexer)
          Called after the lexer is reset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserForwarder

public ParserForwarder(SimpleParser<T> parser)
Creates a parser forwarder.

Parameters:
parser - the parser that will be notified
Method Detail

forwardUnexpectedCharacter

public ForwardReturn forwardUnexpectedCharacter(Lexer<B> lexer)
Forwards unexpected character found during the lexing process. This implementation tries to SimpleParser.branchOnError(Object, String)

Specified by:
forwardUnexpectedCharacter in interface LexerErrorForwarder<B extends LexerBuffer>
Parameters:
lexer - the buffer that push the character
Returns:
DISCARD if lexer must discard input or RETRY otherwise

forwardUnexpectedEndOfFile

public void forwardUnexpectedEndOfFile(Lexer<B> lexer)
Forwards unexpected end of file during the lexing process. If it returns, lexer considers that error is recovered and exits without exception nor warning. This implementation simply tries to SimpleParser.branchOnError(Object, String).

Specified by:
forwardUnexpectedEndOfFile in interface LexerErrorForwarder<B extends LexerBuffer>
Parameters:
lexer - the buffer

lexerReset

public void lexerReset(Lexer<B> lexer)
Called after the lexer is reset. This implementation reset the parser.

Specified by:
lexerReset in interface LifecycleHandler<B extends LexerBuffer>
See Also:
Lexer.reset(fr.umlv.tatoo.runtime.buffer.LexerBuffer)

lexerClosed

public void lexerClosed(Lexer<B> lexer)
Called after the lexer is closed. This implementation close the parser.

Specified by:
lexerClosed in interface LifecycleHandler<B extends LexerBuffer>
See Also:
SimpleLexer.close()