Class Expression
Base class for all expression nodes in the syntax tree.
Inherited Members
Namespace: Mangrove.MetricSetSyntaxTree
Assembly: MetricSetSyntaxTree.dll
Syntax
public abstract class Expression : ICloneable<Expression>, IDirectedAcyclicGraph<Expression>, IVisitable<IExpressionVisitor>
Remarks
All subclasses of this class (i.e., all Expression objects) are guaranteed to have non-null properties, but some of their constructors (e.g., Extern) allow null parameters. This is only allowed for "collection" data structures, and the constructor replaces null with the appropriate empty collection.
Adding a new kind of expression
To add a new expression node, follow these steps:
- Create a subclass of Expression in Mangrove.MetricSetSyntaxTree.ExpressionNodes. Make sure its constructor has arguments with the same name (except case) as the properties they correspond to. Otherwise Newtonsoft won't know how to deserialize those properties correctly.
- Implement Accept(IExpressionVisitor) for the new node as
visitor.Visit(this)
. The compiler will now force you to add a visit method to IExpressionVisitor. - A bunch of visitors in the
MetricSetTransformers
project will break. Fix them. - Add a new unit test to each of the visitors you fixed, checking its behavior on the new kind of expression node.
Standardized parameter order
Each subclass should order its parameters (where possible) as follows:
- Table
- Kind e.g. BinaryOperationKind
- Expression
- Other
Constructors
View SourceExpression(Table)
Declaration
public Expression(Table table)
Parameters
Type | Name | Description |
---|---|---|
Table | table |
Properties
View SourceParents
Ordered list of direct parents of this expression.
Declaration
public abstract IReadOnlyList<Expression> Parents { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Expression> |
Table
The table that this expression lives in.
Declaration
public Table Table { get; }
Property Value
Type | Description |
---|---|
Table |
Methods
View SourceAccept(IExpressionVisitor)
Accept a visitor and return a value of the appropriate type.
Declaration
public abstract void Accept(IExpressionVisitor visitor)
Parameters
Type | Name | Description |
---|---|---|
IExpressionVisitor | visitor | Visitor object to accept |
Clone(IReadOnlyList<Expression>)
Declaration
public abstract Expression Clone(IReadOnlyList<Expression> parents)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<Expression> | parents |
Returns
Type | Description |
---|---|
Expression |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |