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:
ErrorForwarder<B>, LifecycleHandler<B>

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

This class implements a lexer error handler and a lexer lifecycle handler. The lexer error handler part forwards error to the parser branching mechanism (see SimpleParser.branchOnError(Object, String)) or 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 handleClose(Lexer<B> lexer)
          Called after the lexer is closed.
 void handleReset(Lexer<B> lexer)
          Called after the lexer is reseted.
 
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 ErrorForwarder<B extends LexerBuffer>
Parameters:
lexer - the buffer that push the character
Returns:
false if lexer must discard input

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 ErrorForwarder<B extends LexerBuffer>
Parameters:
lexer - the buffer

handleReset

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

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

handleClose

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

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