Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andreasabel opened this issue Mar 6, 2021 · 0 comments
Closed
Assignees
Labels
bug Haskell layout Concerning layout (keywords)
Milestone

Comments

@andreasabel
Copy link
Member

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;
@andreasabel andreasabel added bug Haskell layout Concerning layout (keywords) labels Mar 6, 2021
@andreasabel andreasabel added this to the 2.9.2 milestone Mar 6, 2021
@andreasabel andreasabel self-assigned this Mar 6, 2021
andreasabel added a commit that referenced this issue Mar 6, 2021
```
module A where {
  module B where
  module C where
}
```
is surprisingly parsed as
```
module A where {
  module B where {
    module C where {
      }
    }
  }
```
Yet this conforms with Haskell's indentation rules.

Apparently, the start column after { does not matter, so the input
looks to the parser like:
```
module A where {
module B where
  module C where
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Haskell layout Concerning layout (keywords)
Projects
None yet
Development

No branches or pull requests

1 participant