bnfc icon indicating copy to clipboard operation
bnfc copied to clipboard

BNFC accepts several list pragmas for the same category

Open andreasabel opened this issue 4 years ago • 1 comments

E.g. this should fail BNFC's well-formedness check.

separator nonempty Integer "," ;
terminator Integer "" ;

andreasabel avatar Jan 12 '21 17:01 andreasabel

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!

andreasabel avatar Jan 12 '21 17:01 andreasabel