docs: 优化 LexicalError 类的文档注释
- 为 LexicalError 类添加详细的类文档注释,说明其用途 - 为所有字段和构造方法添加规范的参数注释 - 优化 toString 方法的注释,明确其返回值内容
This commit is contained in:
parent
85d3b129ae
commit
eae66eac8c
@ -1,11 +1,41 @@
|
||||
package org.jcnc.snow.compiler.lexer.core;
|
||||
|
||||
/**
|
||||
* 表示词法分析过程中发生的错误信息。
|
||||
* <p>
|
||||
* 该类用于封装词法分析(lexical analysis)阶段发现的错误,包括错误位置(文件名、行号、列号)
|
||||
* 以及错误描述信息,便于定位和调试。
|
||||
* </p>
|
||||
*/
|
||||
public class LexicalError {
|
||||
/**
|
||||
* 出错所在的源文件名。
|
||||
*/
|
||||
private final String file;
|
||||
|
||||
/**
|
||||
* 出错所在的行号(从1开始)。
|
||||
*/
|
||||
private final int line;
|
||||
|
||||
/**
|
||||
* 出错所在的列号(从1开始)。
|
||||
*/
|
||||
private final int column;
|
||||
|
||||
/**
|
||||
* 错误的详细描述信息。
|
||||
*/
|
||||
private final String message;
|
||||
|
||||
/**
|
||||
* 构造一个新的 {@code LexicalError} 实例。
|
||||
*
|
||||
* @param file 出错的源文件名
|
||||
* @param line 出错所在的行号(从1开始)
|
||||
* @param column 出错所在的列号(从1开始)
|
||||
* @param message 错误的详细描述信息
|
||||
*/
|
||||
public LexicalError(String file, int line, int column, String message) {
|
||||
this.file = file;
|
||||
this.line = line;
|
||||
@ -13,6 +43,11 @@ public class LexicalError {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以易于阅读的字符串形式返回错误信息。
|
||||
*
|
||||
* @return 格式化的错误信息字符串,包含文件名、行号、列号和错误描述
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return file + ": 行 " + line + ", 列 " + column + ": " + message;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user