GuntherRademacher / rr

RR - Railroad Diagram Generator
Apache License 2.0
467 stars 51 forks source link

Maybe a mistake in the 'rr' grammar ? #8

Closed mingodad closed 3 years ago

mingodad commented 3 years ago

Trying to implement rr grammar with CocoR https://ssw.jku.at/Research/Projects/Coco/ it seems that there is a mistake in the rr grammar for the production item:

Item                  ::= Primary ( '?' | '*' | '+' )*

If I understood it correctly it should be:

Item                  ::= Primary ( '?' | '*' | '+' )?

Because constructs like this are invalid, isn't it ?

Item                  ::= Primary ( '?' | '*' | '+' )*?+  //zero or more *?+ after ')'

Cheers !

GuntherRademacher commented 3 years ago

This is as intended. There is no reason to restrict to a single operator. Especially not on syntax level in the Item production - the parenthesized variant would still be allowed. Also, there is no problem at all with the semantics, and RR's grammar transformation will normalize it.

You may be wondering about ambiguities that could arise with some parser generation schemes, but that is a completely different issue.

GuntherRademacher commented 3 years ago

Closing - works as it is supposed to.