Class ParserExtensions
Extension methods for running parsers
Inheritance
- Object
- ParserExtensions
Declaration
public static class ParserExtensions : Object
Methods
Parse<T>(Parser<Byte, T>, Stream, IConfiguration<Byte>)
Applies parser
to input
.
Note that more characters may be consumed from input
than were required for parsing.
You may need to manually rewind input
Declaration
public static Result<byte, T> Parse<T>(this Parser<byte, T> parser, Stream input, IConfiguration<byte> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
parser |
A parser |
|
input |
An input stream |
|
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
The result of parsing |
Type Parameters
Name | Description |
---|---|
T |
Parse<T>(Parser<Char, T>, TextReader, IConfiguration<Char>)
Applies parser
to input
Declaration
public static Result<char, T> Parse<T>(this Parser<char, T> parser, TextReader input, IConfiguration<char> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
parser |
A parser |
|
input |
An input reader |
|
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
The result of parsing |
Type Parameters
Name | Description |
---|---|
T |
Parse<T>(Parser<Char, T>, String, IConfiguration<Char>)
Applies parser
to input
Declaration
public static Result<char, T> Parse<T>(this Parser<char, T> parser, string input, IConfiguration<char> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
parser |
A parser |
|
input |
An input string |
|
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
The result of parsing |
Type Parameters
Name | Description |
---|---|
T |
Parse<TToken, T>(Parser<TToken, T>, TToken[], IConfiguration<TToken>)
Applies parser
to input
Declaration
public static Result<TToken, T> Parse<TToken, T>(this Parser<TToken, T> parser, TToken[] input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
TToken[] |
input |
An input array |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
Result<TToken, T> |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Parse<TToken, T>(Parser<TToken, T>, IEnumerable<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static Result<TToken, T> Parse<TToken, T>(this Parser<TToken, T> parser, IEnumerable<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IEnumerable<TToken> |
input |
An input enumerable |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
Result<TToken, T> |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Parse<TToken, T>(Parser<TToken, T>, IEnumerator<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static Result<TToken, T> Parse<TToken, T>(this Parser<TToken, T> parser, IEnumerator<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IEnumerator<TToken> |
input |
An input enumerator |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
Result<TToken, T> |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Parse<TToken, T>(Parser<TToken, T>, IList<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static Result<TToken, T> Parse<TToken, T>(this Parser<TToken, T> parser, IList<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IList<TToken> |
input |
An input list |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
Result<TToken, T> |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Parse<TToken, T>(Parser<TToken, T>, ReadOnlySpan<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static Result<TToken, T> Parse<TToken, T>(this Parser<TToken, T> parser, ReadOnlySpan<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
ReadOnlySpan<TToken> |
input |
An input span |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
Result<TToken, T> |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
ParseOrThrow<T>(Parser<Byte, T>, Stream, IConfiguration<Byte>)
Applies parser
to input
Declaration
public static T ParseOrThrow<T>(this Parser<byte, T> parser, Stream input, IConfiguration<byte> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
parser |
A parser |
|
input |
An input stream |
|
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<T>(Parser<Char, T>, TextReader, IConfiguration<Char>)
Applies parser
to input
Declaration
public static T ParseOrThrow<T>(this Parser<char, T> parser, TextReader input, IConfiguration<char> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
parser |
A parser |
|
input |
An input reader |
|
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<T>(Parser<Char, T>, String, IConfiguration<Char>)
Applies parser
to input
Declaration
public static T ParseOrThrow<T>(this Parser<char, T> parser, string input, IConfiguration<char> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
parser |
A parser |
|
input |
An input string |
|
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<TToken, T>(Parser<TToken, T>, TToken[], IConfiguration<TToken>)
Applies parser
to input
Declaration
public static T ParseOrThrow<TToken, T>(this Parser<TToken, T> parser, TToken[] input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
TToken[] |
input |
An input array |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<TToken, T>(Parser<TToken, T>, IEnumerable<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static T ParseOrThrow<TToken, T>(this Parser<TToken, T> parser, IEnumerable<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IEnumerable<TToken> |
input |
An input enumerable |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<TToken, T>(Parser<TToken, T>, IEnumerator<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static T ParseOrThrow<TToken, T>(this Parser<TToken, T> parser, IEnumerator<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IEnumerator<TToken> |
input |
An input enumerator |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<TToken, T>(Parser<TToken, T>, IList<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static T ParseOrThrow<TToken, T>(this Parser<TToken, T> parser, IList<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IList<TToken> |
input |
An input list |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseOrThrow<TToken, T>(Parser<TToken, T>, ReadOnlySpan<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static T ParseOrThrow<TToken, T>(this Parser<TToken, T> parser, ReadOnlySpan<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
ReadOnlySpan<TToken> |
input |
An input span |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |
ParseReadOnlyList<TToken, T>(Parser<TToken, T>, IReadOnlyList<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static Result<TToken, T> ParseReadOnlyList<TToken, T>(this Parser<TToken, T> parser, IReadOnlyList<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IReadOnlyList<TToken> |
input |
An input list |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
Result<TToken, T> |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
ParseReadOnlyListOrThrow<TToken, T>(Parser<TToken, T>, IReadOnlyList<TToken>, IConfiguration<TToken>)
Applies parser
to input
Declaration
public static T ParseReadOnlyListOrThrow<TToken, T>(this Parser<TToken, T> parser, IReadOnlyList<TToken> input, IConfiguration<TToken> configuration = null)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> |
parser |
A parser |
IReadOnlyList<TToken> |
input |
An input list |
IConfiguration<TToken> |
configuration |
The configuration, or null to use the default configuration |
Returns
Type | Description |
---|---|
T |
The result of parsing |
Type Parameters
Name | Description |
---|---|
TToken |
|
T |
Exceptions
Type | Condition |
---|---|
Thrown when an error occurs during parsing |