Package eu.bandm.tscore.base
Class Translet.RepParser<D>
- Direct Known Subclasses:
Translet.PlusParser
,Translet.StarParser
- Enclosing class:
- Translet
Common superclass for
Translet.StarParser
and Translet.PlusParser
.-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether this constructor behaves greedy.protected boolean
Whether this constructor treats no match at all as an accept case.protected @Opt Translet.Parser<?>
An optional additional non-terminal parser, which must accept between the repetitions.protected Translet.Parser<D>
The repeated sub-parser. -
Constructor Summary
ModifierConstructorDescriptionprotected
RepParser
(Translet.Parser<D> sub, Translet.Parser<?> sep, boolean greedy, boolean isStar) Constructor only called by factory methods -
Method Summary
Modifier and TypeMethodDescriptionname
(boolean full, Map<Translet.Recursive, String> names) Returns a user-readable text representation.Set<Translet.State<List<D>>>
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".protected void
parseProlongation
(List<D> prefix, Translet.State<?> inState, Set<Translet.Alternative> alternatives, Set<Translet.State<List<D>>> allResults) Basic parser procedure for all four kinds of RepParsers.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, stripOpt, toString, toString
-
Field Details
-
sub
The repeated sub-parser. -
sep
An optional additional non-terminal parser, which must accept between the repetitions. -
greedy
protected boolean greedyWhether this constructor behaves greedy. -
isStar
protected boolean isStarWhether this constructor treats no match at all as an accept case.
-
-
Constructor Details
-
RepParser
Constructor only called by factory methods
-
-
Method Details
-
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<List<D>>
-
parseProlongation
protected void parseProlongation(List<D> prefix, Translet.State<?> inState, Set<Translet.Alternative> alternatives, Set<Translet.State<List<D>>> allResults) Basic parser procedure for all four kinds of RepParsers. Parses new instances after a certain prefix has already been parsed. Adds a result for the incoming prefix if no prolongation is possible or (under the way) if parser is not greedy. Epsilon-productions may appear at most once.- Parameters:
prefix
- already parsed instances of the contentalternatives
- output parameter for accepted partial preficesallResults
- output accu for all result states
-
parseOneState
public Set<Translet.State<List<D>>> 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.. Here it callsparseProlongation(List,Translet.State,Set,Set)
- Specified by:
parseOneState
in classTranslet.Parser<List<D>>
-
name
Description copied from class:Translet.Parser
Returns a user-readable text representation. This is in most cases, but not always, source text to construct the parser.- Specified by:
name
in classTranslet.Parser<List<D>>
- Parameters:
full
- whether storage constructs do appear in the rendering.names
- a map for managing the renderings of recursive calls
-