Portability | ghc |
---|---|
Stability | experimental |
Maintainer | jwlato@gmail.com |
Safe Haskell | None |
This module provides support for representing, checking and exporting c constants, i.e. integral, float, character and string constants.
- escapeChar :: Char -> String
- unescapeChar :: String -> (Char, String)
- unescapeString :: String -> String
- newtype Flags f = Flags Integer
- noFlags :: Flags f
- setFlag :: Enum f => f -> Flags f -> Flags f
- clearFlag :: Enum f => f -> Flags f -> Flags f
- testFlag :: Enum f => f -> Flags f -> Bool
- cChar :: Char -> CChar
- cChar_w :: Char -> CChar
- cChars :: [Char] -> Bool -> CChar
- data CChar
- getCChar :: CChar -> [Char]
- getCCharAsInt :: CChar -> Integer
- isWideChar :: CChar -> Bool
- showCharConst :: Char -> ShowS
- data CIntFlag
- = FlagUnsigned
- | FlagLong
- | FlagLongLong
- | FlagImag
- data CIntRepr
- cInteger :: Integer -> CInteger
- data CInteger = CInteger !Integer !CIntRepr !(Flags CIntFlag)
- getCInteger :: CInteger -> Integer
- readCInteger :: CIntRepr -> String -> Either String CInteger
- cFloat :: Float -> CFloat
- data CFloat = CFloat !String
- readCFloat :: String -> CFloat
- cString :: String -> CString
- cString_w :: String -> CString
- data CString = CString [Char] Bool
- getCString :: CString -> String
- showStringLit :: String -> ShowS
- concatCStrings :: [CString] -> CString
Utilities
escapeChar :: Char -> StringSource
unescapeChar :: String -> (Char, String)Source
unescapeString :: String -> StringSource
C char constants (and multi-character character constants)
construct a character constant from a haskell Char
Use cchar_w
if you want a wide character constant.
C char constants (abstract)
getCCharAsInt :: CChar -> IntegerSource
get integer value of a C char constant undefined result for multi-char char constants
isWideChar :: CChar -> BoolSource
return true
if the character constant is wide.
showCharConst :: Char -> ShowSSource
showCharConst c
prepends _a_ String representing the C char constant corresponding to c
.
If necessary uses octal or hexadecimal escape sequences.
C integral constants
datatype representing type flags for integers
datatype for memorizing the representation of an integer
cInteger :: Integer -> CIntegerSource
construct a integer constant (without type flags) from a haskell integer
getCInteger :: CInteger -> IntegerSource
C floating point constants
Floats (represented as strings)
readCFloat :: String -> CFloatSource
C string literals
C String literals
getCString :: CString -> StringSource
showStringLit :: String -> ShowSSource
showStringLiteral s
prepends a String representing the C string literal corresponding to s
.
If necessary it uses octal or hexadecimal escape sequences.
concatCStrings :: [CString] -> CStringSource
concatenate a list of C string literals