feat: 增强错误定位
This commit is contained in:
parent
d54a2c59b6
commit
3a2a1363e6
@ -50,6 +50,6 @@ public class LexicalError {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return file + ": 行 " + line + ", 列 " + column + ": " + message;
|
return file + ":" + line + ":" + column + ": " + message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,6 @@ public class ParseError {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return file + ": 行 " + line + ", 列 " + column + ": " + message;
|
return file + ":" + line + ":" + column + ": " + message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public record SemanticError(Node node, String message) {
|
|||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (file != null && !file.isBlank()) sb.append(file).append(":");
|
if (file != null && !file.isBlank()) sb.append(file).append(":");
|
||||||
sb.append((line >= 0 && col >= 0) ? "行 " + line + ", 列 " + col : "未知位置");
|
sb.append((line >= 0 && col >= 0) ? line + ":" + col : "未知位置");
|
||||||
sb.append(": ").append(message);
|
sb.append(": ").append(message);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user