| xtc.util.State
All known Subclasses: xtc.lang.CParserState, xtc.parser.PParserState,
State | public interface State (Code) | | 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 global
xtc.Constants.ATT_STATEFUL stateful 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
xtc.Constants.ATT_RESETTING resetting attribute. At the beginning
of the method representing such a production, the global state is
reset by calling
State.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
xtc.Constants.ATT_STATEFUL stateful attribute. At the beginning of the method representing such a
production, a new transaction is started by calling
State.start() . This transaction is completed on a successful parse by
calling
State.commit() and on an erroneous parse by calling
State.abort() .
author: Robert Grimm version: $Revision: 1.9 $ |
Method Summary | |
void | abort() Abort a state-modifying transaction. | void | commit() Commit a state-modifying transaction. | void | reset(String file) Reset the global state object. | void | start() Start a new state-modifying transaction. |
abort | void abort()(Code) | | Abort a state-modifying transaction. This method is called on an
erroneous parse before returning from a method representing a
production with the stateful attribute.
|
commit | void commit()(Code) | | Commit a state-modifying transaction. This method is called on a
successful parse before returning from a method representing a
production with the stateful attribute.
|
reset | void reset(String file)(Code) | | Reset the global state object. This method is called at the
beginning of each method representing a production with the
resetting attribute.
Parameters: file - The file name. |
start | void start()(Code) | | Start a new state-modifying transaction. This method is called
at the beginning of each method representing a production with
the stateful attribute.
|
|
|