Commit 5fa086c5 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Separate NondecreasingIndentation out into its own extension

parent 04a12a3d
...@@ -361,6 +361,7 @@ data ExtensionFlag ...@@ -361,6 +361,7 @@ data ExtensionFlag
| Opt_AlternativeLayoutRule | Opt_AlternativeLayoutRule
| Opt_AlternativeLayoutRuleTransitional | Opt_AlternativeLayoutRuleTransitional
| Opt_DatatypeContexts | Opt_DatatypeContexts
| Opt_NondecreasingIndentation
| Opt_RelaxedLayout | Opt_RelaxedLayout
deriving (Eq, Show) deriving (Eq, Show)
...@@ -795,6 +796,7 @@ languageExtensions Nothing ...@@ -795,6 +796,7 @@ languageExtensions Nothing
-- In due course I'd like Opt_MonoLocalBinds to be on by default -- In due course I'd like Opt_MonoLocalBinds to be on by default
-- But NB it's implied by GADTs etc -- But NB it's implied by GADTs etc
-- SLPJ September 2010 -- SLPJ September 2010
: Opt_NondecreasingIndentation -- This has been on by default for some time
: Opt_RelaxedLayout -- This has been on by default for some time : Opt_RelaxedLayout -- This has been on by default for some time
: languageExtensions (Just Haskell2010) : languageExtensions (Just Haskell2010)
...@@ -1593,6 +1595,7 @@ xFlags = [ ...@@ -1593,6 +1595,7 @@ xFlags = [
( "AlternativeLayoutRule", Opt_AlternativeLayoutRule, nop ), ( "AlternativeLayoutRule", Opt_AlternativeLayoutRule, nop ),
( "AlternativeLayoutRuleTransitional",Opt_AlternativeLayoutRuleTransitional, nop ), ( "AlternativeLayoutRuleTransitional",Opt_AlternativeLayoutRuleTransitional, nop ),
( "DatatypeContexts", Opt_DatatypeContexts, nop ), ( "DatatypeContexts", Opt_DatatypeContexts, nop ),
( "NondecreasingIndentation", Opt_NondecreasingIndentation, nop ),
( "RelaxedLayout", Opt_RelaxedLayout, nop ), ( "RelaxedLayout", Opt_RelaxedLayout, nop ),
( "MonoLocalBinds", Opt_MonoLocalBinds, nop ), ( "MonoLocalBinds", Opt_MonoLocalBinds, nop ),
( "RelaxedPolyRec", Opt_RelaxedPolyRec, ( "RelaxedPolyRec", Opt_RelaxedPolyRec,
......
...@@ -1120,8 +1120,8 @@ new_layout_context strict span _buf _len = do ...@@ -1120,8 +1120,8 @@ new_layout_context strict span _buf _len = do
(AI l _) <- getInput (AI l _) <- getInput
let offset = srcLocCol l let offset = srcLocCol l
ctx <- getContext ctx <- getContext
relaxed <- extension relaxedLayout nondecreasing <- extension nondecreasingIndentation
let strict' = strict || not relaxed let strict' = strict || not nondecreasing
case ctx of case ctx of
Layout prev_off : _ | Layout prev_off : _ |
(strict' && prev_off >= offset || (strict' && prev_off >= offset ||
...@@ -1778,6 +1778,8 @@ alternativeLayoutRuleBit :: Int ...@@ -1778,6 +1778,8 @@ alternativeLayoutRuleBit :: Int
alternativeLayoutRuleBit = 23 alternativeLayoutRuleBit = 23
relaxedLayoutBit :: Int relaxedLayoutBit :: Int
relaxedLayoutBit = 24 relaxedLayoutBit = 24
nondecreasingIndentationBit :: Int
nondecreasingIndentationBit = 25
always :: Int -> Bool always :: Int -> Bool
always _ = True always _ = True
...@@ -1823,6 +1825,8 @@ alternativeLayoutRule :: Int -> Bool ...@@ -1823,6 +1825,8 @@ alternativeLayoutRule :: Int -> Bool
alternativeLayoutRule flags = testBit flags alternativeLayoutRuleBit alternativeLayoutRule flags = testBit flags alternativeLayoutRuleBit
relaxedLayout :: Int -> Bool relaxedLayout :: Int -> Bool
relaxedLayout flags = testBit flags relaxedLayoutBit relaxedLayout flags = testBit flags relaxedLayoutBit
nondecreasingIndentation :: Int -> Bool
nondecreasingIndentation flags = testBit flags nondecreasingIndentationBit
-- PState for parsing options pragmas -- PState for parsing options pragmas
-- --
...@@ -1877,6 +1881,7 @@ mkPState flags buf loc = ...@@ -1877,6 +1881,7 @@ mkPState flags buf loc =
.|. newQualOpsBit `setBitIf` xopt Opt_NewQualifiedOperators flags .|. newQualOpsBit `setBitIf` xopt Opt_NewQualifiedOperators flags
.|. alternativeLayoutRuleBit `setBitIf` xopt Opt_AlternativeLayoutRule flags .|. alternativeLayoutRuleBit `setBitIf` xopt Opt_AlternativeLayoutRule flags
.|. relaxedLayoutBit `setBitIf` xopt Opt_RelaxedLayout flags .|. relaxedLayoutBit `setBitIf` xopt Opt_RelaxedLayout flags
.|. nondecreasingIndentationBit `setBitIf` xopt Opt_NondecreasingIndentation flags
-- --
setBitIf :: Int -> Bool -> Int setBitIf :: Int -> Bool -> Int
b `setBitIf` cond | cond = bit b b `setBitIf` cond | cond = bit b
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment