| Copyright | (c) 2008 Benedikt Huber |
|---|---|
| License | BSD-style |
| Maintainer | benedikt.huber@gmail.com |
| Stability | experimental |
| Portability | ghc |
| Safe Haskell | None |
| Language | Haskell98 |
Language.C.Data
Description
Common data types for Language.C: Identifiers, unique names, source code locations, ast node attributes and extensible errors.
Synopsis
- module Language.C.Data.InputStream
- data SUERef
- isAnonymousRef :: SUERef -> Bool
- sueRefToString :: SUERef -> String
- data Ident
- mkIdent :: Position -> String -> Name -> Ident
- identToString :: Ident -> String
- internalIdent :: String -> Ident
- isInternalIdent :: Ident -> Bool
- builtinIdent :: String -> Ident
- newtype Name = Name {
- nameId :: Int
- newNameSupply :: [Name]
- data Position
- posFile :: Position -> String
- posParent :: Position -> Maybe Position
- class Pos a where
- initPos :: FilePath -> Position
- nopos :: Position
- builtinPos :: Position
- internalPos :: Position
- isSourcePos :: Position -> Bool
- isBuiltinPos :: Position -> Bool
- isInternalPos :: Position -> Bool
- data NodeInfo
- class CNode a where
- fileOfNode :: CNode a => a -> Maybe FilePath
- posOfNode :: NodeInfo -> Position
- nameOfNode :: NodeInfo -> Maybe Name
- undefNode :: NodeInfo
- mkNodeInfoOnlyPos :: Position -> NodeInfo
- mkNodeInfo :: Position -> Name -> NodeInfo
- internalNode :: NodeInfo
- module Language.C.Data.Error
Input stream
module Language.C.Data.InputStream
Identifiers
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
| Eq SUERef Source # | |
| Data SUERef Source # | |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SUERef dataTypeOf :: SUERef -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SUERef) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SUERef) gmapT :: (forall b. Data b => b -> b) -> SUERef -> SUERef gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SUERef -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SUERef -> r gmapQ :: (forall d. Data d => d -> u) -> SUERef -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> SUERef -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> SUERef -> m SUERef gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SUERef -> m SUERef gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SUERef -> m SUERef | |
| Ord SUERef Source # | |
| Show SUERef Source # | |
| Generic SUERef Source # | |
| NFData SUERef Source # | |
Defined in Language.C.Data.Ident | |
| Pretty SUERef Source # | |
Defined in Language.C.Analysis.Debug | |
| type Rep SUERef Source # | |
Defined in Language.C.Data.Ident type Rep SUERef = D1 ('MetaData "SUERef" "Language.C.Data.Ident" "language-c-0.8.3-7uNvBzDEH0bJcSPq5Ubib6" '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.
sueRefToString :: SUERef -> String Source #
string of a SUE ref (empty if anonymous)
C identifiers
Instances
| Eq Ident Source # | |
| Data Ident Source # | |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Ident dataTypeOf :: Ident -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Ident) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Ident) gmapT :: (forall b. Data b => b -> b) -> Ident -> Ident gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r gmapQ :: (forall d. Data d => d -> u) -> Ident -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Ident -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ident -> m Ident gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident | |
| Ord Ident Source # | |
| Show Ident Source # | |
| Generic Ident Source # | |
| NFData Ident Source # | |
Defined in Language.C.Data.Ident | |
| Pos Ident Source # | |
| CNode Ident Source # | |
| Pretty Ident Source # | |
Defined in Language.C.Analysis.Debug | |
| type Rep Ident Source # | |
Defined in Language.C.Data.Ident type Rep Ident = D1 ('MetaData "Ident" "Language.C.Data.Ident" "language-c-0.8.3-7uNvBzDEH0bJcSPq5Ubib6" '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)))) | |
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.
identToString :: Ident -> String Source #
string of an identifier
internalIdent :: String -> Ident Source #
returns an internal identifier (has internal position and no unique name)
isInternalIdent :: Ident -> Bool Source #
return True if the given identifier is internal
builtinIdent :: String -> Ident Source #
returns a builtin identifier (has builtin position and no unique name)
Unqiue names
Name is a unique identifier
Instances
| Enum Name Source # | |
| Eq Name Source # | |
| Data Name Source # | |
Defined in Language.C.Data.Name Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Name -> c Name gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Name dataTypeOf :: Name -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Name) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name) gmapT :: (forall b. Data b => b -> b) -> Name -> Name gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r gmapQ :: (forall d. Data d => d -> u) -> Name -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Name -> m Name gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name | |
| Ord Name Source # | |
| Read Name Source # | |
Defined in Language.C.Data.Name | |
| Show Name Source # | |
| Ix Name Source # | |
| Generic Name Source # | |
| NFData Name Source # | |
Defined in Language.C.Data.Name | |
| type Rep Name Source # | |
Defined in Language.C.Data.Name type Rep Name = D1 ('MetaData "Name" "Language.C.Data.Name" "language-c-0.8.3-7uNvBzDEH0bJcSPq5Ubib6" 'True) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "nameId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) | |
newNameSupply :: [Name] Source #
return an infinite stream of Names starting with nameId 0
Source code positions
uniform representation of source file positions
Instances
| Eq Position Source # | |
| Data Position Source # | |
Defined in Language.C.Data.Position Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Position -> c Position gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Position toConstr :: Position -> Constr dataTypeOf :: Position -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Position) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position) gmapT :: (forall b. Data b => b -> b) -> Position -> Position gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r gmapQ :: (forall d. Data d => d -> u) -> Position -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Position -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Position -> m Position gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position | |
| Ord Position Source # | |
Defined in Language.C.Data.Position | |
| Show Position Source # | |
| Generic Position Source # | |
| NFData Position Source # | |
Defined in Language.C.Data.Position | |
| type Rep Position Source # | |
Defined in Language.C.Data.Position type Rep Position | |
class of type which aggregate a source code location
Instances
initPos :: FilePath -> Position Source #
initialize a Position to the start of the translation unit starting in the given file
builtinPos :: Position Source #
position attached to built-in objects
internalPos :: Position Source #
position used for internal errors
isSourcePos :: Position -> Bool Source #
returns True if the given position refers to an actual source file
isBuiltinPos :: Position -> Bool Source #
returns True if the given position refers to a builtin definition
isInternalPos :: Position -> Bool Source #
returns True if the given position is internal
Syntax tree nodes
Parsed entity attribute
Instances
| Eq NodeInfo Source # | |
| Data NodeInfo Source # | |
Defined in Language.C.Data.Node Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NodeInfo -> c NodeInfo gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NodeInfo toConstr :: NodeInfo -> Constr dataTypeOf :: NodeInfo -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NodeInfo) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NodeInfo) gmapT :: (forall b. Data b => b -> b) -> NodeInfo -> NodeInfo gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NodeInfo -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NodeInfo -> r gmapQ :: (forall d. Data d => d -> u) -> NodeInfo -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> NodeInfo -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> NodeInfo -> m NodeInfo gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NodeInfo -> m NodeInfo gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NodeInfo -> m NodeInfo | |
| Ord NodeInfo Source # | |
Defined in Language.C.Data.Node | |
| Show NodeInfo Source # | |
| Generic NodeInfo Source # | |
| NFData NodeInfo Source # | |
Defined in Language.C.Data.Node | |
| Pos NodeInfo Source # | |
| CNode NodeInfo Source # | |
| Pretty CStrLit Source # | |
Defined in Language.C.Pretty | |
| Pretty CConst Source # | |
Defined in Language.C.Pretty | |
| Pretty CBuiltin Source # | |
Defined in Language.C.Pretty | |
| Pretty CExpr Source # | |
Defined in Language.C.Pretty | |
| Pretty CAttr Source # | |
Defined in Language.C.Pretty | |
| Pretty CDesignator Source # | |
Defined in Language.C.Pretty | |
| Pretty CInit Source # | |
Defined in Language.C.Pretty | |
| Pretty CEnum Source # | |
Defined in Language.C.Pretty | |
| Pretty CStructUnion Source # | |
Defined in Language.C.Pretty | |
| Pretty CAlignSpec Source # | |
Defined in Language.C.Pretty | |
| Pretty CFunSpec Source # | |
Defined in Language.C.Pretty | |
| Pretty CTypeQual Source # | |
Defined in Language.C.Pretty | |
| Pretty CTypeSpec Source # | |
Defined in Language.C.Pretty | |
| Pretty CStorageSpec Source # | |
Defined in Language.C.Pretty | |
| Pretty CDeclSpec Source # | |
Defined in Language.C.Pretty | |
| Pretty CBlockItem Source # | |
Defined in Language.C.Pretty | |
| Pretty CAsmOperand Source # | |
Defined in Language.C.Pretty | |
| Pretty CAsmStmt Source # | |
Defined in Language.C.Pretty | |
| Pretty CStat Source # | |
Defined in Language.C.Pretty | |
| Pretty CArrSize Source # | |
Defined in Language.C.Pretty | |
| Pretty CDeclr Source # | |
Defined in Language.C.Pretty | |
| Pretty CDecl Source # | |
Defined in Language.C.Pretty | |
| Pretty CFunDef Source # | |
Defined in Language.C.Pretty | |
| Pretty CExtDecl Source # | |
Defined in Language.C.Pretty | |
| Pretty CTranslUnit Source # | |
Defined in Language.C.Pretty | |
| type Rep NodeInfo Source # | |
Defined in Language.C.Data.Node type Rep NodeInfo = D1 ('MetaData "NodeInfo" "Language.C.Data.Node" "language-c-0.8.3-7uNvBzDEH0bJcSPq5Ubib6" 'False) (C1 ('MetaCons "OnlyPos" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 PosLength)) :+: C1 ('MetaCons "NodeInfo" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 PosLength) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Name)))) | |
a class for convenient access to the attributes of an attributed object
Instances
fileOfNode :: CNode a => a -> Maybe FilePath Source #
nameOfNode :: NodeInfo -> Maybe Name Source #
mkNodeInfoOnlyPos :: Position -> NodeInfo Source #
| Given only a source position, create a new node attribute
mkNodeInfo :: Position -> Name -> NodeInfo Source #
Given a source position and a unique name, create a new attribute identifier
internalNode :: NodeInfo Source #
Deprecated: use undefNode instead
Extensible errors
module Language.C.Data.Error