Copyright | (c) 2007..2008 Duncan Coutts Benedikt Huber |
---|---|
License | BSD-style |
Maintainer | benedikt.huber@gmail.com |
Stability | experimental |
Portability | ghc |
Safe Haskell | None |
Language | Haskell98 |
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 :: String -> Bool -> CChar
- data CChar
- getCChar :: CChar -> String
- getCCharAsInt :: CChar -> Integer
- isWideChar :: CChar -> Bool
- showCharConst :: Char -> ShowS
- data CIntFlag
- 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 String Bool
- getCString :: CString -> String
- showStringLit :: String -> ShowS
- concatCStrings :: [CString] -> CString
- data ClangCVersion = ClangCVersion !String
- readClangCVersion :: String -> ClangCVersion
Utilities
escapeChar :: Char -> String Source #
unescapeString :: String -> String Source #
Instances
Eq (Flags f) Source # | |
Data f => Data (Flags f) Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Flags f -> c (Flags f) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Flags f) # toConstr :: Flags f -> Constr # dataTypeOf :: Flags f -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Flags f)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Flags f)) # gmapT :: (forall b. Data b => b -> b) -> Flags f -> Flags f # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Flags f -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Flags f -> r # gmapQ :: (forall d. Data d => d -> u) -> Flags f -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Flags f -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Flags f -> m (Flags f) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Flags f -> m (Flags f) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Flags f -> m (Flags f) # | |
Ord (Flags f) Source # | |
Defined in Language.C.Syntax.Constants | |
Generic (Flags f) Source # | |
NFData (Flags f) Source # | |
Defined in Language.C.Syntax.Constants | |
Generic1 Flags Source # | |
type Rep (Flags f) Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep1 Flags Source # | |
Defined in Language.C.Syntax.Constants |
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.
C char constants (abstract)
Instances
Eq CChar Source # | |
Data CChar Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CChar -> c CChar # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CChar # dataTypeOf :: CChar -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CChar) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CChar) # gmapT :: (forall b. Data b => b -> b) -> CChar -> CChar # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CChar -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CChar -> r # gmapQ :: (forall d. Data d => d -> u) -> CChar -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CChar -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CChar -> m CChar # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CChar -> m CChar # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CChar -> m CChar # | |
Ord CChar Source # | |
Show CChar Source # | |
Generic CChar Source # | |
NFData CChar Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep CChar Source # | |
Defined in Language.C.Syntax.Constants type Rep CChar = D1 ('MetaData "CChar" "Language.C.Syntax.Constants" "language-c-0.9-inplace" 'False) (C1 ('MetaCons "CChar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Char) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "CChars" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Char]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))) |
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 necessary uses octal or hexadecimal escape sequences.
C integral constants
datatype representing type flags for integers
Instances
Bounded CIntFlag Source # | |
Enum CIntFlag Source # | |
Defined in Language.C.Syntax.Constants | |
Eq CIntFlag Source # | |
Data CIntFlag Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CIntFlag -> c CIntFlag # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CIntFlag # toConstr :: CIntFlag -> Constr # dataTypeOf :: CIntFlag -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CIntFlag) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CIntFlag) # gmapT :: (forall b. Data b => b -> b) -> CIntFlag -> CIntFlag # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CIntFlag -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CIntFlag -> r # gmapQ :: (forall d. Data d => d -> u) -> CIntFlag -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CIntFlag -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CIntFlag -> m CIntFlag # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CIntFlag -> m CIntFlag # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CIntFlag -> m CIntFlag # | |
Ord CIntFlag Source # | |
Defined in Language.C.Syntax.Constants | |
Show CIntFlag Source # | |
Generic CIntFlag Source # | |
NFData CIntFlag Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep CIntFlag Source # | |
Defined in Language.C.Syntax.Constants type Rep CIntFlag = D1 ('MetaData "CIntFlag" "Language.C.Syntax.Constants" "language-c-0.9-inplace" 'False) ((C1 ('MetaCons "FlagUnsigned" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FlagLong" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "FlagLongLong" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FlagImag" 'PrefixI 'False) (U1 :: Type -> Type))) |
datatype for memorizing the representation of an integer
Instances
Bounded CIntRepr Source # | |
Enum CIntRepr Source # | |
Defined in Language.C.Syntax.Constants | |
Eq CIntRepr Source # | |
Data CIntRepr Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CIntRepr -> c CIntRepr # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CIntRepr # toConstr :: CIntRepr -> Constr # dataTypeOf :: CIntRepr -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CIntRepr) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CIntRepr) # gmapT :: (forall b. Data b => b -> b) -> CIntRepr -> CIntRepr # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CIntRepr -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CIntRepr -> r # gmapQ :: (forall d. Data d => d -> u) -> CIntRepr -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CIntRepr -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CIntRepr -> m CIntRepr # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CIntRepr -> m CIntRepr # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CIntRepr -> m CIntRepr # | |
Ord CIntRepr Source # | |
Defined in Language.C.Syntax.Constants | |
Generic CIntRepr Source # | |
NFData CIntRepr Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep CIntRepr Source # | |
Defined in Language.C.Syntax.Constants type Rep CIntRepr = D1 ('MetaData "CIntRepr" "Language.C.Syntax.Constants" "language-c-0.9-inplace" 'False) (C1 ('MetaCons "DecRepr" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "HexRepr" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OctalRepr" 'PrefixI 'False) (U1 :: Type -> Type))) |
cInteger :: Integer -> CInteger Source #
construct a integer constant (without type flags) from a haskell integer
Instances
Eq CInteger Source # | |
Data CInteger Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CInteger -> c CInteger # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CInteger # toConstr :: CInteger -> Constr # dataTypeOf :: CInteger -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CInteger) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CInteger) # gmapT :: (forall b. Data b => b -> b) -> CInteger -> CInteger # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CInteger -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CInteger -> r # gmapQ :: (forall d. Data d => d -> u) -> CInteger -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CInteger -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CInteger -> m CInteger # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CInteger -> m CInteger # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CInteger -> m CInteger # | |
Ord CInteger Source # | |
Defined in Language.C.Syntax.Constants | |
Show CInteger Source # | |
Generic CInteger Source # | |
NFData CInteger Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep CInteger Source # | |
Defined in Language.C.Syntax.Constants type Rep CInteger = D1 ('MetaData "CInteger" "Language.C.Syntax.Constants" "language-c-0.9-inplace" 'False) (C1 ('MetaCons "CInteger" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CIntRepr) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Flags CIntFlag))))) |
getCInteger :: CInteger -> Integer Source #
C floating point constants
Floats (represented as strings)
Instances
Eq CFloat Source # | |
Data CFloat Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CFloat -> c CFloat # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CFloat # toConstr :: CFloat -> Constr # dataTypeOf :: CFloat -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CFloat) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CFloat) # gmapT :: (forall b. Data b => b -> b) -> CFloat -> CFloat # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CFloat -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CFloat -> r # gmapQ :: (forall d. Data d => d -> u) -> CFloat -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CFloat -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CFloat -> m CFloat # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CFloat -> m CFloat # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CFloat -> m CFloat # | |
Ord CFloat Source # | |
Show CFloat Source # | |
Generic CFloat Source # | |
NFData CFloat Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep CFloat Source # | |
Defined in Language.C.Syntax.Constants |
readCFloat :: String -> CFloat Source #
C string literals
C String literals
Instances
Eq CString Source # | |
Data CString Source # | |
Defined in Language.C.Syntax.Constants gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CString -> c CString # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CString # toConstr :: CString -> Constr # dataTypeOf :: CString -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CString) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CString) # gmapT :: (forall b. Data b => b -> b) -> CString -> CString # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CString -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CString -> r # gmapQ :: (forall d. Data d => d -> u) -> CString -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CString -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CString -> m CString # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CString -> m CString # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CString -> m CString # | |
Ord CString Source # | |
Defined in Language.C.Syntax.Constants | |
Show CString Source # | |
Generic CString Source # | |
NFData CString Source # | |
Defined in Language.C.Syntax.Constants | |
type Rep CString Source # | |
Defined in Language.C.Syntax.Constants type Rep CString = D1 ('MetaData "CString" "Language.C.Syntax.Constants" "language-c-0.9-inplace" 'False) (C1 ('MetaCons "CString" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))) |
getCString :: CString -> String Source #
showStringLit :: String -> ShowS Source #
showStringLiteral s
prepends a String representing the C string literal corresponding to s
.
If necessary it uses octal or hexadecimal escape sequences.
concatCStrings :: [CString] -> CString Source #
concatenate a list of C string literals
Clang C version literals
data ClangCVersion Source #
Clang dotted version literal https://clang.llvm.org/docs/AttributeReference.html#availability