summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Lexer.x15
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 3f762aa5de..1570af32bc 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -80,6 +80,7 @@ import Data.Maybe
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Ratio
+import Data.Word
}
$unispace = \x05 -- Trick Alex into handling Unicode. See alexGetChar.
@@ -1576,14 +1577,22 @@ data AlexInput = AI RealSrcLoc StringBuffer
alexInputPrevChar :: AlexInput -> Char
alexInputPrevChar (AI _ buf) = prevChar buf '\n'
+-- backwards compatibility for Alex 2.x
alexGetChar :: AlexInput -> Maybe (Char,AlexInput)
-alexGetChar (AI loc s)
+alexGetChar inp = case alexGetByte inp of
+ Nothing -> Nothing
+ Just (b,i) -> c `seq` Just (c,i)
+ where c = chr $ fromIntegral b
+
+alexGetByte :: AlexInput -> Maybe (Word8,AlexInput)
+alexGetByte (AI loc s)
| atEnd s = Nothing
- | otherwise = adj_c `seq` loc' `seq` s' `seq`
+ | otherwise = byte `seq` loc' `seq` s' `seq`
--trace (show (ord c)) $
- Just (adj_c, (AI loc' s'))
+ Just (byte, (AI loc' s'))
where (c,s') = nextChar s
loc' = advanceSrcLoc loc c
+ byte = fromIntegral $ ord adj_c
non_graphic = '\x0'
upper = '\x1'