public final class Parsers
extends java.lang.Object
This class provides general parser combinators that work on both character level and token level.
A parser can work on character level or token level.
For each Parser combinator, we write the signature in a haskellish sytax.
A Parser object is safely covariant about the type parameter. Jparsec tries its best to support covariance in the API since java 5 generics has no covariance support. It is always safe to use the convert() method to explicitly force covariance whenever necessary.
A parser has a user state that can be set and retrieved. Only setState, getState, transformState combinators are user state related.
We denote a user state concerned parser as Parser u a, where u is the user state type and a is the return type.
An array of element type t, is denoted as [t].
Constructor and Description |
---|
Parsers() |
Modifier and Type | Method and Description |
---|---|
static <T> Parser<T> |
alt(Parser<T>... alternatives)
To create a Parser that runs an array of Parser objects
until one succeeds.
|
static <T> Parser<T> |
alt(java.lang.String name,
Parser<T>... alternatives)
To create a Parser that runs an array of Parser objects
until one succeeds.
|
static Parser<Tok> |
anyToken()
Consumes a token.
|
static Parser<Tok> |
anyToken(java.lang.String name)
Consumes a token.
|
static <R> Parser<R> |
atomize(java.lang.String name,
Parser<R> p)
Backout input consumption if p fails.
|
static <R> Parser<R> |
between(Parser<?> open,
Parser<?> close,
Parser<R> p)
Runs a Parser that is between a pair of parsers.
|
static <R> Parser<R> |
between(java.lang.String name,
Parser<?> open,
Parser<?> close,
Parser<R> p)
runs a Parser that is between a pair of parsers.
|
static <From,To> Parser<To> |
bind(java.lang.String name,
Parser<From> p,
ToParser<? super From,To> f)
First run p, if it succeeds, run ToParser f with the value returned from p.
|
static <T> ToParser<T,T> |
bindAll(java.lang.String name,
ToParser<T,T>... binders)
Threads an array of ToParser into a single ToParser.
|
static <T> ToParser<T,T> |
bindAll(ToParser<T,T>... binders)
Threads an array of ToParser into a single ToParser.
|
static <R> Parser<R[]> |
endBy(ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy(java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static Parser<_> |
endBy(Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy(java.lang.String name,
ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy(java.lang.String name,
java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static Parser<_> |
endBy(java.lang.String name,
Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy1(ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy1(java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static Parser<_> |
endBy1(Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy1(java.lang.String name,
ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static <R> Parser<R[]> |
endBy1(java.lang.String name,
java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static Parser<_> |
endBy1(java.lang.String name,
Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern ended by Parser sep pattern.
|
static Parser<?> |
eof()
Asserts eof is met.
|
static Parser<?> |
eof(java.lang.String msg)
Asserts eof is met.
|
static Parser<?> |
eof(java.lang.String name,
java.lang.String msg)
Asserts eof is met.
|
static <x> Parser<x> |
expect(java.lang.String lbl)
Create a Parser object that reports a "something expected" error.
|
static <x> Parser<x> |
expect(java.lang.String name,
java.lang.String lbl)
Create a Parser object that reports a "something expected" error.
|
static <R> Parser<R> |
fail(java.lang.String msg)
A parser that always fail with the given error message.
|
static <R> Parser<R> |
fail(java.lang.String name,
java.lang.String msg)
A parser that always fail with the given error message.
|
static <R> Parser<R> |
followedBy(java.lang.String name,
Parser<?> sep,
Parser<R> p)
First run Parser p, then run Parser sep.
|
static Parser<java.lang.Integer> |
getIndex()
Retrieves the current index in the source.
|
static Parser<java.lang.Integer> |
getIndex(java.lang.String name)
Retrieves the current index in the source.
|
static Parser<java.lang.Object> |
getState()
Deprecated.
as of version 0.6
|
static Parser<java.lang.Object> |
getState(java.lang.String name)
Deprecated.
|
static <C,R> Parser<R> |
ifelse(java.lang.String name,
Parser<C> p,
Parser<R> yes,
Parser<? extends R> no)
First run Parser p, if it succeeds, run Parser yes; if it fails and no
input is consumed, run Parser no; fails if p fails and some input is
consumed.
|
static <C,R> Parser<R> |
ifelse(java.lang.String name,
Parser<C> p,
ToParser<? super C,R> yes,
Parser<? extends R> no)
First run Parser p, if it succeeds, thread the return value to ToParser
yes; if it fails and no input is consumed, run Parser no; fails if p fails
and some input is consumed.
|
static <T> Parser<T> |
infixl(Parser<? extends Map2<? super T,? super T,T>> op,
Parser<? extends T> p)
Left associative infix operator.
|
static <T> Parser<T> |
infixl(java.lang.String name,
Parser<? extends Map2<? super T,? super T,T>> op,
Parser<? extends T> p)
Left associative infix operator.
|
static <T> Parser<T> |
infixn(Parser<? extends Map2<? super T,? super T,T>> op,
Parser<? extends T> operand)
Non-associative infix operator.
|
static <T> Parser<T> |
infixn(java.lang.String name,
Parser<? extends Map2<? super T,? super T,T>> op,
Parser<? extends T> operand)
Non-associative infix operator.
|
static <T> Parser<T> |
infixr(Parser<? extends Map2<? super T,? super T,T>> op,
Parser<? extends T> p)
Right associative infix operator.
|
static <T> Parser<T> |
infixr(java.lang.String name,
Parser<? extends Map2<? super T,? super T,T>> op,
Parser<? extends T> p)
Right associative infix operator.
|
static <R> Parser<R> |
isConsumed(Parser<R> p)
First run the Parser p, if it succeeds with input consumed, isConsumed()
succeeds; if it fails or did not consume input, isConsumed() fails.
|
static <R> Parser<R> |
isConsumed(Parser<R> p,
java.lang.String err)
First run the Parser p, if it succeeds with input consumed, isConsumed()
succeeds; if it fails or did not consume input, isConsumed() fails.
|
static <R> Parser<R> |
isConsumed(java.lang.String name,
Parser<R> p)
First run the Parser p, if it succeeds with input consumed, isConsumed()
succeeds; if it fails or did not consume input, isConsumed() fails.
|
static <R> Parser<R> |
isConsumed(java.lang.String name,
Parser<R> p,
java.lang.String err)
First run the Parser p, if it succeeds with input consumed, isConsumed()
succeeds; if it fails or did not consume input, isConsumed() fails.
|
static boolean |
isDebugEnabled()
Is debugging enabled?
|
static <R> Parser<R> |
isReturn(java.lang.String name,
ObjectPredicate<R> op)
Fails if the return value of the previous parser does not satisify the
given predicate.
|
static <R> Parser<R> |
isReturn(java.lang.String name,
Parser<R> p,
ObjectPredicate<? super R> op)
The created Parser object will first run parser p, if the return value of
parser p does not satisify the given predicate, it fails and the input
consumption of parser p is undone.
|
static <R> Parser<R> |
isReturn(java.lang.String name,
Parser<R> p,
ObjectPredicate<? super R> op,
java.lang.String expecting)
The created Parser object will first run parser p, if the return value of
parser p does not satisify the given predicate, it fails and the input
consumption of parser p is undone.
|
static Parser<?> |
isState(ObjectPredicate<java.lang.Object> op)
Deprecated.
as of version 0.6
|
static Parser<?> |
isState(java.lang.String name,
ObjectPredicate<java.lang.Object> op)
Deprecated.
as of version 0.6
|
static <R> Parser<R> |
label(java.lang.String name,
java.lang.String lbl,
Parser<R> p)
if Parser p fails and does not consume input, reports an expecting error
with the given label.
|
static <R> Parser<R> |
lazy(Parser<R>[] placeholder)
Create a lazy evaluated parser.
|
static <R> Parser<R> |
lazy(Parser<R>[] placeholder,
int pos)
Create a lazy evaluated parser.
|
static <R> Parser<R> |
lazy(ParserEval<R> p)
Create a lazy evaluated Parser.
|
static <R> Parser<R> |
lazy(java.lang.String name,
ParserEval<R> p)
Create a lazy evaluated Parser.
|
static <R> Parser<R> |
longer(Parser<R> p1,
Parser<R> p2)
Runs two alternative parsers.
|
static <R> Parser<R> |
longer(java.lang.String name,
Parser<R> p1,
Parser<R> p2)
Runs two alternative parsers.
|
static <R> Parser<R> |
longest(Parser<R>... ps)
Runs an array of alternative parsers.
|
static <R> Parser<R> |
longest(java.lang.String name,
Parser<R>... ps)
Runs an array of alternative parsers.
|
static <R> Parser<R> |
lookahead(java.lang.String name,
int toknum,
Parser<R> p)
By default, ifelse, plus, sum will not try to run the next branch if the
previous branch failed and consumed some input.
|
static <R> Parser<R[]> |
many(java.lang.String name,
ArrayFactory<R> af,
int min,
Parser<? extends R> p)
Greedily runs Parser p repeatedly for at least min times and collect the
result in an array created by ArrayFactory object.
|
static <R> Parser<R[]> |
many(java.lang.String name,
ArrayFactory<R> af,
Parser<? extends R> p)
Greedily runs Parser p repeatedly and collect the result in an array
created by ArrayFactory object.
|
static <R> Parser<R[]> |
many(java.lang.String name,
java.lang.Class<R> etype,
int min,
Parser<? extends R> p)
Greedily runs Parser p repeatedly for at least min times and collect the
result in an array whose element type is etype.
|
static <R> Parser<R[]> |
many(java.lang.String name,
java.lang.Class<R> etype,
Parser<? extends R> p)
Greedily runs Parser p repeatedly and collect the result in an array whose
element type is etype.
|
static <R> Parser<_> |
many(java.lang.String name,
int min,
Parser<?> p)
Greedily runs Parser p repeatedly for at least min times and discard the
results.
|
static Parser<_> |
many(java.lang.String name,
Parser<?> p)
Greedily runs Parser p repeatedly and discard the results.
|
static <From,A extends From,R,To extends R> |
manyAccum(java.lang.String name,
Accumulatable<From,To> accm,
int min,
Parser<A> p)
Greedily runs Parser p repeatedly for at least min times and collect the
result with the Accumulator object created by Accumulatable.
|
static <From,A extends From,R,To extends R> |
manyAccum(java.lang.String name,
Accumulatable<From,To> accm,
Parser<A> p)
Greedily runs Parser p repeatedly for 0 or more times.
|
static <R,From> Parser<R> |
map(java.lang.String name,
Parser<From> p,
Map<? super From,R> m)
Transform the return value of Parser p to a different value.
|
static <A,B,R> Parser<R> |
map2(Parser<A> p1,
Parser<B> p2,
Map2<? super A,? super B,R> m2)
Run 2 Parsers sequentially and transform the return values to a new value.
|
static <A,B,R> Parser<R> |
map2(java.lang.String name,
Parser<A> p1,
Parser<B> p2,
Map2<? super A,? super B,R> m2)
Run 2 Parsers sequentially and transform the return values to a new value.
|
static <A,B,C,R> Parser<R> |
map3(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Map3<? super A,? super B,? super C,R> m3)
Run 3 Parsers sequentially and transform the return values to a new value.
|
static <A,B,C,R> Parser<R> |
map3(java.lang.String name,
Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Map3<? super A,? super B,? super C,R> m3)
Run 3 Parsers sequentially and transform the return values to a new value.
|
static <A,B,C,D,R> |
map4(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Map4<? super A,? super B,? super C,? super D,R> m4)
Run 4 Parsers sequentially and transform the return values to a new value.
|
static <A,B,C,D,R> |
map4(java.lang.String name,
Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Map4<? super A,? super B,? super C,? super D,R> m4)
Run 4 Parsers sequentially and transform the return values to a new value.
|
static <A,B,C,D,E,R> |
map5(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,R> m5)
Run 5 Parsers sequentially and transform the return values to a new value.
|
static <A,B,C,D,E,R> |
map5(java.lang.String name,
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,R> m5)
Run 5 Parsers sequentially and transform the return values to a new value.
|
static <E,R> Parser<R> |
mapn(ArrayFactory<?> af,
Parser<?>[] ps,
Mapn<R> mn)
Sequencing of an array of Parser objects.
|
static <E,R> Parser<R> |
mapn(java.lang.Class<? super E> etype,
Parser<E>[] ps,
Mapn<R> mn)
Sequencing of an array of Parser objects.
|
static <R> Parser<R> |
mapn(Parser<?>[] ps,
Mapn<R> mn)
Sequencing of an array of Parser objects.
|
static <R> Parser<R> |
mapn(java.lang.String name,
ArrayFactory<?> af,
Parser<?>[] ps,
Mapn<R> mn)
Sequencing of an array of Parser objects.
|
static <E,R> Parser<R> |
mapn(java.lang.String name,
java.lang.Class<? super E> etype,
Parser<E>[] ps,
Mapn<R> mn)
Sequencing of an array of Parser objects.
|
static <R> Parser<R> |
mapn(java.lang.String name,
Parser<?>[] ps,
Mapn<R> mn)
Sequencing of an array of Parser objects.
|
static Parser<?> |
not(java.lang.String name,
Parser<?> p)
Succeeds if Parser p fails; Fails otherwise.
|
static Parser<?> |
not(java.lang.String name,
Parser<?> p,
java.lang.String errmsg)
Succeeds if Parser p fails; Fails otherwise.
|
static <R> Parser<R> |
notConsumed(Parser<R> p)
First run the Parser p, if it succeeds with no input consumed,
notConsumed() succeeds; if it fails, notConsumed() fails; if it succeeds
and consumes input, the input consumption is undone and notConsumed()
fails.
|
static <R> Parser<R> |
notConsumed(Parser<R> p,
java.lang.String err)
First run the Parser p, if it succeeds with no input consumed,
notConsumed() succeeds; if it fails, notConsumed() fails; if it succeeds
and consumes input, the input consumption is undone and notConsumed()
fails.
|
static <R> Parser<R> |
notConsumed(java.lang.String name,
Parser<R> p)
First run the Parser p, if it succeeds with no input consumed,
notConsumed() succeeds; if it fails, notConsumed() fails; if it succeeds
and consumes input, the input consumption is undone and notConsumed()
fails.
|
static <R> Parser<R> |
notConsumed(java.lang.String name,
Parser<R> p,
java.lang.String err)
First run the Parser p, if it succeeds with no input consumed,
notConsumed() succeeds; if it fails, notConsumed() fails; if it succeeds
and consumes input, the input consumption is undone and notConsumed()
fails.
|
static Parser<?> |
one()
The parser that always succeed.
|
static Parser<?> |
one(java.lang.String name)
The parser that always succeed.
|
static <R> Parser<R> |
option(R v,
Parser<R> p)
Runs Parser p, if it fails with no input consumed, return default value v
instead.
|
static <R> Parser<R> |
option(java.lang.String name,
R v,
Parser<R> p)
Runs Parser p, if it fails with no input consumed, return default value v
instead.
|
static <R> Parser<R> |
optional(Parser<R> p)
Runs Parser p, if it fails with no input consumed, succeed anyway with null as the result.
|
static <R> Parser<R> |
optional(java.lang.String name,
Parser<R> p)
Runs Parser p, if it fails with no input consumed, succeed anyway with null as result.
|
static Parser<java.lang.Object> |
or(Parser<?>... alternatives)
To create a Parser that runs an array of Parser objects
until one succeeds.
|
static Parser<java.lang.Object> |
or(java.lang.String name,
Parser<?>... alternatives)
To create a Parser that runs an array of Parser objects
until one succeeds.
|
static <A,B> Parser<Pair<A,B>> |
pair(Parser<A> p1,
Parser<B> p2)
Sequentially run 2 parser objects and collect the results in a Pair object.
|
static <A,B> Parser<Pair<A,B>> |
pair(java.lang.String name,
Parser<A> p1,
Parser<B> p2)
Sequentially run 2 parser objects and collect the results in a Pair object.
|
static <R> Parser<R> |
parseTokens(Parser<Tok[]> lexer,
Parser<R> p,
java.lang.String module)
The created parser object will take as input the array of Tok
returned from the lexer object, feed it into the Parser object p and run
it, return the result from parser p.
|
static <R> Parser<R> |
parseTokens(java.lang.String name,
Parser<Tok[]> lexer,
Parser<R> p,
java.lang.String module)
The created parser object will take as input the array of Tok
returned from the lexer object, feed it into the Parser object p and run
it, return the result from parser p.
|
static <R> Parser<R> |
parseTokens(java.lang.String eof_title,
ShowToken show,
Parser<Tok[]> lexer,
Parser<R> p,
java.lang.String module)
The created parser object will take as input the array of Tok
returned from the lexer object, feed it into the Parser object p and run
it, return the result from parser p.
|
static <R> Parser<R> |
parseTokens(java.lang.String name,
java.lang.String eof_title,
ShowToken show,
Parser<Tok[]> lexer,
Parser<R> p,
java.lang.String module)
The created parser object will take as input the array of Tok
returned from the lexer object, feed it into the Parser object p and run
it, return the result from parser p.
|
static <R> Parser<R> |
peek(java.lang.String name,
Parser<R> p)
Look ahead with Parser p.
|
static <R> Parser<R> |
plus(Parser<R>... ps)
combine alternative parser objects.
|
static <R> Parser<R> |
plus(Parser<R> p1,
Parser<? extends R> p2)
2 alternative parser objects.
|
static <R> Parser<R> |
plus(Parser<R> p1,
Parser<? extends R> p2,
Parser<? extends R> p3)
3 alternative parser objects.
|
static <R> Parser<R> |
plus(Parser<R> p1,
Parser<? extends R> p2,
Parser<? extends R> p3,
Parser<? extends R> p4)
4 alternative parser objects.
|
static <R> Parser<R> |
plus(Parser<R> p1,
Parser<? extends R> p2,
Parser<? extends R> p3,
Parser<? extends R> p4,
Parser<? extends R> p5)
5 alternative parser objects.
|
static <R> Parser<R> |
plus(java.lang.String name,
Parser<R>... ps)
combine alternative parser objects.
|
static <R> Parser<R> |
plus(java.lang.String name,
Parser<R> p1,
Parser<? extends R> p2)
2 alternative parser objects.
|
static <R> Parser<R> |
plus(java.lang.String name,
Parser<R> p1,
Parser<? extends R> p2,
Parser<? extends R> p3)
3 alternative parser objects.
|
static <R> Parser<R> |
plus(java.lang.String name,
Parser<R> p1,
Parser<? extends R> p2,
Parser<? extends R> p3,
Parser<? extends R> p4)
4 alternative parser objects.
|
static <R> Parser<R> |
plus(java.lang.String name,
Parser<R> p1,
Parser<? extends R> p2,
Parser<? extends R> p3,
Parser<? extends R> p4,
Parser<? extends R> p5)
5 alternative parser objects.
|
static <T> Parser<T> |
postfix(Parser<? extends Map<? super T,T>> op,
Parser<? extends T> p)
Runs Parser p and then run Parser op for 0 or more times greedily.
|
static <T> Parser<T> |
postfix(java.lang.String name,
Parser<? extends Map<? super T,T>> op,
Parser<? extends T> p)
Runs Parser p and then run Parser op for 0 or more times greedily.
|
static <T> Parser<T> |
prefix(Parser<? extends Map<? super T,T>> op,
Parser<? extends T> p)
Runs Parser op for 0 or more times greedily.
|
static <T> Parser<T> |
prefix(java.lang.String name,
Parser<? extends Map<? super T,T>> op,
Parser<? extends T> p)
Runs Parser op for 0 or more times greedily.
|
static <R> Parser<R> |
raise(java.lang.Object e)
throws a pseudo-exception.
|
static <R> Parser<R> |
raise(java.lang.String name,
java.lang.Object e)
throws a pseudo-exception.
|
static <R> Parser<R[]> |
repeat(java.lang.String name,
ArrayFactory<R> af,
int n,
Parser<? extends R> p)
Runs Parser p for n times, collect the return values in an array created by
the ArrayFactory object.
|
static <R> Parser<R[]> |
repeat(java.lang.String name,
java.lang.Class<R> etype,
int n,
Parser<? extends R> p)
Runs Parser p for n times, collect the return values in an array whose
element type is etype.
|
static Parser<_> |
repeat(java.lang.String name,
int n,
Parser<?> p)
Runs Parser p for n times.
|
static <R> Parser<R> |
retn(R r)
The parser that returns value v.
|
static <R> Parser<R> |
retn(java.lang.String name,
R r)
The parser that returns value v.
|
static Parser<?> |
runnable(java.lang.Runnable runnable)
To create a Parser that always succeeds and causes a certain side effect
using a Runnable object.
|
static Parser<?> |
runnable(java.lang.String name,
java.lang.Runnable runnable)
To create a Parser that always succeeds and causes a certain side effect
using a Runnable object.
|
static <R> R |
runParser(java.lang.CharSequence src,
Parser<R> p,
PositionMap pmap,
java.lang.String module)
Runs a character level parser with a CharSequence input.
|
static <R> R |
runParser(java.lang.CharSequence src,
Parser<R> p,
java.lang.String module)
Runs a character level parser with a CharSequence input.
|
static <R> R |
runParser(Tok[] toks,
int end_index,
Parser<R> p,
ShowToken show,
java.lang.String eof_title,
PositionMap pmap,
java.lang.String module)
Runs a token level Parser object with an array of tokens.
|
static <R> Parser<R[]> |
sepBy(ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepBy(java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static Parser<_> |
sepBy(Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepBy(java.lang.String name,
ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepBy(java.lang.String name,
java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static Parser<_> |
sepBy(java.lang.String name,
Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepBy1(ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepBy1(java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
Class -> Parser a -> Parser [Object].
|
static Parser<_> |
sepBy1(Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R,A extends R> |
sepBy1(java.lang.String name,
ArrayFactory<R> af,
Parser<?> sep,
Parser<A> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepBy1(java.lang.String name,
java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
Class -> Parser a -> Parser [Object].
|
static Parser<_> |
sepBy1(java.lang.String name,
Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated by Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy(ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy(java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static Parser<_> |
sepEndBy(Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy(java.lang.String name,
ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy(java.lang.String name,
java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static Parser<_> |
sepEndBy(java.lang.String name,
Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy1(ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy1(java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static Parser<_> |
sepEndBy1(Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy1(java.lang.String name,
ArrayFactory<R> af,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R[]> |
sepEndBy1(java.lang.String name,
java.lang.Class<R> etype,
Parser<?> sep,
Parser<? extends R> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static Parser<_> |
sepEndBy1(java.lang.String name,
Parser<?> sep,
Parser<?> p)
run a series of Parser p pattern that is seperated and optionally ended by
Parser sep pattern.
|
static <R> Parser<R> |
seq(Parser<?> p1,
Parser<?> p2,
Parser<?> p3,
Parser<?> p4,
Parser<R> p5)
Sequencing 5 parser objects.
|
static <R> Parser<R> |
seq(Parser<?> p1,
Parser<?> p2,
Parser<?> p3,
Parser<R> p4)
Sequencing 4 parser objects.
|
static <R> Parser<R> |
seq(Parser<?> p1,
Parser<?> p2,
Parser<R> p3)
Sequencing 3 parser objects.
|
static <R> Parser<R> |
seq(Parser<?> p1,
Parser<R> p2)
Sequencing 2 parser objects.
|
static <R> Parser<R> |
seq(java.lang.String name,
Parser<?> p1,
Parser<?> p2,
Parser<?> p3,
Parser<?> p4,
Parser<R> p5)
Sequencing 5 parser objects.
|
static <R> Parser<R> |
seq(java.lang.String name,
Parser<?> p1,
Parser<?> p2,
Parser<?> p3,
Parser<R> p4)
Sequencing 4 parser objects.
|
static <R> Parser<R> |
seq(java.lang.String name,
Parser<?> p1,
Parser<?> p2,
Parser<R> p3)
Sequencing 3 parser objects.
|
static <R> Parser<R> |
seq(java.lang.String name,
Parser<?> p1,
Parser<R> p2)
Sequencing 2 parser objects.
|
static Parser<java.lang.Object> |
seqAll(Parser<?>[] ps)
Sequencing of an array of Parser objects.
|
static Parser<java.lang.Object> |
seqAll(java.lang.String name,
Parser<?>[] ps)
Sequencing of an array of Parser objects.
|
static Parser<?> |
sequence(Parser<?>... ps)
Sequencing of an array of Parser objects.
|
static Parser<?> |
sequence(java.lang.String name,
Parser<?>... ps)
Sequencing of an array of Parser objects.
|
static void |
setDebug(boolean debugged)
enable or disable debugging.
|
static Parser<java.lang.Object> |
setState(java.lang.Object s)
Deprecated.
as of version 0.6
|
static Parser<java.lang.Object> |
setState(java.lang.String name,
java.lang.Object s)
Deprecated.
as of version 0.6
|
static <R> Parser<R> |
shorter(Parser<R> p1,
Parser<R> p2)
Runs two alternative parsers.
|
static <R> Parser<R> |
shorter(java.lang.String name,
Parser<R> p1,
Parser<R> p2)
Runs two alternative parsers.
|
static <R> Parser<R> |
shortest(Parser<R>... ps)
Runs an array of alternative parsers.
|
static <R> Parser<R> |
shortest(java.lang.String name,
Parser<R>... ps)
Runs an array of alternative parsers.
|
static <R> Parser<R[]> |
some(java.lang.String name,
ArrayFactory<R> af,
int min,
int max,
Parser<? extends R> p)
Greedily runs Parser p repeatedly for at least min times and at most max
time.
|
static <R> Parser<R[]> |
some(java.lang.String name,
ArrayFactory<R> af,
int max,
Parser<? extends R> p)
Greedily runs Parser p repeatedly for at most max time.
|
static <R> Parser<R[]> |
some(java.lang.String name,
java.lang.Class<R> etype,
int min,
int max,
Parser<? extends R> p)
Greedily runs Parser p repeatedly for at least min times and at most max
times.
|
static <R> Parser<R[]> |
some(java.lang.String name,
java.lang.Class<R> etype,
int max,
Parser<? extends R> p)
Greedily runs Parser p repeatedly for at most max times.
|
static <R> Parser<_> |
some(java.lang.String name,
int min,
int max,
Parser<?> p)
Greedily runs Parser p repeatedly for at least min times and at most max
time.
|
static Parser<_> |
some(java.lang.String name,
int max,
Parser<?> p)
Greedily runs Parser p repeatedly for at most max time.
|
static <From,A extends From,R,To extends R> |
someAccum(java.lang.String name,
Accumulatable<From,To> accm,
int min,
int max,
Parser<A> p)
Greedily runs Parser p repeatedly for at least min times and at most max
times, collect the result with the Accumulator object created by
Accumulatable.
|
static <From,A extends From,R,To extends R> |
someAccum(java.lang.String name,
Accumulatable<From,To> accm,
int max,
Parser<A> p)
Greedily runs Parser p repeatedly for at most max times, collect the result
with the Accumulator object created by Accumulatable.
|
static <R> Parser<R> |
step(java.lang.String name,
int n,
Parser<R> p)
lookahead looks at logical steps.
|
static Parser<java.lang.Object> |
sum(Parser<?>... ps)
An array of alternative Parser objects.
|
static Parser<java.lang.Object> |
sum(java.lang.String name,
Parser<?>... ps)
An array of alternative Parser objects.
|
static <R> Parser<R> |
token(FromToken<R> ft)
Token level parser.
|
static Parser<Tok> |
token(java.lang.Object t)
Token level parser.
|
static <R> Parser<R> |
token(java.lang.String name,
FromToken<R> ft)
Token level parser.
|
static Parser<Tok> |
token(java.lang.String name,
java.lang.Object t)
Token level parser.
|
static <x> ToParser<x,?> |
toOne()
Returns a ToParser that ignores the value passed in and simply returns
one().
|
static <x> ToParser<x,?> |
toOne(java.lang.String name)
Returns a ToParser that ignores the value passed in and simply returns
one().
|
static <x,R> ToParser<x,R> |
toParser(Parser<R> parser)
Creates a ToParser object by always returning the same Parser object.
|
static <T> ToParser<T,T> |
toReturn()
Returns a ToParser instance that simply returns the previous return value.
|
static <T> ToParser<T,T> |
toReturn(java.lang.String name)
Returns a ToParser instance that simply returns the previous return value.
|
static <x,y> ToParser<x,y> |
toZero()
Returns a ToParser that ignores the value passed in and simply returns
zero().
|
static <x,y> ToParser<x,y> |
toZero(java.lang.String name)
Returns a ToParser that ignores the value passed in and simply returns
zero().
|
static <State> Parser<State> |
transformState(Map<State,?> m)
Deprecated.
as of version 0.6
|
static <State> Parser<State> |
transformState(java.lang.String name,
Map<State,?> m)
Deprecated.
as of version 0.6
|
static <R> Parser<R> |
tryParser(Parser<R> p,
Catch<? extends R> hdl)
if Parser p throws an exception, it is handled by Catch hdl.
|
static <R> Parser<R> |
tryParser(java.lang.String name,
Parser<R> p,
Catch<? extends R> hdl)
if Parser p throws an exception, it is handled by Catch hdl.
|
static <A,B,C> Parser<Tuple3<A,B,C>> |
tuple(Parser<A> p1,
Parser<B> p2,
Parser<C> p3)
Sequentially run 3 parser objects and collect the results in a Tuple3 object.
|
static <A,B,C,D> Parser<Tuple4<A,B,C,D>> |
tuple(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4)
Sequentially run 4 parser objects and collect the results in a Tuple4 object.
|
static <A,B,C,D,E> |
tuple(Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Parser<E> p5)
Sequentially run 5 parser objects and collect the results in a Tuple5 object.
|
static <A,B,C> Parser<Tuple3<A,B,C>> |
tuple(java.lang.String name,
Parser<A> p1,
Parser<B> p2,
Parser<C> p3)
Sequentially run 3 parser objects and collect the results in a Tuple3 object.
|
static <A,B,C,D> Parser<Tuple4<A,B,C,D>> |
tuple(java.lang.String name,
Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4)
Sequentially run 4 parser objects and collect the results in a Tuple4 object.
|
static <A,B,C,D,E> |
tuple(java.lang.String name,
Parser<A> p1,
Parser<B> p2,
Parser<C> p3,
Parser<D> p4,
Parser<E> p5)
Sequentially run 5 parser objects and collect the results in a Tuple5 object.
|
static <x> Parser<x> |
unexpected(java.lang.String msg)
Reports an unexpected error.
|
static <x> Parser<x> |
unexpected(java.lang.String name,
java.lang.String msg)
Reports an unexpected error.
|
static <x> Parser<x> |
zero()
The parser that always fails.
|
static <x> Parser<x> |
zero(java.lang.String name)
The parser that always fails.
|
public static boolean isDebugEnabled()
public static void setDebug(boolean debugged)
debugged
- true if debugging is enabled, false otherwise.public static <R> R runParser(java.lang.CharSequence src, Parser<R> p, PositionMap pmap, java.lang.String module)
src
- the input source.p
- the parser object to run.pmap
- the PositionMap object used to map a character index to
line/column number.module
- the module name. Use any name that's meaningful.public static <R> R runParser(java.lang.CharSequence src, Parser<R> p, java.lang.String module)
Parser.parse(CharSequence, String)
is equivalent
to this call and is more convenient.src
- the input source.p
- the parser object to run.module
- the module name. This name apears in error message.public static <R> R runParser(Tok[] toks, int end_index, Parser<R> p, ShowToken show, java.lang.String eof_title, PositionMap pmap, java.lang.String module) throws ParserException
[Tok] -> int -> Parser a -> ShowToken -> String -> PositionMap -> a
toks
- the input tokensend_index
- the index after the last character in the source.p
- the parser object.show
- the object to show the tokens.eof_title
- the name of "end of file".module
- the module name. Use any name that's meaningful. This value will
be shown in any EOF related messages.pmap
- the PositionMap object to map a character index to the line/column
number.ParserException
- when parsing fails.public static Parser<?> runnable(java.lang.String name, java.lang.Runnable runnable)
name
- the parser name.runnable
- the Runnable object.public static Parser<?> runnable(java.lang.Runnable runnable)
runnable
- the Runnable object.public static <R> Parser<R> parseTokens(Parser<Tok[]> lexer, Parser<R> p, java.lang.String module)
lexer
- the lexer object that returns an array of Tok objects.p
- the token level parser object.module
- the module name. Use any name that's meaningful. that will parse
the array of Tok objects.public static <R> Parser<R> parseTokens(java.lang.String name, Parser<Tok[]> lexer, Parser<R> p, java.lang.String module)
name
- the name of the new Parser object.lexer
- the lexer object that returns an array of Tok objects.p
- the token level parser object.module
- the module name. Use any name that's meaningful. that will parse
the array of Tok objects.public static <R> Parser<R> parseTokens(java.lang.String eof_title, ShowToken show, Parser<Tok[]> lexer, Parser<R> p, java.lang.String module)
eof_title
- the name of "end of input"show
- the object to transform a token to a string.lexer
- the lexer object that returns an array of Tok objects.p
- the token level parser object.module
- the module name. Use any name that's meaningful. that will parse
the array of Tok objects.public static <R> Parser<R> parseTokens(java.lang.String name, java.lang.String eof_title, ShowToken show, Parser<Tok[]> lexer, Parser<R> p, java.lang.String module)
name
- the name of the new Parser object.eof_title
- the name of "end of input"show
- the object to transform a token to a string.lexer
- the lexer object that returns an array of Tok objects.p
- the token level parser objectmodule
- the module name. Use any name that's meaningful. that will parse
the array of Tok objects.public static Parser<?> one()
Parser ?
public static Parser<?> one(java.lang.String name)
Parser ?
name
- the name of the Parser.public static <x> Parser<x> zero()
Parser *
public static <x> Parser<x> zero(java.lang.String name)
Parser *
name
- the name of the Parser.public static <R> Parser<R> retn(R r)
a -> Parser a
r
- the value to be returned by the parser.public static <R> Parser<R> retn(java.lang.String name, R r)
a -> Parser a
name
- the name of the Parser.r
- the value to be returned by the parser.public static <From,To> Parser<To> bind(java.lang.String name, Parser<From> p, ToParser<? super From,To> f)
Parser a -> (a->Parser b) -> Parser b
name
- the name of the Parser.p
- the first Parser object.f
- the ToParser object to run if the first succeeds.public static <T> ToParser<T,T> toReturn()
a -> Parser a
public static <T> ToParser<T,T> toReturn(java.lang.String name)
a -> Parser a
public static <x> ToParser<x,?> toOne()
x -> Parser ?
public static <x> ToParser<x,?> toOne(java.lang.String name)
x -> Parser ?
name
- the name of the Parser that ToParser returns.public static <x,y> ToParser<x,y> toZero()
_ -> Parser *
public static <x,y> ToParser<x,y> toZero(java.lang.String name)
_ -> Parser *
name
- the name of the Parser that ToParser returns.public static <x,R> ToParser<x,R> toParser(Parser<R> parser)
x
- the type of the input parameter. "x" is used to indicate that this type is irrelevant and we don't use it.R
- the result type of the Parser object.parser
- the parser object.public static <T> ToParser<T,T> bindAll(ToParser<T,T>... binders)
[(a->Parser a)] -> a -> Parser a
binders
- all the ToParser objects.public static <T> ToParser<T,T> bindAll(java.lang.String name, ToParser<T,T>... binders)
[(a->Parser a)] -> a -> Parser a
binders
- all the ToParser objects.name
- the name of the Parser created by the result ToParser.public static <R> Parser<R> seq(Parser<?> p1, Parser<R> p2)
Parser ? -> Parser b -> Parser b
p1
- 1st Parser.p2
- 2nd Parser.public static <R> Parser<R> seq(java.lang.String name, Parser<?> p1, Parser<R> p2)
Parser ? -> Parser b -> Parser b
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.public static <R> Parser<R> seq(Parser<?> p1, Parser<?> p2, Parser<R> p3)
Parser a -> Parser b -> Parser c -> Parser c
p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.public static <R> Parser<R> seq(java.lang.String name, Parser<?> p1, Parser<?> p2, Parser<R> p3)
Parser a -> Parser b -> Parser c -> Parser c
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.public static <R> Parser<R> seq(Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<R> p4)
Parser a -> Parser b -> Parser c -> Parser c -> Parser d -> Parser d
p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.public static <R> Parser<R> seq(java.lang.String name, Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<R> p4)
Parser a -> Parser b -> Parser c -> Parser c -> Parser d -> Parser d
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.public static <R> Parser<R> seq(Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<?> p4, Parser<R> p5)
Parser a -> Parser b -> Parser c -> Parser c -> Parser d -> Parser e -> Parser e
p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.p5
- 5th Parser.public static <R> Parser<R> seq(java.lang.String name, Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<?> p4, Parser<R> p5)
Parser a -> Parser b -> Parser c -> Parser c -> Parser d -> Parser e -> Parser e
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.p5
- 5th Parser.public static <A,B> Parser<Pair<A,B>> pair(Parser<A> p1, Parser<B> p2)
p1
- the first parser.p2
- the second parser.public static <A,B,C> Parser<Tuple3<A,B,C>> tuple(Parser<A> p1, Parser<B> p2, Parser<C> p3)
p1
- the first parser.p2
- the second parser.p3
- the 3rd parser.public static <A,B,C,D> Parser<Tuple4<A,B,C,D>> tuple(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4)
p1
- the first parser.p2
- the second parser.p3
- the 3rd parser.p4
- the 4th parser.public static <A,B,C,D,E> Parser<Tuple5<A,B,C,D,E>> tuple(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Parser<E> p5)
p1
- the first parser.p2
- the second parser.p3
- the 3rd parser.p4
- the 4th parser.p5
- the 5th parser.public static <A,B> Parser<Pair<A,B>> pair(java.lang.String name, Parser<A> p1, Parser<B> p2)
name
- the result parser name.p1
- the first parser.p2
- the second parser.public static <A,B,C> Parser<Tuple3<A,B,C>> tuple(java.lang.String name, Parser<A> p1, Parser<B> p2, Parser<C> p3)
name
- the result parser name.p1
- the first parser.p2
- the second parser.p3
- the 3rd parser.public static <A,B,C,D> Parser<Tuple4<A,B,C,D>> tuple(java.lang.String name, Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4)
name
- the result parser name.p1
- the first parser.p2
- the second parser.p3
- the 3rd parser.p4
- the 4th parser.public static <A,B,C,D,E> Parser<Tuple5<A,B,C,D,E>> tuple(java.lang.String name, Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Parser<E> p5)
name
- the result parser name.p1
- the first parser.p2
- the second parser.p3
- the 3rd parser.p4
- the 4th parser.p5
- the 5th parser.public static Parser<?> sequence(Parser<?>... ps)
[Parser ?] -> Parser ?
ps
- the array of Parser objects.public static Parser<?> sequence(java.lang.String name, Parser<?>... ps)
[Parser ?] -> Parser ?
name
- the name of the new Parser.ps
- the array of Parser objects.public static Parser<java.lang.Object> seqAll(Parser<?>[] ps)
[Parser ?] -> Parser Object
ps
- the array of Parser objects.public static Parser<java.lang.Object> seqAll(java.lang.String name, Parser<?>[] ps)
[Parser ?] -> Parser Object
name
- the name of the new Parser.ps
- the array of Parser objects.public static <R> Parser<R> isReturn(java.lang.String name, ObjectPredicate<R> op)
name
- the name of the new Parser object.op
- the predicate object.public static <R> Parser<R> isReturn(java.lang.String name, Parser<R> p, ObjectPredicate<? super R> op)
name
- the name of the new Parser object.p
- the parser object to test the return value of.op
- the predicate object.public static <R> Parser<R> isReturn(java.lang.String name, Parser<R> p, ObjectPredicate<? super R> op, java.lang.String expecting)
name
- the name of the new Parser object.p
- the parser object to test the return value of.op
- the predicate object.expecting
- the "expected" error message.@Deprecated public static Parser<?> isState(ObjectPredicate<java.lang.Object> op)
op
- the predicate object.@Deprecated public static Parser<?> isState(java.lang.String name, ObjectPredicate<java.lang.Object> op)
name
- the name of the new Parser object.op
- the predicate object.public static <R> Parser<R> step(java.lang.String name, int n, Parser<R> p)
name
- the name of the new Parser object.n
- the number logical steps. n>=0 has to be true.p
- the Parser object.public static <R> Parser<R> lookahead(java.lang.String name, int toknum, Parser<R> p)
lookahead only affects one nesting level. Parsers.plus(p1,p2).ifelse(yes,no).lookahead(3) will not affect the Parsers.plus(p1,p2) nested within ifelse.
lookahead directly on top of lookahead will override the previous
lookahead. Parsers.plus(p1,p2).lookahead(3).lookahead(1) is equivalent as
Parsers.plus(p1, p2).lookahead(1).
lookahead looks at logical step. by default, each terminal is one logical
step. atomize() combinator ensures at most 1 logical step for a parser. Use
step() combinator to fine control logical steps.
name
- the name of the new Parser object.toknum
- the number of tokens to look ahead.public static <R> Parser<R> mapn(Parser<?>[] ps, Mapn<R> mn)
[Parser a] -> ([a]->r) -> Parser r
ps
- the array of Parser objects.mn
- the Mapn object.public static <R> Parser<R> mapn(java.lang.String name, Parser<?>[] ps, Mapn<R> mn)
[Parser a] -> ([a]->r) -> Parser r
name
- the name of the new Parser.ps
- the array of Parser objects.mn
- the Mapn object.public static <E,R> Parser<R> mapn(java.lang.Class<? super E> etype, Parser<E>[] ps, Mapn<R> mn)
[Parser a] -> ([a]->r) -> Parser r
etype
- the element type of the return value array.ps
- the array of Parser objects.mn
- the Mapn object.public static <E,R> Parser<R> mapn(java.lang.String name, java.lang.Class<? super E> etype, Parser<E>[] ps, Mapn<R> mn)
[Parser a] -> ([a]->r) -> Parser r
name
- the name of the new Parser.etype
- the element type of the return value array.ps
- the array of Parser objects.mn
- the Mapn object.public static <E,R> Parser<R> mapn(ArrayFactory<?> af, Parser<?>[] ps, Mapn<R> mn)
[Parser a] -> ([a]->r) -> Parser r
af
- the ArrayFactory object.ps
- the array of Parser objects.mn
- the Mapn object.public static <R> Parser<R> mapn(java.lang.String name, ArrayFactory<?> af, Parser<?>[] ps, Mapn<R> mn)
[Parser a] -> ([a]->r) -> Parser r
name
- the name of the new Parser.af
- the ArrayFactory object.ps
- the array of Parser objects.mn
- the Mapn object.public static <R> Parser<R> fail(java.lang.String msg)
Parser *
msg
- the error message.public static <R> Parser<R> fail(java.lang.String name, java.lang.String msg)
Parser *
name
- the Parser object name.msg
- the error message.public static <C,R> Parser<R> ifelse(java.lang.String name, Parser<C> p, ToParser<? super C,R> yes, Parser<? extends R> no)
Parser a -> (a->Parser b) -> Parser b -> Parser b
name
- the name of the new Parser object.p
- the Parser object to test.yes
- the true branch.no
- the false branch.public static <C,R> Parser<R> ifelse(java.lang.String name, Parser<C> p, Parser<R> yes, Parser<? extends R> no)
Parser x -> Parser b -> Parser b -> Parser b
name
- the name of the new Parser object.p
- the Parser object to test.yes
- the true branch.no
- the false branch.public static <R> Parser<R> plus(Parser<R> p1, Parser<? extends R> p2)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a
p1
- 1st Parser.p2
- 2nd Parser.public static <R> Parser<R> plus(java.lang.String name, Parser<R> p1, Parser<? extends R> p2)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.public static <R> Parser<R> plus(Parser<R> p1, Parser<? extends R> p2, Parser<? extends R> p3)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a -> Parser a
p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.public static <R> Parser<R> plus(java.lang.String name, Parser<R> p1, Parser<? extends R> p2, Parser<? extends R> p3)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a -> Parser a
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.public static <R> Parser<R> plus(Parser<R> p1, Parser<? extends R> p2, Parser<? extends R> p3, Parser<? extends R> p4)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a -> Parser a -> Parser a
p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.public static <R> Parser<R> plus(java.lang.String name, Parser<R> p1, Parser<? extends R> p2, Parser<? extends R> p3, Parser<? extends R> p4)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a -> Parser a -> Parser a
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.public static <R> Parser<R> plus(Parser<R> p1, Parser<? extends R> p2, Parser<? extends R> p3, Parser<? extends R> p4, Parser<? extends R> p5)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a -> Parser a -> Parser a -> Parser a
p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.p5
- 5th Parser.public static <R> Parser<R> plus(java.lang.String name, Parser<R> p1, Parser<? extends R> p2, Parser<? extends R> p3, Parser<? extends R> p4, Parser<? extends R> p5)
For backwward compatibility with java 1.4. Use the vararg version in java 5.
Parser a -> Parser a -> Parser a -> Parser a -> Parser a -> Parser a
name
- the name of the new Parser object.p1
- 1st Parser.p2
- 2nd Parser.p3
- 3rd Parser.p4
- 4th Parser.p5
- 5th Parser.public static <R> Parser<R> plus(java.lang.String name, Parser<R>... ps)
name
- the name of the created parser.ps
- the Parser objects.public static <R> Parser<R> plus(Parser<R>... ps)
ps
- the Parser objects.public static Parser<java.lang.Object> sum(Parser<?>... ps)
[Parser a] -> Parser a
ps
- the array of alternative Parser objects.public static Parser<java.lang.Object> sum(java.lang.String name, Parser<?>... ps)
[Parser a] -> Parser a
name
- the name of the new Parser object.ps
- the array of alternative Parser objects.public static <R> Parser<R> longer(java.lang.String name, Parser<R> p1, Parser<R> p2)
name
- the name of the new Parser object.p1
- the 1st alternative parser.p2
- the 2nd alternative parser.public static <R> Parser<R> longest(java.lang.String name, Parser<R>... ps)
name
- the name of the new Parser object.ps
- the array of alternative parsers.public static <R> Parser<R> shorter(java.lang.String name, Parser<R> p1, Parser<R> p2)
name
- the name of the new Parser object.p1
- the 1st alternative parser.p2
- the 2nd alternative parser.public static <R> Parser<R> shortest(java.lang.String name, Parser<R>... ps)
name
- the name of the new Parser object.ps
- the array of alternative parsers.public static <R> Parser<R> longer(Parser<R> p1, Parser<R> p2)
p1
- the 1st alternative parser.p2
- the 2nd alternative parser.public static <R> Parser<R> longest(Parser<R>... ps)
ps
- the array of alternative parsers.public static <R> Parser<R> shorter(Parser<R> p1, Parser<R> p2)
p1
- the 1st alternative parser.p2
- the 2nd alternative parser.public static <R> Parser<R> shortest(Parser<R>... ps)
ps
- the array of alternative parsers.public static Parser<java.lang.Object> or(java.lang.String name, Parser<?>... alternatives)
name
- the new parser name.alternatives
- the alternative parsers.public static Parser<java.lang.Object> or(Parser<?>... alternatives)
alternatives
- the alternative parsers.public static <T> Parser<T> alt(java.lang.String name, Parser<T>... alternatives)
name
- the new parser name.alternatives
- the alternative parsers.public static <T> Parser<T> alt(Parser<T>... alternatives)
alternatives
- the alternative parsers.public static <R> Parser<R> isConsumed(Parser<R> p)
Parser a -> Parser a
p
- the Parser object to test.public static <R> Parser<R> isConsumed(Parser<R> p, java.lang.String err)
Parser a -> Parser a
p
- the Parser object to test.err
- the error message when p succeeds with no input consumed.public static <R> Parser<R> isConsumed(java.lang.String name, Parser<R> p)
Parser a -> Parser a
name
- the name of the new Parser object.p
- the Parser object to test.public static <R> Parser<R> isConsumed(java.lang.String name, Parser<R> p, java.lang.String err)
Parser a -> Parser a
name
- the name of the new Parser.p
- the Parser object to test.err
- the error message when p succeeds with no input consumed.public static <R> Parser<R> notConsumed(Parser<R> p)
Parser a -> Parser a
p
- the Parser object to test.public static <R> Parser<R> notConsumed(Parser<R> p, java.lang.String err)
Parser a -> Parser a
p
- the Parser object to test.err
- the error message when p succeeds and consumes some input.public static <R> Parser<R> notConsumed(java.lang.String name, Parser<R> p)
Parser a -> Parser a
name
- the name of the new Parser.p
- the Parser object to test.public static <R> Parser<R> notConsumed(java.lang.String name, Parser<R> p, java.lang.String err)
Parser a -> Parser a
name
- the name of the new Parser.p
- the Parser object to test.err
- the error message when p succeeds and consumes some input.public static <R> Parser<R> lazy(ParserEval<R> p)
Parser a -> Parser a
p
- the ParserEval object.public static <R> Parser<R> lazy(Parser<R>[] placeholder, int pos)
placeholder
- the array that contains parser object.pos
- the position (0-based) of the parser to lazily evaluate.public static <R> Parser<R> lazy(Parser<R>[] placeholder)
placeholder
- the array whose first object is the lazily evaluated parser object.public static <R> Parser<R> lazy(java.lang.String name, ParserEval<R> p)
Parser a -> Parser a
name
- the name of the Parser object.p
- the ParserEval object.@Deprecated public static Parser<java.lang.Object> getState()
Parser u u
@Deprecated public static Parser<java.lang.Object> getState(java.lang.String name)
Parser u u
name
- the name of the Parser object.@Deprecated public static Parser<java.lang.Object> setState(java.lang.Object s)
Parser u1 u
s
- the new user state value.@Deprecated public static Parser<java.lang.Object> setState(java.lang.String name, java.lang.Object s)
Parser u1 u
name
- the name of the Parser object.s
- the new user state value.@Deprecated public static <State> Parser<State> transformState(Map<State,?> m)
(u1->u2) -> Parser u2 u1
m
- the transformation.@Deprecated public static <State> Parser<State> transformState(java.lang.String name, Map<State,?> m)
(u1->u2) -> Parser u2 u1
name
- the name of the Parser object.m
- the transformation.public static Parser<java.lang.Integer> getIndex()
Parser Integer
public static Parser<java.lang.Integer> getIndex(java.lang.String name)
Parser Integer
name
- the name of the Parser object.public static <R> Parser<R> peek(java.lang.String name, Parser<R> p)
Parser a -> Parser a
name
- the name of the new Parser object.p
- the Parser object.public static <R> Parser<R> atomize(java.lang.String name, Parser<R> p)
Parser a -> Parser a
name
- the name of the new Parser object.p
- the Parser object.public static <R> Parser<R> tryParser(Parser<R> p, Catch<? extends R> hdl)
Parser a -> Parser a
p
- the Parser object.hdl
- the exception handler.public static <R> Parser<R> tryParser(java.lang.String name, Parser<R> p, Catch<? extends R> hdl)
Parser a -> Parser a
name
- the name of the new Parser object.p
- the Parser object.hdl
- the exception handler.public static <R,From> Parser<R> map(java.lang.String name, Parser<From> p, Map<? super From,R> m)
Parser a -> (a->b) -> Parser b
name
- the name of the new Parser object.p
- the Parser object.m
- the Map object.public static <x> Parser<x> unexpected(java.lang.String msg)
Parser *
msg
- the error message.public static <x> Parser<x> unexpected(java.lang.String name, java.lang.String msg)
Parser *
name
- the name of the new Parser object.msg
- the error message.public static <R> Parser<R> token(FromToken<R> ft)
(SourcePos->Token->a) -> Parser a
ft
- the FromToken object.public static <R> Parser<R> token(java.lang.String name, FromToken<R> ft)
(SourcePos->Object->a) -> Parser a
name
- the name of the new Parser object.ft
- the FromToken object.public static Parser<Tok> token(java.lang.Object t)
Object -> Parser SourcePos
t
- the expected Token object.public static Parser<Tok> token(java.lang.String name, java.lang.Object t)
Token -> Parser SourcePos
name
- the name of the new Parser object.t
- the expected Token object.public static <R> Parser<R> label(java.lang.String name, java.lang.String lbl, Parser<R> p)
Parser a -> Parser a
name
- the name of the new Parser object.lbl
- the label text.p
- the Parser object to label.public static <x> Parser<x> expect(java.lang.String name, java.lang.String lbl)
x
- the result Parser object is good for any result type.
(it does not return anyway)name
- the parser name.lbl
- the label.public static <x> Parser<x> expect(java.lang.String lbl)
x
- the result Parser object is good for any result type.
(it does not return anyway)lbl
- the label.public static <R> Parser<R> raise(java.lang.Object e)
Parser *
e
- the exception object.public static <R> Parser<R> raise(java.lang.String name, java.lang.Object e)
Parser *
name
- the name of the new Parser object.e
- the exception object.public static <From,A extends From,R,To extends R> Parser<R> manyAccum(java.lang.String name, Accumulatable<From,To> accm, int min, Parser<A> p)
Accumulatable a r -> int -> int -> Parser a -> Parser r
name
- the name of the new Parser object.accm
- the Accumulatable object.min
- the minimum times to repeat.p
- the Parser object.public static <From,A extends From,R,To extends R> Parser<R> manyAccum(java.lang.String name, Accumulatable<From,To> accm, Parser<A> p)
Accumulatable a r -> int -> int -> Parser a -> Parser r
name
- the name of the new Parser object.accm
- the Accumulatable object.p
- the Parser object.public static <From,A extends From,R,To extends R> Parser<R> someAccum(java.lang.String name, Accumulatable<From,To> accm, int min, int max, Parser<A> p)
Accumulatable a r -> int -> int -> Parser a -> Parser r
name
- the name of the new Parser object.accm
- the Accumulatable object.min
- the minimum times to repeat.max
- the maximum times to repeat.p
- the Parser object.public static <From,A extends From,R,To extends R> Parser<R> someAccum(java.lang.String name, Accumulatable<From,To> accm, int max, Parser<A> p)
Accumulatable a r -> int -> int -> Parser a -> Parser r
name
- the name of the new Parser object.accm
- the Accumulatable object.max
- the maximum times to repeat.p
- the Parser object.public static Parser<?> eof()
Parser ?
public static Parser<?> eof(java.lang.String msg)
Parser ?
msg
- the error message if eof is not met.public static Parser<?> eof(java.lang.String name, java.lang.String msg)
Parser ?
name
- the name of the new Parser object.msg
- the error message if eof is not met.public static Parser<?> not(java.lang.String name, Parser<?> p)
Parser ? -> Parser ?
name
- the name of the new Parser object.p
- the Parser to 'not'public static Parser<?> not(java.lang.String name, Parser<?> p, java.lang.String errmsg)
Parser ? -> Parser ?
name
- the name of the new Parser object.p
- the Parser to 'not'errmsg
- the error message if Parser p succeeds.public static <R> Parser<_> many(java.lang.String name, int min, Parser<?> p)
int -> Parser ? -> Parser _
name
- the name of the new Parser object.min
- the minimal times to run.p
- the Parser object.public static Parser<_> many(java.lang.String name, Parser<?> p)
Parser ? -> Parser _
name
- the name of the new Parser object.p
- the Parser object.public static <R> Parser<R[]> many(java.lang.String name, java.lang.Class<R> etype, int min, Parser<? extends R> p)
Class [a] -> int -> Parser a -> Parser [a]
name
- the name of the new Parser object.etype
- the array element type.min
- the maximal times to run.p
- the Parser object.public static <R> Parser<R[]> many(java.lang.String name, java.lang.Class<R> etype, Parser<? extends R> p)
Class [a] -> Parser a -> Parser [a]
name
- the name of the new Parser object.etype
- the array element type.p
- the Parser object.public static <R> Parser<R[]> many(java.lang.String name, ArrayFactory<R> af, int min, Parser<? extends R> p)
ArrayFactory a -> int -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.min
- the maximal times to run.p
- the Parser object.public static <R> Parser<R[]> many(java.lang.String name, ArrayFactory<R> af, Parser<? extends R> p)
ArrayFactory a -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.p
- the Parser object.public static <R> Parser<_> some(java.lang.String name, int min, int max, Parser<?> p)
int -> int -> Parser ? -> Parser _
name
- the name of the new Parser object.min
- the minimal number of times to run.max
- the maximal number of times to run.p
- the Parser object.public static Parser<_> some(java.lang.String name, int max, Parser<?> p)
int -> Parser ? -> Parser _
name
- the name of the new Parser object.max
- the maximal number of times to run.p
- the Parser object.public static <R> Parser<R[]> some(java.lang.String name, ArrayFactory<R> af, int min, int max, Parser<? extends R> p)
ArrayFactory a -> int -> int -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.min
- the minimal number of times to run.max
- the maximal number of times to run.p
- the Parser object.public static <R> Parser<R[]> some(java.lang.String name, ArrayFactory<R> af, int max, Parser<? extends R> p)
ArrayFactory a -> int -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.max
- the maximal number of times to run.p
- the Parser object.public static <R> Parser<R[]> some(java.lang.String name, java.lang.Class<R> etype, int min, int max, Parser<? extends R> p)
Class -> int -> int -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- the array element type.min
- the minimal number of times to run.max
- the maximal number of times to run.p
- the Parser object.public static <R> Parser<R[]> some(java.lang.String name, java.lang.Class<R> etype, int max, Parser<? extends R> p)
Class -> int -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- the array element type.max
- the maximal number of times to run.p
- the Parser object.public static <A,B,R> Parser<R> map2(Parser<A> p1, Parser<B> p2, Map2<? super A,? super B,R> m2)
Parser a->Parser b->(a->b->r)->Parser r
p1
- 1st parser.p2
- 2nd parser.m2
- the transformer.public static <A,B,R> Parser<R> map2(java.lang.String name, Parser<A> p1, Parser<B> p2, Map2<? super A,? super B,R> m2)
Parser a->Parser b->(a->b->r)->Parser r
name
- the name of the new Parser object.p1
- 1st parser.p2
- 2nd parser.m2
- the transformer.public static <A,B,C,R> Parser<R> map3(Parser<A> p1, Parser<B> p2, Parser<C> p3, Map3<? super A,? super B,? super C,R> m3)
Parser a->Parser b->Parser c->(a->b->c->r)->Parser r
p1
- 1st parser.p2
- 2nd parser.p3
- 3rd parser.m3
- the transformer.public static <A,B,C,R> Parser<R> map3(java.lang.String name, Parser<A> p1, Parser<B> p2, Parser<C> p3, Map3<? super A,? super B,? super C,R> m3)
Parser a->Parser b->Parser c->(a->b->c->r)->Parser r
name
- the name of the new Parser object.p1
- 1st parser.p2
- 2nd parser.p3
- 3rd parser.m3
- the transformer.public static <A,B,C,D,R> Parser<R> map4(Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Map4<? super A,? super B,? super C,? super D,R> m4)
Parser a->Parser b->Parser c->Parser d->(a->b->c->d->r)->Parser r
p1
- 1st parser.p2
- 2nd parser.p3
- 3rd parser.p4
- 4th parser.m4
- the transformer.public static <A,B,C,D,R> Parser<R> map4(java.lang.String name, Parser<A> p1, Parser<B> p2, Parser<C> p3, Parser<D> p4, Map4<? super A,? super B,? super C,? super D,R> m4)
Parser a->Parser b->Parser c->Parser d->(a->b->c->d->r)->Parser r
name
- the name of the new Parser object.p1
- 1st parser.p2
- 2nd parser.p3
- 3rd parser.p4
- 4th parser.m4
- the transformer.public static <A,B,C,D,E,R> Parser<R> map5(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,R> m5)
Parser a->Parser b->Parser c->Parser d->Parser e->(a->b->c->d->e->r)->Parser r
p1
- 1st parser.p2
- 2nd parser.p3
- 3rd parser.p4
- 4th parser.p5
- 5th parser.m5
- the transformer.public static <A,B,C,D,E,R> Parser<R> map5(java.lang.String name, 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,R> m5)
Parser a->Parser b->Parser c->Parser d->Parser e->(a->b->c->d->e->r)->Parser r
name
- the name of the new Parser object.p1
- 1st parser.p2
- 2nd parser.p3
- 3rd parser.p4
- 4th parser.p5
- 5th parser.m5
- the transformer.public static <R> Parser<R> option(R v, Parser<R> p)
a -> Parser a -> Parser a
v
- the default value.p
- the Parser object.public static <R> Parser<R> option(java.lang.String name, R v, Parser<R> p)
a -> Parser a -> Parser a
name
- the name of the new Parser object.v
- the default value.p
- the Parser object.public static <R> Parser<R> optional(Parser<R> p)
Parser a -> Parser a
p
- the Parser object.public static <R> Parser<R> optional(java.lang.String name, Parser<R> p)
Parser a -> Parser a
name
- the name of the new Parser object.p
- the Parser object.public static <R> Parser<R> between(Parser<?> open, Parser<?> close, Parser<R> p)
Parser ? -> Parser a -> Parser ? -> Parser a
open
- the opening parser.close
- the closing parser.p
- the Parser object.public static <R> Parser<R> between(java.lang.String name, Parser<?> open, Parser<?> close, Parser<R> p)
Parser ? -> Parser ? -> Parser a -> Parser a
name
- the name of the new Parser object.open
- the opening parser.close
- the closing parser.p
- the Parser object.public static Parser<_> sepBy1(Parser<?> sep, Parser<?> p)
Parser p has to succeed at least once.
For example: pattern "token, token, token, token" is sepBy1(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
sep
- the seperator.p
- the Parser object.public static Parser<_> sepBy1(java.lang.String name, Parser<?> sep, Parser<?> p)
Parser p has to succeed at least once.
For example: pattern "token, token, token, token" is sepBy1(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
name
- the name of the new Parser object.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy1(java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Class -> Parser a -> Parser [Object].
run a series of Parser p pattern that is seperated by Parser sep pattern.
Parser p has to succeed at least once.
For example: pattern "token, token, token, token" is sepBy1(comma, token).
The return values are collected in an array whose element type is etype.
etype
- the array element type.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy1(java.lang.String name, java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Class -> Parser a -> Parser [Object].
run a series of Parser p pattern that is seperated by Parser sep pattern.
Parser p has to succeed at least once.
For example: pattern "token, token, token, token" is sepBy1(comma, token).
The return values are collected in an array whose element type is etype.
name
- the name of the new Parser object.etype
- the array element type.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy1(ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p has to succeed at least once.
For example: pattern "token, token, token, token" is sepBy1(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
af
- the ArrayFacory object.sep
- the seperator.p
- the Parser object.public static <R,A extends R> Parser<R[]> sepBy1(java.lang.String name, ArrayFactory<R> af, Parser<?> sep, Parser<A> p)
Parser p has to succeed at least once.
For example: pattern "token, token, token, token" is sepBy1(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.sep
- the seperator.p
- the Parser object.public static Parser<_> sepBy(Parser<?> sep, Parser<?> p)
Parser p can succeed 0 or more times.
For example: pattern "token, token, token, token" is sepBy(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
sep
- the seperator.p
- the Parser object.public static Parser<_> sepBy(java.lang.String name, Parser<?> sep, Parser<?> p)
Parser p can succeed 0 or more times.
For example: pattern "token, token, token, token" is sepBy(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
name
- the name of the new Parser object.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy(java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token, token, token, token" is sepBy(comma, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
etype
- the array element type.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy(ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token, token, token, token" is sepBy(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
af
- the ArrayFacory object.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy(java.lang.String name, ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token, token, token, token" is sepBy(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.sep
- the seperator.p
- the Parser object.public static <R> Parser<R[]> sepBy(java.lang.String name, java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token, token, token, token" is sepBy(comma, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- the array element type.sep
- the seperator.p
- the Parser object.public static <R> Parser<R> followedBy(java.lang.String name, Parser<?> sep, Parser<R> p)
Parser ? -> Parser a -> Parser a
name
- the name of the new Parser object.sep
- the following parser.p
- the Parser object.public static Parser<_> endBy(Parser<?> sep, Parser<?> p)
Parser p can succeed 0 or more times.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are discarded.
Class -> Parser ? -> Parser _
sep
- the end seperator.p
- the Parser object.public static Parser<_> endBy(java.lang.String name, Parser<?> sep, Parser<?> p)
Parser p can succeed 0 or more times.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
name
- the name of the new Parser object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy(java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
etype
- array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy(ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are discarded.
ArrayFactory a -> Parser ? -> Parser a -> Parser a[]
af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy(java.lang.String name, java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy(java.lang.String name, ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p can succeed 0 or more times.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static Parser<_> endBy1(Parser<?> sep, Parser<?> p)
Parser p should succeed for at least once.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
sep
- the end seperator.p
- the Parser object.public static Parser<_> endBy1(java.lang.String name, Parser<?> sep, Parser<?> p)
Parser p should succeed for at least once.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
name
- the name of the new Parser object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy1(java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed for at least once.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
etype
- array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy1(ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed for at least once.
For example: pattern "token; token; token; token;" is endBy1(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy1(java.lang.String name, ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed for at least once.
For example: pattern "token; token; token; token;" is endBy1(comma, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> endBy1(java.lang.String name, java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed for at least once.
For example: pattern "token; token; token; token;" is endBy(comma, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- array element type.sep
- the end seperator.p
- the Parser object.public static Parser<_> sepEndBy(Parser<?> sep, Parser<?> p)
Parser p may succeed 0 or more times.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy(semicolon, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy(java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p may succeed 0 or more times.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy(semicolon, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
etype
- the array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy(ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p may succeed 0 or more times.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy(semicolon, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static Parser<_> sepEndBy(java.lang.String name, Parser<?> sep, Parser<?> p)
Parser p may succeed 0 or more times.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy(semicolon, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
name
- the name of the new Parser object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy(java.lang.String name, java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p may succeed 0 or more times.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy(semicolon, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- the array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy(java.lang.String name, ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p may succeed 0 or more times.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy(semicolon, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static Parser<_> sepEndBy1(Parser<?> sep, Parser<?> p)
Parser p should succeed at least once.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy1(semicolon, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
sep
- the end seperator.p
- the Parser object.public static Parser<_> sepEndBy1(java.lang.String name, Parser<?> sep, Parser<?> p)
Parser p should succeed at least once.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy1(semicolon, token).
The return values are discarded.
Parser ? -> Parser ? -> Parser _
name
- the name of the new Parser object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy1(java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed at least once.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy1(semicolon, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
etype
- the array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy1(ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed at least once.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy1(semicolon, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser a -> Parser [a]
af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy1(java.lang.String name, java.lang.Class<R> etype, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed at least once.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy1(semicolon, token).
The return values are collected in an array whose element type is etype.
Class -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- the array element type.sep
- the end seperator.p
- the Parser object.public static <R> Parser<R[]> sepEndBy1(java.lang.String name, ArrayFactory<R> af, Parser<?> sep, Parser<? extends R> p)
Parser p should succeed at least once.
For example: patterns "token; token; token; token" and "token;" are both
sepEndBy1(semicolon, token).
The return values are collected in an array created by the ArrayFactory
object af.
ArrayFactory a -> Parser ? -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFacory object.sep
- the end seperator.p
- the Parser object.public static Parser<_> repeat(java.lang.String name, int n, Parser<?> p)
int -> Parser ? -> Parser _
name
- the name of the new Parser object.n
- the number of times to run.p
- the Parser object.public static <R> Parser<R[]> repeat(java.lang.String name, java.lang.Class<R> etype, int n, Parser<? extends R> p)
Class -> int -> Parser a -> Parser [Object]
name
- the name of the new Parser object.etype
- the array element type.n
- the number of times to run.p
- the Parser object.public static <R> Parser<R[]> repeat(java.lang.String name, ArrayFactory<R> af, int n, Parser<? extends R> p)
ArrayFactory a -> int -> Parser a -> Parser [a]
name
- the name of the new Parser object.af
- the ArrayFactory object.n
- the number of times to run.p
- the Parser object.public static <T> Parser<T> prefix(Parser<? extends Map<? super T,T>> op, Parser<? extends T> p)
Parser (a->a) -> Parser a -> Parser a
op
- the operator.p
- the operand.public static <T> Parser<T> prefix(java.lang.String name, Parser<? extends Map<? super T,T>> op, Parser<? extends T> p)
Parser (a->a) -> Parser a -> Parser a
name
- the name of the new Parser object.op
- the operator.p
- the operand.public static <T> Parser<T> postfix(Parser<? extends Map<? super T,T>> op, Parser<? extends T> p)
Parser (a->a) -> Parser a -> Parser a
op
- the operator.p
- the operand.public static <T> Parser<T> postfix(java.lang.String name, Parser<? extends Map<? super T,T>> op, Parser<? extends T> p)
Parser (a->a) -> Parser a -> Parser a
name
- the name of the new Parser object.op
- the operator.p
- the operand.public static <T> Parser<T> infixn(Parser<? extends Map2<? super T,? super T,T>> op, Parser<? extends T> operand)
Parser (a->a->a) -> Parser a -> Parser a
op
- the operator.operand
- the operand.public static <T> Parser<T> infixn(java.lang.String name, Parser<? extends Map2<? super T,? super T,T>> op, Parser<? extends T> operand)
Parser (a->a->a) -> Parser a -> Parser a
name
- the name of the new Parser object.op
- the operator.operand
- the operand.public static <T> Parser<T> infixl(Parser<? extends Map2<? super T,? super T,T>> op, Parser<? extends T> p)
Parser (a->a->a) -> Parser a -> Parser a
op
- the operator.p
- the operand.public static <T> Parser<T> infixl(java.lang.String name, Parser<? extends Map2<? super T,? super T,T>> op, Parser<? extends T> p)
Parser (a->a->a) -> Parser a -> Parser a
name
- the name of the new Parser object.op
- the operator.p
- the operand.public static <T> Parser<T> infixr(Parser<? extends Map2<? super T,? super T,T>> op, Parser<? extends T> p)
Parser (a->a->a) -> Parser a -> Parser a
op
- the operator.p
- the operand.public static <T> Parser<T> infixr(java.lang.String name, Parser<? extends Map2<? super T,? super T,T>> op, Parser<? extends T> p)
Parser (a->a->a) -> Parser a -> Parser a
name
- the name of the new Parser object.op
- the operator.p
- the operand.public static Parser<Tok> anyToken()
Parser Token