1

Is there a difference between these two grammar definitions (where | denotes OR and ; is just a regular character)?

1. <foo> ::= <bar> | <foo> ; <bar>
2. <foo> ::= <bar> | <bar> ; <foo>

It seems to me that foo would match a sequence that looks like <bar> ; <bar> ; <bar> ; .... regardless of which definition is used. Am I missing something here or are they functionally the same?

4

1 回答 1

0

我同意它们是等价的,因为两者的最终结果是一个或多个<bar>。但是,如果添加了任何新规则<foo>(此类规则涉及除 之外的终端或非终端<bar>),它们可能不再是等效的。

于 2013-10-27T01:33:48.923 回答