I was going through the python grammer specification and find the following statement,
for_stmt:
| 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block]
What does ~ means in this grammar rule?. The other symbols used in the grammer(like &, !, |) are already documented but not ~.
The notation is a mixture of
EBNFandPEG. 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)
.