summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2008-06-13 20:35:53 +0000
committerIan Lynagh <igloo@earth.li>2008-06-13 20:35:53 +0000
commit6b4ab02f289394c82f27e46e44c017b4a0c88fb0 (patch)
tree5a8993fb1c539d4adf76c8b89025db69cfe4ab3a /compiler
parentbd4d75bae80df2e9a4d519112532bbdd959382a2 (diff)
downloadhaskell-6b4ab02f289394c82f27e46e44c017b4a0c88fb0.tar.gz
Define and use is_decdigit for lexing escapes; fixes trac #2304
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parser/Ctype.lhs12
-rw-r--r--compiler/parser/Lexer.x2
2 files changed, 9 insertions, 5 deletions
diff --git a/compiler/parser/Ctype.lhs b/compiler/parser/Ctype.lhs
index d813030a9b..6fc346ced3 100644
--- a/compiler/parser/Ctype.lhs
+++ b/compiler/parser/Ctype.lhs
@@ -11,7 +11,7 @@ module Ctype
, is_digit -- Char# -> Bool
, is_alphanum -- Char# -> Bool
- , is_hexdigit, is_octdigit
+ , is_decdigit, is_hexdigit, is_octdigit
, hexDigit, octDecDigit
) where
@@ -60,15 +60,19 @@ Utils
\begin{code}
hexDigit :: Char -> Int
-hexDigit c | is_digit c = ord c - ord '0'
- | otherwise = ord (to_lower c) - ord 'a' + 10
+hexDigit c | is_decdigit c = ord c - ord '0'
+ | otherwise = ord (to_lower c) - ord 'a' + 10
octDecDigit :: Char -> Int
octDecDigit c = ord c - ord '0'
+is_decdigit :: Char -> Bool
+is_decdigit c
+ = c >= '0' && c <= '9'
+
is_hexdigit :: Char -> Bool
is_hexdigit c
- = is_digit c
+ = is_decdigit c
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F')
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index e891cae73b..c935b2adb3 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -1242,7 +1242,7 @@ lex_escape = do
'x' -> readNum is_hexdigit 16 hexDigit
'o' -> readNum is_octdigit 8 octDecDigit
- x | is_digit x -> readNum2 is_digit 10 octDecDigit (octDecDigit x)
+ x | is_decdigit x -> readNum2 is_decdigit 10 octDecDigit (octDecDigit x)
c1 -> do
i <- getInput