BNFC / bnfc

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

Layout: bug when layout keyword on new line is followed by `layoutOpen` "{" #353

Closed andreasabel closed 3 years ago

andreasabel commented 3 years ago

LBNF file:

P.        Decl ::= "private" "{" [Decl] "}" ;
separator Decl ";" ;

layout "private" ;

Input:

private
  private
  private {}  -- should work

This is reconstructed as

private {
  ; private {}
  private {}  -- missing semicolon
}

The problem is that the following code does not check whether a layoutSep needs to be inserted: https://github.com/BNFC/bnfc/blob/e34f1b8b47e7d8ce59de790a44c111ae618000df/source/src/BNFC/Backend/Haskell/CFtoLayout.hs#L103-L105