BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
583 stars 162 forks source link

Layout: patching of columns leads to misalignment #345

Closed andreasabel closed 3 years ago

andreasabel commented 3 years ago

The layout mechanism adjust columns of subsequent tokens on the same line when inserting braces and semicolons. This leads to misalignment and subsequent parse errors. E.g. this parses in haskell but is rejected by the grammar of #344:

f = g + h where g = 3; h = i where i = j
                                   j = 2

Suggested fix: just remove the incrGlobal mechanism, simplifying addToken: https://github.com/BNFC/bnfc/blob/71ebcee11831fab640bb9f39d11c927106d21304/source/src/BNFC/Backend/Haskell/CFtoLayout.hs#L206-L212 https://github.com/BNFC/bnfc/blob/71ebcee11831fab640bb9f39d11c927106d21304/source/src/BNFC/Backend/Haskell/CFtoLayout.hs#L225-L235