| language-c-0.3.1.1: Analysis and generation of C code | Source code | Contents | Index

Language.C.Syntax.Constants

Portability | ghc
Stability | experimental
Maintainer | benedikt.huber@gmail.com

Contents

Utilities
C char constants (and multi-character character constants)
C integral constants
C floating point constants
C string literals

Description
This module provides support for representing, checking and exporting c constants, i.e. integral, float, character and string constants.
Synopsis

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

= CChar !Char !Bool
| CChars [Char] !Bool

getCChar :: CChar -> [Char]
getCCharAsInt :: CChar -> Integer
isWideChar :: CChar -> Bool
showCharConst :: Char -> ShowS

data CIntFlag

= FlagUnsigned
| FlagLong
| FlagLongLong
| FlagImag

data CIntRepr

= DecRepr
| HexRepr
| OctalRepr

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 -> String | Source

unescapeChar :: String -> (Char, String) | Source

unescapeString :: String -> String | Source

newtype Flags f | Source

Constructors

Flags Integer |

Instances

Typeable1 Flags
Eq (Flags f)
Typeable f => Data (Flags f)
Ord (Flags f)

noFlags :: Flags f | Source

setFlag :: Enum f => f -> Flags f -> Flags f | Source

clearFlag :: Enum f => f -> Flags f -> Flags f | Source

testFlag :: Enum f => f -> Flags f -> Bool | Source

C char constants (and multi-character character constants)

cChar :: Char -> CChar | Source

construct a character constant from a haskell `Char` Use cchar_w if you want a wide character constant.

cChar_w :: Char -> CChar | Source

construct a wide chararacter constant

cChars :: [Char] -> Bool -> CChar | Source

create a multi-character character constant

data CChar | Source

C char constants (abstract)
Constructors

CChar !Char !Bool |
CChars [Char] !Bool |

Instances

Eq CChar
Data CChar
Ord CChar
Show CChar
Typeable CChar

getCChar :: CChar -> [Char] | Source

get the haskell representation of a char constant

getCCharAsInt :: CChar -> Integer | Source

get integer value of a C char constant undefined result for multi-char char constants

isWideChar :: CChar -> Bool | Source

return `true` if the character constant is wide.

showCharConst :: Char -> ShowS | Source

`showCharConst c` prepends _a_ String representing the C char constant corresponding to `c`. If neccessary uses octal or hexadecimal escape sequences.
C integral constants

data CIntFlag | Source

datatype representing type flags for integers
Constructors

FlagUnsigned |
FlagLong |
FlagLongLong |
FlagImag |

Instances

Bounded CIntFlag
Enum CIntFlag
Eq CIntFlag
Data CIntFlag
Ord CIntFlag
Show CIntFlag
Typeable CIntFlag

data CIntRepr | Source

datatype for memorizing the representation of an integer
Constructors

DecRepr |
HexRepr |
OctalRepr |

Instances

Bounded CIntRepr
Enum CIntRepr
Eq CIntRepr
Data CIntRepr
Ord CIntRepr
Typeable CIntRepr

cInteger :: Integer -> CInteger | Source

construct a integer constant (without type flags) from a haskell integer

data CInteger | Source

Constructors

CInteger !Integer !CIntRepr !(Flags CIntFlag) |

Instances

Eq CInteger
Data CInteger
Ord CInteger
Show CInteger
Typeable CInteger

getCInteger :: CInteger -> Integer | Source

readCInteger :: CIntRepr -> String -> Either String CInteger | Source

C floating point constants

cFloat :: Float -> CFloat | Source

data CFloat | Source

Floats (represented as strings)
Constructors

CFloat !String |

Instances

Eq CFloat
Data CFloat
Ord CFloat
Show CFloat
Typeable CFloat

readCFloat :: String -> CFloat | Source

C string literals

cString :: String -> CString | Source

cString_w :: String -> CString | Source

data CString | Source

C String literals
Constructors

CString [Char] Bool |

Instances

Eq CString
Data CString
Ord CString
Show CString
Typeable CString

getCString :: CString -> String | Source

showStringLit :: String -> ShowS | Source

`showStringLiteral s` prepends a String representing the C string literal corresponding to `s`. If neccessary it uses octal or hexadecimal escape sequences.

concatCStrings :: [CString] -> CString | Source

concatenate a list of C string literals
Produced by Haddock version 2.4.2