Modifier and Type | Field and Description |
---|---|
static Parser<Object> |
ANY_TOKEN
A
Parser that consumes a token. |
static Parser<?> |
EOF
Parser that succeeds only if EOF is met. |
static Parser<Integer> |
INDEX
A
Parser that retrieves the current index in the source. |
Modifier and Type | Method and Description |
---|---|
static <T> Parser<T> |
always()
Parser that always succeeds. |
static Parser<Object[]> |
array(Parser<?>... parsers)
A
Parser that sequentially runs parsers one by one and collects the return
values in an array. |
static <T> Parser<T> |
between(Parser<?> before,
Parser<T> parser,
Parser<?> after)
Equivalent to
Parser.between(Parser, Parser) . |
static <T> Parser<T> |
constant(T v)
A
Parser that always returns v regardless of input. |
static <T> Parser<T> |
expect(String name)
A
Parser that fails and reports that name is logically expected. |
static <T> Parser<T> |
fail(String message)
A
Parser that always fails with message . |
static <T> Parser<List<T>> |
list(Iterable<? extends Parser<? extends T>> parsers)
|
static <T> Parser<T> |
longer(Parser<? extends T> p1,
Parser<? extends T> p2)
|
static <T> Parser<T> |
longest(Iterable<? extends Parser<? extends T>> parsers)
A
Parser that runs every element of parsers and selects the longest match. |
static <T> Parser<T> |
longest(Parser<? extends T>... parsers)
A
Parser that runs every element of parsers and selects the longest match. |
static <T> Parser<T> |
never()
Parser that always fails. |
static <T> Parser<T> |
or(Iterable<? extends Parser<? extends T>> alternatives)
A
Parser that tries each alternative parser in alternatives . |
static <T> Parser<T> |
or(Parser<? extends T>... alternatives)
A
Parser that tries each alternative parser in alternatives . |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2)
A
Parser that tries 2 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3)
A
Parser that tries 3 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3,
Parser<? extends T> p4)
A
Parser that tries 4 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3,
Parser<? extends T> p4,
Parser<? extends T> p5)
A
Parser that tries 5 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3,
Parser<? extends T> p4,
Parser<? extends T> p5,
Parser<? extends T> p6)
A
Parser that tries 6 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3,
Parser<? extends T> p4,
Parser<? extends T> p5,
Parser<? extends T> p6,
Parser<? extends T> p7)
A
Parser that tries 7 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3,
Parser<? extends T> p4,
Parser<? extends T> p5,
Parser<? extends T> p6,
Parser<? extends T> p7,
Parser<? extends T> p8)
A
Parser that tries 8 alternative parser objects. |
static <T> Parser<T> |
or(Parser<? extends T> p1,
Parser<? extends T> p2,
Parser<? extends T> p3,
Parser<? extends T> p4,
Parser<? extends T> p5,
Parser<? extends T> p6,
Parser<? extends T> p7,
Parser<? extends T> p8,
Parser<? extends T> p9)
A
Parser that tries 9 alternative parser objects. |
static <A,B> Parser<Pair<A,B>> |
pair(Parser<? extends A> p1,
Parser<? extends B> p2)
Deprecated.
Prefer to converting to your own object with a lambda.
|
static Parser<?> |
runnable(Runnable runnable)
Deprecated.
|
static Parser<Object> |
sequence(Iterable<? extends Parser<?>> parsers)
A
Parser that runs parsers sequentially and discards the return values. |
static Parser<Object> |
sequence(Parser<?>... parsers)
A
Parser that runs parsers sequentially and discards the return values. |
static <T> Parser<T> |
sequence(Parser<?> p1,
Parser<?> p2,
Parser<?> p3,
Parser<?> p4,
Parser<T> p5)
A
Parser that runs 5 parser objects sequentially. |
static <T> Parser<T> |
sequence(Parser<?> p1,
Parser<?> p2,
Parser<?> p3,
Parser<T> p4)
A
Parser that runs 4 parser objects sequentially. |
static <T> Parser<T> |
sequence(Parser<?> p1,
Parser<?> p2,
Parser<T> p3)
A
Parser that runs 3 parser objects sequentially. |
static <T> Parser<T> |
sequence(Parser<?> p1,
Parser<T> p2)
A
Parser that runs 2 parser objects sequentially. |
static <A,B,T> Parser<T> |
sequence(Parser<A> p1,
Parser<B> p2,
java.util.function.BiFunction<? super A,? super B,? extends T> map)
|
static <A,B,C,T> Parser<T> |
sequence(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Map3<? super A,? super B,? super C,? extends T> map)
A
Parser that runs 3 parser objects sequentially and transforms the return values
using map . |
static <A,B,C,D,T> |
sequence(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Map4<? super A,? super B,? super C,? super D,? extends T> map)
A
Parser that runs 4 parser objects sequentially and transforms the return values
using map . |
static <A,B,C,D,E,T> |
sequence(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Parser<E> p5,
Map5<? super A,? super B,? super C,? super D,? super E,? extends T> map)
A
Parser that runs 5 parser objects sequentially and transforms the return values
using map . |
static <A,B,C,D,E,F,T> |
sequence(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Parser<E> p5,
Parser<F> p6,
Map6<? super A,? super B,? super C,? super D,? super E,? super F,? extends T> map)
A
Parser that runs 6 parser objects sequentially and transforms the return values
using map . |
static <A,B,C,D,E,F,G,T> |
sequence(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Parser<E> p5,
Parser<F> p6,
Parser<G> p7,
Map7<? super A,? super B,? super C,? super D,? super E,? super F,? super G,? extends T> map)
A
Parser that runs 7 parser objects sequentially and transforms the return values
using map . |
static <A,B,C,D,E,F,G,H,T> |
sequence(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Parser<E> p5,
Parser<F> p6,
Parser<G> p7,
Parser<H> p8,
Map8<? super A,? super B,? super C,? super D,? super E,? super F,? super G,? super H,? extends T> map)
A
Parser that runs 7 parser objects sequentially and transforms the return values
using map . |
static <T> Parser<T> |
shorter(Parser<? extends T> p1,
Parser<? extends T> p2)
|
static <T> Parser<T> |
shortest(Iterable<? extends Parser<? extends T>> parsers)
A
Parser that runs every element of parsers and selects the shortest match. |
static <T> Parser<T> |
shortest(Parser<? extends T>... parsers)
A
Parser that runs every element of parsers and selects the shortest match. |
static <T> Parser<T> |
token(TokenMap<? extends T> fromToken)
Checks the current token with the
fromToken object. |
static <T> Parser<T> |
tokenType(Class<? extends T> type,
String name)
Checks whether the current token value is of
type , in which case, the token value is
returned and parse succeeds. |
static <A,B> Parser<Pair<A,B>> |
tuple(Parser<? extends A> p1,
Parser<? extends B> p2)
Deprecated.
Prefer to converting to your own object with a lambda.
|
static <A,B,C> Parser<Tuple3<A,B,C>> |
tuple(Parser<? extends A> p1,
Parser<? extends B> p2,
Parser<? extends C> p3)
Deprecated.
Prefer to converting to your own object with a lambda.
|
static <A,B,C,D> Parser<Tuple4<A,B,C,D>> |
tuple(Parser<? extends A> p1,
Parser<? extends B> p2,
Parser<? extends C> p3,
Parser<? extends D> p4)
Deprecated.
Prefer to converting to your own object with a lambda.
|
static <A,B,C,D,E> |
tuple(Parser<? extends A> p1,
Parser<? extends B> p2,
Parser<? extends C> p3,
Parser<? extends D> p4,
Parser<? extends E> p5)
Deprecated.
Prefer to converting to your own object with a lambda.
|
static <T> Parser<T> |
unexpected(String name)
A
Parser that fails and reports that name is logically unexpected. |
public static final Parser<Object> ANY_TOKEN
Parser
that consumes a token. The token value is returned from the parser.@Deprecated public static Parser<?> runnable(Runnable runnable)
Parser
that always succeeds and invokes runnable
.public static <T> Parser<T> constant(T v)
Parser
that always returns v
regardless of input.public static <T> Parser<T> sequence(Parser<?> p1, Parser<?> p2, Parser<T> p3)
Parser
that runs 3 parser objects sequentially.public static <T> Parser<T> sequence(Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<T> p4)
Parser
that runs 4 parser objects sequentially.public static <T> Parser<T> sequence(Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<?> p4, Parser<T> p5)
Parser
that runs 5 parser objects sequentially.@Deprecated public static <A,B> Parser<Pair<A,B>> pair(Parser<? extends A> p1, Parser<? extends B> p2)
Parser
that sequentially runs p1
and p2
and collects the results in a
Pair
object. Is equivalent to tuple(Parser, Parser)
.@Deprecated public static <A,B> Parser<Pair<A,B>> tuple(Parser<? extends A> p1, Parser<? extends B> p2)
Parser
that sequentially runs p1
and p2
and collects the results in a
Pair
object. Is equivalent to pair(Parser, Parser)
.@Deprecated public static <A,B,C> Parser<Tuple3<A,B,C>> tuple(Parser<? extends A> p1, Parser<? extends B> p2, Parser<? extends C> p3)
@Deprecated public static <A,B,C,D> Parser<Tuple4<A,B,C,D>> tuple(Parser<? extends A> p1, Parser<? extends B> p2, Parser<? extends C> p3, Parser<? extends D> p4)
@Deprecated public static <A,B,C,D,E> Parser<Tuple5<A,B,C,D,E>> tuple(Parser<? extends A> p1, Parser<? extends B> p2, Parser<? extends C> p3, Parser<? extends D> p4, Parser<? extends E> p5)
public static Parser<Object[]> array(Parser<?>... parsers)
Parser
that sequentially runs parsers
one by one and collects the return
values in an array.public static <T> Parser<T> between(Parser<?> before, Parser<T> parser, Parser<?> after)
Parser.between(Parser, Parser)
. Use this to list the parsers in the
natural order.public static <A,B,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, java.util.function.BiFunction<? super A,? super B,? extends T> map)
public static <A,B,C,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, Parser<C> p3, Map3<? super A,? super B,? super C,? extends T> map)
Parser
that runs 3 parser objects sequentially and transforms the return values
using map
.public static <A,B,C,D,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Map4<? super A,? super B,? super C,? super D,? extends T> map)
Parser
that runs 4 parser objects sequentially and transforms the return values
using map
.public static <A,B,C,D,E,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Parser<E> p5, Map5<? super A,? super B,? super C,? super D,? super E,? extends T> map)
Parser
that runs 5 parser objects sequentially and transforms the return values
using map
.public static <A,B,C,D,E,F,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Parser<E> p5, Parser<F> p6, Map6<? super A,? super B,? super C,? super D,? super E,? super F,? extends T> map)
Parser
that runs 6 parser objects sequentially and transforms the return values
using map
.public static <A,B,C,D,E,F,G,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Parser<E> p5, Parser<F> p6, Parser<G> p7, Map7<? super A,? super B,? super C,? super D,? super E,? super F,? super G,? extends T> map)
Parser
that runs 7 parser objects sequentially and transforms the return values
using map
.public static <A,B,C,D,E,F,G,H,T> Parser<T> sequence(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Parser<E> p5, Parser<F> p6, Parser<G> p7, Parser<H> p8, Map8<? super A,? super B,? super C,? super D,? super E,? super F,? super G,? super H,? extends T> map)
Parser
that runs 7 parser objects sequentially and transforms the return values
using map
.public static Parser<Object> sequence(Parser<?>... parsers)
Parser
that runs parsers
sequentially and discards the return values.public static Parser<Object> sequence(Iterable<? extends Parser<?>> parsers)
Parser
that runs parsers
sequentially and discards the return values.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2)
Parser
that tries 2 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3)
Parser
that tries 3 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3, Parser<? extends T> p4)
Parser
that tries 4 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3, Parser<? extends T> p4, Parser<? extends T> p5)
Parser
that tries 5 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3, Parser<? extends T> p4, Parser<? extends T> p5, Parser<? extends T> p6)
Parser
that tries 6 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3, Parser<? extends T> p4, Parser<? extends T> p5, Parser<? extends T> p6, Parser<? extends T> p7)
Parser
that tries 7 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3, Parser<? extends T> p4, Parser<? extends T> p5, Parser<? extends T> p6, Parser<? extends T> p7, Parser<? extends T> p8)
Parser
that tries 8 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2, Parser<? extends T> p3, Parser<? extends T> p4, Parser<? extends T> p5, Parser<? extends T> p6, Parser<? extends T> p7, Parser<? extends T> p8, Parser<? extends T> p9)
Parser
that tries 9 alternative parser objects.
Fallback happens regardless of partial match.public static <T> Parser<T> or(Parser<? extends T>... alternatives)
Parser
that tries each alternative parser in alternatives
.
Different than alt(Parser[])
, it requires all alternative parsers to have
type T
.
public static <T> Parser<T> or(Iterable<? extends Parser<? extends T>> alternatives)
Parser
that tries each alternative parser in alternatives
.public static <T> Parser<T> longer(Parser<? extends T> p1, Parser<? extends T> p2)
Parser
that runs both p1
and p2
and selects the longer match.
If both matches the same length, the first one is favored.public static <T> Parser<T> longest(Parser<? extends T>... parsers)
Parser
that runs every element of parsers
and selects the longest match.
If two matches have the same length, the first one is favored.public static <T> Parser<T> longest(Iterable<? extends Parser<? extends T>> parsers)
Parser
that runs every element of parsers
and selects the longest match.
If two matches have the same length, the first one is favored.public static <T> Parser<T> shorter(Parser<? extends T> p1, Parser<? extends T> p2)
Parser
that runs both p1
and p2
and selects the shorter match.
If both matches the same length, the first one is favored.public static <T> Parser<T> shortest(Parser<? extends T>... parsers)
Parser
that runs every element of parsers
and selects the shortest match.
If two matches have the same length, the first one is favored.public static <T> Parser<T> shortest(Iterable<? extends Parser<? extends T>> parsers)
Parser
that runs every element of parsers
and selects the shortest match.
If two matches have the same length, the first one is favored.public static <T> Parser<T> expect(String name)
Parser
that fails and reports that name
is logically expected.public static <T> Parser<T> unexpected(String name)
Parser
that fails and reports that name
is logically unexpected.public static <T> Parser<T> token(TokenMap<? extends T> fromToken)
fromToken
object. If the
TokenMap.map(Token)
method returns null, an unexpected token error occurs;
if the method returns a non-null value, the value is returned and the parser succeeds.fromToken
- the FromToken
object.public static <T> Parser<T> tokenType(Class<? extends T> type, String name)
type
, in which case, the token value is
returned and parse succeeds.type
- the expected token value type.name
- the name of what's logically expected.Copyright © 2013–2016 jparsec. All rights reserved.