Package eu.bandm.tscore.base
Class Translet.State<R>
java.lang.Object
eu.bandm.tscore.base.Translet.State<R>
- Enclosing class:
- Translet
Central data type for parser operation. Combines input situation, currently
applied
Translet.Parser
, delivered Result, and the preceding state, thus
forming a kind of parse tree in post order notation:
_______/ ----------- Parser(SEQU) ________________________/ ______/ ^ Parser Parser | ^ ^ | | |.parser | +------------+ .pre +------------+ .pre +------------+ | State | <---- | State | <----- | State | +------------+ +------------+ +------------+ |.s |.pos v v "toConsume"State objects are added (a) when input characters are consumed, (b) when functions are applied for further result generation, or (c) when a storage action must be memorized for later execution.
".s" is constant and always simply copied, to be accessible by the terminal symbol parsing functions; ".pos" is advancing and reflects the situation AFTER ".parser" has consumed.
Parsing is executed in a breadth-first search, so that finally different successful parsing trees can coexist. All STORING operations are not yet performed but done ex-parte-post, after one of these solutions has been selected.
-
Field Summary
Modifier and TypeFieldDescription(package private) final int
FIXME ????static final Predicate<Translet.State>
(package private) final Translet.Parser<R>
The translet parser which has consumed to produce this state.(package private) final int
The position after parsing.(package private) final @Opt Translet.State<?>
The preceding state.(package private) final R
(package private) final String
The input data on which all parsers operate. -
Method Summary
Modifier and TypeMethodDescriptionboolean
atEnd()
Return whether parsing has reached the end of the input string.consumed()
Returns the character input consumed DIRECTLY by the parser of this state, i.e.void
executeStoring
(Event e, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg) Step back through the chain of parser states and execute all store operation.static Translet.State<Object>
Create an initial state with only the input data, no parser or result yet.Return the current rest of the input string.Deliver printable representation only of this state.<N,
M extends N>
Translet.State<N>succ
(Translet.Parser<N> parser, int pos, M result) Return a new State, which is successor of "this", and in which "parser" has delivered "result" and consumed input up to "pos".<N,
M extends N>
Translet.State<N>succ
(Translet.Parser<N> parser, M result) Return a new State, which is successor of "this", and in which "parser" has delivered "result", but no input has been consumed.toString()
Deliver printable representation of the whole chain of states ending here.
-
Field Details
-
parser
The translet parser which has consumed to produce this state. -
pre
The preceding state. Only == null for the very first state. -
s
The input data on which all parsers operate. -
pos
final int posThe position after parsing. -
depth
final int depthFIXME ???? -
result
-
p_atEnd
-
-
Method Details
-
initState
Create an initial state with only the input data, no parser or result yet. -
succ
Return a new State, which is successor of "this", and in which "parser" has delivered "result", but no input has been consumed. -
succ
Return a new State, which is successor of "this", and in which "parser" has delivered "result" and consumed input up to "pos". -
executeStoring
public void executeStoring(Event e, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg) Step back through the chain of parser states and execute all store operation. This is delegated toTranslet.Parser.executeStoring(Translet.State,Event,Location,MessageReceiver)
. Only the instances of some dedicated parser classes really execute storing.- Parameters:
e
- the event which is used as key for all the data mapsloc
- the location of the whole expression, used in all error messages generated by storing.msg
- drain of error messages.
-
atEnd
public boolean atEnd()Return whether parsing has reached the end of the input string. -
consumed
Returns the character input consumed DIRECTLY by the parser of this state, i.e. iff it is a terminal symbol. Both ".pos" and ".pre.pos" must be considered. -
lookingAt
Return the current rest of the input string. -
simpleString
Deliver printable representation only of this state. -
toString
Deliver printable representation of the whole chain of states ending here.
-