-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Analysis and generation of C code -- -- Language C is a haskell library for the analysis and generation of C -- code. It features a complete, well tested parser and pretty printer -- for all of C99 and a large set of C11 and clang/GNU extensions. @package language-c @version 0.8.2 -- | This module manages name spaces. -- --
-- nameSpaceToList ns = (localDefInnermost ns ++ .. ++ localDefsOutermost ns) ++ globalDefs ns --nsMapToList :: (Ord k) => NameSpaceMap k a -> [(k, a)] globalNames :: (Ord k) => NameSpaceMap k v -> Map k v localNames :: (Ord k) => NameSpaceMap k v -> [[(k, v)]] hasLocalNames :: NameSpaceMap k v -> Bool -- | Add global definition -- -- (ns',oldDef) = defGlobal ns ident def adds a global -- definition ident := def to the namespace. It returns the -- modified namespace ns'. If the identifier is already declared -- in the global namespace, the definition is overwritten and the old -- definition oldDef is returned. defGlobal :: (Ord k) => NameSpaceMap k a -> k -> a -> (NameSpaceMap k a, Maybe a) -- | Enter new local scope -- -- ns' = enterNewScope ns creates and enters a new local scope. enterNewScope :: (Ord k) => NameSpaceMap k a -> NameSpaceMap k a -- | Leave innermost local scope -- -- (ns',defs) = leaveScope ns pops leaves the innermost local -- scope. and returns its definitions leaveScope :: (Ord k) => NameSpaceMap k a -> (NameSpaceMap k a, [(k, a)]) -- | Add local definition -- -- (ns',oldDef) = defLocal ns ident def adds the local -- definition ident := def to the innermost local scope, if -- there is a local scope, and to the global scope otherwise. It returns -- the modified name space ns' and the old binding of the -- identifier oldDef, which is overwritten. defLocal :: (Ord k) => NameSpaceMap k a -> k -> a -> (NameSpaceMap k a, Maybe a) -- | Search for a definition -- -- def = find ns ident returns the definition in some scope -- (inner to outer), if there is one. lookupName :: (Ord k) => NameSpaceMap k a -> k -> Maybe a lookupGlobal :: (Ord k) => NameSpaceMap k a -> k -> Maybe a lookupInnermostScope :: (Ord k) => NameSpaceMap k a -> k -> Maybe a -- | Merge two namespaces. If they disagree on the types of any variables, -- all bets are off. mergeNameSpace :: (Ord k) => NameSpaceMap k a -> NameSpaceMap k a -> NameSpaceMap k a -- | Compile time input abstraction for the parser, relying on ByteString. -- The String interface only supports Latin-1 since alex-3, as alex now -- requires byte based access to the input stream. module Language.C.Data.InputStream type InputStream = ByteString -- | read a file into an InputStream readInputStream :: FilePath -> IO InputStream -- | convert InputStream to String inputStreamToString :: InputStream -> String -- | convert a String to an InputStream inputStreamFromString :: String -> InputStream -- | (b,is') = takeByte is reads and removes the first byte -- b from the InputStream is takeByte :: InputStream -> (Word8, InputStream) -- | (c,is') = takeChar is reads and removes the first character -- c from the InputStream is takeChar :: InputStream -> (Char, InputStream) -- | return True if the given input stream is empty inputStreamEmpty :: InputStream -> Bool -- | str = takeChars n is returns the first n characters -- of the given input stream, without removing them takeChars :: Int -> InputStream -> [Char] -- | countLines returns the number of text lines in the given -- InputStream countLines :: InputStream -> Int -- | Unique Names with fast equality (newtype Int) module Language.C.Data.Name -- | Name is a unique identifier newtype Name Name :: Int -> Name [nameId] :: Name -> Int -- | return an infinite stream of Names starting with -- nameId 0 newNameSupply :: [Name] -- | get the infinite stream of unique names starting from the given -- integer namesStartingFrom :: Int -> [Name] instance GHC.Generics.Generic Language.C.Data.Name.Name instance Data.Data.Data Language.C.Data.Name.Name instance GHC.Arr.Ix Language.C.Data.Name.Name instance GHC.Classes.Ord Language.C.Data.Name.Name instance GHC.Classes.Eq Language.C.Data.Name.Name instance GHC.Read.Read Language.C.Data.Name.Name instance GHC.Show.Show Language.C.Data.Name.Name instance Control.DeepSeq.NFData Language.C.Data.Name.Name instance GHC.Enum.Enum Language.C.Data.Name.Name -- | Source code position module Language.C.Data.Position -- | uniform representation of source file positions data Position -- | position absoluteOffset fileName lineNumber columnNumber -- initializes a Position using the given arguments position :: Int -> String -> Int -> Int -> Maybe Position -> Position -- | Position and length of a token type PosLength = (Position, Int) posFile :: Position -> String -- | row (line) in the original file. Affected by #LINE pragmas. posRow :: Position -> Int -- | column in the preprocessed file. Inaccurate w.r.t. to the original -- file in the presence of preprocessor macros. posColumn :: Position -> Int -- | absolute offset in the preprocessed file posOffset :: Position -> Int posParent :: Position -> (Maybe Position) -- | initialize a Position to the start of the translation unit starting in -- the given file initPos :: FilePath -> Position -- | returns True if the given position refers to an actual source -- file isSourcePos :: Position -> Bool -- | no position (for unknown position information) nopos :: Position -- | returns True if the there is no position information -- available isNoPos :: Position -> Bool -- | position attached to built-in objects builtinPos :: Position -- | returns True if the given position refers to a builtin -- definition isBuiltinPos :: Position -> Bool -- | position used for internal errors internalPos :: Position -- | returns True if the given position is internal isInternalPos :: Position -> Bool -- | advance column incPos :: Position -> Int -> Position -- | advance to next line retPos :: Position -> Position -- | advance just the offset incOffset :: Position -> Int -> Position -- | class of type which aggregate a source code location class Pos a posOf :: Pos a => a -> Position instance GHC.Generics.Generic Language.C.Data.Position.FilePosition instance Data.Data.Data Language.C.Data.Position.FilePosition instance GHC.Classes.Ord Language.C.Data.Position.FilePosition instance GHC.Classes.Eq Language.C.Data.Position.FilePosition instance GHC.Generics.Generic Language.C.Data.Position.Position instance Data.Data.Data Language.C.Data.Position.Position instance GHC.Classes.Ord Language.C.Data.Position.Position instance GHC.Classes.Eq Language.C.Data.Position.Position instance Control.DeepSeq.NFData Language.C.Data.Position.FilePosition instance Control.DeepSeq.NFData Language.C.Data.Position.Position instance GHC.Show.Show Language.C.Data.Position.Position -- | source position and unqiue name module Language.C.Data.Node -- | Parsed entity attribute data NodeInfo OnlyPos :: Position -> {-# UNPACK #-} !PosLength -> NodeInfo NodeInfo :: Position -> {-# UNPACK #-} !PosLength -> !Name -> NodeInfo -- | create a node with neither name nor positional information undefNode :: NodeInfo -- | return True if the node carries neither name nor positional -- information isUndefNode :: NodeInfo -> Bool -- | | Given only a source position, create a new node attribute mkNodeInfoOnlyPos :: Position -> NodeInfo -- | Given a source position and the position and length of the last token, -- create a new node attribute mkNodeInfoPosLen :: Position -> PosLength -> NodeInfo -- | Given a source position and a unique name, create a new attribute -- identifier mkNodeInfo :: Position -> Name -> NodeInfo -- | Given a source position, the position and length of the last token and -- a unique name, create a new attribute identifier. Strict in mkNodeInfo' :: Position -> PosLength -> Name -> NodeInfo -- | Deprecated: use undefNode instead internalNode :: NodeInfo -- | a class for convenient access to the attributes of an attributed -- object class CNode a nodeInfo :: CNode a => a -> NodeInfo fileOfNode :: (CNode a) => a -> Maybe FilePath posOfNode :: NodeInfo -> Position nameOfNode :: NodeInfo -> Maybe Name -- | get the position and length of the last token getLastTokenPos :: NodeInfo -> PosLength -- | get the number of characters an AST node spans lengthOfNode :: NodeInfo -> Maybe Int -- | equality by name eqByName :: CNode a => a -> a -> Bool instance GHC.Generics.Generic Language.C.Data.Node.NodeInfo instance GHC.Classes.Ord Language.C.Data.Node.NodeInfo instance GHC.Classes.Eq Language.C.Data.Node.NodeInfo instance Data.Data.Data Language.C.Data.Node.NodeInfo instance Language.C.Data.Node.CNode Language.C.Data.Node.NodeInfo instance (Language.C.Data.Node.CNode a, Language.C.Data.Node.CNode b) => Language.C.Data.Node.CNode (Data.Either.Either a b) instance Control.DeepSeq.NFData Language.C.Data.Node.NodeInfo instance GHC.Show.Show Language.C.Data.Node.NodeInfo instance Language.C.Data.Position.Pos Language.C.Data.Node.NodeInfo -- | 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. module Language.C.Data.Ident -- | C identifiers data Ident Ident :: String -> {-# UNPACK #-} !Int -> NodeInfo -> Ident -- | References uniquely determining a struct, union or enum type. Those -- are either identified by an string identifier, or by a unique name -- (anonymous types). data SUERef AnonymousRef :: Name -> SUERef NamedRef :: Ident -> SUERef -- | Return true if the struct/union/enum reference is anonymous. isAnonymousRef :: SUERef -> Bool -- | build an identifier from a string. -- --
-- <fname>:<row>: (column <col>) [<err lvl>] -- >>> <line_1> -- <line_2> -- ... -- <line_n> --showErrorInfo :: String -> ErrorInfo -> String mkErrorInfo :: ErrorLevel -> String -> NodeInfo -> ErrorInfo -- | error raised if a operation requires an unsupported or not yet -- implemented feature. data UnsupportedFeature unsupportedFeature :: (Pos a) => String -> a -> UnsupportedFeature unsupportedFeature_ :: String -> UnsupportedFeature -- | unspecified error raised by the user (in case the user does not want -- to define her own error types). data UserError userErr :: String -> UserError -- | raise a fatal internal error; message may have multiple lines internalErr :: String -> a instance GHC.Classes.Ord Language.C.Data.Error.ErrorLevel instance GHC.Classes.Eq Language.C.Data.Error.ErrorLevel instance Language.C.Data.Error.Error Language.C.Data.Error.UserError instance GHC.Show.Show Language.C.Data.Error.UserError instance Language.C.Data.Error.Error Language.C.Data.Error.UnsupportedFeature instance GHC.Show.Show Language.C.Data.Error.UnsupportedFeature instance Language.C.Data.Error.Error Language.C.Data.Error.ErrorInfo instance GHC.Show.Show Language.C.Data.Error.CError instance Language.C.Data.Error.Error Language.C.Data.Error.CError instance GHC.Show.Show Language.C.Data.Error.ErrorInfo instance GHC.Show.Show Language.C.Data.Error.ErrorLevel -- | Common data types for Language.C: Identifiers, unique names, source -- code locations, ast node attributes and extensible errors. module Language.C.Data -- | References uniquely determining a struct, union or enum type. Those -- are either identified by an string identifier, or by a unique name -- (anonymous types). data SUERef AnonymousRef :: Name -> SUERef NamedRef :: Ident -> SUERef -- | Return true if the struct/union/enum reference is anonymous. isAnonymousRef :: SUERef -> Bool -- | string of a SUE ref (empty if anonymous) sueRefToString :: SUERef -> String -- | C identifiers data Ident -- | build an identifier from a string. -- --
-- typeof(expr) --CTypeOfExpr :: (CExpression a) -> a -> CTypeSpecifier a -- |
-- typeof(type) --CTypeOfType :: (CDeclaration a) -> a -> CTypeSpecifier a -- |
-- _Atomic(type) --CAtomicType :: (CDeclaration a) -> a -> CTypeSpecifier a data CAlignmentSpecifier a -- |
-- _Alignas(type) --CAlignAsType :: (CDeclaration a) -> a -> CAlignmentSpecifier a -- |
-- _Alignas(expr) --CAlignAsExpr :: (CExpression a) -> a -> CAlignmentSpecifier a data CTypeQualifier a CConstQual :: a -> CTypeQualifier a CVolatQual :: a -> CTypeQualifier a CRestrQual :: a -> CTypeQualifier a CAtomicQual :: a -> CTypeQualifier a CAttrQual :: (CAttribute a) -> CTypeQualifier a CNullableQual :: a -> CTypeQualifier a CNonnullQual :: a -> CTypeQualifier a data CAttribute a CAttr :: Ident -> [CExpression a] -> a -> CAttribute a -- | C declarator (K&R A8.5, C99 6.7.5) and abstract declarator -- (K&R A8.8, C99 6.7.6) -- -- A declarator declares a single object, function, or type. It is always -- associated with a declaration (CDecl), which specifies the -- declaration's type and the additional storage qualifiers and -- attributes, which apply to the declared object. -- -- A declarator is of the form CDeclr name? indirections asm-name? -- attrs _, where name is the name of the declared object -- (missing for abstract declarators), declquals is a set of -- additional declaration specifiers, asm-name is the optional -- assembler name and attributes is a set of attrs is a set of -- attribute annotations for the declared object. -- -- indirections is a set of pointer, array and function -- declarators, which modify the type of the declared object as described -- below. If the declaration specifies the non-derived type -- T, and we have indirections = [D1, D2, ..., Dn] than -- the declared object has type (D1 indirect (D2 -- indirect ... (Dn indirect T))), where -- --
-- int x; -- CDeclr "x" [] ---- --
-- const int * const * restrict x; -- CDeclr "x" [CPtrDeclr [restrict], CPtrDeclr [const]] ---- --
-- int* const f(); -- CDeclr "f" [CFunDeclr [],CPtrDeclr [const]] ---- --
-- int (* const f)(); ==> -- CDeclr "f" [CPtrDeclr [const], CFunDeclr []] --type CDeclr = CDeclarator NodeInfo -- | Derived declarators, see CDeclr -- -- Indirections are qualified using type-qualifiers and generic -- attributes, and additionally -- --
-- CUnknownSize isCompleteType --CNoArrSize :: Bool -> CArraySize a -- |
-- CArrSize isStatic expr --CArrSize :: Bool -> (CExpression a) -> CArraySize a -- | C initialization (K&R A8.7, C99 6.7.8) -- -- Initializers are either assignment expressions or initializer lists -- (surrounded in curly braces), whose elements are themselves -- initializers, paired with an optional list of designators. type CInit = CInitializer NodeInfo -- | Initializer List -- -- The members of an initializer list are of the form -- (designator-list,initializer). The designator-list -- specifies one member of the compound type which is initialized. It is -- allowed to be empty - in this case the initializer refers to the -- 'next' member of the compound type (see C99 6.7.8). -- -- Examples (simplified expressions and identifiers): -- --
-- -- int x[3][4] = { [0][3] = 4, [2] = 5, 8 };
-- -- corresponds to the assignments
-- -- x[0][3] = 4; x[2][0] = 5; x[2][1] = 8;
-- let init1 = ([CArrDesig 0, CArrDesig 3], CInitExpr 4)
-- init2 = ([CArrDesig 2] , CInitExpr 5)
-- init3 = ([] , CInitExpr 8)
-- in CInitList [init1, init2, init3]
--
--
--
-- -- struct { struct { int a[2]; int b[2]; int c[2]; } s; } x = { .s = { {2,3} , .c[0] = 1 } };
-- -- corresponds to the assignments
-- -- x.s.a[0] = 2; x.s.a[1] = 3; x.s.c[0] = 1;
-- let init_s_0 = CInitList [ ([], CInitExpr 2), ([], CInitExpr 3)]
-- init_s = CInitList [
-- ([], init_s_0),
-- ([CMemberDesig "c", CArrDesig 0], CInitExpr 1)
-- ]
-- in CInitList [(CMemberDesig "s", init_s)]
--
type CInitList = CInitializerList NodeInfo
-- | Designators
--
-- A designator specifies a member of an object, either an element or
-- range of an array, or the named member of a struct / union.
type CDesignator = CPartDesignator NodeInfo
data CInitializer a
-- | assignment expression
CInitExpr :: (CExpression a) -> a -> CInitializer a
-- | initialization list (see CInitList)
CInitList :: (CInitializerList a) -> a -> CInitializer a
type CInitializerList a = [([CPartDesignator a], CInitializer a)]
data CPartDesignator a
-- | array position designator
CArrDesig :: (CExpression a) -> a -> CPartDesignator a
-- | member designator
CMemberDesig :: Ident -> a -> CPartDesignator a
-- | array range designator CRangeDesig from to _ (GNU C)
CRangeDesig :: (CExpression a) -> (CExpression a) -> a -> CPartDesignator a
-- | C statement (K&R A9, C99 6.8)
type CStat = CStatement NodeInfo
-- | C99 Block items
--
-- Things that may appear in compound statements: either statements,
-- declarations or nested function definitions.
type CBlockItem = CCompoundBlockItem NodeInfo
-- | GNU Assembler statement
--
-- -- CAssemblyStatement type-qual? asm-expr out-ops in-ops clobbers _ ---- -- is an inline assembler statement. The only type-qualifier (if any) -- allowed is volatile. asm-expr is the actual assembler -- epxression (a string), out-ops and in-ops are the -- input and output operands of the statement. clobbers is a -- list of registers which are clobbered when executing the assembler -- statement type CAsmStmt = CAssemblyStatement NodeInfo -- | Assembler operand -- -- CAsmOperand argName? constraintExpr arg specifies an operand -- for an assembler statement. type CAsmOperand = CAssemblyOperand NodeInfo data CStatement a -- | An (attributed) label followed by a statement CLabel :: Ident -> (CStatement a) -> [CAttribute a] -> a -> CStatement a -- | A statement of the form case expr : stmt CCase :: (CExpression a) -> (CStatement a) -> a -> CStatement a -- | A case range of the form case lower ... upper : stmt CCases :: (CExpression a) -> (CExpression a) -> (CStatement a) -> a -> CStatement a -- | The default case default : stmt CDefault :: (CStatement a) -> a -> CStatement a -- | A simple statement, that is in C: evaluating an expression with -- side-effects and discarding the result. CExpr :: (Maybe (CExpression a)) -> a -> CStatement a -- | compound statement CCompound localLabels blockItems at CCompound :: [Ident] -> [CCompoundBlockItem a] -> a -> CStatement a -- | conditional statement CIf ifExpr thenStmt maybeElseStmt at CIf :: (CExpression a) -> (CStatement a) -> (Maybe (CStatement a)) -> a -> CStatement a -- | switch statement CSwitch selectorExpr switchStmt, where -- switchStmt usually includes case, break and -- default statements CSwitch :: (CExpression a) -> (CStatement a) -> a -> CStatement a -- | while or do-while statement CWhile guard stmt isDoWhile at CWhile :: (CExpression a) -> (CStatement a) -> Bool -> a -> CStatement a -- | for statement CFor init expr-2 expr-3 stmt, where -- init is either a declaration or initializing expression CFor :: (Either (Maybe (CExpression a)) (CDeclaration a)) -> (Maybe (CExpression a)) -> (Maybe (CExpression a)) -> (CStatement a) -> a -> CStatement a -- | goto statement CGoto label CGoto :: Ident -> a -> CStatement a -- | computed goto CGotoPtr labelExpr CGotoPtr :: (CExpression a) -> a -> CStatement a -- | continue statement CCont :: a -> CStatement a -- | break statement CBreak :: a -> CStatement a -- | return statement CReturn returnExpr CReturn :: (Maybe (CExpression a)) -> a -> CStatement a -- | assembly statement CAsm :: (CAssemblyStatement a) -> a -> CStatement a data CCompoundBlockItem a -- | A statement CBlockStmt :: (CStatement a) -> CCompoundBlockItem a -- | A local declaration CBlockDecl :: (CDeclaration a) -> CCompoundBlockItem a -- | A nested function (GNU C) CNestedFunDef :: (CFunctionDef a) -> CCompoundBlockItem a data CAssemblyStatement a CAsmStmt :: (Maybe (CTypeQualifier a)) -> (CStringLiteral a) -> [CAssemblyOperand a] -> [CAssemblyOperand a] -> [CStringLiteral a] -> a -> CAssemblyStatement a data CAssemblyOperand a CAsmOperand :: (Maybe Ident) -> (CStringLiteral a) -> (CExpression a) -> a -> CAssemblyOperand a -- | C expression (K&R A7) -- --
-- (expr, type) --CBuiltinVaArg :: (CExpression a) -> (CDeclaration a) -> a -> CBuiltinThing a -- |
-- (type, designator-list) --CBuiltinOffsetOf :: (CDeclaration a) -> [CPartDesignator a] -> a -> CBuiltinThing a -- |
-- (type,type) --CBuiltinTypesCompatible :: (CDeclaration a) -> (CDeclaration a) -> a -> CBuiltinThing a -- |
-- (expr, type) --CBuiltinConvertVector :: (CExpression a) -> (CDeclaration a) -> a -> CBuiltinThing a -- | C constant (K&R A2.5 & A7.2) type CConst = CConstant NodeInfo -- | Attributed string literals type CStrLit = CStringLiteral NodeInfo cstringOfLit :: CStringLiteral a -> CString -- | Lift a string literal to a C constant liftStrLit :: CStringLiteral a -> CConstant a data CConstant a CIntConst :: CInteger -> a -> CConstant a CCharConst :: CChar -> a -> CConstant a CFloatConst :: CFloat -> a -> CConstant a CStrConst :: CString -> a -> CConstant a data CStringLiteral a CStrLit :: CString -> a -> CStringLiteral a -- | All AST nodes are annotated. Inspired by the Annotated class of Niklas -- Broberg's haskell-src-exts package. In principle, we could have -- Copointed superclass instead of ann, for the price of another -- dependency. class (Functor ast) => Annotated ast -- | get the annotation of an AST node annotation :: Annotated ast => ast a -> a -- | change the annotation (non-recursively) of an AST node. Use fmap for -- recursively modifying the annotation. amap :: Annotated ast => (a -> a) -> ast a -> ast a instance GHC.Generics.Generic1 Language.C.Syntax.AST.CTranslationUnit instance GHC.Generics.Generic (Language.C.Syntax.AST.CTranslationUnit a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CTranslationUnit a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CTranslationUnit a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CExternalDeclaration instance GHC.Generics.Generic (Language.C.Syntax.AST.CExternalDeclaration a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CExternalDeclaration a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CExternalDeclaration a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CAssemblyOperand instance GHC.Generics.Generic (Language.C.Syntax.AST.CAssemblyOperand a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CAssemblyOperand a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CAssemblyOperand a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CAssemblyStatement instance GHC.Generics.Generic (Language.C.Syntax.AST.CAssemblyStatement a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CAssemblyStatement a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CAssemblyStatement a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CArraySize instance GHC.Generics.Generic (Language.C.Syntax.AST.CArraySize a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CArraySize a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CArraySize a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CDerivedDeclarator a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CDerivedDeclarator a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CDerivedDeclarator a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CDeclarator instance GHC.Generics.Generic (Language.C.Syntax.AST.CDeclarator a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CDeclarator a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CDeclarator a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CStructureUnion instance GHC.Generics.Generic (Language.C.Syntax.AST.CStructureUnion a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CStructureUnion a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CStructureUnion a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CEnumeration instance GHC.Generics.Generic (Language.C.Syntax.AST.CEnumeration a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CEnumeration a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CEnumeration a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CTypeSpecifier instance GHC.Generics.Generic (Language.C.Syntax.AST.CTypeSpecifier a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CTypeSpecifier a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CTypeSpecifier a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CTypeQualifier instance GHC.Generics.Generic (Language.C.Syntax.AST.CTypeQualifier a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CTypeQualifier a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CTypeQualifier a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CAlignmentSpecifier instance GHC.Generics.Generic (Language.C.Syntax.AST.CAlignmentSpecifier a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CAlignmentSpecifier a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CAlignmentSpecifier a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CDeclarationSpecifier instance GHC.Generics.Generic (Language.C.Syntax.AST.CDeclarationSpecifier a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CDeclarationSpecifier a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CDeclarationSpecifier a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CFunctionDef instance GHC.Generics.Generic (Language.C.Syntax.AST.CFunctionDef a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CFunctionDef a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CFunctionDef a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CCompoundBlockItem instance GHC.Generics.Generic (Language.C.Syntax.AST.CCompoundBlockItem a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CCompoundBlockItem a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CCompoundBlockItem a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CAttribute instance GHC.Generics.Generic (Language.C.Syntax.AST.CAttribute a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CAttribute a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CAttribute a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CStatement a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CStatement a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CStatement a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CInitializer a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CInitializer a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CInitializer a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CPartDesignator a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CPartDesignator a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CPartDesignator a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CBuiltinThing a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CBuiltinThing a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CBuiltinThing a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CExpression a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CExpression a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CExpression a) instance GHC.Generics.Generic (Language.C.Syntax.AST.CDeclaration a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CDeclaration a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CDeclaration a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CStringLiteral instance GHC.Generics.Generic (Language.C.Syntax.AST.CStringLiteral a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CStringLiteral a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CStringLiteral a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CConstant instance GHC.Generics.Generic (Language.C.Syntax.AST.CConstant a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CConstant a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CConstant a) instance GHC.Generics.Generic Language.C.Syntax.AST.CStructTag instance Data.Data.Data Language.C.Syntax.AST.CStructTag instance GHC.Classes.Eq Language.C.Syntax.AST.CStructTag instance GHC.Show.Show Language.C.Syntax.AST.CStructTag instance GHC.Generics.Generic1 Language.C.Syntax.AST.CFunctionSpecifier instance GHC.Generics.Generic (Language.C.Syntax.AST.CFunctionSpecifier a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CFunctionSpecifier a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CFunctionSpecifier a) instance GHC.Generics.Generic1 Language.C.Syntax.AST.CStorageSpecifier instance GHC.Generics.Generic (Language.C.Syntax.AST.CStorageSpecifier a) instance Data.Data.Data a => Data.Data.Data (Language.C.Syntax.AST.CStorageSpecifier a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Language.C.Syntax.AST.CStorageSpecifier a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.C.Syntax.AST.CStorageSpecifier a) instance GHC.Show.Show a => GHC.Show.Show (Language.C.Syntax.AST.CStorageSpecifier a) instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CTranslationUnit instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CExternalDeclaration instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CFunctionDef instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CDeclaration instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CDeclarator instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CDerivedDeclarator instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CStatement instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CAssemblyStatement instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CAssemblyOperand instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CCompoundBlockItem instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CDeclarationSpecifier instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CStorageSpecifier instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CTypeSpecifier instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CTypeQualifier instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CFunctionSpecifier instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CAlignmentSpecifier instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CStructureUnion instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CEnumeration instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CInitializer instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CPartDesignator instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CAttribute instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CExpression instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CBuiltinThing instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CConstant instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CStringLiteral instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CTranslationUnit a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CTranslationUnit t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CTranslationUnit t1) instance GHC.Base.Functor Language.C.Syntax.AST.CTranslationUnit instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CExternalDeclaration a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CExternalDeclaration t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CExternalDeclaration t1) instance GHC.Base.Functor Language.C.Syntax.AST.CExternalDeclaration instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CFunctionDef a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CDeclaration a) instance GHC.Base.Functor Language.C.Syntax.AST.CDeclaration instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CDeclarator a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CDerivedDeclarator a) instance GHC.Base.Functor Language.C.Syntax.AST.CDerivedDeclarator instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CArraySize a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CStatement a) instance GHC.Base.Functor Language.C.Syntax.AST.CStatement instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CAssemblyStatement a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CAssemblyOperand a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CCompoundBlockItem a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CDeclarationSpecifier a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CTypeSpecifier a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CTypeQualifier a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CAlignmentSpecifier a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CStructureUnion a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CEnumeration a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CInitializer a) instance GHC.Base.Functor Language.C.Syntax.AST.CInitializer instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CPartDesignator a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CAttribute a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CExpression a) instance GHC.Base.Functor Language.C.Syntax.AST.CExpression instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CBuiltinThing a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CFunctionDef t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CFunctionDef t1) instance GHC.Base.Functor Language.C.Syntax.AST.CFunctionDef instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CDeclaration t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CDeclaration t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CDeclarator t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CDeclarator t1) instance GHC.Base.Functor Language.C.Syntax.AST.CDeclarator instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CDerivedDeclarator t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CDerivedDeclarator t1) instance GHC.Base.Functor Language.C.Syntax.AST.CArraySize instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CStatement t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CStatement t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CAssemblyStatement t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CAssemblyStatement t1) instance GHC.Base.Functor Language.C.Syntax.AST.CAssemblyStatement instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CAssemblyOperand t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CAssemblyOperand t1) instance GHC.Base.Functor Language.C.Syntax.AST.CAssemblyOperand instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CCompoundBlockItem t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CCompoundBlockItem t1) instance GHC.Base.Functor Language.C.Syntax.AST.CCompoundBlockItem instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CDeclarationSpecifier t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CDeclarationSpecifier t1) instance GHC.Base.Functor Language.C.Syntax.AST.CDeclarationSpecifier instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CTypeSpecifier t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CTypeSpecifier t1) instance GHC.Base.Functor Language.C.Syntax.AST.CTypeSpecifier instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CTypeQualifier t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CTypeQualifier t1) instance GHC.Base.Functor Language.C.Syntax.AST.CTypeQualifier instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CAlignmentSpecifier t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CAlignmentSpecifier t1) instance GHC.Base.Functor Language.C.Syntax.AST.CAlignmentSpecifier instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CStructureUnion t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CStructureUnion t1) instance GHC.Base.Functor Language.C.Syntax.AST.CStructureUnion instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CEnumeration t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CEnumeration t1) instance GHC.Base.Functor Language.C.Syntax.AST.CEnumeration instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CInitializer t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CInitializer t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CPartDesignator t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CPartDesignator t1) instance GHC.Base.Functor Language.C.Syntax.AST.CPartDesignator instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CAttribute t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CAttribute t1) instance GHC.Base.Functor Language.C.Syntax.AST.CAttribute instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CExpression t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CExpression t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CBuiltinThing t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CBuiltinThing t1) instance GHC.Base.Functor Language.C.Syntax.AST.CBuiltinThing instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CStringLiteral a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CStringLiteral t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CStringLiteral t1) instance GHC.Base.Functor Language.C.Syntax.AST.CStringLiteral instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CConstant a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CConstant t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CConstant t1) instance GHC.Base.Functor Language.C.Syntax.AST.CConstant instance Control.DeepSeq.NFData Language.C.Syntax.AST.CStructTag instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CFunctionSpecifier a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CFunctionSpecifier t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CFunctionSpecifier t1) instance GHC.Base.Functor Language.C.Syntax.AST.CFunctionSpecifier instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Language.C.Syntax.AST.CStorageSpecifier a) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Node.CNode (Language.C.Syntax.AST.CStorageSpecifier t1) instance Language.C.Data.Node.CNode t1 => Language.C.Data.Position.Pos (Language.C.Syntax.AST.CStorageSpecifier t1) instance GHC.Base.Functor Language.C.Syntax.AST.CStorageSpecifier -- | Syntax of C files: The abstract syntax tree and constants. module Language.C.Syntax -- | This module provides a pretty printer for the parse tree (AST). module Language.C.Pretty -- | A class of types which can be pretty printed class Pretty p -- | pretty print the given value pretty :: Pretty p => p -> Doc -- | prettyPrec prec p pretty prints p assuming that the -- surrounding context has a precedence of prec prettyPrec :: Pretty p => Int -> p -> Doc -- | Pretty print the given tranlation unit, but replace declarations from -- header files with #include directives. -- -- The resulting file may not compile (because of missing -- #define directives and similar things), but is very useful -- for testing, as otherwise the pretty printed file will be cluttered -- with declarations from system headers. prettyUsingInclude :: CTranslUnit -> Doc instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CTranslUnit instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CExtDecl instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CFunDef instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CStat instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CAsmStmt instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CAsmOperand instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CBlockItem instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CDecl instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CDeclSpec instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CAlignSpec instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CStorageSpec instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CTypeSpec instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CTypeQual instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CFunSpec instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CStructUnion instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CStructTag instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CEnum instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CDeclr instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CArrSize instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CInit instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CDesignator instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CAttr instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CExpr instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CBuiltin instance Language.C.Pretty.Pretty Language.C.Syntax.Ops.CAssignOp instance Language.C.Pretty.Pretty Language.C.Syntax.Ops.CBinaryOp instance Language.C.Pretty.Pretty Language.C.Syntax.Ops.CUnaryOp instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CConst instance Language.C.Pretty.Pretty Language.C.Syntax.AST.CStrLit -- | Language.C parser module Language.C.Parser -- | parseC input initialPos parses the given preprocessed -- C-source input and returns the AST or a list of parse errors. parseC :: InputStream -> Position -> Either ParseError CTranslUnit data P a -- | execute the given parser on the supplied input stream. returns -- ParseError if the parser failed, and a pair of result and -- remaining name supply otherwise -- -- Synopsis: execParser parser inputStream initialPos -- predefinedTypedefs uniqNameSupply execParser :: P a -> InputStream -> Position -> [Ident] -> [Name] -> Either ParseError (a, [Name]) -- | run the given parser using a new name supply and builtin typedefs see -- execParser -- -- Synopsis: runParser parser inputStream initialPos execParser_ :: P a -> InputStream -> Position -> Either ParseError a builtinTypeNames :: [Ident] -- | translUnitP provides a parser for a complete C translation -- unit, i.e. a list of external declarations. translUnitP :: P CTranslUnit -- | extDeclP provides a parser for an external (file-scope) -- declaration extDeclP :: P CExtDecl -- | statementP provides a parser for C statements statementP :: P CStat -- | expressionP provides a parser for C expressions expressionP :: P CExpr newtype ParseError ParseError :: ([String], Position) -> ParseError -- | This module contains definitions for representing C translation units. -- In contrast to AST, the representation tries to express the -- semantics of of a translation unit. module Language.C.Analysis.SemRep -- | Composite type definitions (tags) data TagDef CompDef :: CompType -> TagDef EnumDef :: EnumType -> TagDef -- | return the type corresponding to a tag definition typeOfTagDef :: TagDef -> TypeName -- | All datatypes aggregating a declaration are instances of -- Declaration class Declaration n -- | get the name, type and declaration attributes of a declaration or -- definition getVarDecl :: Declaration n => n -> VarDecl -- | get the variable identifier of a declaration (only safe if the the -- declaration is known to have a name) declIdent :: (Declaration n) => n -> Ident -- | get the variable name of a Declaration declName :: (Declaration n) => n -> VarName -- | get the type of a Declaration declType :: (Declaration n) => n -> Type -- | get the declaration attributes of a Declaration declAttrs :: (Declaration n) => n -> DeclAttrs -- | identifiers, typedefs and enumeration constants (namespace sum) data IdentDecl -- | object or function declaration Declaration :: Decl -> IdentDecl -- | object definition ObjectDef :: ObjDef -> IdentDecl -- | function definition FunctionDef :: FunDef -> IdentDecl -- | definition of an enumerator EnumeratorDef :: Enumerator -> IdentDecl -- | textual description of the kind of an object objKindDescr :: IdentDecl -> String -- | splitIdentDecls includeAllDecls splits a map of object, -- function and enumerator declarations and definitions into one map -- holding declarations, and three maps for object definitions, -- enumerator definitions and function definitions. If -- includeAllDecls is True all declarations are present -- in the first map, otherwise only those where no corresponding -- definition is available. splitIdentDecls :: Bool -> Map Ident IdentDecl -> (Map Ident Decl, (Map Ident Enumerator, Map Ident ObjDef, Map Ident FunDef)) -- | global declaration/definition table returned by the analysis data GlobalDecls GlobalDecls :: Map Ident IdentDecl -> Map SUERef TagDef -> Map Ident TypeDef -> GlobalDecls [gObjs] :: GlobalDecls -> Map Ident IdentDecl [gTags] :: GlobalDecls -> Map SUERef TagDef [gTypeDefs] :: GlobalDecls -> Map Ident TypeDef -- | empty global declaration table emptyGlobalDecls :: GlobalDecls -- | filter global declarations filterGlobalDecls :: (DeclEvent -> Bool) -> GlobalDecls -> GlobalDecls -- | merge global declarations mergeGlobalDecls :: GlobalDecls -> GlobalDecls -> GlobalDecls -- | Declaration events -- -- Those events are reported to callbacks, which are executed during the -- traversal. data DeclEvent -- | file-scope struct/union/enum event TagEvent :: TagDef -> DeclEvent -- | file-scope declaration or definition DeclEvent :: IdentDecl -> DeclEvent -- | parameter declaration ParamEvent :: ParamDecl -> DeclEvent -- | local variable declaration or definition LocalEvent :: IdentDecl -> DeclEvent -- | a type definition TypeDefEvent :: TypeDef -> DeclEvent -- | assembler block AsmEvent :: AsmBlock -> DeclEvent -- | Declarations, which aren't definitions data Decl Decl :: VarDecl -> NodeInfo -> Decl -- | Object Definitions -- -- An object definition is a declaration together with an initializer. -- -- If the initializer is missing, it is a tentative definition, i.e. a -- definition which might be overriden later on. data ObjDef ObjDef :: VarDecl -> (Maybe Initializer) -> NodeInfo -> ObjDef -- | Returns True if the given object definition is tentative. isTentative :: ObjDef -> Bool -- | Function definitions -- -- A function definition is a declaration together with a statement (the -- function body). data FunDef FunDef :: VarDecl -> Stmt -> NodeInfo -> FunDef -- | Parameter declaration data ParamDecl ParamDecl :: VarDecl -> NodeInfo -> ParamDecl AbstractParamDecl :: VarDecl -> NodeInfo -> ParamDecl -- | Struct/Union member declaration data MemberDecl -- |
-- MemberDecl vardecl bitfieldsize node --MemberDecl :: VarDecl -> (Maybe Expr) -> NodeInfo -> MemberDecl -- |
-- AnonBitField typ size --AnonBitField :: Type -> Expr -> NodeInfo -> MemberDecl -- | typedef definitions. -- -- The identifier is a new name for the given type. data TypeDef TypeDef :: Ident -> Type -> Attributes -> NodeInfo -> TypeDef -- | return the idenitifier of a typedef identOfTypeDef :: TypeDef -> Ident -- | Generic variable declarations data VarDecl VarDecl :: VarName -> DeclAttrs -> Type -> VarDecl -- | Declaration attributes of the form DeclAttrs isInlineFunction -- storage linkage attrs -- -- They specify the storage and linkage of a declared object. data DeclAttrs -- |
-- DeclAttrs fspecs storage attrs --DeclAttrs :: FunctionAttrs -> Storage -> Attributes -> DeclAttrs isExtDecl :: (Declaration n) => n -> Bool data FunctionAttrs FunctionAttrs :: Bool -> Bool -> FunctionAttrs [isInline] :: FunctionAttrs -> Bool [isNoreturn] :: FunctionAttrs -> Bool -- | get the `function attributes' of a declaration functionAttrs :: (Declaration d) => d -> FunctionAttrs noFunctionAttrs :: FunctionAttrs -- | Storage duration and linkage of a variable data Storage -- | no storage NoStorage :: Storage -- | automatic storage (optional: register) Auto :: Register -> Storage -- | static storage, linkage spec and thread local specifier (gnu c) Static :: Linkage -> ThreadLocal -> Storage -- | function, either internal or external linkage FunLinkage :: Linkage -> Storage -- | get the Storage of a declaration declStorage :: (Declaration d) => d -> Storage type ThreadLocal = Bool type Register = Bool -- | Linkage: Either no linkage, internal to the translation unit or -- external data Linkage NoLinkage :: Linkage InternalLinkage :: Linkage ExternalLinkage :: Linkage -- | return True if the object has linkage hasLinkage :: Storage -> Bool -- | Get the linkage of a definition declLinkage :: (Declaration d) => d -> Linkage -- | types of C objects data Type -- | a non-derived type DirectType :: TypeName -> TypeQuals -> Attributes -> Type -- | pointer type PtrType :: Type -> TypeQuals -> Attributes -> Type -- | array type ArrayType :: Type -> ArraySize -> TypeQuals -> Attributes -> Type -- | function type FunctionType :: FunType -> Attributes -> Type -- | a defined type TypeDefType :: TypeDefRef -> TypeQuals -> Attributes -> Type -- | Function types are of the form FunType return-type params -- isVariadic. -- -- If the parameter types aren't yet known, the function has type -- FunTypeIncomplete type attrs. data FunType FunType :: Type -> [ParamDecl] -> Bool -> FunType FunTypeIncomplete :: Type -> FunType -- | An array type may either have unknown size or a specified array size, -- the latter either variable or constant. Furthermore, when used as a -- function parameters, the size may be qualified as static. In a -- function prototype, the size may be `Unspecified variable size' -- ([*]). data ArraySize -- |
-- UnknownArraySize is-starred --UnknownArraySize :: Bool -> ArraySize -- |
-- FixedSizeArray is-static size-expr --ArraySize :: Bool -> Expr -> ArraySize -- | typdef references If the actual type is known, it is attached for -- convenience data TypeDefRef TypeDefRef :: Ident -> Type -> NodeInfo -> TypeDefRef -- | normalized type representation data TypeName TyVoid :: TypeName TyIntegral :: IntType -> TypeName TyFloating :: FloatType -> TypeName TyComplex :: FloatType -> TypeName TyComp :: CompTypeRef -> TypeName TyEnum :: EnumTypeRef -> TypeName TyBuiltin :: BuiltinType -> TypeName -- | Builtin type (va_list, anything) data BuiltinType TyVaList :: BuiltinType TyAny :: BuiltinType -- | integral types (C99 6.7.2.2) data IntType TyBool :: IntType TyChar :: IntType TySChar :: IntType TyUChar :: IntType TyShort :: IntType TyUShort :: IntType TyInt :: IntType TyUInt :: IntType TyInt128 :: IntType TyUInt128 :: IntType TyLong :: IntType TyULong :: IntType TyLLong :: IntType TyULLong :: IntType -- | floating point type (C99 6.7.2.2) data FloatType TyFloat :: FloatType TyDouble :: FloatType TyLDouble :: FloatType TyFloatN :: Int -> Bool -> FloatType -- | accessor class : struct/union/enum names class HasSUERef a sueRef :: HasSUERef a => a -> SUERef -- | accessor class : composite type tags (struct or union) class HasCompTyKind a compTag :: HasCompTyKind a => a -> CompTyKind -- | composite type declarations data CompTypeRef CompTypeRef :: SUERef -> CompTyKind -> NodeInfo -> CompTypeRef -- | Composite type (struct or union). data CompType CompType :: SUERef -> CompTyKind -> [MemberDecl] -> Attributes -> NodeInfo -> CompType -- | return the type of a composite type definition typeOfCompDef :: CompType -> TypeName -- | a tag to determine wheter we refer to a struct or -- union, see CompType. data CompTyKind StructTag :: CompTyKind UnionTag :: CompTyKind data EnumTypeRef EnumTypeRef :: SUERef -> NodeInfo -> EnumTypeRef -- | Representation of C enumeration types data EnumType -- |
-- EnumType name enumeration-constants attrs node --EnumType :: SUERef -> [Enumerator] -> Attributes -> NodeInfo -> EnumType -- | return the type of an enum definition typeOfEnumDef :: EnumType -> TypeName -- | An Enumerator consists of an identifier, a constant expressions and -- the link to its type data Enumerator Enumerator :: Ident -> Expr -> EnumType -> NodeInfo -> Enumerator -- | Type qualifiers: constant, volatile and restrict data TypeQuals TypeQuals :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> TypeQuals [constant] :: TypeQuals -> Bool [volatile] :: TypeQuals -> Bool [restrict] :: TypeQuals -> Bool [atomic] :: TypeQuals -> Bool [nullable] :: TypeQuals -> Bool [nonnull] :: TypeQuals -> Bool -- | no type qualifiers noTypeQuals :: TypeQuals -- | merge (&&) two type qualifier sets mergeTypeQuals :: TypeQuals -> TypeQuals -> TypeQuals -- | VarName name assembler-name is a name of an declared object data VarName VarName :: Ident -> (Maybe AsmName) -> VarName NoName :: VarName identOfVarName :: VarName -> Ident isNoName :: VarName -> Bool -- | Assembler name (alias for CStrLit) type AsmName = CStrLit -- | attribute annotations -- -- Those are of the form Attr attribute-name -- attribute-parameters, and serve as generic properties of some -- syntax tree elements. -- -- Some examples: -- --
typeof(T)
-- int f(d,c,a,b)
-- char a,*b;
-- int c;
-- { }
--
--
-- is converted to
--
-- -- int f(int d, int c, char a, char* b) ---- -- TODO: This could be moved to syntax, as it operates on the AST only mergeOldStyle :: (MonadCError m) => NodeInfo -> [CDecl] -> [CDerivedDeclr] -> m [CDerivedDeclr] canonicalTypeSpec :: (MonadTrav m) => [CTypeSpec] -> m TypeSpecAnalysis data NumBaseType NoBaseType :: NumBaseType BaseChar :: NumBaseType BaseInt :: NumBaseType BaseInt128 :: NumBaseType BaseFloat :: NumBaseType BaseFloatN :: Int -> Bool -> NumBaseType BaseDouble :: NumBaseType data SignSpec NoSignSpec :: SignSpec Signed :: SignSpec Unsigned :: SignSpec data SizeMod NoSizeMod :: SizeMod ShortMod :: SizeMod LongMod :: SizeMod LongLongMod :: SizeMod data NumTypeSpec NumTypeSpec :: NumBaseType -> SignSpec -> SizeMod -> Bool -> NumTypeSpec [base] :: NumTypeSpec -> NumBaseType [signSpec] :: NumTypeSpec -> SignSpec [sizeMod] :: NumTypeSpec -> SizeMod [isComplex] :: NumTypeSpec -> Bool data TypeSpecAnalysis TSNone :: TypeSpecAnalysis TSVoid :: TypeSpecAnalysis TSBool :: TypeSpecAnalysis TSNum :: NumTypeSpec -> TypeSpecAnalysis TSTypeDef :: TypeDefRef -> TypeSpecAnalysis TSType :: Type -> TypeSpecAnalysis TSNonBasic :: CTypeSpec -> TypeSpecAnalysis canonicalStorageSpec :: (MonadCError m) => [CStorageSpec] -> m StorageSpec data StorageSpec NoStorageSpec :: StorageSpec AutoSpec :: StorageSpec RegSpec :: StorageSpec ThreadSpec :: StorageSpec StaticSpec :: Bool -> StorageSpec ExternSpec :: Bool -> StorageSpec hasThreadLocalSpec :: StorageSpec -> Bool isTypeDef :: [CDeclSpec] -> Bool data VarDeclInfo VarDeclInfo :: VarName -> FunctionAttrs -> StorageSpec -> Attributes -> Type -> NodeInfo -> VarDeclInfo -- | translate attribute annotations TODO: This is a unwrap -- and wrap stub tAttr :: (MonadCError m, MonadSymtab m) => CAttr -> m Attr -- | construct a name for a variable TODO: more or less bogus mkVarName :: (MonadCError m, MonadSymtab m) => NodeInfo -> Maybe Ident -> Maybe AsmName -> m VarName getOnlyDeclr :: (MonadCError m) => CDecl -> m CDeclr nameOfDecl :: (MonadCError m) => CDecl -> m Ident -- | analyse declarators analyseVarDecl :: (MonadTrav m) => Bool -> [CStorageSpec] -> [CAttr] -> [CTypeQual] -> TypeSpecAnalysis -> [CFunSpec] -> CDeclr -> [CDecl] -> Maybe CInit -> m VarDeclInfo analyseVarDecl' :: (MonadTrav m) => Bool -> [CDeclSpec] -> CDeclr -> [CDecl] -> Maybe CInit -> m VarDeclInfo instance GHC.Classes.Ord Language.C.Analysis.DeclAnalysis.SizeMod instance GHC.Classes.Eq Language.C.Analysis.DeclAnalysis.SizeMod instance GHC.Classes.Ord Language.C.Analysis.DeclAnalysis.SignSpec instance GHC.Classes.Eq Language.C.Analysis.DeclAnalysis.SignSpec instance GHC.Classes.Ord Language.C.Analysis.DeclAnalysis.NumBaseType instance GHC.Classes.Eq Language.C.Analysis.DeclAnalysis.NumBaseType instance GHC.Read.Read Language.C.Analysis.DeclAnalysis.StorageSpec instance GHC.Show.Show Language.C.Analysis.DeclAnalysis.StorageSpec instance GHC.Classes.Ord Language.C.Analysis.DeclAnalysis.StorageSpec instance GHC.Classes.Eq Language.C.Analysis.DeclAnalysis.StorageSpec module Language.C.Analysis.ConstEval data MachineDesc MachineDesc :: IntType -> Integer -> FloatType -> Integer -> BuiltinType -> Integer -> Integer -> Integer -> IntType -> Integer -> FloatType -> Integer -> BuiltinType -> Integer -> Integer -> Integer -> MachineDesc [iSize] :: MachineDesc -> IntType -> Integer [fSize] :: MachineDesc -> FloatType -> Integer [builtinSize] :: MachineDesc -> BuiltinType -> Integer [ptrSize] :: MachineDesc -> Integer [voidSize] :: MachineDesc -> Integer [iAlign] :: MachineDesc -> IntType -> Integer [fAlign] :: MachineDesc -> FloatType -> Integer [builtinAlign] :: MachineDesc -> BuiltinType -> Integer [ptrAlign] :: MachineDesc -> Integer [voidAlign] :: MachineDesc -> Integer intExpr :: (Pos n, MonadName m) => n -> Integer -> m CExpr sizeofType :: (MonadTrav m, CNode n) => MachineDesc -> n -> Type -> m Integer alignofType :: (MonadTrav m, CNode n) => MachineDesc -> n -> Type -> m Integer compSize :: MonadTrav m => MachineDesc -> CompTypeRef -> m Integer intOp :: CBinaryOp -> Integer -> Integer -> Integer intUnOp :: CUnaryOp -> Integer -> Maybe Integer withWordBytes :: Int -> Integer -> Integer boolValue :: CExpr -> Maybe Bool intValue :: CExpr -> Maybe Integer constEval :: (MonadTrav m) => MachineDesc -> Map Ident CExpr -> CExpr -> m CExpr module Language.C.Analysis.TypeCheck pType :: Type -> String typeErrorOnLeft :: (MonadCError m) => NodeInfo -> Either String a -> m a typeError :: MonadCError m => NodeInfo -> String -> m a notFound :: Ident -> Either String a checkScalar' :: MonadCError m => NodeInfo -> Type -> m () checkIntegral' :: MonadCError m => NodeInfo -> Type -> m () assignCompatible' :: MonadCError m => NodeInfo -> CAssignOp -> Type -> Type -> m () binopType' :: MonadCError m => NodeInfo -> CBinaryOp -> Type -> Type -> m Type conditionalType' :: MonadCError m => NodeInfo -> Type -> Type -> m Type checkScalar :: Type -> Either String () checkIntegral :: Type -> Either String () -- | Determine the type of a constant. constType :: (MonadCError m, MonadName m) => CConst -> m Type -- | Determine whether two types are compatible. compatible :: Type -> Type -> Either String () -- | Determine the composite type of two compatible types. compositeType :: Type -> Type -> Either String Type compositeSize :: ArraySize -> ArraySize -> Either String ArraySize sizeEqual :: CExpr -> CExpr -> Bool mergeAttrs :: Attributes -> Attributes -> Attributes compositeParamDecl :: ParamDecl -> ParamDecl -> Either String ParamDecl compositeParamDecl' :: (VarDecl -> NodeInfo -> ParamDecl) -> VarDecl -> VarDecl -> NodeInfo -> Either String ParamDecl compositeVarDecl :: VarDecl -> VarDecl -> Either String VarDecl compositeDeclAttrs :: DeclAttrs -> DeclAttrs -> DeclAttrs castCompatible :: Type -> Type -> Either String () -- | Determine whether two types are compatible in an assignment -- expression. assignCompatible :: CAssignOp -> Type -> Type -> Either String () -- | Determine the type of a binary operation. binopType :: CBinaryOp -> Type -> Type -> Either String Type -- | Determine the type of a conditional expression. conditionalType :: Type -> Type -> Either String Type derefType :: Type -> Either String Type varAddrType :: IdentDecl -> Either String Type -- | Get the type of field m of type t fieldType :: (MonadCError m, MonadSymtab m) => NodeInfo -> Ident -> Type -> m Type -- | Get all members of a struct, union, or enum, with their types. -- Collapse fields of anonymous members. tagMembers :: (MonadCError m, MonadSymtab m) => NodeInfo -> TagDef -> m [(Ident, Type)] -- | Expand an anonymous composite type into a list of member names and -- their associated types. expandAnonymous :: (MonadCError m, MonadSymtab m) => NodeInfo -> (VarName, Type) -> m [(Ident, Type)] lookupSUE :: (MonadCError m, MonadSymtab m) => NodeInfo -> SUERef -> m TagDef deepTypeAttrs :: (MonadCError m, MonadSymtab m) => Type -> m Attributes typeDefAttrs :: (MonadCError m, MonadSymtab m) => NodeInfo -> Ident -> m Attributes sueAttrs :: (MonadCError m, MonadSymtab m) => NodeInfo -> SUERef -> m Attributes module Language.C.Syntax.Utils getSubStmts :: CStat -> [CStat] mapSubStmts :: (CStat -> Bool) -> (CStat -> CStat) -> CStat -> CStat mapBlockItemStmts :: (CStat -> Bool) -> (CStat -> CStat) -> CBlockItem -> CBlockItem getLabels :: CStat -> [Ident] -- | Analyse the parse tree -- -- Traverses the AST, analyses declarations and invokes handlers. module Language.C.Analysis.AstAnalysis -- | Analyse the given AST -- -- analyseAST ast results in global declaration dictionaries. If -- you want to perform specific actions on declarations or definitions, -- you may provide callbacks in the MonadTrav m. -- -- Returns the set of global declarations and definitions which where -- successfully translated. It is the users responsibility to check -- whether any hard errors occurred (runTrav does this for you). analyseAST :: (MonadTrav m) => CTranslUnit -> m GlobalDecls -- | Analyse an top-level declaration analyseExt :: (MonadTrav m) => CExtDecl -> m () -- | Analyse a function definition analyseFunDef :: (MonadTrav m) => CFunDef -> m () -- | Analyse a declaration other than a function definition -- -- Note: static assertions are not analysed analyseDecl :: (MonadTrav m) => Bool -> CDecl -> m () analyseFunctionBody :: (MonadTrav m) => NodeInfo -> VarDecl -> CStat -> m Stmt defineParams :: MonadTrav m => NodeInfo -> VarDecl -> m () tExpr :: MonadTrav m => [StmtCtx] -> ExprSide -> CExpr -> m Type data ExprSide LValue :: ExprSide RValue :: ExprSide -- | Typecheck a statement, given a statement context. The type of a -- statement is usually void, but expression statements and -- blocks can sometimes have other types. tStmt :: MonadTrav m => [StmtCtx] -> CStat -> m Type data StmtCtx FunCtx :: VarDecl -> StmtCtx LoopCtx :: StmtCtx SwitchCtx :: StmtCtx tDesignator :: MonadTrav m => Type -> [CDesignator] -> m Type defaultMD :: MachineDesc instance GHC.Show.Show Language.C.Analysis.AstAnalysis.ExprSide instance GHC.Classes.Eq Language.C.Analysis.AstAnalysis.ExprSide -- | Analysis of the AST. -- -- Currently, we provide a monad for analysis and analyze declarations -- and types. Especially note that there is no direct support for -- analyzing function bodies and constant expressions. -- -- NOTE This is an experimental interface, and therefore the API -- will change in the future. -- -- DONE: -- --
-- Synopsis: parseCFile preprocesssor tmp-dir? cpp-opts file -- Example: parseCFile (newGCC "gcc") Nothing ["-I/usr/include/gtk-2.0"] my-gtk-exts.c --parseCFile :: (Preprocessor cpp) => cpp -> Maybe FilePath -> [String] -> FilePath -> IO (Either ParseError CTranslUnit) -- | parse an already preprocessed C file -- --
-- Synopsis: parseCFilePre file.i --parseCFilePre :: FilePath -> IO (Either ParseError CTranslUnit)