projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Trac #2358: 1-tuples in Template Haskell
[ghc-hetmet.git]
/
compiler
/
parser
/
Ctype.lhs
diff --git
a/compiler/parser/Ctype.lhs
b/compiler/parser/Ctype.lhs
index
b9f44d6
..
6fc346c
100644
(file)
--- a/
compiler/parser/Ctype.lhs
+++ b/
compiler/parser/Ctype.lhs
@@
-1,13
+1,6
@@
Character classification
\begin{code}
Character classification
\begin{code}
-{-# OPTIONS -w #-}
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and fix
--- any warnings in the module. See
--- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
--- for details
-
module Ctype
( is_ident -- Char# -> Bool
, is_symbol -- Char# -> Bool
module Ctype
( is_ident -- Char# -> Bool
, is_symbol -- Char# -> Bool
@@
-18,7
+11,7
@@
module Ctype
, is_digit -- Char# -> Bool
, is_alphanum -- Char# -> Bool
, is_digit -- Char# -> Bool
, is_alphanum -- Char# -> Bool
- , is_hexdigit, is_octdigit
+ , is_decdigit, is_hexdigit, is_octdigit
, hexDigit, octDecDigit
) where
, hexDigit, octDecDigit
) where
@@
-27,6
+20,7
@@
module Ctype
import Data.Int ( Int32 )
import Data.Bits ( Bits((.&.)) )
import Data.Char ( ord, chr )
import Data.Int ( Int32 )
import Data.Bits ( Bits((.&.)) )
import Data.Char ( ord, chr )
+import Panic
\end{code}
Bit masks
\end{code}
Bit masks
@@
-50,7
+44,8
@@
at the big case below.
is_ctype :: Int -> Char -> Bool
is_ctype mask c = (fromIntegral (charType c) .&. fromIntegral mask) /= (0::Int32)
is_ctype :: Int -> Char -> Bool
is_ctype mask c = (fromIntegral (charType c) .&. fromIntegral mask) /= (0::Int32)
-is_ident, is_symbol, is_any, is_space, is_lower, is_upper, is_digit :: Char -> Bool
+is_ident, is_symbol, is_any, is_space, is_lower, is_upper, is_digit,
+ is_alphanum :: Char -> Bool
is_ident = is_ctype cIdent
is_symbol = is_ctype cSymbol
is_any = is_ctype cAny
is_ident = is_ctype cIdent
is_symbol = is_ctype cSymbol
is_any = is_ctype cAny
@@
-65,20
+60,27
@@
Utils
\begin{code}
hexDigit :: Char -> Int
\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'
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_hexdigit c
- = is_digit c
+ = is_decdigit c
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F')
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F')
+is_octdigit :: Char -> Bool
is_octdigit c = c >= '0' && c <= '7'
is_octdigit c = c >= '0' && c <= '7'
-to_lower c
+to_lower :: Char -> Char
+to_lower c
| c >= 'A' && c <= 'Z' = chr (ord c - (ord 'A' - ord 'a'))
| otherwise = c
\end{code}
| c >= 'A' && c <= 'Z' = chr (ord c - (ord 'A' - ord 'a'))
| otherwise = c
\end{code}
@@
-345,4
+347,5
@@
charType c = case c of
'\253' -> cAny + cIdent + cLower -- ý
'\254' -> cAny + cIdent + cLower -- þ
'\255' -> cAny + cIdent + cLower -- ÿ
'\253' -> cAny + cIdent + cLower -- ý
'\254' -> cAny + cIdent + cLower -- þ
'\255' -> cAny + cIdent + cLower -- ÿ
+ _ -> panic ("charType: " ++ show c)
\end{code}
\end{code}