aspclassic-core/AspClassic.Parser/ExpressionBlockStatement.cs
Jelle Luteijn 484dbfc9d9 progress
2022-05-15 11:19:49 +02:00

42 lines
1.2 KiB
C#

#define DEBUG
using System.Collections.Generic;
using System.Diagnostics;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for an expression block statement.
/// </summary>
public abstract class ExpressionBlockStatement : BlockStatement
{
private readonly Expression _Expression;
private readonly EndBlockStatement _EndStatement;
/// <summary>
/// The expression.
/// </summary>
public Expression Expression => _Expression;
/// <summary>
/// The End statement for the block, if any.
/// </summary>
public EndBlockStatement EndStatement => _EndStatement;
protected ExpressionBlockStatement(TreeType type, Expression expression, StatementCollection statements, EndBlockStatement endStatement, Span span, IList<Comment> comments)
: base(type, statements, span, comments)
{
Debug.Assert(type == TreeType.WithBlockStatement || type == TreeType.SyncLockBlockStatement || type == TreeType.WhileBlockStatement || type == TreeType.UsingBlockStatement);
SetParent(expression);
SetParent(endStatement);
_Expression = expression;
_EndStatement = endStatement;
}
protected override void GetChildTrees(IList<Tree> childList)
{
Tree.AddChild(childList, Expression);
base.GetChildTrees(childList);
Tree.AddChild(childList, EndStatement);
}
}