Currently, whenever a macro defines a parameter whose name is already used as the identifier of a rule, the macro will use the rule instead of the parameter. This can lead to weird behaviors when extending the grammar.
Below is an example. Grammar 2 extends Grammar 1 by the last definition.
Now, while Grammar 1 will only accept the code "c", Grammar 2 will only accept "d".
I would have excepted for Grammar 2 to also accept only "c" as I assumed parameter and rule names were scoped and hence D was the parameter and not the rule. Using the playground I found out that this is not the case.
Regarding the unexpected behavior when extending a grammar, is this the intended implementation?
Currently, whenever a macro defines a parameter whose name is already used as the identifier of a rule, the macro will use the rule instead of the parameter. This can lead to weird behaviors when extending the grammar.
Below is an example. Grammar 2 extends Grammar 1 by the last definition. Now, while Grammar 1 will only accept the code
"c"
, Grammar 2 will only accept"d"
.I would have excepted for Grammar 2 to also accept only
"c"
as I assumed parameter and rule names were scoped and henceD
was the parameter and not the rule. Using the playground I found out that this is not the case.Regarding the unexpected behavior when extending a grammar, is this the intended implementation?
Grammar 1:
Grammar 2: