feat(parser): 支持 Viper 软关键字 fn/fun/func/function 展开为 def

行首缩进+软关键字+空白+标识符形态的函数定义(fn foo(): / function bar())
展开为 def,行号不变,供 ast.parse 使用;变量名/调用/注解中的 fn 不受影响。
Converter 同步改为 stub 语法错误直接终止(fail-fast),不再生成残缺 vpi
被全局缓存命中后以 undefined symbol 形式爆发。
This commit is contained in:
TermiNexus committed 2026-08-13 07:51:21 +08:00
1 parent 6a672037c2
commit a99f126cfa
6 files changed
+48 -11

No files matched your search

+4 -1
View File
@@ -6,7 +6,7 @@ import struct
from lib.utils.helpers import DetectFileType
from lib.core.Handles.HandlesBase import CTypeInfo
from lib.core.SymbolUtils import IsTModule, AnnotationContainsName
from lib.core.SymbolUtils import IsTModule, AnnotationContainsName, ExpandSoftKeywords
from lib.includes import t
from lib.constants.config import mode as _ConfigMode
from lib.core.VLogger import get_logger as _vlog
@@ -72,6 +72,9 @@ class PythonParserMixin:
with open(FilePath, 'r', encoding=encoding) as f:
content: str = f.read()
# 软关键字展开:fn/fun/func/function -> def,供 ast.parse 使用
content = ExpandSoftKeywords(content)
# 保存当前处理的文件路径(仅在主文件处理时更新)
if UpdateCurrentFile:
self.CurrentFile = FilePath