BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
586 stars 165 forks source link

Haskell: spurious character in .cf file leads to ill-formed semantic parse actions #214

Closed andreasabel closed 4 years ago

andreasabel commented 7 years ago
A. S ::= "A"; x -- Here is a superfluous character 
B. S ::= "B";

BNFC swallows this, but then the generated parser does not compile. In the .y file, this grammar turns into:

S :: { S }
S : 'A' { Min.Abs.A } | 'B' { Min.Abs.x_ }
andreasabel commented 6 years ago

Still do not fully understand this, but the profiles feature allows two identifiers to be given as rule name, and then the second one is taken. I don't know why x is turned into name variable x_, though.

andreasabel commented 5 years ago

I don't know why x is turned into name variable x_, though.

This comes from the syntactic sugar feature. BNFC should check for the presence of the definition, like

define x = ...

instead of silently assuming there is a definition. Currently, definitions are unusable since there is an errorneous qualification Min.Abs.x_ instead of x_.

andreasabel commented 4 years ago

The situation is much better already:

$ bnfc --check test.cf
Lower case rule labels need a definition.
ERROR: undefined rule label(s): x

Aborting.  (Use option --force to continue despite errors.)

We would wish for an error location.