fix(diag): AST 解析失败日志行内联 行/列 + 原因

四处解析失败上报点(Phase2 的 [Phase A-pre-vpi]、Phase1 的 [Phase 1b-pre] 与单文件、main.vp 单文件)此前只打 AST 解析失败,看不到定位与原因;现内联 第 N 行第 M 列: <原因>,与 dump_parse_traceback 的完整 traceback 同源(原因由 includes/ast/parser.vp 的 _record_* 与 parse_tokens 出口兜底补记提供)。另:App/main.vp 同时带上你工作区既有的 define 迁移/版本号改动。
This commit is contained in:
TermiNexus committed 2026-09-27 17:32:34 +08:00
1 parent e65f04f16b
commit d82f24e17a
3 files changed
+35 -29

No files matched your search

+8 -6
View File
@@ -780,11 +780,11 @@ def RunPhase1(mb: memhub.MemBuddy*, includes_dir: str, temp_dir: str,
if tree_pv is None:
stdlib.free(src_buf_pv)
p1bpre_failed += 1
# 解析失败:改由 Python 风格 traceback 统一上报(Traceback + File/行 +
# 源码行 + caret + SyntaxError: 消息;消息本身含 token 类型与前/后 token
# 附注,见 includes/ast/parser.vp 的 _record_parse_err_ctx),与单文件
# 管线 BuildPipeline 同一条上报路径。
VLogger.error(f"[Phase 1b-pre] {file_path_pv} | AST 解析失败", "Phase1")
# 解析失败:**日志行内联 行/列 + 原因**,并附完整 Python 风格 traceback
# (Traceback + File/行 + 源码行 + caret + SyntaxError: 消息;消息含 token
# 类型与前/后 token 附注,见 includes/ast/parser.vp 的 _record_parse_err_ctx
# / parse_tokens 兜底补记),与单文件管线 BuildPipeline 同一条上报路径。
VLogger.error(f"[Phase 1b-pre] {file_path_pv} | AST 解析失败(第 {ast.get_parse_err_line()} 行第 {ast.get_parse_err_col()} 列: {ast.get_parse_err_msg()})", "Phase1")
GenApi.dump_parse_traceback(file_path_pv)
continue
pyi_buf_pv: bytes = stdlib.malloc(Phase1.PYI_BUF_SIZE)
@@ -984,7 +984,9 @@ def RunPhase1(mb: memhub.MemBuddy*, includes_dir: str, temp_dir: str,
tokens: ast.Token* = ast.tokenize(lx)
tree: ast.AST* = ast.parse_tokens(mb, tokens)
if tree is None:
VLogger.error(f"AST 解析失败: {file_path}", "Phase1")
# 解析失败:行/列 + 原因一并进日志行(原因由 parser.vp 的 _record_* /
# parse_tokens 兜底补记提供)
VLogger.error(f"AST 解析失败: {file_path}(第 {ast.get_parse_err_line()} 行第 {ast.get_parse_err_col()} 列: {ast.get_parse_err_msg()})", "Phase1")
stdlib.free(src_buf)
failed += 1
continue
+6 -5
View File
@@ -805,11 +805,12 @@ def RunMultiFileProject(mb: memhub.MemBuddy*,
if tree_vp2 is None:
stdlib.free(src_buf_vp2)
vpi_failed_p2 += 1
# 解析失败:改由 Python 风格 traceback 统一上报(Traceback + File/行 +
# 源码行 + caret + SyntaxError: 消息;消息本身含 token 类型与前/后 token
# 附注,见 includes/ast/parser.vp 的 _record_parse_err_ctx),与单文件
# 管线 BuildPipeline 同一条上报路径。
VLogger.error(f"[Phase A-pre-vpi] {ent_vp2.Path} | AST 解析失败", "PhaseA")
# 解析失败:**日志行内联 行/列 + 原因**(与下方 dump_parse_traceback 的完整
# Python 风格 traceback 同源:Traceback + File/行 + 源码行 + caret +
# SyntaxError: 消息;消息含 token 类型与前/后 token 附注,见
# includes/ast/parser.vp 的 _record_parse_err_ctx / parse_tokens 兜底补记)。
# 只打 "AST 解析失败" 时用户看不到任何定位与原因(traceback 未落到终端时更甚)。
VLogger.error(f"[Phase A-pre-vpi] {ent_vp2.Path} | AST 解析失败(第 {ast.get_parse_err_line()} 行第 {ast.get_parse_err_col()} 列: {ast.get_parse_err_msg()})", "PhaseA")
GenApi.dump_parse_traceback(ent_vp2.Path)
continue
pyi_buf_vp2: bytes = stdlib.malloc(PYI_BUF_SIZE_P2)