BNFC / bnfc

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

Lists of builtin categories #222

Closed andreasabel closed 6 years ago

andreasabel commented 6 years ago
Sum. S ::= [Integer]  ;
separator Integer "+" ;

Test input:

1+2 +3 +  4+ 5

haskell and haskell-gadt do not print this correctly:

[Abstract Syntax]
Sum [1,2,3,4,5]

[Linearized tree]
1 2 3 4 5

The reason is that the printing classes for builtins do not define the prtList function.

andreasabel commented 6 years ago

Took me forever to find the bug, there was a (maybe intended?) mixup between TokenCat (correct) and Cat (not correct of Integer and friends). Maybe this was a hack not to generate the prtList method for the (errorneous) justification that there is a generic print method for lists (polymorphic).