【发布时间】:2018-07-20 14:51:44
【问题描述】:
我正在观察manual 中列出的 python 语法,并考虑其 EBNF 形式的输出,特别是 varargslist:
varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [
'*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
| '**' vfpdef [',']]]
| '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
| '**' vfpdef [',']
虽然我对这个部分特别感兴趣:
['*' [vfpdef] (',' vfpdef ['=' test])* ]
我解释为:
[ [ non-terminal1 ] ( non-terminal2) ]
我都知道
non-terminal1 (non-terminal2)
(non-terminal2)
是此表单中的有效选项,但是否包括:
non-terminal1
也一样? EBNF 状态的wiki 页面
That is, everything that is set within the square brackets may be
present just once, or not at all
但这是否将方括号内的所有内容组合为一个可能只出现一次的实体,或者选项是选择性的,例如:
[ [non-terminal1] [(non-terminal2)] ]
【问题讨论】: