Pidgin

Struct Expected<TToken>

Represents a parsing expectation for error reporting. Expected values are either a sequence of expected tokens (in which case Label == null && Tokens != null), a custom-named parser (Label != null && Tokens == null), or the end of the input stream (Label == null && Tokens == null).

Implements
Inherited Members
Declaration
public readonly struct Expected<TToken> : IEquatable<Expected<TToken>>, IComparable<Expected<TToken>>
Type Parameters
Name Description

TToken

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

Properties

IsEof

Did the parser expect the end of the input stream?.

Declaration
public bool IsEof { get; }
Property Value
Type Description

bool

True if the parser expected the end of the input stream.

Label

The custom name of the parser that produced this error, or null if the expectation was a sequence of tokens.

Declaration
public string? Label { get; }
Property Value
Type Description

string

The label.

Tokens

The sequence of tokens that were expected at the point of the error, null if the parser had a custom name.

Declaration
public ImmutableArray<TToken> Tokens { get; }
Property Value
Type Description

ImmutableArray<TToken>

The sequence of tokens that were expected.

Methods

CompareTo(Expected<TToken>)

Represents a parsing expectation for error reporting. Expected values are either a sequence of expected tokens (in which case Label == null && Tokens != null), a custom-named parser (Label != null && Tokens == null), or the end of the input stream (Label == null && Tokens == null).

Declaration
public int CompareTo(Expected<TToken> other)
Parameters
Type Name Description

Expected<TToken>

other

Returns
Type Description

int

Equals(Expected<TToken>)

Represents a parsing expectation for error reporting. Expected values are either a sequence of expected tokens (in which case Label == null && Tokens != null), a custom-named parser (Label != null && Tokens == null), or the end of the input stream (Label == null && Tokens == null).

Declaration
public bool Equals(Expected<TToken> other)
Parameters
Type Name Description

Expected<TToken>

other

Returns
Type Description

bool

Equals(object?)

Represents a parsing expectation for error reporting. Expected values are either a sequence of expected tokens (in which case Label == null && Tokens != null), a custom-named parser (Label != null && Tokens == null), or the end of the input stream (Label == null && Tokens == null).

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description

object

obj

Returns
Type Description

bool

Overrides
ValueType.Equals(object)

GetHashCode()

Represents a parsing expectation for error reporting. Expected values are either a sequence of expected tokens (in which case Label == null && Tokens != null), a custom-named parser (Label != null && Tokens == null), or the end of the input stream (Label == null && Tokens == null).

Declaration
public override int GetHashCode()
Returns
Type Description

int

Overrides
ValueType.GetHashCode()

ToString()

Represents a parsing expectation for error reporting. Expected values are either a sequence of expected tokens (in which case Label == null && Tokens != null), a custom-named parser (Label != null && Tokens == null), or the end of the input stream (Label == null && Tokens == null).

Declaration
public override string ToString()
Returns
Type Description

string

Overrides
ValueType.ToString()

Operators

operator ==(Expected<TToken>, Expected<TToken>)

Equality operator.

Declaration
public static bool operator ==(Expected<TToken> left, Expected<TToken> right)
Parameters
Type Name Description

Expected<TToken>

left

The left Expected<TToken>.

Expected<TToken>

right

The right Expected<TToken>.

Returns
Type Description

bool

operator >(Expected<TToken>, Expected<TToken>)

Comparison operator.

Declaration
public static bool operator >(Expected<TToken> left, Expected<TToken> right)
Parameters
Type Name Description

Expected<TToken>

left

The left Expected<TToken>.

Expected<TToken>

right

The right Expected<TToken>.

Returns
Type Description

bool

operator >=(Expected<TToken>, Expected<TToken>)

Comparison operator.

Declaration
public static bool operator >=(Expected<TToken> left, Expected<TToken> right)
Parameters
Type Name Description

Expected<TToken>

left

The left Expected<TToken>.

Expected<TToken>

right

The right Expected<TToken>.

Returns
Type Description

bool

operator !=(Expected<TToken>, Expected<TToken>)

Inequality operator.

Declaration
public static bool operator !=(Expected<TToken> left, Expected<TToken> right)
Parameters
Type Name Description

Expected<TToken>

left

The left Expected<TToken>.

Expected<TToken>

right

The right Expected<TToken>.

Returns
Type Description

bool

operator <(Expected<TToken>, Expected<TToken>)

Comparison operator.

Declaration
public static bool operator <(Expected<TToken> left, Expected<TToken> right)
Parameters
Type Name Description

Expected<TToken>

left

The left Expected<TToken>.

Expected<TToken>

right

The right Expected<TToken>.

Returns
Type Description

bool

operator <=(Expected<TToken>, Expected<TToken>)

Comparison operator.

Declaration
public static bool operator <=(Expected<TToken> left, Expected<TToken> right)
Parameters
Type Name Description

Expected<TToken>

left

The left Expected<TToken>.

Expected<TToken>

right

The right Expected<TToken>.

Returns
Type Description

bool

Implements

IEquatable<T>
IComparable<T>