diff options
| author | Ian Lynagh <igloo@earth.li> | 2010-11-24 20:59:57 +0000 |
|---|---|---|
| committer | Ian Lynagh <igloo@earth.li> | 2010-11-24 20:59:57 +0000 |
| commit | 04a12a3d4ee3eb098b1fed40195b27095a31c5ec (patch) | |
| tree | e04c57a61bc826aa4cb9c39e313f09c6e3c31290 /compiler/parser | |
| parent | 1e70cb6e14de98a75207796a2fb8eb7de03ea779 (diff) | |
| download | haskell-04a12a3d4ee3eb098b1fed40195b27095a31c5ec.tar.gz | |
Add another GHC layout rule relaxation to RelaxedLayout
Diffstat (limited to 'compiler/parser')
| -rw-r--r-- | compiler/parser/Lexer.x | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index e52880b64b..823fc6dbc9 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -211,7 +211,7 @@ $tab+ { warn Opt_WarnTabs (text "Warning: Tab character") } -- context if the curly brace is missing. -- Careful! This stuff is quite delicate. <layout, layout_do> { - \{ / { notFollowedBy '-' } { pop_and open_brace } + \{ / { notFollowedBy '-' } { hopefully_open_brace } -- we might encounter {-# here, but {- has been handled already \n ; ^\# (line)? { begin line_prag1 } @@ -757,6 +757,19 @@ pop :: Action pop _span _buf _len = do _ <- popLexState lexToken +hopefully_open_brace :: Action +hopefully_open_brace span buf len + = do relaxed <- extension relaxedLayout + ctx <- getContext + (AI l _) <- getInput + let offset = srcLocCol l + isOK = relaxed || + case ctx of + Layout prev_off : _ -> prev_off < offset + _ -> True + if isOK then pop_and open_brace span buf len + else failSpanMsgP span (text "Missing block") + pop_and :: Action -> Action pop_and act span buf len = do _ <- popLexState act span buf len |
