diff --git a/lib/vast/Nodes.py b/lib/vast/Nodes.py index 035dd16..028b65f 100644 --- a/lib/vast/Nodes.py +++ b/lib/vast/Nodes.py @@ -49,6 +49,9 @@ class AST: # ============================================================================= _POS_ATTRS: tuple[str, ...] = ('lineno', 'col_offset', 'end_lineno', 'end_col_offset') +# extern/export 软关键字标记(_ParseExternDef/_ParseExportDef 写入,unparse 还原)。 +# __slots__ 类无 __dict__,必须纳入槽位,否则 node.Extern = True 抛 AttributeError。 +_FUNC_ATTRS: tuple[str, ...] = _POS_ATTRS + ('Extern', 'Export') _NODE_DEFS: dict[str, tuple[tuple[str, ...], tuple[str, ...]]] = { # ---- 模块/交互/表达式顶层 ---- @@ -59,8 +62,8 @@ _NODE_DEFS: dict[str, tuple[tuple[str, ...], tuple[str, ...]]] = { 'Suite': ((), ()), # ---- 语句 ---- - 'FunctionDef': (('name', 'args', 'body', 'decorator_list', 'returns', 'type_comment', 'type_params'), _POS_ATTRS), - 'AsyncFunctionDef': (('name', 'args', 'body', 'decorator_list', 'returns', 'type_comment', 'type_params'), _POS_ATTRS), + 'FunctionDef': (('name', 'args', 'body', 'decorator_list', 'returns', 'type_comment', 'type_params'), _FUNC_ATTRS), + 'AsyncFunctionDef': (('name', 'args', 'body', 'decorator_list', 'returns', 'type_comment', 'type_params'), _FUNC_ATTRS), 'ClassDef': (('name', 'bases', 'keywords', 'body', 'decorator_list', 'type_params'), _POS_ATTRS), 'Return': (('value',), _POS_ATTRS), 'Delete': (('targets',), _POS_ATTRS),