[project @ 2002-02-14 16:24:59 by sof]
[ghc-hetmet.git] / ghc / compiler / parser / Lex.lhs
index 5dd61c3..501dd43 100644 (file)
@@ -54,8 +54,15 @@ import StringBuffer
 import GlaExts
 import Ctype
 import Char            ( chr, ord )
+
+import Bits            ( Bits(..) )       -- non-std
+
+#if __GLASGOW_HASKELL__ >= 503
+import GHC.Read        ( readRational__ ) -- Glasgow non-std
+#else
 import PrelRead        ( readRational__ ) -- Glasgow non-std
-import PrelBits                ( Bits(..) )       -- non-std
+#endif
+import Int             ( Int32 )
 \end{code}
 
 %************************************************************************
@@ -925,9 +932,9 @@ lex_num cont exts acc buf =
                    do_exponent 
                        = let buf3 = incLexeme buf2 in
                          case currentChar# buf3 of
-                               '-'# | is_digit (lookAhead# buf 1#)
+                               '-'# | is_digit (lookAhead# buf3 1#)
                                   -> expandWhile# is_digit (incLexeme buf3)
-                               '+'# | is_digit (lookAhead# buf 1#)
+                               '+'# | is_digit (lookAhead# buf3 1#)
                                   -> expandWhile# is_digit (incLexeme buf3)
                                x | is_digit x -> expandWhile# is_digit buf3
                                _ -> buf2
@@ -1366,7 +1373,7 @@ popContext = \ buf s@(PState{ context = ctx, loc = loc }) ->
 -}
 checkVersion :: Maybe Integer -> P ()
 checkVersion mb@(Just v) buf s@(PState{loc = loc})
- | (v==0) || (v == fromInt opt_HiVersion) || opt_NoHiCheck = POk s ()
+ | (v==0) || (v == fromIntegral opt_HiVersion) || opt_NoHiCheck = POk s ()
  | otherwise = PFailed (ifaceVersionErr mb loc ([]::[Token]){-Todo-})
 checkVersion mb@Nothing  buf s@(PState{loc = loc})
  | "hi-boot" `isSuffixOf` (_UNPK_ (srcLocFile loc)) = POk s ()
@@ -1383,9 +1390,12 @@ ffiBit      = 1  -- FIXME: not used yet; still part of `glaExtsBit'
 parrBit           = 2
 
 glaExtsEnabled, ffiEnabled, parrEnabled :: Int# -> Bool
-glaExtsEnabled flags = testBit (I# flags) glaExtsBit
-ffiEnabled     flags = testBit (I# flags) ffiBit
-parrEnabled    flags = testBit (I# flags) parrBit
+glaExtsEnabled flags = testBit (toInt32 flags) glaExtsBit
+ffiEnabled     flags = testBit (toInt32 flags) ffiBit
+parrEnabled    flags = testBit (toInt32 flags) parrBit
+
+toInt32 :: Int# -> Int32
+toInt32 x# = fromIntegral (I# x#)
 
 -- convenient record-based bitmap for the interface to the rest of the world
 --
@@ -1400,7 +1410,7 @@ data ExtFlags = ExtFlags {
 mkPState          :: SrcLoc -> ExtFlags -> PState
 mkPState loc exts  = PState {
                       loc        = loc,
-                      extsBitmap = case bitmap of {I# bits -> bits},
+                      extsBitmap = case (fromIntegral bitmap) of {I# bits -> bits},
                       bol        = 0#,
                       atbol      = 1#,
                       context    = []
@@ -1410,6 +1420,7 @@ mkPState loc exts  = PState {
 --                             .|. ffiBit     `setBitIf` ffiEF         exts
                                .|. parrBit    `setBitIf` parrEF        exts
                        --
+                      setBitIf :: Int -> Bool -> Int32
                       b `setBitIf` cond | cond      = bit b
                                         | otherwise = 0