Skip to content

Layout: closing explicit block does not close open implicit blocks #344

@andreasabel

Description

@andreasabel

This parses in haskell but not in a suitable grammar using BNFC's layout mechanism:

f = 5 + g where {
g = 3 + h where
  h = 2 }

The problem seems to be that implicit blocks are dropped from the layout stack without emitting layoutClose tokens, see:

, " | isLayoutClose t0 = "
, " let st' = drop 1 (dropWhile isImplicit st)"

I am using this grammar:

layout toplevel;
separator nonempty Decl ";" ;

Empty.      Decl ::= ;
FunClause.  Decl ::= Ident "=" Expr WhereOpt;

layout "where";
YesWhere.   WhereOpt ::= "where" "{" [Decl] "}";
NoWhere.    WhereOpt ::= ;

EId.        Expr1 ::= Ident;
EInt.       Expr1 ::= Integer;
EPlus.      Expr  ::= Expr "+" Expr1;
coercions   Expr 1;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions