63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AspClassic.Parser;
|
|
|
|
/// <summary>
|
|
/// A parse tree for an argument to a call or index.
|
|
/// </summary>
|
|
public sealed class Argument : Tree
|
|
{
|
|
private readonly SimpleName _Name;
|
|
|
|
private readonly Location _ColonEqualsLocation;
|
|
|
|
private readonly Expression _Expression;
|
|
|
|
/// <summary>
|
|
/// The name of the argument, if any.
|
|
/// </summary>
|
|
public SimpleName Name => _Name;
|
|
|
|
/// <summary>
|
|
/// The location of the ':=', if any.
|
|
/// </summary>
|
|
public Location ColonEqualsLocation => _ColonEqualsLocation;
|
|
|
|
/// <summary>
|
|
/// The argument, if any.
|
|
/// </summary>
|
|
public Expression Expression => _Expression;
|
|
|
|
/// <summary>
|
|
/// Constructs a new parse tree for an argument.
|
|
/// </summary>
|
|
/// <param name="name">The name of the argument, if any.</param>
|
|
/// <param name="colonEqualsLocation">The location of the ':=', if any.</param>
|
|
/// <param name="expression">The expression, if any.</param>
|
|
/// <param name="span">The location of the parse tree.</param>
|
|
public Argument(SimpleName name, Location colonEqualsLocation, Expression expression, Span span)
|
|
: base(TreeType.Argument, span)
|
|
{
|
|
if (expression == null)
|
|
{
|
|
throw new ArgumentNullException("expression");
|
|
}
|
|
SetParent(name);
|
|
SetParent(expression);
|
|
_Name = name;
|
|
_ColonEqualsLocation = colonEqualsLocation;
|
|
_Expression = expression;
|
|
}
|
|
|
|
private Argument()
|
|
: base(TreeType.Argument, default(Span))
|
|
{
|
|
}
|
|
|
|
protected override void GetChildTrees(IList<Tree> childList)
|
|
{
|
|
Tree.AddChild(childList, Name);
|
|
Tree.AddChild(childList, Expression);
|
|
}
|
|
}
|