chore(parse): 已删除的 CIf 家族名字表补齐 CElif/CElse/CEndif

ExprParser 的 _REMOVED_CIF_NAMES 与 vast_c.c 的 Interesting/Removed 名字表原本只认 CIf/CIfdef/CIfndef,现补齐三件套六个拼写(含 c. 前缀形式),使 parser 阶段即可给出指向 cif/celif/celse 的 FailFast;_parser.pyd 同步重编。
This commit is contained in:
TermiNexus committed 2026-10-07 19:59:28 +08:00
1 parent 6a7b27e14f
commit b49b5c3ba6
3 files changed
+10 -6

No files matched your search

+5 -3
View File
@@ -40,10 +40,12 @@ def _JoinConstParts(parts: list[object]) -> str | bytes:
_HEX_ALPHABET: str = '0123456789abcdefABCDEF'
# 已删除的用户可见 CIf 族名:用户再写 c.CIf / c.CIfdef / c.CIfndef ⇒ FailFast,
# 提示改用原生 cif/celif/celse 与 defined() 谓词(内部标记由解析期合成,不走此处)。
# 已删除的用户可见 CIf 族名(CIf/CIfdef/CIfndef/CElif/CElse/CEndif 及 c. 前缀形式):
# 用户再写即 FailFast,提示改用原生 cif/celif/celse 与 defined() 谓词
#(内部标记 c.@CIf 族由解析期合成,不走此处)。
_REMOVED_CIF_NAMES: frozenset[str] = frozenset({
'CIf', 'CIfdef', 'CIfndef', 'c.CIf', 'c.CIfdef', 'c.CIfndef',
'CIf', 'CIfdef', 'CIfndef', 'CElif', 'CElse', 'CEndif',
'c.CIf', 'c.CIfdef', 'c.CIfndef', 'c.CElif', 'c.CElse', 'c.CEndif',
})
Binary file not shown.
+5 -3
View File
@@ -3103,7 +3103,8 @@ static int StrIsOneOf(PyObject *S, const char *const *Names) {
/* 调用点特殊 desugar / fail-fast:接管 Node 的引用,返回新引用(失败返回 NULL)。
* - defined(NAME):仅 cif/celif 条件内合法(P->InCIfCond)⇒ desugar 为 c.@CIfdef(NAME);
* 其余位置 ⇒ FailFast。
* - c.CIf / c.CIfdef / c.CIfndef(及裸名):已删除 ⇒ FailFast,指向原生新语法。 */
* - c.CIf / c.CIfdef / c.CIfndef / c.CElif / c.CElse / c.CEndif(及裸名):已删除 ⇒ FailFast,
* 指向原生新语法。 */
static PyObject *DesugarSpecialCall(Parser *P, PyObject *Node, Token *Start) {
PyObject *Func = PyObject_GetAttrString(Node, "func");
if (Func == NULL) {
@@ -3123,7 +3124,7 @@ static PyObject *DesugarSpecialCall(Parser *P, PyObject *Node, Token *Start) {
Py_DECREF(Func);
return Node;
}
static const char *Interesting[] = {"CIf", "CIfdef", "CIfndef", "defined", NULL};
static const char *Interesting[] = {"CIf", "CIfdef", "CIfndef", "CElif", "CElse", "CEndif", "defined", NULL};
int Hit = StrIsOneOf(Short, Interesting);
Py_DECREF(Short);
if (!Hit) {
@@ -3137,7 +3138,8 @@ static PyObject *DesugarSpecialCall(Parser *P, PyObject *Node, Token *Start) {
return Node;
}
static const char *Removed[] = {
"CIf", "CIfdef", "CIfndef", "c.CIf", "c.CIfdef", "c.CIfndef", NULL
"CIf", "CIfdef", "CIfndef", "CElif", "CElse", "CEndif",
"c.CIf", "c.CIfdef", "c.CIfndef", "c.CElif", "c.CElse", "c.CEndif", NULL
};
if (StrIsOneOf(Callee, Removed)) {
PyErr_Format(PyExc_SyntaxError,