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
+32 -26

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)
+18 -15
View File
@@ -33,26 +33,27 @@ import lib.Phase.Phase1.Phase1Main as Phase1Main
# Main Pool 1 GiB
POOL_SIZE: t.CDefine = 1073741824
define POOL_SIZE = 1073741824
# Permanent memory pool size: 2^29 + 264 = 512MB usable, then change to 1 GiB
PERM_POOL_SIZE: t.CDefine = 1073741824
define PERM_POOL_SIZE = 1073741824
# Code page: UTF-8 (Windows 65001)
CODE_PAGE: t.CDefine = 65001
define CODE_PAGE = 65001
# Source code buffer size (1MB)
SRC_BUF_SIZE: t.CDefine = 1048576
define SRC_BUF_SIZE = 1048576
# Version (dev/beta/rc)
V_VIPER_VERSION: t.CDefine = "1.0.3-dev.31 2026-07-27 Non-LTS"
V_TPV_VERSION: t.CArray[char] | t.attr.section(".PRVERSN") = "0.0.3-dev.428"
V_RUNTIME_VERSION: t.CDefine = "0.2.3+19-Non-LTS"
V_TPC_COMMIT: t.CDefine = "e376b949c9"
V_TPV_COMMIT: t.CDefine = "ab0f37e1a8"
V_RUNTIME_COMMIT: t.CDefine = "f087aa88e2"
V_TARGET: t.CDefine = "x86_64-w64-windows-gnu"
V_LLVM: t.CDefine = "22.1.8"
V_TPV_VERSION: __attribute__(section(".PRVERSN")) []char = "0.0.3-dev.428"
define V_VIPER_VERSION = "1.0.4-dev.579 2026-09-27 Non-LTS"
define V_RUNTIME_VERSION = "0.2.3+19-Non-LTS"
define V_TPC_COMMIT = "e376b949c9"
define V_TPV_COMMIT = "ab0f37e1a8"
define V_RUNTIME_COMMIT = "f087aa88e2"
define V_TARGET = "x86_64-w64-windows-gnu"
define V_LLVM = "22.1.8"
# --repl 模板工程查找缓冲(repl.vpj 命中路径 / 未命中诊断文本)
REPL_PROJ_PATH_CAP: t.CDefine = 1024
REPL_PROJ_DIAG_CAP: t.CDefine = 2048
define REPL_PROJ_PATH_CAP = 1024
define REPL_PROJ_DIAG_CAP = 2048
a: static int
# ============================================================
# main: Command-line entry
# ============================================================
@@ -536,7 +537,9 @@ Target: %s
tokens: ast.Token* = ast.tokenize(lx)
tree: ast.AST* = ast.parse_tokens(mb, tokens)
if tree is None:
log.error("AST 解析失败", "ast")
# 解析失败:行/列 + 原因一并进日志行(原因由 parser.vp 的 _record_* /
# parse_tokens 兜底补记提供)
log.error(f"AST 解析失败(第 {ast.get_parse_err_line()} 行第 {ast.get_parse_err_col()} 列: {ast.get_parse_err_msg()})", "ast")
argparse.release(args)
return 1