feat: 增强错误定位

This commit is contained in:
zhangxun 2025-08-04 13:45:23 +08:00
parent d54a2c59b6
commit 3a2a1363e6
3 changed files with 4 additions and 4 deletions

View File

@ -50,6 +50,6 @@ public class LexicalError {
*/
@Override
public String toString() {
return file + ":" + line + ", 列 " + column + ": " + message;
return file + ":" + line + ":" + column + ": " + message;
}
}

View File

@ -40,6 +40,6 @@ public class ParseError {
*/
@Override
public String toString() {
return file + ":" + line + ", 列 " + column + ": " + message;
return file + ":" + line + ":" + column + ": " + message;
}
}

View File

@ -49,8 +49,8 @@ public record SemanticError(Node node, String message) {
StringBuilder sb = new StringBuilder();
if (file != null && !file.isBlank()) sb.append(file).append(": ");
sb.append((line >= 0 && col >= 0) ? "" + line + ", 列 " + col : "未知位置");
if (file != null && !file.isBlank()) sb.append(file).append(":");
sb.append((line >= 0 && col >= 0) ? line + ":" + col : "未知位置");
sb.append(": ").append(message);
return sb.toString();
}