|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfr.umlv.tatoo.runtime.parser.Parser<T,N,P,V>
T - type of terminal.N - type of non-terminal.P - type of production.V - type of version.public class Parser<T,N,P,V>
Tatoo parser class.
Builder.parser(ParserTable)| 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. |
|
static
|
createParser(ParserTable<T,N,P,V> table,
ParserListener<? super T,? super N,? super P> listener,
ParserErrorRecoveryPolicy<T,N,P,V> policy,
N start,
V version,
LookaheadMap<? extends T,? super V> lookaheadMap)
Creates a parser. |
|
static
|
formatMessage(SimpleParser<T> parser,
String message,
T terminal)
Default way to create a message from arguments |
|
int |
getBranchingLevel()
Returns current the number of recursive call to this parser. |
|
BranchingParserListener<? super T> |
getBranchingParserListener()
Returns the branching parser listener associated with the current parser. |
|
Set<? extends T> |
getLookahead()
Returns the set of terminals which don't lead to an error for the current state with the current version. |
|
LookaheadMap<? extends T,? super V> |
getLookaheadMap()
Returns the lookahead map. |
|
ParserListener<? super T,? super N,? super P> |
getParserListener()
Returns the parser listener associated with the current parser. |
|
N |
getStartNonTerminal()
Returns the start non-terminal |
|
ReadOnlyIntStack |
getStateStack()
Returns a view on the current parser state stack. |
|
ParserTable<T,N,P,V> |
getTable()
Returns the table associated with the parser. |
|
V |
getVersion()
|
|
boolean |
isBranchingParser()
Returns true if the current parser is a branching parser |
|
void |
push(N start,
V version)
Push a new context into the state stack |
|
boolean |
push(T next)
Performs the actions induced by a particular terminal. |
|
void |
reset()
Resets the parser and clears the state stack. |
|
void |
reset(N start)
Resets the parser, clears the state stack and changes a new start non-terminal and reset the error recovery policy. |
|
void |
setBranchingParserListener(BranchingParserListener<? super T> branchingParserListener)
Set the branching parser listener associated with the current parser. |
|
void |
setVersion(V version)
Change the version. |
|
void |
step(T next)
Performs the actions induced by a particular terminal. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T,N,P,V> Parser<T,N,P,V> createParser(ParserTable<T,N,P,V> table,
ParserListener<? super T,? super N,? super P> listener,
ParserErrorRecoveryPolicy<T,N,P,V> policy,
N start,
V version,
LookaheadMap<? extends T,? super V> lookaheadMap)
T - type of terminal.N - type of non-terminal.P - type of production.V - type of version.table - the table produced by Tatoo.lookaheadMap - a map of valid terminals in a particular state.listener - the listener of parser actions.policy - the error recovery policy.start - the start non-terminal.version -
IllegalStateException - if the initial state
corresponding to the non-terminal is incompatible with the version.reset(Object),
setVersion(Object)public void reset()
reset() is roughly equivalent
to a call to reset(Object) with the current
start non-terminal.
reset in interface SimpleParser<T>public void reset(N start)
start - the new start non-terminal.
IllegalStateException - if the initial state
corresponding to the non-terminal is incompatible with the current version.reset(),
push(Object,Object),
ParserErrorRecoveryPolicy.reset()public void setVersion(V version)
version - version of the grammar
IllegalStateException - if the state stack contains
incompatible state with the version.reset(Object)public N getStartNonTerminal()
reset(Object)
public void push(N start,
V version)
start - the new start non-terminal.version - new versionclose(),
reset(Object)public Set<? extends T> getLookahead()
getLookahead in interface SimpleParser<T>null if no lookahead states was provided
at construction of the parser.public V getVersion()
public LookaheadMap<? extends T,? super V> getLookaheadMap()
getLookaheadMap in interface SimpleParser<T>null if no lookahead
map was provided at construction of the parser or
by reset(Object).public ParserListener<? super T,? super N,? super P> getParserListener()
public BranchingParserListener<? super T> getBranchingParserListener()
public void setBranchingParserListener(BranchingParserListener<? super T> branchingParserListener)
branchingParserListener - the new sub-parser listener or null.public boolean isBranchingParser()
isBranchingParser in interface SimpleParser<T>setBranchingParserListener(BranchingParserListener)public int getBranchingLevel()
push.
public static <T> String formatMessage(SimpleParser<T> parser,
String message,
T terminal)
T - terminals typeparser - the parsermessage - the message to include in the outputterminal - the terminal that caused this message
public ParserTable<T,N,P,V> getTable()
getTable in interface SimpleParser<T>public ReadOnlyIntStack getStateStack()
push(Object)
or close() then returned view is modified.
getStateStack in interface SimpleParser<T>ReadOnlyIntStack.duplicate()
public ActionReturn branchOnError(T terminal,
String message)
branchOnError in interface SimpleParser<T>SimpleParser.isBranchingParser(),
ParserErrorRecoveryPolicy.recoverOnError(Parser, IntArrayList, Object, String)public void step(T next)
SimpleParser.push(Object)
followed by a runtime check on step return value.
step in interface SimpleParser<T>next - the terminal.SimpleParser.push(Object),
ParserForwarder.forwardUnexpectedCharacter(fr.umlv.tatoo.runtime.lexer.Lexer)public boolean push(T next)
SimpleParser.step(Object).
If you want to call this method without taking into account the return value
use next(terminal) instead.
push in interface SimpleParser<T>next - the new terminal
public void close()
close in interface SimpleParser<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||