Show / Hide Table of Contents

Class Expression

Base class for all expression nodes in the syntax tree.

Inheritance
Object
Expression
Expression<TExpr, TTable>
Implements
ICloneable<Expression>
IDirectedAcyclicGraph<Expression>
IVisitable<IExpressionVisitor>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
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:

  1. 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.
  2. Implement Accept(IExpressionVisitor) for the new node as visitor.Visit(this). The compiler will now force you to add a visit method to IExpressionVisitor.
  3. A bunch of visitors in the MetricSetTransformers project will break. Fix them.
  4. 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:

  1. Table
  2. Kind e.g. BinaryOperationKind
  3. Expression
  4. Other

Constructors

View Source

Expression(Table)

Declaration
public Expression(Table table)
Parameters
Type Name Description
Table table

Properties

View Source

Parents

Ordered list of direct parents of this expression.

Declaration
public abstract IReadOnlyList<Expression> Parents { get; }
Property Value
Type Description
IReadOnlyList<Expression>
View Source

Table

The table that this expression lives in.

Declaration
public Table Table { get; }
Property Value
Type Description
Table

Methods

View Source

Accept(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

View Source

Clone(IReadOnlyList<Expression>)

Declaration
public abstract Expression Clone(IReadOnlyList<Expression> parents)
Parameters
Type Name Description
IReadOnlyList<Expression> parents
Returns
Type Description
Expression
View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()

Implements

ICloneable<T>
IDirectedAcyclicGraph<T>
IVisitable<TVisitor>

Extension Methods

ExpressionExtensions.WrapUniqueName(Expression, String)
ExpressionExtensions.WrapName(Expression, String)
ExpressionExtensions.Unwrap(Expression, Boolean)
ExpressionExtensions.UnwrapParentheses(Expression)
ExpressionExtensions.NeedsColumnReferenceWrap(Expression)
ExpressionExtensions.TopParentsOfType<TParent>(Expression)
ExpressionExtensions.References(Expression, ISet<Table>)
ParsedExtensions.SearchWith<T, R>(T, Func<T, IParsed<R>>)
ExpressionExtensions.IsAggregation(Expression)
ExpressionExtensions.IsOperation(Expression)
ExpressionExtensions.IsConstant(Expression)
ExpressionExtensions.Type(Expression)
ExpressionExtensions.IsOfNullableType(Expression)
ExpressionExtensions.IsOfNonNullableType(Expression)
IDirectedAcyclicGraphExtensions.Ancestors(Expression, Boolean)
IDirectedAcyclicGraphExtensions.Closure(Expression)
IDirectedAcyclicGraphExtensions.Closure<T>(T)
IDirectedAcyclicGraphExtensions.DescendantsIn<T>(T, IEnumerable<T>)
IDirectedAcyclicGraphExtensions.TopParentsWith<T>(T, Func<T, Boolean>)
IDirectedAcyclicGraphExtensions.ToPrettyString<T>(T, Int32, Int32)
IDirectedAcyclicGraphExtensions.PathTo<T>(T, T)
IDirectedAcyclicGraphExtensions.AddClosure<T>(T, Stack<T>, Func<T, Boolean>, Action<T>)
IDirectedAcyclicGraphExtensions.OrderedDescendants<T>(T, Func<T, IEnumerable<T>>)
ObjectExtensions.EventId(Object)
  • View Source
Back to top Generated by DocFX