BNFC / bnfc

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

Weird special behavior of layout resolution at beginning of file #412

Open andreasabel opened 2 years ago

andreasabel commented 2 years ago

Given grammar:

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

The following is accepted but should not, without top-level layout:

private
private

This is parsed as:

Priv [Priv []]

One could argue that this is a case of NondecreasingIndentation, but it is not in line with the following example:

private
  private
  private

This gives, as naturally expected:

Priv [Priv [],Priv []]

Finally, this fails (as naturally expected):

private
  private
  private
private

EDIT: Apparently, this is a feature, not a bug: https://github.com/BNFC/bnfc/blob/19151603ff5b0fd8fab3b1a6892321246362e76c/testing/regression-tests/194_layout/good05.in