You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
alex/alex-ghc74-fix-bang-pattern...

54 lines
1.6 KiB

# Author : Erik de Castro Lopo <erikd@mega-nerd.com>
# Description : Fix generated haskell code so it doesn't fail with -Werror.
# Debian Version : 2.3.5
# Date : Sun, 17 Apr 2011 15:45:41 +1000
--- a/templates/GenericTemplate.hs
+++ b/templates/GenericTemplate.hs
@@ -9,7 +9,7 @@
#ifdef ALEX_GHC
#define ILIT(n) n#
-#define FAST_INT_BINDING(n) (n)
+#define FAST_INT_BINDING(n) (!(n))
#define IBOX(n) (I# (n))
#define FAST_INT Int#
#define LT(n,m) (n <# m)
@@ -57,10 +57,10 @@
ALEX_IF_BIGENDIAN
narrow16Int# i
where
- i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)
- high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
- low = int2Word# (ord# (indexCharOffAddr# arr off'))
- off' = off *# 2#
+ !i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)
+ !high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
+ !low = int2Word# (ord# (indexCharOffAddr# arr off'))
+ !off' = off *# 2#
ALEX_ELSE
indexInt16OffAddr# arr off
ALEX_ENDIF
--- a/src/Scan.x
+++ b/src/Scan.x
@@ -11,7 +11,7 @@
-------------------------------------------------------------------------------
{
-{-# OPTIONS_GHC -w #-}
+{-# OPTIONS_GHC -w -XBangPatterns #-}
module Scan(lexer, AlexPosn(..), Token(..), Tkn(..), tokPosn) where
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -203,7 +203,7 @@
hPutStrLn hdl code
optsToInject :: Target -> [CLIFlags] -> String
-optsToInject GhcTarget _ = "{-# LANGUAGE CPP,MagicHash #-}\n"
+optsToInject GhcTarget _ = "{-# LANGUAGE CPP,MagicHash,BangPatterns #-}\n"
optsToInject _ _ = "{-# LANGUAGE CPP #-}\n"
importsToInject :: Target -> [CLIFlags] -> String