X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fparser%2FLexer.x;h=f6863c6286083b64ae1136f9bb08fa95a40c93f5;hb=77452bc2888f3fd071774b1177868e95f85a43dc;hp=1ede5f61c4c292cb8307c73572359c46898fe183;hpb=9e18e7e9673e7839458179db64503d9d31b34bd4;p=ghc-hetmet.git diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 1ede5f6..f6863c6 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -1210,6 +1210,7 @@ alexGetChar :: AlexInput -> Maybe (Char,AlexInput) alexGetChar (AI loc ofs s) | atEnd s = Nothing | otherwise = adj_c `seq` loc' `seq` ofs' `seq` s' `seq` + --trace (show (ord c)) $ Just (adj_c, (AI loc' ofs' s')) where (c,s') = nextChar s loc' = advanceSrcLoc loc c @@ -1259,6 +1260,7 @@ alexGetChar' :: AlexInput -> Maybe (Char,AlexInput) alexGetChar' (AI loc ofs s) | atEnd s = Nothing | otherwise = c `seq` loc' `seq` ofs' `seq` s' `seq` + --trace (show (ord c)) $ Just (c, (AI loc' ofs' s')) where (c,s') = nextChar s loc' = advanceSrcLoc loc c @@ -1443,15 +1445,13 @@ lexToken = do span `seq` setLastToken span bytes t span buf bytes --- ToDo: Alex reports the buffer at the start of the erroneous lexeme, --- but it would be more informative to report the location where the --- error was actually discovered, especially if this is a decoding --- error. -reportLexError loc1 loc2 buf str = +reportLexError loc1 loc2 buf str + | atEnd buf = failLocMsgP loc1 loc2 (str ++ " at end of input") + | otherwise = let c = fst (nextChar buf) in if c == '\0' -- decoding errors are mapped to '\0', see utf8DecodeChar# - then failLocMsgP loc2 loc2 "UTF-8 decoding error" + then failLocMsgP loc2 loc2 (str ++ " (UTF-8 decoding error)") else failLocMsgP loc1 loc2 (str ++ " at character " ++ show c) }