31 lines
840 B
C#
31 lines
840 B
C#
using System;
|
|
|
|
namespace AspClassic.Parser;
|
|
|
|
/// <summary>
|
|
/// A lexical error.
|
|
/// </summary>
|
|
public sealed class ErrorToken : Token
|
|
{
|
|
private readonly SyntaxError _SyntaxError;
|
|
|
|
/// <summary>
|
|
/// The syntax error that represents the lexical error.
|
|
/// </summary>
|
|
public SyntaxError SyntaxError => _SyntaxError;
|
|
|
|
/// <summary>
|
|
/// Creates a new lexical error token.
|
|
/// </summary>
|
|
/// <param name="errorType">The type of the error.</param>
|
|
/// <param name="span">The location of the error.</param>
|
|
public ErrorToken(SyntaxErrorType errorType, Span span)
|
|
: base(TokenType.LexicalError, span)
|
|
{
|
|
if (errorType < SyntaxErrorType.InvalidEscapedIdentifier || errorType > SyntaxErrorType.InvalidDecimalLiteral)
|
|
{
|
|
throw new ArgumentOutOfRangeException("errorType");
|
|
}
|
|
_SyntaxError = new SyntaxError(errorType, span);
|
|
}
|
|
}
|