public abstract class Combinators extends Object
Constructor and Description |
---|
Combinators() |
Modifier and Type | Method and Description |
---|---|
static <I> Parser<I,I> |
any()
A parser that succeeds on any input symbol, and returns that symbol.
|
static <I> Parser<I,I> |
any(Class<I> clazz)
A parser that succeeds on any input symbol, and returns that symbol.
|
static <I,A> Parser<I,A> |
choice(Parser<I,? extends A> p1,
Parser<I,? extends A> p2)
A parser that attempts one or more parsers in turn and returns the result
of the first that succeeds, or else fails.
|
static <I,A> Parser<I,A> |
choice(Parser<I,? extends A> p1,
Parser<I,? extends A> p2,
Parser<I,? extends A> p3)
A parser that attempts one or more parsers in turn and returns the result
of the first that succeeds, or else fails.
|
static <I,A> Parser<I,A> |
choice(Parser<I,? extends A> p1,
Parser<I,? extends A> p2,
Parser<I,? extends A> p3,
Parser<I,? extends A> p4)
A parser that attempts one or more parsers in turn and returns the result
of the first that succeeds, or else fails.
|
static <I,A> Parser<I,A> |
choice(Parser<I,? extends A> p1,
Parser<I,? extends A> p2,
Parser<I,? extends A> p3,
Parser<I,? extends A> p4,
Parser<I,? extends A> p5)
A parser that attempts one or more parsers in turn and returns the result
of the first that succeeds, or else fails.
|
static <I,A> Parser<I,A> |
choice(Parser<I,? extends A> p1,
Parser<I,? extends A> p2,
Parser<I,? extends A> p3,
Parser<I,? extends A> p4,
Parser<I,? extends A> p5,
Parser<I,? extends A> p6)
A parser that attempts one or more parsers in turn and returns the result
of the first that succeeds, or else fails.
|
static <I,A> Parser<I,A> |
choice(Parser<I,A>... ps)
A parser that attempts one or more parsers in turn and returns the result
of the first that succeeds, or else fails.
|
static <I> Parser<I,Unit> |
eof()
A parser that succeeds if the end of the input has been reached.
|
static <I,A> Parser<I,A> |
fail()
A parser that always fails.
|
static <I,A> Parser<I,A> |
fail(String msg)
A parser that always fails.
|
static <I,A,B> Parser<I,Tuple2<A,B>> |
product(Parser<I,A> pa,
Parser<I,B> pb)
Combine two parser to form a parser which applies both parsers,
and if they are both successful then returns a
Tuple2 of the results. |
static <I> Parser<I,I> |
satisfy(String name,
Functions.Predicate<I> pred)
A parser that succeeds if the next input symbol satisfies the given predicate.
|
static <I> Parser<I,I> |
value(I val)
A parser that succeeds if the next input symbol equals the given
value ,
and returns the value. |
static <I,A> Parser<I,A> |
value(I val,
A res)
A parser that succeeds if the next input symbol equals the given
value ,
and returns the given res value. |
public Combinators()
public static <I,A> Parser<I,A> fail()
I
- the input stream symbol typeA
- the parser result typepublic static <I,A> Parser<I,A> fail(String msg)
I
- the input stream symbol typeA
- the parser result typemsg
- the failure messagepublic static <I> Parser<I,Unit> eof()
I
- the input stream symbol typepublic static <I> Parser<I,I> value(I val)
value
,
and returns the value.I
- the input stream symbol typeval
- the value expected by the parservalue
public static <I,A> Parser<I,A> value(I val, A res)
value
,
and returns the given res
value.I
- the input stream symbol typeA
- the parser result typeval
- the value expected by the parserres
- the value returned by the parservalue
public static <I> Parser<I,I> satisfy(String name, Functions.Predicate<I> pred)
I
- the input stream symbol typename
- a name for the parser (used for error messages)pred
- the predicate to be applied to the next inputpublic static <I> Parser<I,I> any()
I
- the input stream symbol typepublic static <I> Parser<I,I> any(Class<I> clazz)
I
- the input stream symbol typeclazz
- a dummy param for type inference of generic type I
public static <I,A,B> Parser<I,Tuple2<A,B>> product(Parser<I,A> pa, Parser<I,B> pb)
Tuple2
of the results.I
- the input stream symbol typeA
- the result type of first parserB
- the result type of second parserpa
- the first parserpb
- the second parser@SafeVarargs public static <I,A> Parser<I,A> choice(Parser<I,A>... ps)
I
- the input stream symbol typeA
- the parser result typeps
- the var-arg list of parserspublic static <I,A> Parser<I,A> choice(Parser<I,? extends A> p1, Parser<I,? extends A> p2)
I
- the input stream symbol typeA
- the parser result typep1
- the first parserp2
- the second parserpublic static <I,A> Parser<I,A> choice(Parser<I,? extends A> p1, Parser<I,? extends A> p2, Parser<I,? extends A> p3)
I
- the input stream symbol typeA
- the parser result typep1
- the first parserp2
- the second parserp3
- the third parserpublic static <I,A> Parser<I,A> choice(Parser<I,? extends A> p1, Parser<I,? extends A> p2, Parser<I,? extends A> p3, Parser<I,? extends A> p4)
I
- the input stream symbol typeA
- the parser result typep1
- the first parserp2
- the second parserp3
- the third parserp4
- the fourth parserpublic static <I,A> Parser<I,A> choice(Parser<I,? extends A> p1, Parser<I,? extends A> p2, Parser<I,? extends A> p3, Parser<I,? extends A> p4, Parser<I,? extends A> p5)
I
- the input stream symbol typeA
- the parser result typep1
- the first parserp2
- the second parserp3
- the third parserp4
- the fourth parserp5
- the fifth parserpublic static <I,A> Parser<I,A> choice(Parser<I,? extends A> p1, Parser<I,? extends A> p2, Parser<I,? extends A> p3, Parser<I,? extends A> p4, Parser<I,? extends A> p5, Parser<I,? extends A> p6)
I
- the input stream symbol typeA
- the parser result typep1
- the first parserp2
- the second parserp3
- the third parserp4
- the fourth parserp5
- the fifth parserp6
- the sixth parserCopyright © 2019. All rights reserved.