namespace Canon.Core.Exceptions;
using Enums;
///
/// 词法分析中引发的异常
///
public class LexemeException : CanonException
{
public LexemeErrorType ErrorType { get; }
public uint Line { get; }
public uint CharPosition { get; }
private readonly string _message;
/// 错误类型
/// 单词的行号
/// 单词的列号
/// 错误信息
public LexemeException(LexemeErrorType errorType, uint line, uint charPosition, string message)
{
ErrorType = errorType;
Line = line;
CharPosition = charPosition;
_message = message;
}
public override string Message => ToString();
public override string ToString()
{
return $"LexemeException: ErrorType={ErrorType}, Line={Line}, CharPosition={CharPosition}, Message={_message}\n";
}
}