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

61 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for an enumerated value declaration.
/// </summary>
public sealed class EnumValueDeclaration : ModifiedDeclaration
{
private readonly Name _Name;
private readonly Location _EqualsLocation;
private readonly Expression _Expression;
/// <summary>
/// The name of the enumerated value.
/// </summary>
public Name Name => _Name;
/// <summary>
/// The location of the '=', if any.
/// </summary>
public Location EqualsLocation => _EqualsLocation;
/// <summary>
/// The enumerated value, if any.
/// </summary>
public Expression Expression => _Expression;
/// <summary>
/// Constructs a new parse tree for an enumerated value.
/// </summary>
/// <param name="attributes">The attributes on the declaration.</param>
/// <param name="name">The name of the declaration.</param>
/// <param name="equalsLocation">The location of the '=', if any.</param>
/// <param name="expression">The enumerated value, if any.</param>
/// <param name="span">The location of the parse tree.</param>
/// <param name="comments">The comments for the parse tree.</param>
public EnumValueDeclaration(AttributeBlockCollection attributes, Name name, Location equalsLocation, Expression expression, Span span, IList<Comment> comments)
: base(TreeType.EnumValueDeclaration, attributes, null, span, comments)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
SetParent(name);
SetParent(expression);
_Name = name;
_EqualsLocation = equalsLocation;
_Expression = expression;
}
protected override void GetChildTrees(IList<Tree> childList)
{
base.GetChildTrees(childList);
Tree.AddChild(childList, Name);
Tree.AddChild(childList, Expression);
}
}