79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AspClassic.Parser;
|
|
|
|
/// <summary>
|
|
/// A parse tree for a line If statement.
|
|
/// </summary>
|
|
public sealed class LineIfStatement : Statement
|
|
{
|
|
private readonly Expression _Expression;
|
|
|
|
private readonly Location _ThenLocation;
|
|
|
|
private readonly StatementCollection _IfStatements;
|
|
|
|
private readonly Location _ElseLocation;
|
|
|
|
private readonly StatementCollection _ElseStatements;
|
|
|
|
/// <summary>
|
|
/// The conditional expression.
|
|
/// </summary>
|
|
public Expression Expression => _Expression;
|
|
|
|
/// <summary>
|
|
/// The location of the 'Then'.
|
|
/// </summary>
|
|
public Location ThenLocation => _ThenLocation;
|
|
|
|
/// <summary>
|
|
/// The If statements.
|
|
/// </summary>
|
|
public StatementCollection IfStatements => _IfStatements;
|
|
|
|
/// <summary>
|
|
/// The location of the 'Else', if any.
|
|
/// </summary>
|
|
public Location ElseLocation => _ElseLocation;
|
|
|
|
/// <summary>
|
|
/// The Else statements.
|
|
/// </summary>
|
|
public StatementCollection ElseStatements => _ElseStatements;
|
|
|
|
/// <summary>
|
|
/// Constructs a new parse tree for a line If statement.
|
|
/// </summary>
|
|
/// <param name="expression">The conditional expression.</param>
|
|
/// <param name="thenLocation">The location of the 'Then'.</param>
|
|
/// <param name="ifStatements">The If statements.</param>
|
|
/// <param name="elseLocation">The location of the 'Else', if any.</param>
|
|
/// <param name="elseStatements">The Else statements.</param>
|
|
/// <param name="span">The location of the parse tree.</param>
|
|
/// <param name="comments">The comments for the parse tree.</param>
|
|
public LineIfStatement(Expression expression, Location thenLocation, StatementCollection ifStatements, Location elseLocation, StatementCollection elseStatements, Span span, IList<Comment> comments)
|
|
: base(TreeType.LineIfBlockStatement, span, comments)
|
|
{
|
|
if (expression == null)
|
|
{
|
|
throw new ArgumentNullException("expression");
|
|
}
|
|
SetParent(expression);
|
|
SetParent(ifStatements);
|
|
SetParent(elseStatements);
|
|
_Expression = expression;
|
|
_ThenLocation = thenLocation;
|
|
_IfStatements = ifStatements;
|
|
_ElseLocation = elseLocation;
|
|
_ElseStatements = elseStatements;
|
|
}
|
|
|
|
protected override void GetChildTrees(IList<Tree> childList)
|
|
{
|
|
Tree.AddChild(childList, Expression);
|
|
Tree.AddChild(childList, IfStatements);
|
|
Tree.AddChild(childList, ElseStatements);
|
|
}
|
|
}
|