bnfc
bnfc copied to clipboard
BNFC accepts several list pragmas for the same category
E.g. this should fail BNFC's well-formedness check.
separator nonempty Integer "," ;
terminator Integer "" ;
Printer has overlapping patterns because both pragmas lead to clauses in the printer for integer lists:
[4 of 6] Compiling PrintTest ( PrintTest.hs, PrintTest.o )
PrintTest.hs:97:3: warning: [-Woverlapping-patterns]
Pattern match is redundant
In an equation for ‘prtList’: prtList _ [] = ...
|
97 | prtList _ [] = concatD []
| ^^^^^^^^^^^^^^^^^^^^^^^^^
PrintTest.hs:100:3: warning: [-Woverlapping-patterns]
Pattern match is redundant
In an equation for ‘prtList’: prtList _ (x : xs) = ...
|
100 | prtList _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The generate parser seems to accept both types of lists:
$ haskell/TestTest <<< "5 6"
Parse Successful!
[Abstract Syntax]
[5,6]
[Linearized tree]
5 6
$ haskell/TestTest <<< "5,6"
Parse Successful!
[Abstract Syntax]
[5,6]
[Linearized tree]
5 6
Could be a feature, not a bug, haha!