using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a Mid assignment statement.
///
public sealed class MidAssignmentStatement : Statement
{
private readonly bool _HasTypeCharacter;
private readonly Location _LeftParenthesisLocation;
private readonly Expression _TargetExpression;
private readonly Location _StartCommaLocation;
private readonly Expression _StartExpression;
private readonly Location _LengthCommaLocation;
private readonly Expression _LengthExpression;
private readonly Location _RightParenthesisLocation;
private readonly Location _OperatorLocation;
private readonly Expression _SourceExpression;
///
/// Whether the Mid identifier had a type character.
///
public bool HasTypeCharacter => _HasTypeCharacter;
///
/// The location of the left parenthesis.
///
public Location LeftParenthesisLocation => _LeftParenthesisLocation;
///
/// The target of the assignment.
///
public Expression TargetExpression => _TargetExpression;
///
/// The location of the comma before the start expression.
///
public Location StartCommaLocation => _StartCommaLocation;
///
/// The expression representing the start of the string to replace.
///
public Expression StartExpression => _StartExpression;
///
/// The location of the comma before the length expression, if any.
///
public Location LengthCommaLocation => _LengthCommaLocation;
///
/// The expression representing the length of the string to replace, if any.
///
public Expression LengthExpression => _LengthExpression;
///
/// The right parenthesis location.
///
public Location RightParenthesisLocation => _RightParenthesisLocation;
///
/// The location of the operator.
///
public Location OperatorLocation => _OperatorLocation;
///
/// The source of the assignment.
///
public Expression SourceExpression => _SourceExpression;
///
/// Constructs a new parse tree for an assignment statement.
///
/// Whether the Mid identifier has a type character.
/// The location of the left parenthesis.
/// The target of the assignment.
/// The location of the comma before the start expression.
/// The expression representing the start of the string to replace.
/// The location of the comma before the length expression, if any.
/// The expression representing the length of the string to replace, if any.
/// The location of the operator.
/// The source of the assignment.
/// The location of the parse tree.
/// The comments for the parse tree.
public MidAssignmentStatement(bool hasTypeCharacter, Location leftParenthesisLocation, Expression targetExpression, Location startCommaLocation, Expression startExpression, Location lengthCommaLocation, Expression lengthExpression, Location rightParenthesisLocation, Location operatorLocation, Expression sourceExpression, Span span, IList comments)
: base(TreeType.MidAssignmentStatement, span, comments)
{
if (targetExpression == null)
{
throw new ArgumentNullException("targetExpression");
}
if (startExpression == null)
{
throw new ArgumentNullException("startExpression");
}
if (sourceExpression == null)
{
throw new ArgumentNullException("sourceExpression");
}
SetParent(targetExpression);
SetParent(startExpression);
SetParent(lengthExpression);
SetParent(sourceExpression);
_HasTypeCharacter = hasTypeCharacter;
_LeftParenthesisLocation = leftParenthesisLocation;
_TargetExpression = targetExpression;
_StartCommaLocation = startCommaLocation;
_StartExpression = startExpression;
_LengthCommaLocation = lengthCommaLocation;
_LengthExpression = lengthExpression;
_RightParenthesisLocation = rightParenthesisLocation;
_OperatorLocation = operatorLocation;
_SourceExpression = sourceExpression;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, TargetExpression);
Tree.AddChild(childList, StartExpression);
Tree.AddChild(childList, LengthExpression);
Tree.AddChild(childList, SourceExpression);
}
}