Package eu.bandm.tscore.base
Class Translet.OptionParser<D>
java.lang.Object
eu.bandm.tscore.base.Translet.Parser<D>
eu.bandm.tscore.base.Translet.OptionParser<D>
- Enclosing class:
- Translet
Option parser, in greedy and non-deterministic variant, with or without default value.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionOptionParser
(Translet.Parser<D> sub, D deflt, boolean greedy) Constructor called by the factory methods. -
Method Summary
Modifier and TypeMethodDescriptionname
(boolean full, Map<Translet.Recursive, String> names) Returns a user-readable text representation.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
.Reverse the parsing process (as far as possible) and deliver a string representation which when parsed delivered the parse result.Methods inherited from class eu.bandm.tscore.base.Translet.Parser
executeStoring, isTerminal, mparse, name, parseEpsilon, toString, toString
-
Field Details
-
sub
The sub-parser to parse or ski. -
deflt
Default value, returned when sub-parser did not match. -
greedy
protected boolean greedyWhether parser behaves greedily or non-deterministically. In the latter case it returns two results when the sub-parser matches: One with and one without this match.
-
-
Constructor Details
-
OptionParser
Constructor called by the factory methods.
-
-
Method Details
-
stripOpt
Description copied from class:Translet.Parser
Returns the first nested parser which is NOT anTranslet.OptionParser
.- Overrides:
stripOpt
in classTranslet.Parser<D>
-
unparse
Description copied from class:Translet.Parser
Reverse the parsing process (as far as possible) and deliver a string representation which when parsed delivered the parse result.- Specified by:
unparse
in classTranslet.Parser<D>
-
parseOneState
public Set<Translet.State<D>> parseOneState(Translet.State<?> inState, Set<Translet.Alternative> alternatives) Description copied from class:Translet.Parser
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.- Specified by:
parseOneState
in classTranslet.Parser<D>
-
name
Returns a user-readable text representation. for this class it is not the reverse of a constructor call, but a symbolic representation "[content]?
" for the non-greedy and . "[content]?_
" for the greedy variant. If sub-parser isCONST("")
with no default and full==false, then dismiss completely.- Specified by:
name
in classTranslet.Parser<D>
- Parameters:
full
- whether storing operators do appear in the rendering.names
- map to handle recursive loops in the parser structure.
-