summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-11-29 14:58:40 +0000
committerIan Lynagh <igloo@earth.li>2009-11-29 14:58:40 +0000
commitd8b99b7e9b2ce9fd8ba97fa10657082ceac09c59 (patch)
tree22abf2c522b77153e8e89517e9e9caad0c666446 /compiler
parentf9460db84b4eb145d1356435127cce0a1a775c70 (diff)
downloadhaskell-d8b99b7e9b2ce9fd8ba97fa10657082ceac09c59.tar.gz
Make the alternative layout rule cope with file pragmas
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parser/Lexer.x4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index dca51e4726..43ddf7c4c5 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -1144,6 +1144,7 @@ setLine code span buf len = do
setFile :: Int -> Action
setFile code span buf len = do
let file = lexemeToFastString (stepOn buf) (len-2)
+ setAlrLastLoc noSrcSpan
setSrcLoc (mkSrcLoc file (srcSpanEndLine span) (srcSpanEndCol span))
_ <- popLexState
pushLexState code
@@ -1981,7 +1982,8 @@ alternativeLayoutRuleToken t
mExpectingOCurly <- getAlrExpectingOCurly
let thisLoc = getLoc t
thisCol = srcSpanStartCol thisLoc
- newLine = srcSpanStartLine thisLoc > srcSpanEndLine lastLoc
+ newLine = (lastLoc == noSrcSpan)
+ || (srcSpanStartLine thisLoc > srcSpanEndLine lastLoc)
case (unLoc t, context, mExpectingOCurly) of
-- I think our implicit open-curly handling is slightly
-- different to John's, in how it interacts with newlines