fr.umlv.tatoo.runtime.tools.builder
Class Builder.ExpertLexerBuilder<R,B extends LexerBuffer>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.tools.builder.Builder.ExpertLexerBuilder<R,B>
Type Parameters:
R - type of rules.
B - type of the buffer.
Enclosing class:
Builder

public static class Builder.ExpertLexerBuilder<R,B extends LexerBuffer>
extends Object

A lexer builder that configures the error policy and lifecycle handler of the lexer.


Method Summary
 Lexer<B> create()
          Creates a lexer with all values.
 Builder.ExpertLexerBuilder<R,B> defaultErrorPolicy(LexerErrorForwarder<B> forwarder, LexerWarningReporter<B> lexerWarningReporter)
          Configures the lexer error recovery policy with the default policy.
 Builder.ExpertLexerBuilder<R,B> defaultErrorPolicy(LexerWarningReporter<B> lexerWarningReporter)
          Configures the lexer error recovery policy with the default policy.
 Builder.ExpertLexerBuilder<R,B> errorPolicy(LexerErrorRecoveryPolicy<R,B> errorPolicy)
          Set a pluggable error recovery policy.
 Builder.ExpertLexerBuilder<R,B> lifecycleHandler(LifecycleHandler<B> lifecycleHandler)
          Configures a lifecycle handler for the lexer.
 Builder.ExpertLexerBuilder<R,B> noErrorPolicy()
          Configures the lexer error recovery policy to throw a lexing exception if a character is not recognized.
<T,N,P,V> Builder.AnalyzerFromParserBuilder<R,B,T,N,P,V>
parser(Parser<T,N,P,V> parser)
          Asks to configure the lexer with an existing parser.
<T,N,P,V> Builder.AnalyzerFromParserBuilder<R,B,T,N,P,V>
parser(Parser<T,N,P,V> parser, ToolsTable<R,T> toolsTable)
          Asks to configure the lexer with an existing parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

lifecycleHandler

public Builder.ExpertLexerBuilder<R,B> lifecycleHandler(LifecycleHandler<B> lifecycleHandler)
Configures a lifecycle handler for the lexer.

Parameters:
lifecycleHandler - a lifecycle handler.
Returns:
the current lexer builder.

noErrorPolicy

public Builder.ExpertLexerBuilder<R,B> noErrorPolicy()
Configures the lexer error recovery policy to throw a lexing exception if a character is not recognized.

Returns:
the current lexer builder.
See Also:
errorPolicy(LexerErrorRecoveryPolicy), NoLexerErrorRecoveryPolicy

defaultErrorPolicy

public Builder.ExpertLexerBuilder<R,B> defaultErrorPolicy(LexerErrorForwarder<B> forwarder,
                                                          LexerWarningReporter<B> lexerWarningReporter)
Configures the lexer error recovery policy with the default policy. The default policy forwards the lexing error to a lexer error forwarder the return value indicates if the lexer state must be reset to try to re-lex or if one character must be discarded. In that case, the lexer warning reporter will be called.

Parameters:
forwarder - an error forwarder
lexerWarningReporter - a warning reporter called each time a character is discarded.
Returns:
the current lexer builder.
See Also:
errorPolicy(LexerErrorRecoveryPolicy), defaultErrorPolicy(LexerWarningReporter), DefaultLexerErrorRecoveryPolicy

defaultErrorPolicy

public Builder.ExpertLexerBuilder<R,B> defaultErrorPolicy(LexerWarningReporter<B> lexerWarningReporter)
Configures the lexer error recovery policy with the default policy. If an error occurs during the parsing the offending character is removed and the lexing process continue with the following character. Each time a character is discarded, the warning reporter is called with an error message. If there is no more character and the lexer is closed and LexingException will be thrown.

Parameters:
lexerWarningReporter - a warning reporter called each time a character is discarded.
Returns:
the current lexer builder
See Also:
errorPolicy(LexerErrorRecoveryPolicy), defaultErrorPolicy(LexerErrorForwarder, LexerWarningReporter), DefaultLexerWarningReporter

errorPolicy

public Builder.ExpertLexerBuilder<R,B> errorPolicy(LexerErrorRecoveryPolicy<R,B> errorPolicy)
Set a pluggable error recovery policy. This policy will be called when a character is not recognized by any automata of the lexer.

Parameters:
errorPolicy - an error recovery policy
Returns:
the current builder

parser

public <T,N,P,V> Builder.AnalyzerFromParserBuilder<R,B,T,N,P,V> parser(Parser<T,N,P,V> parser,
                                                                       ToolsTable<R,T> toolsTable)
Asks to configure the lexer with an existing parser. The tools table is used to create a rule activator that will depend on the parser state.

Type Parameters:
T - type of terminals.
N - type of non-terminals
P - type of productions.
V - type of versions.
Parameters:
parser - a parser.
toolsTable - a tools table or null.
Returns:
an analyzer builder that is able to configure the link between a lexer and a parser.

parser

public <T,N,P,V> Builder.AnalyzerFromParserBuilder<R,B,T,N,P,V> parser(Parser<T,N,P,V> parser)
Asks to configure the lexer with an existing parser. This method is roughly equivalent to a call to parser(parser, null).

Type Parameters:
T - type of terminals.
N - type of non-terminals.
P - type of productions.
V - type of versions.
Parameters:
parser - a parser.
Returns:
an analyzer builder that is able to configure the link between a lexer and a parser.

create

public Lexer<B> create()
Creates a lexer with all values. If no error recovery policy is set, the default one is used with default warning reporter.

Returns:
a new Lexer configured with all options previously set.
See Also:
Lexer.createLexer(LexerTable, LexerBuffer, LexerListener, RuleActivator, LifecycleHandler, LexerErrorRecoveryPolicy)