summaryrefslogtreecommitdiff
path: root/src/Transfer/Syntax/Layout.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Transfer/Syntax/Layout.hs')
-rw-r--r--src/Transfer/Syntax/Layout.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Transfer/Syntax/Layout.hs b/src/Transfer/Syntax/Layout.hs
index c0bf9e5d8..d5eae2010 100644
--- a/src/Transfer/Syntax/Layout.hs
+++ b/src/Transfer/Syntax/Layout.hs
@@ -105,10 +105,17 @@ resolveLayout tp = res Nothing [if tl then Implicit 1 else Explicit]
-- Nothing to see here, move along.
res _ st (t:ts) = moveAlong st [t] ts
- -- We are at EOF, close all open implicit non-top-level layout blocks.
- res (Just t) st [] =
- addTokens (position t) [layoutClose | Implicit n <- st,
- not (tl && n == 1)] []
+ -- At EOF: skip explicit blocks.
+ res (Just t) (Explicit:bs) [] | null bs = []
+ | otherwise = res (Just t) bs []
+
+ -- If we are using top-level layout, insert a semicolon after the last token
+ res (Just t) [Implicit n] [] = addToken (nextPos t) layoutSep []
+
+ -- At EOF in an implicit, non-top-level block: close the block
+ res (Just t) (Implicit n:bs) [] =
+ let c = addToken (nextPos t) layoutClose []
+ in moveAlong bs c []
-- This should only happen if the input is empty.
res Nothing st [] = []