language-c-0.10.1: Analysis and generation of C code

Copyright | (c) [1995..1999] Manuel M. T. Chakravarty (c) 2008 Benedikt Huber
License | BSD-style
Maintainer | benedikt.huber@gmail.com
Stability | experimental
Portability | ghc
Safe Haskell | None
Language | Haskell2010

Language.C.Data.Ident

Description

This module provides the notion of identifiers in C, speed up using hashing. Identifiers are associated optionally associated with a `NodeInfo`, i.e. with a unique `Name` and a source location (`Position`). The ordering relation on identifiers is based on the hash and does not follow the lexical order.

Synopsis

- data Ident = Ident String !Int NodeInfo
- data SUERef
  - = AnonymousRef Name
  - | NamedRef Ident
- isAnonymousRef :: SUERef -> Bool
- mkIdent :: Position -> String -> Name -> Ident
- builtinIdent :: String -> Ident
- internalIdent :: String -> Ident
- internalIdentAt :: Position -> String -> Ident
- isInternalIdent :: Ident -> Bool
- identToString :: Ident -> String
- sueRefToString :: SUERef -> String
- dumpIdent :: Ident -> String

# Documentation

data Ident Source #

C identifiers

Constructors

Ident String !Int NodeInfo |

#### Instances

Instances details

NFData Ident Source # |
Instance details Defined in Language.C.Data.Ident Methods rnf :: Ident -> () Source #
Data Ident Source # |

Instance details

Defined in Language.C.Data.Ident

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ident -> c Ident Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Ident Source #

toConstr :: Ident -> Constr Source #

dataTypeOf :: Ident -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Ident) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Ident) Source #

gmapT :: (forall b. Data b => b -> b) -> Ident -> Ident Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Ident -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Ident -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ident -> m Ident Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident Source #

Generic Ident Source # |

Instance details

Defined in Language.C.Data.Ident

Associated Types

type Rep Ident |

Instance details

Defined in Language.C.Data.Ident

type Rep Ident = D1 ('MetaData "Ident" "Language.C.Data.Ident" "language-c-0.10.1-IbTB6TwjqRkHrdbw3CJkeG" 'False) (C1 ('MetaCons "Ident" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeInfo))))

Methods

from :: Ident -> Rep Ident x Source #

to :: Rep Ident x -> Ident Source #

Show Ident Source # |
Instance details Defined in Language.C.Data.Ident Methods showsPrec :: Int -> Ident -> ShowS Source # show :: Ident -> String Source # showList :: [Ident] -> ShowS Source #
Eq Ident Source # |
Instance details Defined in Language.C.Data.Ident Methods (==) :: Ident -> Ident -> Bool Source # (/=) :: Ident -> Ident -> Bool Source #
Ord Ident Source # |
Instance details Defined in Language.C.Data.Ident Methods compare :: Ident -> Ident -> Ordering Source # (<) :: Ident -> Ident -> Bool Source # (<=) :: Ident -> Ident -> Bool Source # (>) :: Ident -> Ident -> Bool Source # (>=) :: Ident -> Ident -> Bool Source # max :: Ident -> Ident -> Ident Source # min :: Ident -> Ident -> Ident Source #
CNode Ident Source # |
Instance details Defined in Language.C.Data.Ident Methods nodeInfo :: Ident -> NodeInfo Source #
Pos Ident Source # |
Instance details Defined in Language.C.Data.Ident Methods posOf :: Ident -> Position Source #
Pretty Ident Source # |
Instance details Defined in Language.C.Analysis.Debug Methods pretty :: Ident -> Doc Source # prettyPrec :: Int -> Ident -> Doc Source #
type Rep Ident Source # |

Instance details

Defined in Language.C.Data.Ident

type Rep Ident = D1 ('MetaData "Ident" "Language.C.Data.Ident" "language-c-0.10.1-IbTB6TwjqRkHrdbw3CJkeG" 'False) (C1 ('MetaCons "Ident" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeInfo))))

data SUERef Source #

References uniquely determining a struct, union or enum type. Those are either identified by an string identifier, or by a unique name (anonymous types).

Constructors

AnonymousRef Name |
NamedRef Ident |

#### Instances

Instances details

NFData SUERef Source # |
Instance details Defined in Language.C.Data.Ident Methods rnf :: SUERef -> () Source #
Data SUERef Source # |

Instance details

Defined in Language.C.Data.Ident

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SUERef -> c SUERef Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SUERef Source #

toConstr :: SUERef -> Constr Source #

dataTypeOf :: SUERef -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SUERef) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SUERef) Source #

gmapT :: (forall b. Data b => b -> b) -> SUERef -> SUERef Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SUERef -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SUERef -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SUERef -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SUERef -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SUERef -> m SUERef Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SUERef -> m SUERef Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SUERef -> m SUERef Source #

Generic SUERef Source # |

Instance details

Defined in Language.C.Data.Ident

Associated Types

type Rep SUERef |

Instance details

Defined in Language.C.Data.Ident

type Rep SUERef = D1 ('MetaData "SUERef" "Language.C.Data.Ident" "language-c-0.10.1-IbTB6TwjqRkHrdbw3CJkeG" 'False) (C1 ('MetaCons "AnonymousRef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name)) :+: C1 ('MetaCons "NamedRef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident)))

Methods

from :: SUERef -> Rep SUERef x Source #

to :: Rep SUERef x -> SUERef Source #

Show SUERef Source # |
Instance details Defined in Language.C.Data.Ident Methods showsPrec :: Int -> SUERef -> ShowS Source # show :: SUERef -> String Source # showList :: [SUERef] -> ShowS Source #
Eq SUERef Source # |
Instance details Defined in Language.C.Data.Ident Methods (==) :: SUERef -> SUERef -> Bool Source # (/=) :: SUERef -> SUERef -> Bool Source #
Ord SUERef Source # |
Instance details Defined in Language.C.Data.Ident Methods compare :: SUERef -> SUERef -> Ordering Source # (<) :: SUERef -> SUERef -> Bool Source # (<=) :: SUERef -> SUERef -> Bool Source # (>) :: SUERef -> SUERef -> Bool Source # (>=) :: SUERef -> SUERef -> Bool Source # max :: SUERef -> SUERef -> SUERef Source # min :: SUERef -> SUERef -> SUERef Source #
Pretty SUERef Source # |
Instance details Defined in Language.C.Analysis.Debug Methods pretty :: SUERef -> Doc Source # prettyPrec :: Int -> SUERef -> Doc Source #
type Rep SUERef Source # |

Instance details

Defined in Language.C.Data.Ident

type Rep SUERef = D1 ('MetaData "SUERef" "Language.C.Data.Ident" "language-c-0.10.1-IbTB6TwjqRkHrdbw3CJkeG" 'False) (C1 ('MetaCons "AnonymousRef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name)) :+: C1 ('MetaCons "NamedRef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident)))

isAnonymousRef :: SUERef -> Bool Source #

Return true if the struct/union/enum reference is anonymous.

mkIdent :: Position -> String -> Name -> Ident Source #

build an identifier from a string.

- only minimal error checking, e.g., the characters of the identifier are not checked for being alphanumerical only; the correct lexis of the identifier should be ensured by the caller, e.g., the scanner.
- for reasons of simplicity the complete lexeme is hashed.

builtinIdent :: String -> Ident Source #

returns a builtin identifier (has builtin position and no unique name)

internalIdent :: String -> Ident Source #

returns an internal identifier (has internal position and no unique name)

internalIdentAt :: Position -> String -> Ident Source #

return an internal identifier with position info

isInternalIdent :: Ident -> Bool Source #

return `True` if the given identifier is internal

identToString :: Ident -> String Source #

string of an identifier

sueRefToString :: SUERef -> String Source #

string of a SUE ref (empty if anonymous)

dumpIdent :: Ident -> String Source #

dump the identifier string and its positions for debugging purposes