diff options
author | Ian Lynagh <igloo@earth.li> | 2010-11-20 21:53:40 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-11-20 21:53:40 +0000 |
commit | 9a82b1ffa35fa4c3927c66a1037a37d436cf6aac (patch) | |
tree | f89a534b2d3d6978a0df798014c6f2b8b5059449 /compiler/parser | |
parent | dc03e1edd86d02a94de6367edd16ecba24ca9936 (diff) | |
download | haskell-9a82b1ffa35fa4c3927c66a1037a37d436cf6aac.tar.gz |
Add an extension for GHC's layout-rule relaxations
Still TODO: Add the other relaxation (#1060) and update the alternative
layout rule to use the extension.
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/Lexer.x | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 07179b8584..e52880b64b 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -1107,10 +1107,12 @@ new_layout_context strict span _buf _len = do (AI l _) <- getInput let offset = srcLocCol l ctx <- getContext + relaxed <- extension relaxedLayout + let strict' = strict || not relaxed case ctx of Layout prev_off : _ | - (strict && prev_off >= offset || - not strict && prev_off > offset) -> do + (strict' && prev_off >= offset || + not strict' && prev_off > offset) -> do -- token is indented to the left of the previous context. -- we must generate a {} sequence now. pushLexState layout_left @@ -1761,6 +1763,8 @@ recBit :: Int recBit = 22 -- rec alternativeLayoutRuleBit :: Int alternativeLayoutRuleBit = 23 +relaxedLayoutBit :: Int +relaxedLayoutBit = 24 always :: Int -> Bool always _ = True @@ -1804,6 +1808,8 @@ oldQualOps :: Int -> Bool oldQualOps flags = not (newQualOps flags) alternativeLayoutRule :: Int -> Bool alternativeLayoutRule flags = testBit flags alternativeLayoutRuleBit +relaxedLayout :: Int -> Bool +relaxedLayout flags = testBit flags relaxedLayoutBit -- PState for parsing options pragmas -- @@ -1857,6 +1863,7 @@ mkPState flags buf loc = .|. rawTokenStreamBit `setBitIf` dopt Opt_KeepRawTokenStream flags .|. newQualOpsBit `setBitIf` xopt Opt_NewQualifiedOperators flags .|. alternativeLayoutRuleBit `setBitIf` xopt Opt_AlternativeLayoutRule flags + .|. relaxedLayoutBit `setBitIf` xopt Opt_RelaxedLayout flags -- setBitIf :: Int -> Bool -> Int b `setBitIf` cond | cond = bit b |