55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System;
|
|
|
|
namespace AspClassic.Parser;
|
|
|
|
/// <summary>
|
|
/// A parse tree for an integer literal.
|
|
/// </summary>
|
|
public sealed class IntegerLiteralExpression : LiteralExpression
|
|
{
|
|
private readonly int _Literal;
|
|
|
|
private readonly TypeCharacter _TypeCharacter;
|
|
|
|
private readonly IntegerBase _IntegerBase;
|
|
|
|
/// <summary>
|
|
/// The literal value.
|
|
/// </summary>
|
|
public int Literal => _Literal;
|
|
|
|
public override object Value => _Literal;
|
|
|
|
/// <summary>
|
|
/// The type character on the literal.
|
|
/// </summary>
|
|
public TypeCharacter TypeCharacter => _TypeCharacter;
|
|
|
|
/// <summary>
|
|
/// The integer base of the literal.
|
|
/// </summary>
|
|
public IntegerBase IntegerBase => _IntegerBase;
|
|
|
|
/// <summary>
|
|
/// Constructs a new parse tree for an integer literal.
|
|
/// </summary>
|
|
/// <param name="literal">The literal value.</param>
|
|
/// <param name="integerBase">The integer base of the literal.</param>
|
|
/// <param name="typeCharacter">The type character on the literal.</param>
|
|
/// <param name="span">The location of the parse tree.</param>
|
|
public IntegerLiteralExpression(int literal, IntegerBase integerBase, TypeCharacter typeCharacter, Span span)
|
|
: base(TreeType.IntegerLiteralExpression, span)
|
|
{
|
|
if (integerBase < IntegerBase.Decimal || integerBase > IntegerBase.Hexadecimal)
|
|
{
|
|
throw new ArgumentOutOfRangeException("integerBase");
|
|
}
|
|
if (typeCharacter != 0 && typeCharacter != TypeCharacter.IntegerSymbol && typeCharacter != TypeCharacter.IntegerChar && typeCharacter != TypeCharacter.ShortChar && typeCharacter != TypeCharacter.LongSymbol && typeCharacter != TypeCharacter.LongChar)
|
|
{
|
|
throw new ArgumentOutOfRangeException("typeCharacter");
|
|
}
|
|
_Literal = literal;
|
|
_IntegerBase = integerBase;
|
|
_TypeCharacter = typeCharacter;
|
|
}
|
|
}
|