progress
This commit is contained in:
parent
16e76d6b31
commit
484dbfc9d9
529 changed files with 113694 additions and 0 deletions
74
AspClassic.Parser/SimpleName.cs
Normal file
74
AspClassic.Parser/SimpleName.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a simple name (e.g. 'foo').
|
||||
/// </summary>
|
||||
public sealed class SimpleName : Name
|
||||
{
|
||||
private readonly string _Name;
|
||||
|
||||
private readonly TypeCharacter _TypeCharacter;
|
||||
|
||||
private readonly bool _Escaped;
|
||||
|
||||
/// <summary>
|
||||
/// The name, if any.
|
||||
/// </summary>
|
||||
public string Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The type character.
|
||||
/// </summary>
|
||||
public TypeCharacter TypeCharacter => _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the name is escaped.
|
||||
/// </summary>
|
||||
public bool Escaped => _Escaped;
|
||||
|
||||
public override bool IsBad => Name == null;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bad simple name.
|
||||
/// </summary>
|
||||
/// <param name="Span">The location of the parse tree.</param>
|
||||
/// <returns>A bad simple name.</returns>
|
||||
public static SimpleName GetBadSimpleName(Span span)
|
||||
{
|
||||
return new SimpleName(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new simple name parse tree.
|
||||
/// </summary>
|
||||
/// <param name="name">The name, if any.</param>
|
||||
/// <param name="typeCharacter">The type character.</param>
|
||||
/// <param name="escaped">Whether the name is escaped.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public SimpleName(string name, TypeCharacter typeCharacter, bool escaped, Span span)
|
||||
: base(TreeType.SimpleName, span)
|
||||
{
|
||||
if (typeCharacter != 0 && escaped)
|
||||
{
|
||||
throw new ArgumentException("Escaped named cannot have type characters.");
|
||||
}
|
||||
if (typeCharacter != 0 && typeCharacter != TypeCharacter.DecimalSymbol && typeCharacter != TypeCharacter.DoubleSymbol && typeCharacter != TypeCharacter.IntegerSymbol && typeCharacter != TypeCharacter.LongSymbol && typeCharacter != TypeCharacter.SingleSymbol && typeCharacter != TypeCharacter.StringSymbol)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("typeCharacter");
|
||||
}
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
_Name = name;
|
||||
_TypeCharacter = typeCharacter;
|
||||
_Escaped = escaped;
|
||||
}
|
||||
|
||||
private SimpleName(Span span)
|
||||
: base(TreeType.SimpleName, span)
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue