Class Parser<I,A,E>
java.lang.Object
fj.parser.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
Nested ClassesModifier and TypeClassDescriptionstatic final classParsers that acceptStream<Character>input.static final classParsers that acceptStreaminput. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPerforms function application within a parser.Binds the given function across the parser with a final join.Binds the given function across the parsers with a final join.Binds the given function across the parsers with a final join.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 <I,A, E> Parser <I, A, E> fail(E e) Returns a parser that always fails with the given error.Returns a parser that fails with the given error if the result value does not meet the given predicate.Maps the given result type across this parser.Maps the given function across this parser's error.Returns a parser that negates this parser.Returns a parser that negates this parser.Returns a parser that tries this parser and if it fails, then tries the given parser.Returns a parser that tries this parser and if it fails, then tries the given parser.Returns a parser that tries this parser and if it fails, then tries the given parser.Returns a parser that tries this parser and if it fails, then tries the given parser.Validation<E, Result<I, A>> Parses the input to produce a result or error.static <I,A, E> Parser <I, A, E> parser(F<I, Validation<E, Result<I, A>>> f) Returns a parser that computes using the given function.repeat()Returns a parser that repeats application of this parser zero or many times.repeat1()Returns a parser that repeats application of this parser one or many times.Sequence the list of parsers throughbind(F).Binds anonymously, ignoring the result value.static <I,A, E> Parser <I, A, E> value(A a) Constructs a parser that always returns the given value.Maps the parse input type through an invariant functor.
-
Field Details
-
f
-
-
Constructor Details
-
Parser
-
-
Method Details
-
parse
-
xmap
-
map
-
filter
Returns a parser that fails with the given error if the result value does not meet the given predicate.- Parameters:
f- The predicate to filter on.e- The error to in the event that the predicate is not met.- Returns:
- A parser that fails with the given error if the result value does not meet the given predicate.
-
bind
-
bind
Binds the given function across the parsers with a final join.- Parameters:
pb- A given parser to bind the given function with.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
bind
Binds the given function across the parsers with a final join.- Parameters:
pb- A given parser to bind the given function with.pc- A given parser to bind the given function with.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
bind
public <B,C, Parser<I,D, E$> E$, bindE> (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.- Parameters:
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.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
bind
public <B,C, Parser<I,D, E$, F$> F$, bindE> (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.- Parameters:
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.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
bind
public <B,C, Parser<I,D, E$, F$, G> G, bindE> (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.- Parameters:
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.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
bind
public <B,C, Parser<I,D, E$, F$, G, H> H, bindE> (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.- Parameters:
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.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
bind
public <B,C, Parser<I,D, E$, F$, G, H, I$> I$, bindE> (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.- Parameters:
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.f- The function to apply to the element of the parsers.- Returns:
- A new parser after performing the map, then final join.
-
sequence
-
apply
-
or
-
or
-
or
Returns a parser that tries this parser and if it fails, then tries the given parser. If both parsers fail, then append their errors with the given semigroup.- Parameters:
alt- The parser to try if this parser fails.s- The semigroup to append error messages if both parsers fail.- Returns:
- A parser that tries this parser and if it fails, then tries the given parser.
-
or
Returns a parser that tries this parser and if it fails, then tries the given parser. If both parsers fail, then append their errors with the given semigroup.- Parameters:
alt- The parser to try if this parser fails.s- The semigroup to append error messages if both parsers fail.- Returns:
- A parser that tries this parser and if it fails, then tries the given parser.
-
not
-
not
-
repeat
-
repeat1
-
mapError
-
parser
Returns a parser that computes using the given function.- Parameters:
f- The function to construct the parser with.- Returns:
- A parser that computes using the given function.
-
value
Constructs a parser that always returns the given value. The unital for a parser.- Parameters:
a- The value to consistently return from a parser.- Returns:
- A parser that always returns the given value.
-
fail
Returns a parser that always fails with the given error.- Parameters:
e- The error to fail with.- Returns:
- A parser that always fails with the given error.
-
sequence
-