diff --git a/Canon.Core/Exceptions/GrammarException.cs b/Canon.Core/Exceptions/GrammarException.cs new file mode 100644 index 0000000..59fa1de --- /dev/null +++ b/Canon.Core/Exceptions/GrammarException.cs @@ -0,0 +1,12 @@ +namespace Canon.Core.Exceptions; +/// +/// 语法分析中引发的异常 +/// +public class GrammarException : Exception +{ + public GrammarException() { } + + public GrammarException(string message) : base(message) { } + + public GrammarException(string message, Exception innerException) : base(message, innerException) { } +} diff --git a/Canon.Core/Exceptions/LexemeException.cs b/Canon.Core/Exceptions/LexemeException.cs new file mode 100644 index 0000000..b20c4ed --- /dev/null +++ b/Canon.Core/Exceptions/LexemeException.cs @@ -0,0 +1,25 @@ +namespace Canon.Core.Exceptions; +/// +/// 词法分析中引发的异常 +/// +public class LexemeException : Exception +{ + public LexemeException() { } + + public LexemeException(string message) : base(message) { } + + public LexemeException(string message, Exception innerException) : + base(message, innerException) { } + + /// 单词的行号 + /// 单词的列号 + /// 错误信息 + 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) { } +} diff --git a/Canon.Core/Exceptions/SemanticException.cs b/Canon.Core/Exceptions/SemanticException.cs new file mode 100644 index 0000000..ddb9201 --- /dev/null +++ b/Canon.Core/Exceptions/SemanticException.cs @@ -0,0 +1,12 @@ +namespace Canon.Core.Exceptions; +/// +/// 语义分析中引发的异常 +/// +public class SemanticException : Exception +{ + public SemanticException() : base() { } + + public SemanticException(string message) : base(message) { } + + public SemanticException(string message, Exception innerException) : base(message, innerException) { } +}