using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a Do statement.
///
public sealed class DoBlockStatement : BlockStatement
{
private readonly bool _IsWhile;
private readonly Location _WhileOrUntilLocation;
private readonly Expression _Expression;
private readonly LoopStatement _EndStatement;
///
/// Whether the Do is followed by a While or Until, if any.
///
public bool IsWhile => _IsWhile;
///
/// The location of the While or Until, if any.
///
public Location WhileOrUntilLocation => _WhileOrUntilLocation;
///
/// The While or Until expression, if any.
///
public Expression Expression => _Expression;
///
/// The ending Loop statement.
///
public LoopStatement EndStatement => _EndStatement;
///
/// Constructs a new parse tree for a Do statement.
///
/// The While or Until expression, if any.
/// Whether the Do is followed by a While or Until, if any.
/// The location of the While or Until, if any.
/// The statements in the block.
/// The ending Loop statement.
/// The location of the parse tree.
/// The comments on the parse tree.
public DoBlockStatement(Expression expression, bool isWhile, Location whileOrUntilLocation, StatementCollection statements, LoopStatement endStatement, Span span, IList comments)
: base(TreeType.DoBlockStatement, statements, span, comments)
{
SetParent(expression);
SetParent(endStatement);
_Expression = expression;
_IsWhile = isWhile;
_WhileOrUntilLocation = whileOrUntilLocation;
_EndStatement = endStatement;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, Expression);
base.GetChildTrees(childList);
Tree.AddChild(childList, EndStatement);
}
}