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

42 lines
1.3 KiB
C#

using System;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for a floating point literal.
/// </summary>
public sealed class FloatingPointLiteralExpression : LiteralExpression
{
private readonly double _Literal;
private readonly TypeCharacter _TypeCharacter;
/// <summary>
/// The literal value.
/// </summary>
public double Literal => _Literal;
public override object Value => _Literal;
/// <summary>
/// The type character on the literal value.
/// </summary>
public TypeCharacter TypeCharacter => _TypeCharacter;
/// <summary>
/// Constructs a new parse tree for a floating point literal.
/// </summary>
/// <param name="literal">The literal value.</param>
/// <param name="typeCharacter">The type character on the literal.</param>
/// <param name="span">The location of the parse tree.</param>
public FloatingPointLiteralExpression(double literal, TypeCharacter typeCharacter, Span span)
: base(TreeType.FloatingPointLiteralExpression, span)
{
if (typeCharacter != 0 && typeCharacter != TypeCharacter.SingleSymbol && typeCharacter != TypeCharacter.SingleChar && typeCharacter != TypeCharacter.DoubleSymbol && typeCharacter != TypeCharacter.DoubleChar)
{
throw new ArgumentOutOfRangeException("typeCharacter");
}
_Literal = literal;
_TypeCharacter = typeCharacter;
}
}