diff options
author | David Terei <davidterei@gmail.com> | 2011-04-25 12:14:21 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-06-17 18:19:48 -0700 |
commit | 6de1b0f2f4fe0455df72adb7b43449586b40ba89 (patch) | |
tree | f8ef6e2b5348103132fbe0a1d419947b0cc90792 /compiler/parser | |
parent | f8279ea9fef8c16782a3cd5bc81cf90de3e46cb5 (diff) | |
download | haskell-6de1b0f2f4fe0455df72adb7b43449586b40ba89.tar.gz |
SafeHaskell: Add safe import flag (not functional)
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/Lexer.x | 5 | ||||
-rw-r--r-- | compiler/parser/Parser.y.pp | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 43a400471e..736ab0967b 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -661,7 +661,7 @@ reservedWordsFM = listToUFM $ ( "export", ITexport, bit ffiBit), ( "label", ITlabel, bit ffiBit), ( "dynamic", ITdynamic, bit ffiBit), - ( "safe", ITsafe, bit ffiBit), + ( "safe", ITsafe, bit ffiBit .|. bit safeHaskellBit), ( "threadsafe", ITthreadsafe, bit ffiBit), -- ToDo: remove ( "interruptible", ITinterruptible, bit ffiBit), ( "unsafe", ITunsafe, bit ffiBit), @@ -1807,6 +1807,8 @@ relaxedLayoutBit :: Int relaxedLayoutBit = 24 nondecreasingIndentationBit :: Int nondecreasingIndentationBit = 25 +safeHaskellBit :: Int +safeHaskellBit = 26 always :: Int -> Bool always _ = True @@ -1902,6 +1904,7 @@ mkPState flags buf loc = .|. alternativeLayoutRuleBit `setBitIf` xopt Opt_AlternativeLayoutRule flags .|. relaxedLayoutBit `setBitIf` xopt Opt_RelaxedLayout flags .|. nondecreasingIndentationBit `setBitIf` xopt Opt_NondecreasingIndentation flags + .|. safeHaskellBit `setBitIf` safeHaskellOn flags -- setBitIf :: Int -> Bool -> Int b `setBitIf` cond | cond = bit b diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 1ad519b116..bb82aaa2d1 100644 --- a/compiler/parser/Parser.y.pp +++ b/compiler/parser/Parser.y.pp @@ -500,13 +500,17 @@ importdecls :: { [LImportDecl RdrName] } | {- empty -} { [] } importdecl :: { LImportDecl RdrName } - : 'import' maybe_src optqualified maybe_pkg modid maybeas maybeimpspec - { L (comb4 $1 $5 $6 $7) (ImportDecl $5 $4 $2 $3 (unLoc $6) (unLoc $7)) } + : 'import' maybe_src maybe_safe optqualified maybe_pkg modid maybeas maybeimpspec + { L (comb4 $1 $6 $7 $8) (ImportDecl $6 $5 $2 $3 $4 (unLoc $7) (unLoc $8)) } maybe_src :: { IsBootInterface } : '{-# SOURCE' '#-}' { True } | {- empty -} { False } +maybe_safe :: { Bool } + : 'safe' { True } + | {- empty -} { False } + maybe_pkg :: { Maybe FastString } : STRING { Just (getSTRING $1) } | {- empty -} { Nothing } |