using System; namespace AspClassic.Parser; /// /// An integer literal. /// public sealed class IntegerLiteralToken : Token { private readonly int _Literal; private readonly TypeCharacter _TypeCharacter; private readonly IntegerBase _IntegerBase; /// /// The value of the literal. /// public int Literal => _Literal; /// /// The type character of the literal. /// public TypeCharacter TypeCharacter => _TypeCharacter; /// /// The integer base of the literal. /// public IntegerBase IntegerBase => _IntegerBase; /// /// Constructs a new integer literal. /// /// The literal value. /// The integer base of the literal. /// The type character of the literal. /// The location of the literal. public IntegerLiteralToken(int literal, IntegerBase integerBase, TypeCharacter typeCharacter, Span span) : base(TokenType.IntegerLiteral, 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; } }