HJX-001
(CP_PRAJ)
March 11, 2025, 10:25pm
1
in cpython’s peg_generator source as per metagrammar.gram
grammar, item
can be optional
item[Item]:
| '[' ~ alts ']' {Opt(alts)}
| atom '*' {Repeat0(atom)}
by this it can be concluded that alt
can be optional and so on. As understood by me is that it is possible to write a rule like rulename:
with no alts
. pls clerify.
encukou
(Petr Viktorin)
March 12, 2025, 10:25am
2
Note that the '['
is quoted. It matches a literal square bracket in the (non-meta) grammar; it doesn’t make alt
optional.
HJX-001
(CP_PRAJ)
March 12, 2025, 11:50am
3
thanks.
Now I realize that this rule wont make this ‘alt’ optional, instead it will allow rules like(maybe more complex)
start: [ NAME ]
and
start: NAME*