Class InfixExpression<T>
- Namespace
- RandomizerCore.StringParsing
- Assembly
- RandomizerCore.dll
An infix expression (infix operator applied between 2 nested expressions)
public abstract record InfixExpression<T> : IExpression<T>, IEquatable<InfixExpression<T>>
Type Parameters
T
- Inheritance
-
InfixExpression<T>
- Implements
-
IExpression<T>
- Derived
- Inherited Members
Constructors
InfixExpression(IExpression<T>, OperatorToken, IExpression<T>)
An infix expression (infix operator applied between 2 nested expressions)
protected InfixExpression(IExpression<T> Left, OperatorToken Operator, IExpression<T> Right)
Parameters
Left
IExpression<T>The left-hand operand
Operator
OperatorTokenRight
IExpression<T>The right-hand operand
Properties
EndChar
public int EndChar { get; }
Property Value
Left
The left-hand operand
public IExpression<T> Left { get; init; }
Property Value
- IExpression<T>
Operator
public OperatorToken Operator { get; init; }
Property Value
Right
The right-hand operand
public IExpression<T> Right { get; init; }
Property Value
- IExpression<T>
StartChar
public int StartChar { get; }
Property Value
Methods
Evaluate()
Speculates possible types for an expression. If the result { T.A, T.B } is returned, then the result is to be interpreted as "A or B".
public abstract IEnumerable<T> Evaluate()
Returns
- IEnumerable<T>
FlattenAssoc<U>(U)
For the given associative infix expression type, recursively unfolds that type and any intermediate grouping expressions, returning a sequence of expressions on which the infix operator acts left to right.
public static IEnumerable<IExpression<T>> FlattenAssoc<U>(U u) where U : InfixExpression<T>
Parameters
u
U
Returns
Type Parameters
U
Print()
Reconstructs the original string representation of the expression
public string Print()
Returns
Validate(ExpressionValidator<T>)
Validates whether the expression is structurally and semantically valid and aggregates any errors using the provided expression validator.
public abstract bool Validate(ExpressionValidator<T> validator)
Parameters
validator
ExpressionValidator<T>The validator to use to aggregate errors.
Returns
- bool
Whether the expression is valid or not.