Class ParsedExtensions
Wrapper for static extension methods on the IParsed
interface.
You shouldn't have to refer to this class directly.
Inheritance
ParsedExtensions
Assembly: Mangrove.Parsing.dll
Syntax
public static class ParsedExtensions
Methods
View Source
Combine<T>(IEnumerable<IParsed<T>>)
Return the collection of results if no member of the collection has an error,
otherwise return a single failed parse.
Declaration
public static IParsed<IReadOnlyList<T>> Combine<T>(this IEnumerable<IParsed<T>> parsed)
where T : class
Parameters
Returns
Type Parameters
View Source
Lookup<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Nullable<ErrorKind>, String)
Treat looking up a key in a dictionary as parsing, with possible injected
error kind and message when it does not exist.
Declaration
public static IParsed<TValue> Lookup<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, ErrorKind? error = default(ErrorKind? ), string message = null)
where TValue : class
Parameters
Returns
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
View Source
SearchWith<T, R>(T, Func<T, IParsed<R>>)
Using search
function through node
and its direct and indirect parents
in a BFS manner and return the first successful one.
Declaration
public static IParsed<R> SearchWith<T, R>(this T node, Func<T, IParsed<R>> search)
where T : IDirectedAcyclicGraph<T> where R : class
Parameters
Type |
Name |
Description |
T |
node |
|
Func<T, IParsed<R>> |
search |
|
Returns
Type Parameters
View Source
Success<T>(IParsed<T>)
Declaration
public static bool Success<T>(this IParsed<T> parsed)
where T : class
Parameters
Type |
Name |
Description |
IParsed<T> |
parsed |
|
Returns
Type Parameters
View Source
When<T>(IParsed<T>, Action<T>, Action<IDiagnostics>)
Invoke the appropriate function depending on whether parsed
is a success or not.
Declaration
public static IParsed<T> When<T>(this IParsed<T> parsed, Action<T> success, Action<IDiagnostics> failure = null)
where T : class
Parameters
Returns
Type Parameters
View Source
With<T, TResult>(IParsed<T>, Func<T, TResult>)
Return the result of evaluating success
on the result, with the
natural default failure function.
Declaration
public static IParsed<TResult> With<T, TResult>(this IParsed<T> parsed, Func<T, TResult> success)
where T : class where TResult : class
Parameters
Type |
Name |
Description |
IParsed<T> |
parsed |
|
Func<T, TResult> |
success |
|
Returns
Type Parameters
Name |
Description |
T |
|
TResult |
|
View Source
With<T, TResult>(IParsed<T>, Func<T, TResult>, Func<IDiagnostics, TResult>)
Return the result of evaluating the appropriate function on the
content of parsed
.
Declaration
public static TResult With<T, TResult>(this IParsed<T> parsed, Func<T, TResult> success, Func<IDiagnostics, TResult> failure)
where T : class where TResult : class
Parameters
Returns
Type Parameters
Name |
Description |
T |
|
TResult |
|
View Source
With<T, TResult>(IParsed<T>, Func<T, IParsed<TResult>>)
Return the result of evaluating success
on the result, with the
natural default failure function.
Declaration
public static IParsed<TResult> With<T, TResult>(this IParsed<T> parsed, Func<T, IParsed<TResult>> success)
where T : class where TResult : class
Parameters
Returns
Type Parameters
Name |
Description |
T |
|
TResult |
|