|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface State
The interface for a global parser state object.
To correctly integrate with a memoizing parser, global state for parsers generated by Rats! is modified through light-weight, nested transactions, as expressed through this interface. A grammar utilizing global state needs to have a globalstateful attribute, whose value is the
name of the class implementing this interface. The class, in turn,
must have a no-argument constructor, which is used to create the
global state object.
Each production that resets the global state (i.e., serves as
a top-level entry point) needs to be marked with the resetting attribute. At the beginning
of the method representing such a production, the global state is
reset by calling reset(String).
Each production that might modify the global state (or that
depends on other productions that modify the global state) needs to
be marked with the stateful
attribute. At the beginning of the method representing such a
production, a new transaction is started by calling start(). This transaction is completed on a successful parse by
calling commit() and on an erroneous parse by calling
abort().
| Method Summary | |
|---|---|
void |
abort()
Abort a state-modifying transaction. |
void |
commit()
Commit a state-modifying transaction. |
void |
reset(java.lang.String file)
Reset the global state object. |
void |
start()
Start a new state-modifying transaction. |
| Method Detail |
|---|
void reset(java.lang.String file)
resetting attribute.
file - The file name.void start()
stateful attribute.
void commit()
stateful attribute.
void abort()
stateful attribute.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||