public final class Combinators
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Combinators.BiCombinator<A,B,R> |
static interface |
Combinators.PentaCombinator<A,B,C,D,E,R> |
static interface |
Combinators.QuaterCombinator<A,B,C,D,R> |
static interface |
Combinators.TerCombinator<A,B,C,R> |
| Constructor and Description |
|---|
Combinators() |
| Modifier and Type | Method and Description |
|---|---|
static <A,B,R> Parser<R> |
chain(Parser<A> aParser,
Parser<B> bParser,
Combinators.BiCombinator<A,B,R> combinator)
Take two parsers and return a new one, which will pass iff both parsers succeed when running
one after the other.
|
static <A,B,C,R> Parser<R> |
chain(Parser<A> aParser,
Parser<B> bParser,
Parser<C> cParser,
Combinators.TerCombinator<A,B,C,R> combinator)
Same as
chain(Parser, Parser, BiCombinator), just with 3 parsers. |
static <A,B,C,D,R> |
chain(Parser<A> aParser,
Parser<B> bParser,
Parser<C> cParser,
Parser<D> dParser,
Combinators.QuaterCombinator<A,B,C,D,R> combinator)
Same as
chain(Parser, Parser, BiCombinator), just with 4 parsers. |
static <A,B,C,D,E,R> |
chain(Parser<A> aParser,
Parser<B> bParser,
Parser<C> cParser,
Parser<D> dParser,
Parser<E> eParser,
Combinators.PentaCombinator<A,B,C,D,E,R> combinator)
Same as
chain(Parser, Parser, BiCombinator), just with 5 parsers. |
static <T> Parser<T> |
oneOf(Parser<? extends T>... parsers)
Given a list of parsers of the same type, return a result of the first one that succeeds.
|
static <T> Parser<java.util.Optional<T>> |
optional(Parser<T> parser)
Return a parser which succeeds even in cases when it can't parse anything.
|
static <T> Parser<java.util.List<T>> |
repeat(Parser<T> parser)
Construct a new parser, that will try to run the given one repeatedly and return a list.
|
public static <A,B,R> Parser<R> chain(Parser<A> aParser, Parser<B> bParser, Combinators.BiCombinator<A,B,R> combinator)
A - Return type of the first parser.B - Return type of the second parser.R - The new return type.aParser - The parser that should run first.bParser - The second parser.combinator - A function to combine the result of both parsers into one object.public static <A,B,C,R> Parser<R> chain(Parser<A> aParser, Parser<B> bParser, Parser<C> cParser, Combinators.TerCombinator<A,B,C,R> combinator)
chain(Parser, Parser, BiCombinator), just with 3 parsers.public static <A,B,C,D,R> Parser<R> chain(Parser<A> aParser, Parser<B> bParser, Parser<C> cParser, Parser<D> dParser, Combinators.QuaterCombinator<A,B,C,D,R> combinator)
chain(Parser, Parser, BiCombinator), just with 4 parsers.public static <A,B,C,D,E,R> Parser<R> chain(Parser<A> aParser, Parser<B> bParser, Parser<C> cParser, Parser<D> dParser, Parser<E> eParser, Combinators.PentaCombinator<A,B,C,D,E,R> combinator)
chain(Parser, Parser, BiCombinator), just with 5 parsers.public static <T> Parser<java.util.List<T>> repeat(Parser<T> parser)
Note: This parser always succeeds, because if it won't match anything, it will still return an empty list.
T - Return type of the input parser.parser - The parser to repeatedly run.public static <T> Parser<java.util.Optional<T>> optional(Parser<T> parser)
T - The return type of the parser.parser - A parser to wrap with an optional check.@SafeVarargs public static <T> Parser<T> oneOf(Parser<? extends T>... parsers)
T - The return type of all the parsers involved.parsers - The input parsers to all try.