我的EBNF逻辑错了吗?

我在Python程序中使用SimpleParse来解析一些相当简单的语言学。它应该能够解析以下示例文本(每行分别):
d6
(d4 + d8 + 5) + 6
{5d20}+12
[d10 + 6d6] + 9
(d10 + d12) + 8d8
我已经为上面写了下面的EBNF,但解析器一直在崩溃,即使是在“d6”的简单情况下:
# 'number' is already predefined in SimpleParse to parse exactly what you think it will parse
root          := roll
roll          := space,operations,space
operations    := function+
function      := ((dice,op,function)/(grouping,op,function)/(function,op,grouping))/(dice/grouping/constant) #just to clarify, the '/' is a FirstOf operator
constant      := number
grouping      := ([[(],operations,[])])/'{',dice,'}'
dice          := number?,[dD],number
op            := space,[-+],space
space         := [ t]*
我开始怀疑是否有可能我的EBNF中的逻辑错误。 编辑:对于好奇,这是最终的EBNF看起来像:
roll          := space,operations,space
operations    := function
function      := (dice,op,operations)/(grouping,op,operations)/dice/constant/grouping
constant      := number
grouping      := ('(',operations,')')/('{',dice,'}')/('[',operations,']')
dice          := number?,[dD],number
op            := space,[-+],space
space         := [ t]*
    
已邀请:
你还没有定义
number
,我没有在文档中预先定义它。     

要回复问题请先登录注册