【问题标题】:How to debug 'no production for X' in lbnf / bnfc grammar?如何在 lbnf / bnfc 语法中调试“X 没有生产”?
【发布时间】:2021-03-02 10:00:33
【问题描述】:

在使用 lbnf/bnfc 时,在某些情况下,我希望它可以选择允许复数形式。然而,它总是说“规则中出现'复数'没有生产”,我不明白为什么。 下面的相关行。 SomeOther 和 SomeToken 基本上都是字符串。

HeadAuthors. Authors::= "AUTHOR" [Plural] ":" SomeOther SomeToken ;

Plural. Plural::= "S" ;

【问题讨论】:

    标签: grammar bnfc


    【解决方案1】:

    我会跳过这个列表,把复数变成这样的规则

    rules Plural ::= "S" | ;
    

    有关rules 宏的文档,请参阅https://bnfc.readthedocs.io/en/latest/lbnf.html#rules。

    如果你想保留列表,那么你需要给复数一个分隔符或终止符,见这里https://bnfc.readthedocs.io/en/latest/lbnf.html#terminator,否则它不会成为一个列表。你可以写

    terminator Plural "" ;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-10
      • 2010-09-07
      相关资源
      最近更新 更多