Class ExpressionParser
Contains tools for parsing expression languages with associative infix operators.
Namespace: Pidgin.Expression
Assembly: Pidgin.dll
Syntax
public static class ExpressionParser : object
Methods
| Improve this Doc View SourceBuild<TToken, T>(Func<Parser<TToken, T>, Parser<TToken, T>>, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>>)
Builds a parser for expressions built from the operators in operatorTable
.
The operator table is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
This overload is useful for recursive expressions (for example, languages with parenthesised subexpressions).
termFactory
's argument will be a parser which parses a full subexpression.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Func<Parser<TToken, T>, Parser<TToken, T>> termFactory, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>> operatorTable)
Parameters
Type | Name | Description |
---|---|---|
Func<Parser<TToken, T>, Parser<TToken, T>> | termFactory | A function which produces a parser for a single term |
IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>> | operatorTable | A table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Func<Parser<TToken, T>, Parser<TToken, T>>, IEnumerable<OperatorTableRow<TToken, T>>)
Builds a parser for expressions built from the operators in operatorTable
.
The operator table is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
This overload is useful for recursive expressions (for example, languages with parenthesised subexpressions).
termFactory
's argument will be a parser which parses a full subexpression.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Func<Parser<TToken, T>, Parser<TToken, T>> termFactory, IEnumerable<OperatorTableRow<TToken, T>> operatorTable)
Parameters
Type | Name | Description |
---|---|---|
Func<Parser<TToken, T>, Parser<TToken, T>> | termFactory | A function which produces a parser for a single term |
IEnumerable<OperatorTableRow<TToken, T>> | operatorTable | A table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Func<Parser<TToken, T>, (Parser<TToken, T> term, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>> operatorTable)>)
Builds a parser for expressions built from the operators in termAndOperatorTableFactory
's second result.
The operator table is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
This overload is useful for recursive expressions (for example, languages with parenthesised subexpressions).
termAndOperatorTableFactory
's argument will be a parser which parses a full subexpression.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Func<Parser<TToken, T>, (Parser<TToken, T> term, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>> operatorTable)> termAndOperatorTableFactory)
Parameters
Type | Name | Description |
---|---|---|
Func<Parser<TToken, T>, ValueTuple<Parser<TToken, T>, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>>>> | termAndOperatorTableFactory | A function which produces a parser for a single term and a table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in the operator table |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Func<Parser<TToken, T>, (Parser<TToken, T> term, IEnumerable<OperatorTableRow<TToken, T>> operatorTable)>)
Builds a parser for expressions built from the operators in termAndOperatorTableFactory
's second result.
The operator table is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
This overload is useful for recursive expressions (for example, languages with parenthesised subexpressions).
termAndOperatorTableFactory
's argument will be a parser which parses a full subexpression.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Func<Parser<TToken, T>, (Parser<TToken, T> term, IEnumerable<OperatorTableRow<TToken, T>> operatorTable)> termAndOperatorTableFactory)
Parameters
Type | Name | Description |
---|---|---|
Func<Parser<TToken, T>, ValueTuple<Parser<TToken, T>, IEnumerable<OperatorTableRow<TToken, T>>>> | termAndOperatorTableFactory | A function which produces a parser for a single term and a table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in the operator table |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Parser<TToken, T>, Func<Parser<TToken, T>, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>>>)
Builds a parser for expressions built from the operators in operatorTableFactory
's result.
The operator table is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
This overload is useful for recursive expressions (for example, languages with parenthesised subexpressions).
operatorTableFactory
's argument will be a parser which parses a full subexpression.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Parser<TToken, T> term, Func<Parser<TToken, T>, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>>> operatorTableFactory)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> | term | A parser for a single term in an expression language |
Func<Parser<TToken, T>, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>>> | operatorTableFactory | A function which produces a table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in the operator table |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Parser<TToken, T>, Func<Parser<TToken, T>, IEnumerable<OperatorTableRow<TToken, T>>>)
Builds a parser for expressions built from the operators in operatorTableFactory
's result.
The operator table is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
This overload is useful for recursive expressions (for example, languages with parenthesised subexpressions).
operatorTableFactory
's argument will be a parser which parses a full subexpression.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Parser<TToken, T> term, Func<Parser<TToken, T>, IEnumerable<OperatorTableRow<TToken, T>>> operatorTableFactory)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> | term | A parser for a single term in an expression language |
Func<Parser<TToken, T>, IEnumerable<OperatorTableRow<TToken, T>>> | operatorTableFactory | A function which produces a table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in the operator table |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Parser<TToken, T>, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>>)
Builds a parser for expressions built from the operators in operatorTable
.
operatorTable
is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Parser<TToken, T> term, IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>> operatorTable)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> | term | A parser for a single term in an expression language |
IEnumerable<IEnumerable<OperatorTableRow<TToken, T>>> | operatorTable | A table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in |
Type Parameters
Name | Description |
---|---|
TToken | |
T |
Build<TToken, T>(Parser<TToken, T>, IEnumerable<OperatorTableRow<TToken, T>>)
Builds a parser for expressions built from the operators in operatorTable
.
operatorTable
is a sequence of operators in precedence order:
the operators in the first row have the highest precedence and operators in later rows have lower precedence.
Declaration
public static Parser<TToken, T> Build<TToken, T>(Parser<TToken, T> term, IEnumerable<OperatorTableRow<TToken, T>> operatorTable)
Parameters
Type | Name | Description |
---|---|---|
Parser<TToken, T> | term | A parser for a single term in an expression language |
IEnumerable<OperatorTableRow<TToken, T>> | operatorTable | A table of operators |
Returns
Type | Description |
---|---|
Parser<TToken, T> | A parser for expressions built from the operators in |
Type Parameters
Name | Description |
---|---|
TToken | |
T |