Class Translet
The application to a track of a timescape model is done by calling a utility
function from Util
.
The static factory methods in this class realize combinators for
the construction of parsers. Some specialized basic parsers can be found in
TransletLib
; instructive examples can be found in
MaWiCM
etc.; see also the
user documentation.
Implementation:
Parsing is done in brute-force breadth-first, which is feasible thanks to
relatively small input sizes.
Error diagnosis is included as first-class resident by collecting all
failed attempts, in parallel to the successful.
This is realized by all functions operating on a SET of Translet.State
, each
representing such a parsing hypothesis.
The type parameter of any Translet.Parser
is the type of its result.
This type is the fundamental means to direct or reject all combinator applications.
It is extensively checked by all static combinator methods, including
the store operations which deliver the final conversion results for further
processing. This strategy heavily contributes to the overall type safety of
the resulting network.
Furthermore, types are mostly inferred when using the static constructor methods,
which increases compactness and elegance of notation.
The Translet.State
object duplicates the type parameter of the related parser.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Implements a greedy longest prefix match from a collection of strings.static class
Parser for a simple string constant which must appear verbatim, as is.static class
Parser for text input following a regular expression.protected static class
Realizes a protocol tree of alternatives to the parsing results.static class
Common superclass for Parsers which accept one of many alternatives and return aCoTuple
(ORn and PRIORn).(package private) static enum
Kinds of disjunctive parser combinators.static class
Common superclass for Parsers which accept one of many alternatives.static class
Format printer which puts maximally one ParserFormat to each screen column and memorizes this for later alignment of consumed char data.static class
Accepts a sequence "A,B,C", where only the middle parsing/processing result is stored as result in theTranslet.State
object, discarding the frame.static class
Accepts a sequence "A,B,..", where only the very first parsing/processing result is stored as result in theTranslet.State
object, discarding all the tail.static class
Common superclass for Parsers which accept one of many alternatives and return the upper limit of the different result classes (OR1 and PRIOR1).static class
Option parser, in greedy and non-deterministic variant, with or without default value.static class
Realizes disjunction which is nondeterministic and returns a CoTuple.static class
Realizes disjunction which is nondeterministic and returns an upper limit class.static interface
Used to retrieve aTranslet.Parser
in a particular (human) language, to plug it into the tscore parsing process.static class
Base class for all parser classes, contains most of the working methods.static class
Specialized Format which refers to a Parser for alignment of char data.static class
Variant ofTranslet.ProductParser
which accepts all permutations of sub-parsers.static class
Repetition parser which does not allow allow empty list as result.static class
Realizes disjunction which is priorized and returns a CoTuple.static class
Realizes disjunction which is priorized and returns an upper limit class.static class
Common superclass for Parsers which produce a product type as their result.static final class
A placeholder which can be formandum into a parser construct, and later be assigned the complete parser as a whole, for recursive use.static class
Common superclass forTranslet.StarParser
andTranslet.PlusParser
.static class
Variant ofTranslet.ProductParser
which accepts a certain sequence of sub-parsers.static class
Repetition parser which allows empty list as result.static class
Central data type for parser operation.static class
Common superclass of the storing oeprators.static class
Storing operator which only one(1) value per key.static class
Storing operator which can store multiple (>1) values per key, preserving the sequential order in the source.static class
Storing operator which can store multiple (>1) values per key. -
Field Summary
Modifier and TypeFieldDescriptionprotected static eu.bandm.tools.location.LocationMap<Object,
eu.bandm.tools.util.xml.XMLDocumentIdentifier> Maps the zero-th line of an "Object" type location to the zero-th line of an "XMLDocumentIdentifier" type location.static final char
Appended to any input string as final delimiter.static final String
Appended to any input string as final delimiter.(package private) static final Translet.Parser<String>
A parser matching an empty character sequecen in the input.static final Format
Format containing an closing parenthesis.static final Format
Format containing an opening square bracket.static final Format
Format containing a comma.static final Format
Format containing a comma and a space.static final Format
Format containing a double quote.static final Format
Format to indicate "greediness" when building the name of a repetition or option parser.static final int
Default indetation depth for nested format.static final Format
Format containing an closing parenthesis.static final Format
Format containing an opening parenthesis.static final int
static final eu.bandm.tscore.base.Translet.NA
One instance of NA is enough (all parser terms are algebraic) and can be used everywhere.static eu.bandm.tscore.base.Translet.NonGreedy
Marker object to distinguish greedy and non-greedy (=non-deterministic) variants.static final eu.bandm.tools.location.Location<Object>
Constant location at column number 0. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static <R> Set<Translet.State<R>>
__SET_CAST
(Set<? extends Translet.State<?>> set) Aux function for casting a "Set<State<?>>" into a "Set<State<R>>", where R must be given explicitly by "Translet.<R>setCast(...)".static Translet._CAT<String>
Factory method for a catalog parser with a list of inputs texts = result objects.static Translet._CAT<String>
CAT
(Collection<String> s) Factory method for a catalog parser with a list of inputs texts = result objects.static Translet._CAT<String>
Factory method for a catalog parser with a list of inputs texts = result objects.static <R> Translet._CAT<R>
Factory method for a catalog parser with a map of inputs texts to result objects.static Translet._CONST<String>
Factory method for a const parser where the accepted string is the parsing result.static <X> Translet._CONST<X>
Factory method for a const parser with explicit parsing result.protected static void
disj_makeAlternative
(Translet.disj_flavour flavour, Translet.State<?> inState, Set<Translet.Alternative> alternatives, List<Translet.Parser<?>> notHit, Set<Translet.Alternative> subAlts) Constructs a new disjunction parser of the given kind with all failed sub-parser, to add this new expression to alternatives.protected static Format
disj_makeName
(String operator, boolean full, Map<Translet.Recursive, String> names, Translet.Parser<?> p1, Translet.Parser<?> p2, Translet.Parser<?> p3, Translet.Parser<?> p4) Construct the pretty-print name for a disjunctive parser.protected static <R,
S> void disj_testOneBranch
(Translet.DisjunctionParser<S> disj_parser, Translet.Parser<R> parser, List<Translet.Parser<?>> notHit, int index, Translet.State<?> inState, Set<Translet.State<S>> outStates, Set<Translet.Alternative> alternatives) Tests one of the branch-parsers (with the given index) of the disj_parser, with the given start state.static <R> void
displayBindings
(CatalogByString cat, List<String> prefs, PrintStream ps, int width, boolean full, Object locationtext, Translet.Parser<?> parser, Set<Translet.State<R>> results, @Opt Translet.State<R> selected, @Opt Set<Translet.State<R>> rests, @Opt Set<Translet.Alternative> alts, Modifiers modifiers, boolean showAlts, boolean showRests) Presents all collected prefixes of possible parse trees to the user for error diagnosis.static <R> void
displayBindings
(CatalogByString cat, List<String> prefs, PrintWriter pw, int width, boolean full, @Opt Object locationtext, Translet.Parser<?> parser, @Opt Set<Translet.State<R>> results, @Opt Translet.State<R> selected, Set<Translet.State<R>> rests, Set<Translet.Alternative> alts, Modifiers modifiers, boolean showAlts, boolean showRests) Show complete parsing situation on a PrintStream, possibly multi-lingual.static int
displayOneBinding
(PrintWriter pw, Translet.FormatPrinter_memo positions, @Opt Translet.State<?> result, Modifiers modifiers) Prints one prefix of a parse tree, i.e.static final <T> eu.bandm.tscore.base.Translet.Fail<T>
FAIL()
One instance of NA is enough (all parser terms are algebraic) and can be used everywhere.protected static <R> R
findResult
(Translet.State<?> start, Set<Translet.State<R>> set) Provide "deflt=null" forfindResult(State, Set, Object)
.protected static <R> R
findResult
(Translet.State<?> start, Set<Translet.State<R>> set, R deflt) Search the chain of all predecessors starting with "start" and return the ".result" value of the first state which is contained in "set".protected static Object
findResult_untyp
(Translet.State<?> start, Set<? extends Translet.State<?>> set) Provide "deflt=null" forfindResult_untyp(State, Set, Object)
.findResult_untyp
(Translet.State<?> start, Set<? extends Translet.State<?>> set, @Opt Object deflt) static Format
formatApplication
(String op, Iterable<Format> data) Makes a format for one operator and an argument list using an "append" Format.static Format
formatArgList
(Iterable<Format> data) Makes a "list" format: "block"/"append" is outer/inner combinator; commma and space the delimiters; all together in a pair of parentheses and indented.static <D> Translet.FramedParser<D>
FRAME
(Translet.Parser<?> p0, Translet.Parser<D> sub, Translet.Parser<?> p1) Factors method to create one frame parser.protected static Translet.Parser<?>
getSubOrNa
(List<Translet.Parser<?>> subs, int size, int idx) Return the element number "idx" (zero based!) from the list, orna
, it the index is too large.static <D> Translet.HeadParser<D>
HEAD
(Translet.Parser<D> sub, Translet.Parser<?>... subs) Factors method to create one head parser.static <D> Translet.Store_I<D>
INCSTORE
(Map<Event, List<D>> store, Translet.Parser<D> sub) Factory method for a store with a list of values per key.protected static MessageFormatter.Formandum
Synthesizes a multi-lingual verbal description of parameter input text location, namely voicename, paramname, and the text itself.protected static void
Throws exception with given text if object reference is null.static <D> Translet.OptionParser<D>
OPT
(boolean greedy, D deflt, Translet.Parser<D> sub) Factory method for an option with the given default value and greediness.static <D> Translet.OptionParser<D>
OPT
(Translet.Parser<D> sub) Factory method for a non-greey option without default.static <A> Translet.OrLimesParser<A>
OR1
(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2) Factory method for a nondeterministic disjunction returning the limes type.static <A> Translet.OrLimesParser<A>
OR1
(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3) Factory method for a nondeterministic disjunction returning the limes type.static <A> Translet.OrLimesParser<A>
OR1
(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3, Translet.Parser<? extends A> p4) Factory method for a nondeterministic disjunction returning the limes type.static <A,
B> Translet.OrCoTupleParser<A, B, Object, Object> ORn
(Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a nondeterministic disjunction returning a co-tuple.static <A,
B, C> Translet.OrCoTupleParser<A, B, C, Object> ORn
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a nondeterministic disjunction returning a co-tuple.static <A,
B, C, D> Translet.OrCoTupleParser<A, B, C, D> ORn
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a nondeterministic disjunction returning a co-tuple.static <R> R
parseAndDiagnosis
(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, PrintStream displayStream, CatalogByString cat, List<String> prefs, eu.bandm.tools.location.LocationMap<Object, eu.bandm.tools.util.xml.XMLDocumentIdentifier> locationMap, @Opt String paramName, @Opt String voiceName, Event storageKey, String data, Translet.Parser<R> parser, Modifiers modifiers) Central entry point for parsing one(1) text input for one(1) event and one(1) parameter name.PERM
(Function3<A, B, C, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a permutation of three, applying the given function to get the result.static <R,
A, B, C, D>
Translet.PermutationParser<R,A, B, C, D, Object, Object, Object, Object> PERM
(Function4<A, B, C, D, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a permutation of four, applying the given function to get the result.static <R,
A, B, C, D, E>
Translet.PermutationParser<R,A, B, C, D, E, Object, Object, Object> PERM
(Function5<A, B, C, D, E, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a permutation of five, applying the given function to get the result.static <R,
A, B, C, D, E, F>
Translet.PermutationParser<R,A, B, C, D, E, F, Object, Object> PERM
(Function6<A, B, C, D, E, F, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a permutation of six, applying the given function to get the result.static <R,
A, B, C, D, E, F, G>
Translet.PermutationParser<R,A, B, C, D, E, F, G, Object> PERM
(Function7<A, B, C, D, E, F, G, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a permutation of seven, applying the given function to get the result.static <R,
A, B, C, D, E, F, G, H>
Translet.PermutationParser<R,A, B, C, D, E, F, G, H> PERM
(Function8<A, B, C, D, E, F, G, H, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a permutation of eight, applying the given function to get the result.PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a permutation of two, creating no result.PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a permutation of three, creating no result.static <R,
A, B, C, D>
Translet.PermutationParser<R,A, B, C, D, Object, Object, Object, Object> PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a permutation of four, creating no result.static <R,
A, B, C, D, E>
Translet.PermutationParser<R,A, B, C, D, E, Object, Object, Object> PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a permutation of five, creating no result.static <R,
A, B, C, D, E, F>
Translet.PermutationParser<R,A, B, C, D, E, F, Object, Object> PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a permutation of six, creating no result.static <R,
A, B, C, D, E, F, G>
Translet.PermutationParser<R,A, B, C, D, E, F, G, Object> PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a permutation of seven, creating no result.static <R,
A, B, C, D, E, F, G, H>
Translet.PermutationParser<R,A, B, C, D, E, F, G, H> PERM
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a permutation of eight, creating no result.PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a permutation of two, applying a constructor for the given class to get the result.PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a permutation of three, applying a constructor for the given class to get the result.static <R,
A, B, C, D>
Translet.PermutationParser<R,A, B, C, D, Object, Object, Object, Object> PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a permutation of four, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E>
Translet.PermutationParser<R,A, B, C, D, E, Object, Object, Object> PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a permutation of five, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E, F>
Translet.PermutationParser<R,A, B, C, D, E, F, Object, Object> PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a permutation of six, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E, F, G>
Translet.PermutationParser<R,A, B, C, D, E, F, G, Object> PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a permutation of seven, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E, F, G, H>
Translet.PermutationParser<R,A, B, C, D, E, F, G, H> PERM
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a permutation of eight, applying a constructor for the given class to get the result.PERM
(BiFunction<A, B, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a permutation of two, applying the given function to get the result.static <D> Translet.PlusParser<D>
PLUS
(boolean greedy, Translet.Parser<D> sub) Factory method for repetitions which may not be empty; greediness set by paraemter.static <D> Translet.PlusParser<D>
PLUS
(boolean greedy, Translet.Parser<D> sub, @Opt Translet.Parser<?> sep) Factory method for repetitions which may not be empty, need the separator between repetitions and are greedy according to the parameter value.static <D> Translet.PlusParser<D>
PLUS
(eu.bandm.tscore.base.Translet.NonGreedy nonGreedy, Translet.Parser<D> sub) Factory method for repetitions which may not be empty and parse non-greedily.static <D> Translet.PlusParser<D>
PLUS
(Translet.Parser<D> sub) Factory method for repetitions which may not be empty and parse greedily.static <A> Translet.PriorLimesParser<A>
PRIOR1
(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2) Factory method for a first-wins disjunction returning the limes type.static <A> Translet.PriorLimesParser<A>
PRIOR1
(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3) Factory method for a first-wins disjunction returning the limes type.static <A> Translet.PriorLimesParser<A>
PRIOR1
(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3, Translet.Parser<? extends A> p4) Factory method for a first-wins disjunction returning the limes type.static <A,
B> Translet.PriorCoTupleParser<A, B, Object, Object> PRIORn
(Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a first-wins disjunction returning a co-tuple.static <A,
B, C> Translet.PriorCoTupleParser<A, B, C, Object> PRIORn
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a first-wins disjunction returning a co-tuple.static <A,
B, C, D> Translet.PriorCoTupleParser<A, B, C, D> PRIORn
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a first-wins disjunction returning a co-tuple.static <R> Translet.Recursive<R>
Factory method for a Parser with a synthetic name in all print-outs.static <R> Translet.Recursive<R>
Factory method for a Parser with the given name in all print-outs.static Translet._REGEX
Factory method for a parser which accepts all strings matched by the Java regex pattern.SEQU
(Function3<A, B, C, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a sequence of three, applying the given function to get the result.static <R,
A, B, C, D>
Translet.SequParser<R,A, B, C, D, Object, Object, Object, Object> SEQU
(Function4<A, B, C, D, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a sequence of four, applying the given function to get the result.static <R,
A, B, C, D, E>
Translet.SequParser<R,A, B, C, D, E, Object, Object, Object> SEQU
(Function5<A, B, C, D, E, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a sequence of five, applying the given function to get the result.static <R,
A, B, C, D, E, F>
Translet.SequParser<R,A, B, C, D, E, F, Object, Object> SEQU
(Function6<A, B, C, D, E, F, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a sequence of six, applying the given function to get the result.static <R,
A, B, C, D, E, F, G>
Translet.SequParser<R,A, B, C, D, E, F, G, Object> SEQU
(Function7<A, B, C, D, E, F, G, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a sequence of seven, applying the given function to get the result.static <R,
A, B, C, D, E, F, G, H>
Translet.SequParser<R,A, B, C, D, E, F, G, H> SEQU
(Function8<A, B, C, D, E, F, G, H, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a sequence of eight, applying the given function to get the result.SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a sequence of two, creating no result.SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a sequence of three, creating no result.SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a sequence of four, creating no result.static <A,
B, C, D, E>
Translet.SequParser<Object,A, B, C, D, E, Object, Object, Object> SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a sequence of five, creating no result.static <A,
B, C, D, E, F>
Translet.SequParser<Object,A, B, C, D, E, F, Object, Object> SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a sequence of six, creating no result.static <A,
B, C, D, E, F, G>
Translet.SequParser<Object,A, B, C, D, E, F, G, Object> SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a sequence of seven, creating no result.static <A,
B, C, D, E, F, G, H>
Translet.SequParser<Object,A, B, C, D, E, F, G, H> SEQU
(Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a sequence of eight, creating no result.SEQU
(Class<R> cons, Translet.Parser<A> p1) Factory method for a singleton sequence, applying a constructor for the given class to get the result.SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a sequence of two, applying a constructor for the given class to get the result.SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a sequence of three, applying a constructor for the given class to get the result.static <R,
A, B, C, D>
Translet.SequParser<R,A, B, C, D, Object, Object, Object, Object> SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a sequence of four, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E>
Translet.SequParser<R,A, B, C, D, E, Object, Object, Object> SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a sequence of five, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E, F>
Translet.SequParser<R,A, B, C, D, E, F, Object, Object> SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a sequence of six, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E, F, G>
Translet.SequParser<R,A, B, C, D, E, F, G, Object> SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a sequence of seven, applying a constructor for the given class to get the result.static <R,
A, B, C, D, E, F, G, H>
Translet.SequParser<R,A, B, C, D, E, F, G, H> SEQU
(Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a sequence of eight, applying a constructor for the given class to get the result.SEQU
(BiFunction<A, B, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a sequence of two, applying the given function to get the result.SEQU
(Function<A, R> f, Translet.Parser<A> p1) Factory method for a singleton sequence, applying the given function to get the result.protected static boolean
significantAltsExist
(int index, Set<Translet.Alternative> alts) Find whether an alternative exists which started AFTER having consumed some input > epsilon.static <D> Translet.StarParser<D>
STAR
(boolean greedy, Translet.Parser<D> sub) Factory method for repetitions which may be empty; greediness set by paraemter.static <D> Translet.StarParser<D>
STAR
(boolean greedy, Translet.Parser<D> sub, @Opt Translet.Parser<?> sep) Factory method for repetitions which may be empty, need the separator between repetitions and are greedy accroding to the parameer value.static <D> Translet.StarParser<D>
STAR
(eu.bandm.tscore.base.Translet.NonGreedy nonGreedy, Translet.Parser<D> sub) Factory method for repetitions which may be empty and parse non-greedily.static <D> Translet.StarParser<D>
STAR
(Translet.Parser<D> sub) Factory method for repetitions which may be empty and parse greedily.static <D> Translet.Store_M<D>
STORE
(Multimap<Event, ? super D> store, Translet.Parser<D> sub) Factory method for a store with multiple values per key.static <D> Translet.Store_1<D>
STORE
(Map<Event, ? super D> store, Translet.Parser<D> sub) Factory method for a store with single values per key.static <R> R
testParse
(String data, Translet.Parser<R> parser, boolean verbose, boolean showParser) Same astestParse(String,Parser,MessageReceiver,boolean,boolean)
, but sends all error messages to a MessagePrinter to System.err, without localization.static <R> R
testParse
(String data, Translet.Parser<R> parser, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, boolean verbose, boolean showParser) Test method for a given parser and a given text input.protected static String
Translates the text and formats the arguments ("printf") un-translated.protected static Translet.Parser<?>
wrapSequ
(List<Translet.Parser<?>> subs) Wrap a list of parsers into one(1) top-level sequence parser, iff longer than one (>1).
-
Field Details
-
MESSAGEWIDTH
public static final int MESSAGEWIDTH- See Also:
-
format_indent
public static final int format_indentDefault indetation depth for nested format.- See Also:
-
format_dq
Format containing a double quote. -
format_popen
Format containing an opening parenthesis. -
format_pclose
Format containing an closing parenthesis. -
format_bropen
Format containing an opening square bracket. -
format_brclose
Format containing an closing parenthesis. -
format_comma
Format containing a comma. -
format_commaSp
Format containing a comma and a space. -
format_greedy
Format to indicate "greediness" when building the name of a repetition or option parser. -
na
public static final eu.bandm.tscore.base.Translet.NA naOne instance of NA is enough (all parser terms are algebraic) and can be used everywhere. -
eps
A parser matching an empty character sequecen in the input. -
eoInput
Appended to any input string as final delimiter.- See Also:
-
endChar
public static final char endCharAppended to any input string as final delimiter.- See Also:
-
startOfString
Constant location at column number 0. -
dummyLocationMap
protected static eu.bandm.tools.location.LocationMap<Object,eu.bandm.tools.util.xml.XMLDocumentIdentifier> dummyLocationMapMaps the zero-th line of an "Object" type location to the zero-th line of an "XMLDocumentIdentifier" type location. -
nonGreedy
public static eu.bandm.tscore.base.Translet.NonGreedy nonGreedyMarker object to distinguish greedy and non-greedy (=non-deterministic) variants. Is the single instance of its class.
-
-
Constructor Details
-
Translet
public Translet()
-
-
Method Details
-
formatApplication
Makes a format for one operator and an argument list using an "append" Format. The argument list is equpped with parens and commas byformatArgList(Iterable)
. -
formatArgList
Makes a "list" format: "block"/"append" is outer/inner combinator; commma and space the delimiters; all together in a pair of parentheses and indented. -
getSubOrNa
Return the element number "idx" (zero based!) from the list, orna
, it the index is too large. -
wrapSequ
Wrap a list of parsers into one(1) top-level sequence parser, iff longer than one (>1). Do so repeatedly, as long as necessary. Is needed by diagnosis tools which re-construct a (synthetic) sequence of possible inputs. -
translate
protected static String translate(CatalogByString cat, List<String> prefs, String text, Object... args) Translates the text and formats the arguments ("printf") un-translated. -
displayBindings
public static <R> void displayBindings(CatalogByString cat, List<String> prefs, PrintStream ps, int width, boolean full, Object locationtext, Translet.Parser<?> parser, Set<Translet.State<R>> results, @Opt @Opt Translet.State<R> selected, @Opt @Opt Set<Translet.State<R>> rests, @Opt @Opt Set<Translet.Alternative> alts, Modifiers modifiers, boolean showAlts, boolean showRests) Presents all collected prefixes of possible parse trees to the user for error diagnosis.- Parameters:
ps
- drain for a print writer in the system's default encoding.- See Also:
-
displayBindings
public static <R> void displayBindings(CatalogByString cat, List<String> prefs, PrintWriter pw, int width, boolean full, @Opt @Opt Object locationtext, Translet.Parser<?> parser, @Opt @Opt Set<Translet.State<R>> results, @Opt @Opt Translet.State<R> selected, Set<Translet.State<R>> rests, Set<Translet.Alternative> alts, Modifiers modifiers, boolean showAlts, boolean showRests) Show complete parsing situation on a PrintStream, possibly multi-lingual.
FIXME in exmples interaktive beispiele wiederfinden !?!? All output details can be enabled individually. These are- the coordinates of the parsing (voice, parameter, source text).
- the grammar of the parser.
- the selected match (iff there are more than one) and all other matches.
- unused, but possible alternatives after a certain prefix of the input.
- matches which did not consume the complete input.
Translet._CAT
orTranslet._CONST
orTranslet._REGEX
).A typical example is
kdf_vii.tscore:6:34 No parsing result for "C*2uX" grammar rule for this input is Parser all = OR1(SEQU(OR1(SEQU(CAT("I", "II", "III", "IV")), CAT("D", "C")?), SEQU( "", CAT("D", "C"))), | PERM((">")?, ( "u")?, ("r")?, | OR1(SEQU( "/",REGEX("[2-9]")), | SEQU( "*", REGEX("[2-9]"))), | ) | || ), SEQU(REGEX( "[1-9]"), PERM(( ">")?, ("u")?, ("r")?)), "X", "%" | || | ) | || | After having parsed ... | || | | || "C" "*" |"2" "u" there could follow input according to ... PERM( ">"?, "r"?) There are unparsable rest characters "X" at position 5
(See Lepper,Trancón "Translets", Bad Honnef 2018, pgs.113-130)
- Parameters:
cat
- Translations for the constant explanation texts. (Since this output is directed to domain experts, it is multi lingual.)prefs
- Language preferences of translationpw
- drain for the printed textswidth
- column number of the outputfull
- FIXMElocationtext
- leading information text where this display belongs to (is redundant if this display follows an error message or warning.)parser
- the complete syntax expression which rules the parsing and print out.results
- states which represent different successful parsingsselected
- one state which has been chosen from "results" by some oraclerests
- FIXMEalts
- FIXMEmodifiers
- the ubiquituous configuration object for parsingshowAlts
- whether the alternatives shall be printedshowRests
- whether the alternatives with unparsed rests shall be printed
-
displayOneBinding
public static int displayOneBinding(PrintWriter pw, Translet.FormatPrinter_memo positions, @Opt @Opt Translet.State<?> result, Modifiers modifiers) Prints one prefix of a parse tree, i.e. the relation of parsed input fragments to the terminals parsers contained in the syntax definition by horizontal alignment. This method calls itself recursively in pre-order to print the predecessor states of the state "result".- Parameters:
pw
- drain of the outputpositions
- maps terminal parsers to output columnsresult
- the final state of the parsing tree to be printedmodifiers
- general modifiers for parsing- Returns:
- the column number after the printing of the consumed input, in double quotes.
-
nonNull
Throws exception with given text if object reference is null. -
FAIL
public static final <T> eu.bandm.tscore.base.Translet.Fail<T> FAIL()One instance of NA is enough (all parser terms are algebraic) and can be used everywhere. -
RECURSIVE
Factory method for a Parser with a synthetic name in all print-outs. -
RECURSIVE
Factory method for a Parser with the given name in all print-outs. -
testParse
@Opt public static <R> R testParse(String data, Translet.Parser<R> parser, boolean verbose, boolean showParser) Same astestParse(String,Parser,MessageReceiver,boolean,boolean)
, but sends all error messages to a MessagePrinter to System.err, without localization. -
testParse
@Opt public static <R> R testParse(String data, Translet.Parser<R> parser, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, boolean verbose, boolean showParser) Test method for a given parser and a given text input. Auxiliary objects (Locations, Event, etc.) are provided locally.- Parameters:
data
- the text to parseparser
- the parser to applymsg
- drain of all messagesverbose
- whether diagnosis information shall be printedshowParser
- whether the synthesized parser name shall be shown in the start message. (This may appear clumsy when nesting is complicated.)
-
locationIndication
protected static MessageFormatter.Formandum locationIndication(@Opt @Opt String paramName, @Opt @Opt String voiceName, String data, Modifiers modifiers) Synthesizes a multi-lingual verbal description of parameter input text location, namely voicename, paramname, and the text itself. (The result will be used in addition to input file Location information.)- Parameters:
voiceName
- the name of the voice (maybe ==null, if not related to a voice)paramName
- the name of the parameter (maybe ==null if the main parameter is meant)data
- the source input textmodifiers
- only used to quote the source input text
-
parseAndDiagnosis
public static <R> R parseAndDiagnosis(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, PrintStream displayStream, CatalogByString cat, List<String> prefs, eu.bandm.tools.location.LocationMap<Object, eu.bandm.tools.util.xml.XMLDocumentIdentifier> locationMap, @Opt @Opt String paramName, @Opt @Opt String voiceName, Event storageKey, String data, Translet.Parser<R> parser, Modifiers modifiers) Central entry point for parsing one(1) text input for one(1) event and one(1) parameter name. Used mainly byUtil.parseParamTrack(MessageReceiver,Vox,String,String,Translet.Parser,Modifiers)
Calls displayBindings(...) for diagnosis output.- Parameters:
msg
- drain of all messagescat
- FIXME RAUS ???prefs
- FIXME RAUS ???locationMap
- maps the positions relative to the input string to the original source file, if any.paramName
- maybe null, iff local parsing situation of source text is NOT related to a score OR main parameter is meant. (will be translated)voiceName
- maybe null, iff local parsing situation of source text is NOT related to a score.storageKey
- under which all storage operations formandum in the parser will finally store the resultsdata
- input to parseparser
- to applymodifiers
- define the parsing conditions
-
CONST
Factory method for a const parser where the accepted string is the parsing result. -
CONST
Factory method for a const parser with explicit parsing result. -
REGEX
Factory method for a parser which accepts all strings matched by the Java regex pattern. -
CAT
Factory method for a catalog parser with a list of inputs texts = result objects. -
CAT
Factory method for a catalog parser with a list of inputs texts = result objects. -
CAT
Factory method for a catalog parser with a list of inputs texts = result objects. -
CAT
Factory method for a catalog parser with a map of inputs texts to result objects. -
STORE
Factory method for a store with single values per key. -
STORE
public static <D> Translet.Store_M<D> STORE(Multimap<Event, ? super D> store, Translet.Parser<D> sub) Factory method for a store with multiple values per key. -
INCSTORE
Factory method for a store with a list of values per key. (This can later be abstracted to a *fully compositional* version, where any event may be mapped to a sequence of sub-events/aux-events.) -
findResult_untyp
protected static Object findResult_untyp(Translet.State<?> start, Set<? extends Translet.State<?>> set) Provide "deflt=null" forfindResult_untyp(State, Set, Object)
. -
findResult_untyp
@Opt protected static @Opt Object findResult_untyp(Translet.State<?> start, Set<? extends Translet.State<?>> set, @Opt @Opt Object deflt) SeefindResult(State, Set, Object)
. This untyped variant is needed for stepping by index through a sub-result-array which contains function arguments of different types.- See Also:
-
findResult
Provide "deflt=null" forfindResult(State, Set, Object)
. -
findResult
@Opt protected static <R> R findResult(Translet.State<?> start, Set<Translet.State<R>> set, @Opt R deflt) Search the chain of all predecessors starting with "start" and return the ".result" value of the first state which is contained in "set". If no such found, return "deflt". This function is needed to collect the results as arguments for further function application. To use it, the states resulting from the corresponding sub-parser must have been memorized into "set" when executing the higher-level combinator parser. -
significantAltsExist
Find whether an alternative exists which started AFTER having consumed some input > epsilon. -
HEAD
Factors method to create one head parser. -
FRAME
public static <D> Translet.FramedParser<D> FRAME(Translet.Parser<?> p0, Translet.Parser<D> sub, Translet.Parser<?> p1) Factors method to create one frame parser. -
__SET_CAST
Aux function for casting a "Set<State<?>>" into a "Set<State<R>>", where R must be given explicitly by "Translet.<R>setCast(...)". -
SEQU
public static <R,A> Translet.SequParser<R,A, SEQUObject, Object, Object, Object, Object, Object, Object> (Function<A, R> f, Translet.Parser<A> p1) Factory method for a singleton sequence, applying the given function to get the result. (It could be named "FUN(..)" or "APPLY(..)", but is not for systematic reasons. -
SEQU
public static <R,A> Translet.SequParser<R,A, SEQUObject, Object, Object, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1) Factory method for a singleton sequence, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. (It could be named "CONS(..)" or "NEW(..)", but is not for systematic reasons. -
SEQU
public static <A,B> Translet.SequParser<Object,A, SEQUB, Object, Object, Object, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a sequence of two, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B> A, SEQUB, Object, Object, Object, Object, Object, Object> (BiFunction<A, B, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a sequence of two, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B> A, SEQUB, Object, Object, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a sequence of two, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
SEQU
public static <A,B, Translet.SequParser<Object,C> A, SEQUB, C, Object, Object, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a sequence of three, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B, C> A, SEQUB, C, Object, Object, Object, Object, Object> (Function3<A, B, C, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a sequence of three, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B, C> A, SEQUB, C, Object, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a sequence of three, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
SEQU
public static <A,B, Translet.SequParser<Object,C, D> A, SEQUB, C, D, Object, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a sequence of four, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D> A, SEQUB, C, D, Object, Object, Object, Object> (Function4<A, B, C, D, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a sequence of four, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D> A, SEQUB, C, D, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a sequence of four, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
SEQU
public static <A,B, Translet.SequParser<Object,C, D, E> A, SEQUB, C, D, E, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a sequence of five, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E> A, SEQUB, C, D, E, Object, Object, Object> (Function5<A, B, C, D, E, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a sequence of five, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E> A, SEQUB, C, D, E, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a sequence of five, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
SEQU
public static <A,B, Translet.SequParser<Object,C, D, E, F> A, SEQUB, C, D, E, F, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a sequence of six, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E, F> A, SEQUB, C, D, E, F, Object, Object> (Function6<A, B, C, D, E, F, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a sequence of six, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E, F> A, SEQUB, C, D, E, F, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a sequence of six, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
SEQU
public static <A,B, Translet.SequParser<Object,C, D, E, F, G> A, SEQUB, C, D, E, F, G, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a sequence of seven, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E, F, G> A, SEQUB, C, D, E, F, G, Object> (Function7<A, B, C, D, E, F, G, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a sequence of seven, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E, F, G> A, SEQUB, C, D, E, F, G, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a sequence of seven, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
SEQU
public static <A,B, Translet.SequParser<Object,C, D, E, F, G, H> A, SEQUB, C, D, E, F, G, H> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a sequence of eight, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E, F, G, H> A, SEQUB, C, D, E, F, G, H> (Function8<A, B, C, D, E, F, G, H, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a sequence of eight, applying the given function to get the result. -
SEQU
public static <R,A, Translet.SequParser<R,B, C, D, E, F, G, H> A, SEQUB, C, D, E, F, G, H> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a sequence of eight, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B> A, PERMB, Object, Object, Object, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a permutation of two, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B> A, PERMB, Object, Object, Object, Object, Object, Object> (BiFunction<A, B, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a permutation of two, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B> A, PERMB, Object, Object, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a permutation of two, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C> A, PERMB, C, Object, Object, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a permutation of three, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C> A, PERMB, C, Object, Object, Object, Object, Object> (Function3<A, B, C, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a permutation of three, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C> A, PERMB, C, Object, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a permutation of three, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D> A, PERMB, C, D, Object, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a permutation of four, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D> A, PERMB, C, D, Object, Object, Object, Object> (Function4<A, B, C, D, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a permutation of four, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D> A, PERMB, C, D, Object, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a permutation of four, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E> A, PERMB, C, D, E, Object, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a permutation of five, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E> A, PERMB, C, D, E, Object, Object, Object> (Function5<A, B, C, D, E, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a permutation of five, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E> A, PERMB, C, D, E, Object, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5) Factory method for a permutation of five, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F> A, PERMB, C, D, E, F, Object, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a permutation of six, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F> A, PERMB, C, D, E, F, Object, Object> (Function6<A, B, C, D, E, F, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a permutation of six, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F> A, PERMB, C, D, E, F, Object, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6) Factory method for a permutation of six, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F, G> A, PERMB, C, D, E, F, G, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a permutation of seven, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F, G> A, PERMB, C, D, E, F, G, Object> (Function7<A, B, C, D, E, F, G, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a permutation of seven, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F, G> A, PERMB, C, D, E, F, G, Object> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7) Factory method for a permutation of seven, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F, G, H> A, PERMB, C, D, E, F, G, H> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a permutation of eight, creating no result. Result storing must already be done by the result operators contained in the sub-expressions. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F, G, H> A, PERMB, C, D, E, F, G, H> (Function8<A, B, C, D, E, F, G, H, R> f, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a permutation of eight, applying the given function to get the result. -
PERM
public static <R,A, Translet.PermutationParser<R,B, C, D, E, F, G, H> A, PERMB, C, D, E, F, G, H> (Class<R> cons, Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4, Translet.Parser<E> p5, Translet.Parser<F> p6, Translet.Parser<G> p7, Translet.Parser<H> p8) Factory method for a permutation of eight, applying a constructor for the given class to get the result. The constructor is found by trying all found by reflection. -
disj_makeName
protected static Format disj_makeName(String operator, boolean full, Map<Translet.Recursive, String> names, Translet.Parser<?> p1, Translet.Parser<?> p2, Translet.Parser<?> p3, Translet.Parser<?> p4) Construct the pretty-print name for a disjunctive parser. This is a common routine forTranslet.CoTupleParser
andTranslet.LimesParser
, but cannot be abstracted by inheritance since Java does not support multiple inheritance and CoTupleParser and LimesParser have different type signature.- Parameters:
operator
- the operator text to be printed at the head of the representationfull
- whether to include storage operators, seeTranslet.Parser.name(boolean)
.names
- map to deal with recursionp1
- sub-parserp2
- sub-parserp3
- sub-parserp4
- sub-parser
-
disj_makeAlternative
protected static void disj_makeAlternative(Translet.disj_flavour flavour, Translet.State<?> inState, Set<Translet.Alternative> alternatives, List<Translet.Parser<?>> notHit, Set<Translet.Alternative> subAlts) Constructs a new disjunction parser of the given kind with all failed sub-parser, to add this new expression to alternatives.- Parameters:
flavour
- the kind of parser to constructinState
- the state after which the sub-parsers failedalternatives
- where to put the resultnotHit
- the parsers which did not succeeedsubAlts
- alternatives found by the succeeding sub-parsers
-
disj_testOneBranch
protected static <R,S> void disj_testOneBranch(Translet.DisjunctionParser<S> disj_parser, Translet.Parser<R> parser, List<Translet.Parser<?>> notHit, int index, Translet.State<?> inState, Set<Translet.State<S>> outStates, Set<Translet.Alternative> alternatives) Tests one of the branch-parsers (with the given index) of the disj_parser, with the given start state. Used by all four flavours of disjunctive parsers (OR1, ORn, PRIOR1, PRIORn). Results are wrapped in the disjunction's result type and stored to "outStates", which is an output accu passed to all sub-branches. A sub-parser delivering neither results nor alternatives is stored to "notHit" for later constructing an Alternative, on the caller's level.
"alternatives" is the output accu for alternatives coming from the lower levels.
This is a common routine forTranslet.CoTupleParser
andTranslet.LimesParser
, but Java does not support multiple inheritance. -
ORn
public static <A,B> Translet.OrCoTupleParser<A,B, ORnObject, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a nondeterministic disjunction returning a co-tuple. -
ORn
public static <A,B, Translet.OrCoTupleParser<A,C> B, ORnC, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a nondeterministic disjunction returning a co-tuple. -
ORn
public static <A,B, Translet.OrCoTupleParser<A,C, D> B, ORnC, D> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a nondeterministic disjunction returning a co-tuple. -
OR1
public static <A> Translet.OrLimesParser<A> OR1(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2) Factory method for a nondeterministic disjunction returning the limes type. -
OR1
public static <A> Translet.OrLimesParser<A> OR1(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3) Factory method for a nondeterministic disjunction returning the limes type. -
OR1
public static <A> Translet.OrLimesParser<A> OR1(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3, Translet.Parser<? extends A> p4) Factory method for a nondeterministic disjunction returning the limes type. -
PRIORn
public static <A,B> Translet.PriorCoTupleParser<A,B, PRIORnObject, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2) Factory method for a first-wins disjunction returning a co-tuple. -
PRIORn
public static <A,B, Translet.PriorCoTupleParser<A,C> B, PRIORnC, Object> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3) Factory method for a first-wins disjunction returning a co-tuple. -
PRIORn
public static <A,B, Translet.PriorCoTupleParser<A,C, D> B, PRIORnC, D> (Translet.Parser<A> p1, Translet.Parser<B> p2, Translet.Parser<C> p3, Translet.Parser<D> p4) Factory method for a first-wins disjunction returning a co-tuple. -
PRIOR1
public static <A> Translet.PriorLimesParser<A> PRIOR1(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2) Factory method for a first-wins disjunction returning the limes type. -
PRIOR1
public static <A> Translet.PriorLimesParser<A> PRIOR1(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3) Factory method for a first-wins disjunction returning the limes type. -
PRIOR1
public static <A> Translet.PriorLimesParser<A> PRIOR1(Translet.Parser<? extends A> p1, Translet.Parser<? extends A> p2, Translet.Parser<? extends A> p3, Translet.Parser<? extends A> p4) Factory method for a first-wins disjunction returning the limes type. -
PLUS
Factory method for repetitions which may not be empty and parse greedily. -
PLUS
Factory method for repetitions which may not be empty; greediness set by paraemter. -
PLUS
public static <D> Translet.PlusParser<D> PLUS(eu.bandm.tscore.base.Translet.NonGreedy nonGreedy, Translet.Parser<D> sub) Factory method for repetitions which may not be empty and parse non-greedily. -
PLUS
public static <D> Translet.PlusParser<D> PLUS(boolean greedy, Translet.Parser<D> sub, @Opt @Opt Translet.Parser<?> sep) Factory method for repetitions which may not be empty, need the separator between repetitions and are greedy according to the parameter value. -
STAR
Factory method for repetitions which may be empty and parse greedily. -
STAR
Factory method for repetitions which may be empty; greediness set by paraemter. -
STAR
public static <D> Translet.StarParser<D> STAR(eu.bandm.tscore.base.Translet.NonGreedy nonGreedy, Translet.Parser<D> sub) Factory method for repetitions which may be empty and parse non-greedily. -
STAR
public static <D> Translet.StarParser<D> STAR(boolean greedy, Translet.Parser<D> sub, @Opt @Opt Translet.Parser<?> sep) Factory method for repetitions which may be empty, need the separator between repetitions and are greedy accroding to the parameer value. -
OPT
Factory method for a non-greey option without default. -
OPT
public static <D> Translet.OptionParser<D> OPT(boolean greedy, @Opt D deflt, Translet.Parser<D> sub) Factory method for an option with the given default value and greediness.
-