I
- the input stream symbol typeA
- the parser result typepublic interface Result<I,A>
Success
or a Failure
.Modifier and Type | Interface and Description |
---|---|
static class |
Result.Failure<I,A>
Base class for the results of a failed parse.
|
static class |
Result.FailureMessage<I,A>
The result of a failed parse, where the failure is descriobed by an error message.
|
static class |
Result.FailureOnExpected<I,A>
The result of a failed parse, where the failure was due an expected symbol not being found.
|
static class |
Result.Success<I,A>
The result of a successful parse.
|
Modifier and Type | Method and Description |
---|---|
static <I,A> Result<I,A> |
failure(Input<I> in,
SymSet<I> expected) |
static <I,A> Result<I,A> |
failureEof(Input<I> in,
SymSet<I> expected) |
static <I,A> Result<I,A> |
failureMessage(Input<I> in,
String error) |
A |
getOrThrow()
Returns the parse value if the parse was successful, otherwise throws an exception
|
void |
handle(SideEffect.F<Result.Success<I,A>> success,
SideEffect.F<Result.Failure<I,A>> failure)
Apply one of two side-effects functions to this value.
|
boolean |
isSuccess()
Indicates if this result is successful.
|
<B> Result<I,B> |
map(Functions.F<A,B> f)
Map a function over this
Result value |
<B> B |
match(Functions.F<Result.Success<I,A>,B> success,
Functions.F<Result.Failure<I,A>,B> failure)
Apply one of two functions to this value.
|
static <I,A> Result<I,A> |
success(A result,
Input<I> next) |
static <I,A> Result<I,A> failureEof(Input<I> in, SymSet<I> expected)
static <I,A> Result<I,A> failureMessage(Input<I> in, String error)
boolean isSuccess()
Success
, otherwise falseA getOrThrow()
RuntimeException
- if the parse was unsuccessful<B> Result<I,B> map(Functions.F<A,B> f)
Result
valueB
- the function return typef
- the functionSuccess
then return a Success
which wraps the result
of applying the function to the success value, otherwise return this valuevoid handle(SideEffect.F<Result.Success<I,A>> success, SideEffect.F<Result.Failure<I,A>> failure)
success
- the function to be applied to a successful valuefailure
- the function to be applied to a failure value<B> B match(Functions.F<Result.Success<I,A>,B> success, Functions.F<Result.Failure<I,A>,B> failure)
B
- the function return typesuccess
- the function to be applied to a successful valuefailure
- the function to be applied to a failure valueCopyright © 2019. All rights reserved.