add: exceptions(#7)

Reviewed-on: PostGuard/Canon#7
Co-authored-by: Lan_G <2911328695@qq.com>
Co-committed-by: Lan_G <2911328695@qq.com>
This commit is contained in:
Lan_G 2024-03-13 16:39:00 +08:00 committed by jackfiled
parent 35aec34a8e
commit e191c1e077
3 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,12 @@
namespace Canon.Core.Exceptions;
/// <summary>
/// 语法分析中引发的异常
/// </summary>
public class GrammarException : Exception
{
public GrammarException() { }
public GrammarException(string message) : base(message) { }
public GrammarException(string message, Exception innerException) : base(message, innerException) { }
}

View File

@ -0,0 +1,25 @@
namespace Canon.Core.Exceptions;
/// <summary>
/// 词法分析中引发的异常
/// </summary>
public class LexemeException : Exception
{
public LexemeException() { }
public LexemeException(string message) : base(message) { }
public LexemeException(string message, Exception innerException) :
base(message, innerException) { }
/// <param name="line">单词的行号</param>
/// <param name="charPosition">单词的列号</param>
/// <param name="message">错误信息</param>
public LexemeException(uint line, uint charPosition, string message) :
base("line:" + line + ", charPosition:" + charPosition + " :" + message) { }
public LexemeException(uint line, uint charPosition, Exception innerException) :
base("line:" + line + ", charPosition:" + charPosition + " : ", innerException) { }
public LexemeException(uint line, uint charPosition, string message, Exception innerException) :
base("line:" + line + ", charPosition:" + charPosition + " :" + message, innerException) { }
}

View File

@ -0,0 +1,12 @@
namespace Canon.Core.Exceptions;
/// <summary>
/// 语义分析中引发的异常
/// </summary>
public class SemanticException : Exception
{
public SemanticException() : base() { }
public SemanticException(string message) : base(message) { }
public SemanticException(string message, Exception innerException) : base(message, innerException) { }
}