Pidgin

Class ParserExtensions

Extension methods for running parsers.

Inheritance
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<Byte, T>

parser

A parser.

Stream

input

An input stream.

IConfiguration<Byte>

configuration

The configuration, or null to use the default configuration.

Returns
Type Description

Result<Byte, T>

The result of parsing.

Type Parameters
Name Description

T

The type of the value returned by the parser.

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<Char, T>

parser

A parser.

TextReader

input

An input reader.

IConfiguration<Char>

configuration

The configuration, or null to use the default configuration.

Returns
Type Description

Result<Char, T>

The result of parsing.

Type Parameters
Name Description

T

The type of the value returned by the parser.

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<Char, T>

parser

A parser.

String

input

An input string.

IConfiguration<Char>

configuration

The configuration, or null to use the default configuration.

Returns
Type Description

Result<Char, T>

The result of parsing.

Type Parameters
Name Description

T

The type of the value returned by the parser.

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

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<Byte, T>

parser

A parser.

Stream

input

An input stream.

IConfiguration<Byte>

configuration

The configuration, or null to use the default configuration.

Returns
Type Description

T

The result of parsing.

Type Parameters
Name Description

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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<Char, T>

parser

A parser.

TextReader

input

An input reader.

IConfiguration<Char>

configuration

The configuration, or null to use the default configuration.

Returns
Type Description

T

The result of parsing.

Type Parameters
Name Description

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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<Char, T>

parser

A parser.

String

input

An input string.

IConfiguration<Char>

configuration

The configuration, or null to use the default configuration.

Returns
Type Description

T

The result of parsing.

Type Parameters
Name Description

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

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

The type of the tokens in the parser's input stream.

T

The type of the value returned by the parser.

Exceptions
Type Condition

ParseException

Thrown when an error occurs during parsing.