python 语法中的`~` 是什么意思

What is the meaning of `~` in python grammar

我正在浏览 python grammer specification 并找到以下语句,

for_stmt:
    | 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block]

~在这个语法规则中是什么意思?。语法中使用的其他符号(如 &!|)已经记录在案,但没有 ~.

The notation is a mixture of EBNF and PEG. In particular, & followed by a symbol, token or parenthesized group indicates a positive lookahead (i.e., is required to match but not consumed), while ! indicates a negative lookahead (i.e., is required not to match). We use the | separator to mean PEG’s “ordered choice” (written as / in traditional PEG grammars)

.

它记录在 PEP 617 下的语法表达式中:

~

Commit to the current alternative, even if it fails to parse.

rule_name: '(' ~ some_rule ')' | some_alt

In this example, if a left parenthesis is parsed, then the other alternative won’t be considered, even if some_rule or ‘)’ fail to be parsed.

~ 基本上表明,一旦达到它,您就被锁定在特定规则中,如果解析失败,则无法进入下一条规则。 PEP 617 前面提到 | some_alt 可以写在下一行