Pidgin

Class Operator

Methods to create OperatorTableRow<TToken, T> values.

Inheritance
Inherited Members
Declaration
public static class Operator

Methods

Binary<TToken, T>(BinaryOperatorType, Parser<TToken, Func<T, T, T>>)

Creates a row in a table of operators which contains a single binary infix operator with the specified associativity. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> Binary<TToken, T>(BinaryOperatorType type, Parser<TToken, Func<T, T, T>> opParser)
Parameters
Type Name Description

BinaryOperatorType

type

The associativity of the infix operator.

Parser<TToken, Func<T, T, T>>

opParser

A parser for an infix operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single infix operator.

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.

InfixL<TToken, T>(Parser<TToken, Func<T, T, T>>)

Creates a row in a table of operators which contains a single left-associative infix operator. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> InfixL<TToken, T>(Parser<TToken, Func<T, T, T>> opParser)
Parameters
Type Name Description

Parser<TToken, Func<T, T, T>>

opParser

A parser for an infix operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single infix operator.

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.

InfixN<TToken, T>(Parser<TToken, Func<T, T, T>>)

Creates a row in a table of operators which contains a single non-associative infix operator. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> InfixN<TToken, T>(Parser<TToken, Func<T, T, T>> opParser)
Parameters
Type Name Description

Parser<TToken, Func<T, T, T>>

opParser

A parser for an infix operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single infix operator.

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.

InfixR<TToken, T>(Parser<TToken, Func<T, T, T>>)

Creates a row in a table of operators which contains a single right-associative infix operator. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> InfixR<TToken, T>(Parser<TToken, Func<T, T, T>> opParser)
Parameters
Type Name Description

Parser<TToken, Func<T, T, T>>

opParser

A parser for an infix operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single infix operator.

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.

PostfixChainable<TToken, T>(params Parser<TToken, Func<T, T>>[])

Creates a row in a table of operators which contains a chainable collection of postfix operators. By default Postfix<TToken, T>(Parser<TToken, Func<T, T>>) operators can only appear once, so foo()() would not be parsed as "call(call(foo))".

This method is equivalent to:

Postfix(
    OneOf(opParsers)
        .AtLeastOnce()
        .Select<Func<T, T>>(fs => z => fs.Aggregate(z, (x, f) => f(x)))
)
Declaration
public static OperatorTableRow<TToken, T> PostfixChainable<TToken, T>(params Parser<TToken, Func<T, T>>[] opParsers)
Parameters
Type Name Description

Parser<TToken, Func<T, T>>[]

opParsers

A collection of parsers for individual postfix operators.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a chainable collection of postfix operators.

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.

PostfixChainable<TToken, T>(IEnumerable<Parser<TToken, Func<T, T>>>)

Creates a row in a table of operators which contains a chainable collection of postfix operators. By default Postfix<TToken, T>(Parser<TToken, Func<T, T>>) operators can only appear once, so foo()() would not be parsed as "call(call(foo))".

This method is equivalent to:

Postfix(
    OneOf(opParsers)
        .AtLeastOnce()
        .Select<Func<T, T>>(fs => z => fs.Aggregate(z, (x, f) => f(x)))
)
Declaration
public static OperatorTableRow<TToken, T> PostfixChainable<TToken, T>(IEnumerable<Parser<TToken, Func<T, T>>> opParsers)
Parameters
Type Name Description

IEnumerable<Parser<TToken, Func<T, T>>>

opParsers

A collection of parsers for individual postfix operators.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a chainable collection of postfix operators.

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.

Postfix<TToken, T>(Parser<TToken, Func<T, T>>)

Creates a row in a table of operators which contains a single postfix operator. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> Postfix<TToken, T>(Parser<TToken, Func<T, T>> opParser)
Parameters
Type Name Description

Parser<TToken, Func<T, T>>

opParser

A parser for an postfix operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single postfix operator.

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.

PrefixChainable<TToken, T>(params Parser<TToken, Func<T, T>>[])

Creates a row in a table of operators which contains a chainable collection of prefix operators. By default Prefix<TToken, T>(Parser<TToken, Func<T, T>>) operators can only appear once, so - - 1 would not be parsed as "minus minus 1".

This method is equivalent to:

Prefix(
    OneOf(opParsers)
        .AtLeastOnce()
        .Select<Func<T, T>>(fs => z => fs.AggregateR(z, (f, x) => f(x)))
)
Declaration
public static OperatorTableRow<TToken, T> PrefixChainable<TToken, T>(params Parser<TToken, Func<T, T>>[] opParsers)
Parameters
Type Name Description

Parser<TToken, Func<T, T>>[]

opParsers

A collection of parsers for individual prefix operators.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a chainable collection of prefix operators.

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.

PrefixChainable<TToken, T>(IEnumerable<Parser<TToken, Func<T, T>>>)

Creates a row in a table of operators which contains a chainable collection of prefix operators. By default Prefix<TToken, T>(Parser<TToken, Func<T, T>>) operators can only appear once, so - - 1 would not be parsed as "minus minus 1".

This method is equivalent to:

Prefix(
    OneOf(opParsers)
        .AtLeastOnce()
        .Select<Func<T, T>>(fs => z => fs.AggregateR(z, (f, x) => f(x)))
)
Declaration
public static OperatorTableRow<TToken, T> PrefixChainable<TToken, T>(IEnumerable<Parser<TToken, Func<T, T>>> opParsers)
Parameters
Type Name Description

IEnumerable<Parser<TToken, Func<T, T>>>

opParsers

A collection of parsers for individual prefix operators.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a chainable collection of prefix operators.

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.

Prefix<TToken, T>(Parser<TToken, Func<T, T>>)

Creates a row in a table of operators which contains a single prefix operator. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> Prefix<TToken, T>(Parser<TToken, Func<T, T>> opParser)
Parameters
Type Name Description

Parser<TToken, Func<T, T>>

opParser

A parser for an prefix operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single prefix operator.

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.

Unary<TToken, T>(UnaryOperatorType, Parser<TToken, Func<T, T>>)

Creates a row in a table of operators which contains a single unary operator - either a prefix operator or a postfix operator. Can be combined with other OperatorTableRow<TToken, T>s using And(OperatorTableRow<TToken, T>) to build a larger row.

Declaration
public static OperatorTableRow<TToken, T> Unary<TToken, T>(UnaryOperatorType type, Parser<TToken, Func<T, T>> opParser)
Parameters
Type Name Description

UnaryOperatorType

type

The type of the unary operator.

Parser<TToken, Func<T, T>>

opParser

A parser for a unary operator.

Returns
Type Description

OperatorTableRow<TToken, T>

A row in a table of operators which contains a single unary operator.

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.