fr.umlv.tatoo.runtime.parser
Interface SimpleParser<T>

Type Parameters:
T - type of terminal.
All Known Implementing Classes:
Parser

public interface SimpleParser<T>

Author:
Remi

Method Summary
 ActionReturn branchOnError(T terminal, String message)
          Signals to the parser an external error, (by example a lexer error) has occurred allowing the parser to try to branch (enter or exit from the current grammar).
 void close()
          Indicates to the parser that there is no more terminals.
 Set<? extends T> getLookahead()
          Returns the set of terminals which don't lead to an error for the current state.
 LookaheadMap<? extends T,?> getLookaheadMap()
          Returns the lookahead map.
 ReadOnlyIntStack getStateStack()
          Returns a view on the current parser state stack.
 ParserTable<T,?,?,?> getTable()
          Returns the table associated with the parser.
 boolean isBranchingParser()
          Returns true if the current parser is a branching parser
 boolean push(T next)
          Performs the actions induced by a particular terminal.
 void reset()
          Resets the parser and clears the state stack.
 void step(T next)
          Performs the actions induced by a particular terminal.
 

Method Detail

isBranchingParser

boolean isBranchingParser()
Returns true if the current parser is a branching parser

Returns:
true if the current parser is a branching parser

push

boolean push(T next)
Performs the actions induced by a particular terminal. Return false if error recovery asks for relexing which means that the lexer should reconsider its active rule set and true otherwise. If this feature is used lexical semantic actions must not have already been performed. Caller may ignore false advice by calling this method again, or directly calling step(Object). If you want to call this method without taking into account the return value use next(terminal) instead.

Parameters:
next - the new terminal
Returns:
false if error recovery asks for relexing which means that the lexer should reconsider its active rule set and true if next token is required

step

void step(T next)
Performs the actions induced by a particular terminal. This method must be used with lexer that doesn't listen parser lookahead set. This call is roughly equivalent to a call to push(Object) followed by a runtime check on step return value.

Parameters:
next - the terminal.
Throws:
IllegalStateException - if lexer error policy ask for a relexing.
See Also:
push(Object), ParserForwarder.forwardUnexpectedCharacter(fr.umlv.tatoo.runtime.lexer.Lexer)

reset

void reset()
Resets the parser and clears the state stack.


close

void close()
Indicates to the parser that there is no more terminals.


getLookahead

Set<? extends T> getLookahead()
Returns the set of terminals which don't lead to an error for the current state. This is roughly equivalent to a call to getLookaheadMap().get(getStateStack().last()).

Returns:
a set of terminals or null if no lookahead states was provided at construction of the parser.

getLookaheadMap

LookaheadMap<? extends T,?> getLookaheadMap()
Returns the lookahead map.

Returns:
the lookahead map or null if no lookahead map was provided at construction of the parser.

getStateStack

ReadOnlyIntStack getStateStack()
Returns a view on the current parser state stack.

Returns:
an unmodifiable list of states.

getTable

ParserTable<T,?,?,?> getTable()
Returns the table associated with the parser.

Returns:
the parser table.

branchOnError

ActionReturn branchOnError(T terminal,
                           String message)
Signals to the parser an external error, (by example a lexer error) has occurred allowing the parser to try to branch (enter or exit from the current grammar).

See Also:
isBranchingParser(), ParserErrorRecoveryPolicy.recoverOnError(Parser, IntArrayList, Object, String)