public abstract static class Translet.ProductParser<R,A,B,C,D,E,F,G,H> extends Translet.Parser<R>
Class
object, from which a constructor is retrieved
by reflection.
// ????? FIXME The first method is type safe, the second is just "try and error".
A function may return any value, including null. All are taken as success.
To reject acceptance, the function must throw any exception, e.g. via a
MessageThrower
.
If neither function nor constructor is given, one new state will come out,
showing successful parsing, but its "result" field will be set to "null".
(In this case the storing of the results is
left to storage operators contained in the sub-expressions.)Modifier and Type | Field and Description |
---|---|
protected int |
arity
Arity of the tuple type, intended to be in the range 2 to 8.
|
protected @Opt Class<R> |
cons
Constructor to pack the sub-results into one result.
|
protected List<Constructor<R>> |
constructors
List of all constructors found for the result type R by reflection.
|
protected @Opt Object |
f
Function to pack the sub-results into one result.
|
protected Translet.Parser<A> |
p0
Parser of the 0th subresult.
|
protected Translet.Parser<B> |
p1
Parser of the 1st subresult.
|
protected Translet.Parser<C> |
p2
Parser of the 2nd subresult.
|
protected Translet.Parser<D> |
p3
Parser of the 3rd subresult.
|
protected Translet.Parser<E> |
p4
Parser of the 4th subresult.
|
protected Translet.Parser<F> |
p5
Parser of the 5th subresult.
|
protected Translet.Parser<G> |
p6
Parser of the 6th subresult.
|
protected Translet.Parser<H> |
p7
Parser of the 7th subresult.
|
(package private) @Opt Translet.Parser<?> |
separator
A separator which must be appear between two (non-epsilon) applications of
two sub-parsers.
|
protected Translet.Parser<?>[] |
subParsers
List of all sub-parsers, needed for name generation and parser loops.
|
Modifier | Constructor and Description |
---|---|
protected |
ProductParser(int arity,
@Opt Object f,
@Opt Class<R> cons,
Translet.Parser<A> p0,
@Opt Translet.Parser<B> p1,
@Opt Translet.Parser<C> p2,
@Opt Translet.Parser<D> p3,
@Opt Translet.Parser<E> p4,
@Opt Translet.Parser<F> p5,
@Opt Translet.Parser<G> p6,
@Opt Translet.Parser<H> p7)
Only constructor, called by the sub-classes.
|
Modifier and Type | Method and Description |
---|---|
protected R |
applyConstructor(Object[] args)
Tries to apply the constructors collected in
constructors , one
after the other, until the first succeeds. |
protected Format |
name_0(boolean full,
Map<Translet.Recursive,String> names,
String myConstructor)
Construct the part of the names which is common for all subclasses.
|
Translet.ProductParser<R,A,B,C,D,E,F,G,H> |
withSeparator(String sep)
Set the separator which must appear between two non-epsilon-consuming
applications of the sub-parsers.
|
Translet.ProductParser<R,A,B,C,D,E,F,G,H> |
withSeparator(Translet.Parser<?> sep)
Set the separator which must appear between two non-epsilon-consuming
applications of the sub-parsers.
|
executeStoring, isTerminal, mparse, name, name, parseEpsilon, parseOneState, stripOpt, toString, toString, unparse, wrapResult
protected final int arity
@Opt protected final @Opt Object f
@Opt protected final @Opt Class<R> cons
protected final Translet.Parser<A> p0
protected final Translet.Parser<B> p1
protected final Translet.Parser<C> p2
protected final Translet.Parser<D> p3
protected final Translet.Parser<E> p4
protected final Translet.Parser<F> p5
protected final Translet.Parser<G> p6
protected final Translet.Parser<H> p7
protected final List<Constructor<R>> constructors
protected final Translet.Parser<?>[] subParsers
@Opt @Opt Translet.Parser<?> separator
protected ProductParser(int arity, @Opt @Opt Object f, @Opt @Opt Class<R> cons, Translet.Parser<A> p0, @Opt @Opt Translet.Parser<B> p1, @Opt @Opt Translet.Parser<C> p2, @Opt @Opt Translet.Parser<D> p3, @Opt @Opt Translet.Parser<E> p4, @Opt @Opt Translet.Parser<F> p5, @Opt @Opt Translet.Parser<G> p6, @Opt @Opt Translet.Parser<H> p7)
Translet.na
if not required.
Either a function can given by "f" or a class by "cons".
If neither, the results are discarded.public Translet.ProductParser<R,A,B,C,D,E,F,G,H> withSeparator(Translet.Parser<?> sep)
public Translet.ProductParser<R,A,B,C,D,E,F,G,H> withSeparator(String sep)
protected R applyConstructor(Object[] args)
constructors
, one
after the other, until the first succeeds.IllegalArgumentException
- iff no success.protected Format name_0(boolean full, Map<Translet.Recursive,String> names, String myConstructor)
full
- whether to show all technical details of the parser expressionnames
- for displaying recursive referencesmyConstructor
- the name of the parse constructor to display