Package eu.bandm.tscore.base
Class Translet.Parser<R>
java.lang.Object
eu.bandm.tscore.base.Translet.Parser<R>
- Direct Known Subclasses:
Translet._CAT
,Translet._CONST
,Translet._REGEX
,Translet.DisjunctionParser
,Translet.FramedParser
,Translet.HeadParser
,Translet.OptionParser
,Translet.ProductParser
,Translet.Recursive
,Translet.RepParser
,Translet.StorageWrapper
,TransletLib._TEST
- Enclosing class:
- Translet
Base class for all parser classes, contains most of the working methods.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
executeStoring
(Translet.State<R> s, Event e, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg) Execute the store operation represented by "this" parser.boolean
Whether the parser does directly consume character data.final Set<Translet.State<R>>
mparse
(Set<? extends Translet.State<?>> inStates, Set<Translet.Alternative> alternatives) "*M*ultiple Parse" means to apply the parser to a set of incomingTranslet.State
s, which represent the parsing situations reached so far.name
(boolean full) Returns a user-readable text representation.abstract Format
name
(boolean full, Map<Translet.Recursive, String> names) Returns a user-readable text representation.protected @Opt Translet.State<?>
parseEpsilon
(Translet.State<?> inState) Find one parse result which consumes no characters.protected abstract Set<Translet.State<R>>
parseOneState
(Translet.State<?> inState, Set<Translet.Alternative> alternatives) Calculate a set of possible successor states by applying this parser to the incoming state and append all altenatives found underways to the parameter "alternatives".stripOpt()
Returns the first nested parser which is NOT anTranslet.OptionParser
.toString()
Returns a user-readable text representation.toString
(boolean includeStoring) Returns a user-readable text representation.abstract String
Reverse the parsing process (as far as possible) and deliver a string representation which when parsed delivered the parse result.
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
isTerminal
public boolean isTerminal()Whether the parser does directly consume character data. (is true forTranslet._CONST
,Translet._CAT
andTranslet._REGEX
).- Returns:
- false
-
unparse
Reverse the parsing process (as far as possible) and deliver a string representation which when parsed delivered the parse result. -
stripOpt
Returns the first nested parser which is NOT anTranslet.OptionParser
. -
name
Returns a user-readable text representation. This is in most cases, but not always, source text to construct the parser.- Parameters:
full
- whether storing operators do appear in the rendering.
-
name
Returns a user-readable text representation. This is in most cases, but not always, source text to construct the parser.- Parameters:
full
- whether storage constructs do appear in the rendering.names
- a map for managing the renderings of recursive calls
-
toString
Returns a user-readable text representation. This corresponds to the source text to construct the parser.- Parameters:
includeStoring
- whether storage constructs do appear in the rendering.
-
toString
Returns a user-readable text representation. It callstoString(boolean)
with the argument set to true. -
executeStoring
public void executeStoring(Translet.State<R> s, Event e, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg) Execute the store operation represented by "this" parser. -
mparse
public final Set<Translet.State<R>> mparse(Set<? extends Translet.State<?>> inStates, Set<Translet.Alternative> alternatives) "*M*ultiple Parse" means to apply the parser to a set of incomingTranslet.State
s, which represent the parsing situations reached so far. ExecutesparseOneState(Translet.State,Set)
for each incoming state. Finally delivers one single set, the set union of all States resulting from these calls.
"alternatives" is an IN AND OUT parameter, and alternatives are collected in parallel with the parsing:- The parser as a whole is simply appended to all incoming alternatives, not considering its internal structure.
- In case there is no single result nor alternative returned in a particular parsing situation, this and the parser are turned into a new Alternative and added to this set.
- All Alternatives returned by sub-parser calls represent partly parsed sequences (i.e. matching of prefices) and are added to the returned set of alternatives.
-
parseEpsilon
Find one parse result which consumes no characters. (Alternatives are not accumulated)- Parameters:
inState
- the start state of parsing- Returns:
- a state after successful parsing zero charachters, if any
-
parseOneState
protected abstract Set<Translet.State<R>> parseOneState(Translet.State<?> inState, Set<Translet.Alternative> alternatives) Calculate a set of possible successor states by applying this parser to the incoming state and append all altenatives found underways to the parameter "alternatives". This method is specific to and overridden by the subclasses of Parser.
-