using System; namespace AspClassic.Parser; /// /// A parse tree for an integer literal. /// public sealed class IntegerLiteralExpression : LiteralExpression { private readonly int _Literal; private readonly TypeCharacter _TypeCharacter; private readonly IntegerBase _IntegerBase; /// /// The literal value. /// public int Literal => _Literal; public override object Value => _Literal; /// /// The type character on the literal. /// public TypeCharacter TypeCharacter => _TypeCharacter; /// /// The integer base of the literal. /// public IntegerBase IntegerBase => _IntegerBase; /// /// Constructs a new parse tree for an integer literal. /// /// The literal value. /// The integer base of the literal. /// The type character on the literal. /// The location of the parse tree. 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; } }