rascal
rascal copied to clipboard
Grammar reifier forgets non-terminals if there exists a layout non-terminal with the same name.
Describe the bug
rascal>layout A = " "*;
ok
rascal>syntax A = "a" | "b" "b";
ok
rascal>#A
type[A]: type(
sort("A"),
(
layouts("$default$"):choice(
layouts("$default$"),
{prod(
layouts("$default$"),
[],
{})}),
empty():choice(
empty(),
{prod(
empty(),
[],
{})}),
layouts("A"):choice(
layouts("A"),
{
prod(
layouts("A"),
[lit("a")],
{}),
prod(
layouts("A"),
[
lit("b"),
layouts("A"),
lit("b")
],
{})
})
))
rascal>
If we reify #A then the syntax sort is lost and all the productions for syntax A end up with layout A. The original rule for layout A seems to be lost completely. That's probably due to an update in the definitions map that overwrites the original value at key layouts("A").
- We might have to add a warning or error to the type-checker to prevent this situation from happening
- It's worth fixing the bug in the code of the parser generator that does the reification of the syntax definition into a grammar value.