|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfj.parser.Parser<I,A,E>
public class Parser<I,A,E>
A parser is a function that takes some input (I) and produces either an error (E) or a parse result (A) and the remainder of the input.
Nested Class Summary | |
---|---|
static class |
Parser.CharsParser
Parsers that accept Stream<Character> input. |
static class |
Parser.StreamParser
Parsers that accept Stream input. |
Method Summary | ||
---|---|---|
|
apply(Parser<I,F<A,B>,E> p)
Performs function application within a parser. |
|
|
bind(F<A,Parser<I,B,E>> f)
Binds the given function across the parser with a final join. |
|
|
bind(Parser<I,B,E> pb,
F<A,F<B,C>> f)
Binds the given function across the parsers with a final join. |
|
|
bind(Parser<I,B,E> pb,
Parser<I,C,E> pc,
F<A,F<B,F<C,D>>> f)
Binds the given function across the parsers with a final join. |
|
|
bind(Parser<I,B,E> pb,
Parser<I,C,E> pc,
Parser<I,D,E> pd,
F<A,F<B,F<C,F<D,E$>>>> f)
Binds the given function across the parsers with a final join. |
|
|
bind(Parser<I,B,E> pb,
Parser<I,C,E> pc,
Parser<I,D,E> pd,
Parser<I,E$,E> pe,
F<A,F<B,F<C,F<D,F<E$,F$>>>>> f)
Binds the given function across the parsers with a final join. |
|
|
bind(Parser<I,B,E> pb,
Parser<I,C,E> pc,
Parser<I,D,E> pd,
Parser<I,E$,E> pe,
Parser<I,F$,E> pf,
F<A,F<B,F<C,F<D,F<E$,F<F$,G>>>>>> f)
Binds the given function across the parsers with a final join. |
|
|
bind(Parser<I,B,E> pb,
Parser<I,C,E> pc,
Parser<I,D,E> pd,
Parser<I,E$,E> pe,
Parser<I,F$,E> pf,
Parser<I,G,E> pg,
F<A,F<B,F<C,F<D,F<E$,F<F$,F<G,H>>>>>>> f)
Binds the given function across the parsers with a final join. |
|
|
bind(Parser<I,B,E> pb,
Parser<I,C,E> pc,
Parser<I,D,E> pd,
Parser<I,E$,E> pe,
Parser<I,F$,E> pf,
Parser<I,G,E> pg,
Parser<I,H,E> ph,
F<A,F<B,F<C,F<D,F<E$,F<F$,F<G,F<H,I$>>>>>>>> f)
Binds the given function across the parsers with a final join. |
|
static
|
fail(E e)
Returns a parser that always fails with the given error. |
|
Parser<I,A,E> |
filter(F<A,Boolean> f,
E e)
Returns a parser that fails with the given error if the result value does not meet the given predicate. |
|
|
map(F<A,B> f)
Maps the given result type across this parser. |
|
|
mapError(F<E,K> f)
Maps the given function across this parser's error. |
|
Parser<I,Unit,E> |
not(E e)
Returns a parser that negates this parser. |
|
Parser<I,Unit,E> |
not(P1<E> e)
Returns a parser that negates this parser. |
|
Parser<I,A,E> |
or(P1<Parser<I,A,E>> alt)
Returns a parser that tries this parser and if it fails, then tries the given parser. |
|
Parser<I,A,E> |
or(P1<Parser<I,A,E>> alt,
Semigroup<E> s)
Returns a parser that tries this parser and if it fails, then tries the given parser. |
|
Parser<I,A,E> |
or(Parser<I,A,E> alt)
Returns a parser that tries this parser and if it fails, then tries the given parser. |
|
Parser<I,A,E> |
or(Parser<I,A,E> alt,
Semigroup<E> s)
Returns a parser that tries this parser and if it fails, then tries the given parser. |
|
Validation<E,Result<I,A>> |
parse(I i)
Parses the input to produce a result or error. |
|
static
|
parser(F<I,Validation<E,Result<I,A>>> f)
Returns a parser that computes using the given function. |
|
Parser<I,Stream<A>,E> |
repeat()
Returns a parser that repeats application of this parser zero or many times. |
|
Parser<I,Stream<A>,E> |
repeat1()
Returns a parser that repeats application of this parser one or many times. |
|
static
|
sequence(List<Parser<I,A,E>> ps)
Sequence the list of parsers through bind(fj.F>) . |
|
|
sequence(Parser<I,B,E> p)
Binds anonymously, ignoring the result value. |
|
static
|
value(A a)
Constructs a parser that always returns the given value. |
|
|
xmap(F<I,Z> f,
F<Z,I> g)
Maps the parse input type through an invariant functor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public Validation<E,Result<I,A>> parse(I i)
i
- The input to parse.
public <Z> Parser<Z,A,E> xmap(F<I,Z> f, F<Z,I> g)
f
- The function to covariant map.g
- The function to contra-variant map.
public <B> Parser<I,B,E> map(F<A,B> f)
f
- The function to map.
public Parser<I,A,E> filter(F<A,Boolean> f, E e)
f
- The predicate to filter on.e
- The error to in the event that the predicate is not met.
public <B> Parser<I,B,E> bind(F<A,Parser<I,B,E>> f)
f
- The function to apply to the element of this parser.
public <B,C> Parser<I,C,E> bind(Parser<I,B,E> pb, F<A,F<B,C>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.
public <B,C,D> Parser<I,D,E> bind(Parser<I,B,E> pb, Parser<I,C,E> pc, F<A,F<B,F<C,D>>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.pc
- A given parser to bind the given function with.
public <B,C,D,E$> Parser<I,E$,E> bind(Parser<I,B,E> pb, Parser<I,C,E> pc, Parser<I,D,E> pd, F<A,F<B,F<C,F<D,E$>>>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.pc
- A given parser to bind the given function with.pd
- A given parser to bind the given function with.
public <B,C,D,E$,F$> Parser<I,F$,E> bind(Parser<I,B,E> pb, Parser<I,C,E> pc, Parser<I,D,E> pd, Parser<I,E$,E> pe, F<A,F<B,F<C,F<D,F<E$,F$>>>>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.pc
- A given parser to bind the given function with.pd
- A given parser to bind the given function with.pe
- A given parser to bind the given function with.
public <B,C,D,E$,F$,G> Parser<I,G,E> bind(Parser<I,B,E> pb, Parser<I,C,E> pc, Parser<I,D,E> pd, Parser<I,E$,E> pe, Parser<I,F$,E> pf, F<A,F<B,F<C,F<D,F<E$,F<F$,G>>>>>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.pc
- A given parser to bind the given function with.pd
- A given parser to bind the given function with.pe
- A given parser to bind the given function with.pf
- A given parser to bind the given function with.
public <B,C,D,E$,F$,G,H> Parser<I,H,E> bind(Parser<I,B,E> pb, Parser<I,C,E> pc, Parser<I,D,E> pd, Parser<I,E$,E> pe, Parser<I,F$,E> pf, Parser<I,G,E> pg, F<A,F<B,F<C,F<D,F<E$,F<F$,F<G,H>>>>>>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.pc
- A given parser to bind the given function with.pd
- A given parser to bind the given function with.pe
- A given parser to bind the given function with.pf
- A given parser to bind the given function with.pg
- A given parser to bind the given function with.
public <B,C,D,E$,F$,G,H,I$> Parser<I,I$,E> bind(Parser<I,B,E> pb, Parser<I,C,E> pc, Parser<I,D,E> pd, Parser<I,E$,E> pe, Parser<I,F$,E> pf, Parser<I,G,E> pg, Parser<I,H,E> ph, F<A,F<B,F<C,F<D,F<E$,F<F$,F<G,F<H,I$>>>>>>>> f)
f
- The function to apply to the element of the parsers.pb
- A given parser to bind the given function with.pc
- A given parser to bind the given function with.pd
- A given parser to bind the given function with.pe
- A given parser to bind the given function with.pf
- A given parser to bind the given function with.pg
- A given parser to bind the given function with.ph
- A given parser to bind the given function with.
public <B> Parser<I,B,E> sequence(Parser<I,B,E> p)
p
- The parser to bind with.
public <B> Parser<I,B,E> apply(Parser<I,F<A,B>,E> p)
p
- The parser returning a function value.
public Parser<I,A,E> or(P1<Parser<I,A,E>> alt)
alt
- The parser to try if this parser fails.
public Parser<I,A,E> or(Parser<I,A,E> alt)
alt
- The parser to try if this parser fails.
public Parser<I,A,E> or(P1<Parser<I,A,E>> alt, Semigroup<E> s)
alt
- The parser to try if this parser fails.s
- The semigroup to append error messages if both parsers fail.
public Parser<I,A,E> or(Parser<I,A,E> alt, Semigroup<E> s)
alt
- The parser to try if this parser fails.s
- The semigroup to append error messages if both parsers fail.
public Parser<I,Unit,E> not(P1<E> e)
e
- The error message to fail with if this parser succeeds.
public Parser<I,Unit,E> not(E e)
e
- The error message to fail with if this parser succeeds.
public Parser<I,Stream<A>,E> repeat()
public Parser<I,Stream<A>,E> repeat1()
public <K> Parser<I,A,K> mapError(F<E,K> f)
f
- The function to map this parser's error with.
public static <I,A,E> Parser<I,A,E> parser(F<I,Validation<E,Result<I,A>>> f)
f
- The function to construct the parser with.
public static <I,A,E> Parser<I,A,E> value(A a)
a
- The value to consistently return from a parser.
public static <I,A,E> Parser<I,A,E> fail(E e)
e
- The error to fail with.
public static <I,A,E> Parser<I,List<A>,E> sequence(List<Parser<I,A,E>> ps)
bind(fj.F>)
.
ps
- The parsers to sequence.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |