-- 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.6.1


-- | This module manages name spaces.
--   
--   <ul>
--   <li>A name space map associates identifiers with their
--   definition.</li>
--   <li>Each name space map is organized in a hierarchical way using the
--   notion of scopes. A name space map, at any moment, always has a global
--   scope and may have several local scopes. Definitions in inner scopes
--   hide definitions of the same identifier in outer scopes.</li>
--   </ul>
module Language.C.Analysis.NameSpaceMap

-- | <tt>NameSpaceMap a</tt> is a Map from identifiers to <tt>a</tt>, which
--   manages global and local name spaces.
data NameSpaceMap k v

-- | create a name space
nameSpaceMap :: (Ord k) => NameSpaceMap k v

-- | flatten a namespace into a assoc list
--   
--   <pre>
--   nameSpaceToList ns = (localDefInnermost ns ++ .. ++ localDefsOutermost ns) ++ globalDefs ns
--   </pre>
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
--   
--   <tt>(ns',oldDef) = defGlobal ns ident def</tt> adds a global
--   definition <tt>ident := def</tt> to the namespace. It returns the
--   modified namespace <tt>ns'</tt>. If the identifier is already declared
--   in the global namespace, the definition is overwritten and the old
--   definition <tt>oldDef</tt> is returned.
defGlobal :: (Ord k) => NameSpaceMap k a -> k -> a -> (NameSpaceMap k a, Maybe a)

-- | Enter new local scope
--   
--   <tt>ns' = enterNewScope ns</tt> creates and enters a new local scope.
enterNewScope :: (Ord k) => NameSpaceMap k a -> NameSpaceMap k a

-- | Leave innermost local scope
--   
--   <tt>(ns',defs) = leaveScope ns</tt> pops leaves the innermost local
--   scope. and returns its definitions
leaveScope :: (Ord k) => NameSpaceMap k a -> (NameSpaceMap k a, [(k, a)])

-- | Add local definition
--   
--   <tt>(ns',oldDef) = defLocal ns ident def</tt> adds the local
--   definition <tt>ident := def</tt> to the innermost local scope, if
--   there is a local scope, and to the global scope otherwise. It returns
--   the modified name space <tt>ns'</tt> and the old binding of the
--   identifier <tt>oldDef</tt>, which is overwritten.
defLocal :: (Ord k) => NameSpaceMap k a -> k -> a -> (NameSpaceMap k a, Maybe a)

-- | Search for a definition
--   
--   <tt>def = find ns ident</tt> 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


-- | Unary, binary and asssignment operators. Exported via AST.
module Language.C.Syntax.Ops

-- | C assignment operators (K&amp;R A7.17)
data CAssignOp
CAssignOp :: CAssignOp
CMulAssOp :: CAssignOp
CDivAssOp :: CAssignOp

-- | remainder and assignment
CRmdAssOp :: CAssignOp
CAddAssOp :: CAssignOp
CSubAssOp :: CAssignOp
CShlAssOp :: CAssignOp
CShrAssOp :: CAssignOp
CAndAssOp :: CAssignOp
CXorAssOp :: CAssignOp
COrAssOp :: CAssignOp
assignBinop :: CAssignOp -> CBinaryOp

-- | C binary operators (K&amp;R A7.6-15)
data CBinaryOp
CMulOp :: CBinaryOp
CDivOp :: CBinaryOp

-- | remainder of division
CRmdOp :: CBinaryOp
CAddOp :: CBinaryOp
CSubOp :: CBinaryOp

-- | shift left
CShlOp :: CBinaryOp

-- | shift right
CShrOp :: CBinaryOp

-- | less
CLeOp :: CBinaryOp

-- | greater
CGrOp :: CBinaryOp

-- | less or equal
CLeqOp :: CBinaryOp

-- | greater or equal
CGeqOp :: CBinaryOp

-- | equal
CEqOp :: CBinaryOp

-- | not equal
CNeqOp :: CBinaryOp

-- | bitwise and
CAndOp :: CBinaryOp

-- | exclusive bitwise or
CXorOp :: CBinaryOp

-- | inclusive bitwise or
COrOp :: CBinaryOp

-- | logical and
CLndOp :: CBinaryOp

-- | logical or
CLorOp :: CBinaryOp
isCmpOp :: CBinaryOp -> Bool
isPtrOp :: CBinaryOp -> Bool
isBitOp :: CBinaryOp -> Bool
isLogicOp :: CBinaryOp -> Bool

-- | C unary operator (K&amp;R A7.3-4)
data CUnaryOp

-- | prefix increment operator
CPreIncOp :: CUnaryOp

-- | prefix decrement operator
CPreDecOp :: CUnaryOp

-- | postfix increment operator
CPostIncOp :: CUnaryOp

-- | postfix decrement operator
CPostDecOp :: CUnaryOp

-- | address operator
CAdrOp :: CUnaryOp

-- | indirection operator
CIndOp :: CUnaryOp

-- | prefix plus
CPlusOp :: CUnaryOp

-- | prefix minus
CMinOp :: CUnaryOp

-- | one's complement
CCompOp :: CUnaryOp

-- | logical negation
CNegOp :: CUnaryOp
isEffectfulOp :: CUnaryOp -> Bool
instance Data.Data.Data Language.C.Syntax.Ops.CUnaryOp
instance GHC.Show.Show Language.C.Syntax.Ops.CUnaryOp
instance GHC.Classes.Ord Language.C.Syntax.Ops.CUnaryOp
instance GHC.Classes.Eq Language.C.Syntax.Ops.CUnaryOp
instance Data.Data.Data Language.C.Syntax.Ops.CBinaryOp
instance GHC.Show.Show Language.C.Syntax.Ops.CBinaryOp
instance GHC.Classes.Ord Language.C.Syntax.Ops.CBinaryOp
instance GHC.Classes.Eq Language.C.Syntax.Ops.CBinaryOp
instance Data.Data.Data Language.C.Syntax.Ops.CAssignOp
instance GHC.Show.Show Language.C.Syntax.Ops.CAssignOp
instance GHC.Classes.Ord Language.C.Syntax.Ops.CAssignOp
instance GHC.Classes.Eq Language.C.Syntax.Ops.CAssignOp


-- | This module provides support for representing, checking and exporting
--   c constants, i.e. integral, float, character and string constants.
module Language.C.Syntax.Constants
escapeChar :: Char -> String
unescapeChar :: String -> (Char, String)
unescapeString :: String -> String
newtype Flags f
Flags :: Integer -> Flags f
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

-- | construct a character constant from a haskell <a>Char</a> Use
--   <tt>cchar_w</tt> if you want a wide character constant.
cChar :: Char -> CChar

-- | construct a wide chararacter constant
cChar_w :: Char -> CChar

-- | create a multi-character character constant
cChars :: String -> Bool -> CChar

-- | C char constants (abstract)
data CChar
CChar :: !Char -> !Bool -> CChar
CChars :: [Char] -> !Bool -> CChar

-- | get the haskell representation of a char constant
getCChar :: CChar -> String

-- | get integer value of a C char constant undefined result for multi-char
--   char constants
getCCharAsInt :: CChar -> Integer

-- | return <tt>true</tt> if the character constant is <i>wide</i>.
isWideChar :: CChar -> Bool

-- | <tt>showCharConst c</tt> prepends _a_ String representing the C char
--   constant corresponding to <tt>c</tt>. If necessary uses octal or
--   hexadecimal escape sequences.
showCharConst :: Char -> ShowS

-- | datatype representing type flags for integers
data CIntFlag
FlagUnsigned :: CIntFlag
FlagLong :: CIntFlag
FlagLongLong :: CIntFlag
FlagImag :: CIntFlag

-- | datatype for memorizing the representation of an integer
data CIntRepr
DecRepr :: CIntRepr
HexRepr :: CIntRepr
OctalRepr :: CIntRepr

-- | construct a integer constant (without type flags) from a haskell
--   integer
cInteger :: Integer -> CInteger
data CInteger
CInteger :: !Integer -> !CIntRepr -> !(Flags CIntFlag) -> CInteger
getCInteger :: CInteger -> Integer
readCInteger :: CIntRepr -> String -> Either String CInteger
cFloat :: Float -> CFloat

-- | Floats (represented as strings)
data CFloat
CFloat :: !String -> CFloat
readCFloat :: String -> CFloat
cString :: String -> CString
cString_w :: String -> CString

-- | C String literals
data CString
CString :: String -> Bool -> CString
getCString :: CString -> String

-- | <tt>showStringLiteral s</tt> prepends a String representing the C
--   string literal corresponding to <tt>s</tt>. If necessary it uses octal
--   or hexadecimal escape sequences.
showStringLit :: String -> ShowS

-- | concatenate a list of C string literals
concatCStrings :: [CString] -> CString

-- | Clang dotted version literal
--   <a>https://clang.llvm.org/docs/AttributeReference.html#availability</a>
data ClangCVersion
ClangCVersion :: !String -> ClangCVersion
readClangCVersion :: String -> ClangCVersion
instance Data.Data.Data Language.C.Syntax.Constants.CInteger
instance GHC.Classes.Ord Language.C.Syntax.Constants.CInteger
instance GHC.Classes.Eq Language.C.Syntax.Constants.CInteger
instance Data.Data.Data f => Data.Data.Data (Language.C.Syntax.Constants.Flags f)
instance GHC.Classes.Ord (Language.C.Syntax.Constants.Flags f)
instance GHC.Classes.Eq (Language.C.Syntax.Constants.Flags f)
instance Data.Data.Data Language.C.Syntax.Constants.CString
instance GHC.Classes.Ord Language.C.Syntax.Constants.CString
instance GHC.Classes.Eq Language.C.Syntax.Constants.CString
instance Data.Data.Data Language.C.Syntax.Constants.ClangCVersion
instance GHC.Classes.Ord Language.C.Syntax.Constants.ClangCVersion
instance GHC.Classes.Eq Language.C.Syntax.Constants.ClangCVersion
instance Data.Data.Data Language.C.Syntax.Constants.CFloat
instance GHC.Classes.Ord Language.C.Syntax.Constants.CFloat
instance GHC.Classes.Eq Language.C.Syntax.Constants.CFloat
instance Data.Data.Data Language.C.Syntax.Constants.CIntFlag
instance GHC.Enum.Bounded Language.C.Syntax.Constants.CIntFlag
instance GHC.Enum.Enum Language.C.Syntax.Constants.CIntFlag
instance GHC.Classes.Ord Language.C.Syntax.Constants.CIntFlag
instance GHC.Classes.Eq Language.C.Syntax.Constants.CIntFlag
instance Data.Data.Data Language.C.Syntax.Constants.CIntRepr
instance GHC.Enum.Bounded Language.C.Syntax.Constants.CIntRepr
instance GHC.Enum.Enum Language.C.Syntax.Constants.CIntRepr
instance GHC.Classes.Ord Language.C.Syntax.Constants.CIntRepr
instance GHC.Classes.Eq Language.C.Syntax.Constants.CIntRepr
instance Data.Data.Data Language.C.Syntax.Constants.CChar
instance GHC.Classes.Ord Language.C.Syntax.Constants.CChar
instance GHC.Classes.Eq Language.C.Syntax.Constants.CChar
instance GHC.Show.Show Language.C.Syntax.Constants.CChar
instance GHC.Show.Show Language.C.Syntax.Constants.CIntFlag
instance GHC.Show.Show Language.C.Syntax.Constants.CInteger
instance GHC.Show.Show Language.C.Syntax.Constants.CFloat
instance GHC.Show.Show Language.C.Syntax.Constants.ClangCVersion
instance GHC.Show.Show Language.C.Syntax.Constants.CString


-- | Source code position
module Language.C.Data.Position

-- | uniform representation of source file positions
data Position

-- | <tt>position absoluteOffset fileName lineNumber columnNumber</tt>
--   initializes a <tt>Position</tt> using the given arguments
position :: Int -> String -> Int -> Int -> Position

-- | Position and length of a token
type PosLength = (Position, Int)

-- | source file
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

-- | initialize a Position to the start of the translation unit starting in
--   the given file
initPos :: FilePath -> Position

-- | returns <tt>True</tt> if the given position refers to an actual source
--   file
isSourcePos :: Position -> Bool

-- | no position (for unknown position information)
nopos :: Position

-- | returns <tt>True</tt> if the there is no position information
--   available
isNoPos :: Position -> Bool

-- | position attached to built-in objects
builtinPos :: Position

-- | returns <tt>True</tt> if the given position refers to a builtin
--   definition
isBuiltinPos :: Position -> Bool

-- | position used for internal errors
internalPos :: Position

-- | returns <tt>True</tt> if the given position is internal
isInternalPos :: Position -> Bool

-- | advance column
incPos :: Position -> Int -> Position

-- | advance to next line
retPos :: Position -> Position

-- | adjust position: change file and line number, reseting column to 1.
--   This is usually used for #LINE pragmas. The absolute offset is not
--   changed - this can be done by <tt>adjustPos newFile line . incPos
--   (length pragma)</tt>.
adjustPos :: FilePath -> Int -> 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 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 GHC.Show.Show Language.C.Data.Position.Position


-- | Unique Names with fast equality (newtype <a>Int</a>)
module Language.C.Data.Name

-- | Name is a unique identifier
newtype Name
Name :: Int -> Name
[nameId] :: Name -> Int

-- | return an infinite stream of <a>Name</a>s starting with
--   <tt>nameId</tt> 0
newNameSupply :: [Name]

-- | get the infinite stream of unique names starting from the given
--   integer
namesStartingFrom :: Int -> [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 GHC.Enum.Enum Language.C.Data.Name.Name


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

-- | <i>Deprecated: use undefNode instead</i>
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.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 GHC.Show.Show Language.C.Data.Node.NodeInfo
instance Language.C.Data.Position.Pos 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)


-- | This module provides the notion of identifiers in C, speed up using
--   hashing. Identifiers are associated optionally associated with a
--   <a>NodeInfo</a>, i.e. with a unique <a>Name</a> and a source location
--   (<a>Position</a>). 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.
--   
--   <ul>
--   <li>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.</li>
--   <li>for reasons of simplicity the complete lexeme is hashed.</li>
--   </ul>
mkIdent :: Position -> String -> Name -> Ident

-- | returns a <i>builtin</i> identifier (has builtin position and no
--   unique name)
builtinIdent :: String -> Ident

-- | returns an <i>internal</i> identifier (has internal position and no
--   unique name)
internalIdent :: String -> Ident

-- | return an <i>internal</i> identifier with position info
internalIdentAt :: Position -> String -> Ident

-- | return <tt>True</tt> if the given identifier is <i>internal</i>
isInternalIdent :: Ident -> Bool

-- | string of an identifier
identToString :: Ident -> String

-- | string of a SUE ref (empty if anonymous)
sueRefToString :: SUERef -> String

-- | dump the identifier string and its positions for debugging purposes
dumpIdent :: Ident -> String
instance GHC.Show.Show Language.C.Data.Ident.SUERef
instance GHC.Classes.Eq Language.C.Data.Ident.SUERef
instance GHC.Classes.Ord Language.C.Data.Ident.SUERef
instance Data.Data.Data Language.C.Data.Ident.SUERef
instance GHC.Show.Show Language.C.Data.Ident.Ident
instance Data.Data.Data Language.C.Data.Ident.Ident
instance GHC.Classes.Eq Language.C.Data.Ident.Ident
instance GHC.Classes.Ord Language.C.Data.Ident.Ident
instance Language.C.Data.Node.CNode Language.C.Data.Ident.Ident
instance Language.C.Data.Position.Pos Language.C.Data.Ident.Ident


-- | Abstract syntax of C source and header files.
--   
--   The tree structure is based on the grammar in Appendix A of K&amp;R.
--   The abstract syntax simplifies the concrete syntax by merging similar
--   concrete constructs into a single type of abstract tree structure:
--   declarations are merged with structure declarations, parameter
--   declarations and type names, and declarators are merged with abstract
--   declarators.
--   
--   With K&amp;R we refer to ``The C Programming Language'', second
--   edition, Brain W. Kernighan and Dennis M. Ritchie, Prentice Hall,
--   1988. The AST supports all of C99
--   <a>http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf</a> and
--   several GNU extensions
--   <a>http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html</a>.
module Language.C.Syntax.AST

-- | Complete C tranlsation unit (C99 6.9, K&amp;R A10)
--   
--   A complete C translation unit, for example representing a C header or
--   source file. It consists of a list of external (i.e. toplevel)
--   declarations.
type CTranslUnit = CTranslationUnit NodeInfo

-- | External C declaration (C99 6.9, K&amp;R A10)
--   
--   Either a toplevel declaration, function definition or external
--   assembler.
type CExtDecl = CExternalDeclaration NodeInfo
data CTranslationUnit a
CTranslUnit :: [CExternalDeclaration a] -> a -> CTranslationUnit a
data CExternalDeclaration a
CDeclExt :: (CDeclaration a) -> CExternalDeclaration a
CFDefExt :: (CFunctionDef a) -> CExternalDeclaration a
CAsmExt :: (CStringLiteral a) -> a -> CExternalDeclaration a

-- | C function definition (C99 6.9.1, K&amp;R A10.1)
--   
--   A function definition is of the form <tt>CFunDef specifiers declarator
--   decllist? stmt</tt>.
--   
--   <ul>
--   <li><tt>specifiers</tt> are the type and storage-class specifiers of
--   the function. The only storage-class specifiers allowed are
--   <i>extern</i> and <i>static</i>.</li>
--   <li>The <tt>declarator</tt> must be such that the declared identifier
--   has <i>function type</i>. The return type shall be void or an object
--   type other than array type.</li>
--   <li>The optional declaration list <tt>decllist</tt> is for old-style
--   function declarations.</li>
--   <li>The statement <tt>stmt</tt> is a compound statement.</li>
--   </ul>
type CFunDef = CFunctionDef NodeInfo

-- | C declarations (K&amp;R A8, C99 6.7), including structure
--   declarations, parameter declarations and type names.
--   
--   A declaration is of the form <tt>CDecl specifiers
--   init-declarator-list</tt>, where the form of the declarator list's
--   elements depends on the kind of declaration:
--   
--   1) Toplevel declarations (K&amp;R A8, C99 6.7 declaration)
--   
--   <ul>
--   <li>C99 requires that there is at least one specifier, though this is
--   merely a syntactic restriction</li>
--   <li>at most one storage class specifier is allowed per
--   declaration</li>
--   <li>the elements of the non-empty <tt>init-declarator-list</tt> are of
--   the form <tt>(Just declr, init?, Nothing)</tt>. The declarator
--   <tt>declr</tt> has to be present and non-abstract and the
--   initialization expression is optional.</li>
--   </ul>
--   
--   2) Structure declarations (K&amp;R A8.3, C99 6.7.2.1
--   struct-declaration)
--   
--   Those are the declarations of a structure's members.
--   
--   <ul>
--   <li>do not allow storage specifiers</li>
--   <li>in strict C99, the list of declarators has to be non-empty</li>
--   <li>the elements of <tt>init-declarator-list</tt> are either of the
--   form <tt>(Just declr, Nothing, size?)</tt>, representing a member with
--   optional bit-field size, or of the form <tt>(Nothing, Nothing, Just
--   size)</tt>, for unnamed bitfields. <tt>declr</tt> has to be
--   non-abstract.</li>
--   <li>no member of a structure shall have incomplete type</li>
--   </ul>
--   
--   3) Parameter declarations (K&amp;R A8.6.3, C99 6.7.5
--   parameter-declaration)
--   
--   <ul>
--   <li><tt>init-declarator-list</tt> must contain at most one triple of
--   the form <tt>(Just declr, Nothing, Nothing)</tt>, i.e. consist of a
--   single declarator, which is allowed to be abstract (i.e.
--   unnamed).</li>
--   </ul>
--   
--   4) Type names (A8.8, C99 6.7.6)
--   
--   <ul>
--   <li>do not allow storage specifiers</li>
--   <li><tt>init-declarator-list</tt> must contain at most one triple of
--   the form <tt>(Just declr, Nothing, Nothing)</tt>. where <tt>declr</tt>
--   is an abstract declarator (i.e. doesn't contain a declared
--   identifier)</li>
--   </ul>
type CDecl = CDeclaration NodeInfo

-- | C structure or union specifiers (K&amp;R A8.3, C99 6.7.2.1)
--   
--   <tt>CStruct tag identifier struct-decls c-attrs</tt> represents a
--   struct or union specifier (depending on <tt>tag</tt>).
--   
--   <ul>
--   <li>either <tt>identifier</tt> or the declaration list
--   <tt>struct-decls</tt> (or both) have to be present.</li>
--   </ul>
--   
--   Example: in <tt>struct foo x;</tt>, the identifier is present, in
--   <tt>struct { int y; } x</tt> the declaration list, and in <tt>struct
--   foo { int y; } x;</tt> both of them.
--   
--   <ul>
--   <li><tt>c-attrs</tt> is a list of <tt><b>attribute</b></tt>
--   annotations associated with the struct or union specifier</li>
--   </ul>
type CStructUnion = CStructureUnion NodeInfo

-- | C enumeration specifier (K&amp;R A8.4, C99 6.7.2.2)
--   
--   <tt>CEnum identifier enumerator-list attrs</tt> represent as enum
--   specifier
--   
--   <ul>
--   <li>Either the identifier or the enumerator-list (or both) have to be
--   present.</li>
--   <li>If <tt>enumerator-list</tt> is present, it has to be
--   non-empty.</li>
--   <li>The enumerator list is of the form <tt>(enumeration-constant,
--   enumeration-value?)</tt>, where the latter is an optional constant
--   integral expression.</li>
--   <li><tt>attrs</tt> is a list of <tt><b>attribute</b></tt> annotations
--   associated with the enumeration specifier</li>
--   </ul>
type CEnum = CEnumeration NodeInfo
data CFunctionDef a
CFunDef :: [CDeclarationSpecifier a] -> (CDeclarator a) -> [CDeclaration a] -> (CStatement a) -> a -> CFunctionDef a
data CDeclaration a
CDecl :: [CDeclarationSpecifier a] -> [(Maybe (CDeclarator a), Maybe (CInitializer a), Maybe (CExpression a))] -> a -> CDeclaration a
CStaticAssert :: (CExpression a) -> (CStringLiteral a) -> a -> CDeclaration a

-- | A tag to determine wheter we refer to a <tt>struct</tt> or
--   <tt>union</tt>, see <a>CStructUnion</a>.
data CStructTag
CStructTag :: CStructTag
CUnionTag :: CStructTag
data CStructureUnion a
CStruct :: CStructTag -> (Maybe Ident) -> (Maybe [CDeclaration a]) -> [CAttribute a] -> a -> CStructureUnion a
data CEnumeration a
CEnum :: (Maybe Ident) -> (Maybe [(Ident, Maybe (CExpression a))]) -> [CAttribute a] -> a -> CEnumeration a

-- | C declaration specifiers and qualifiers
--   
--   Declaration specifiers include at most one storage-class specifier
--   (C99 6.7.1), type specifiers (6.7.2) and type qualifiers (6.7.3).
type CDeclSpec = CDeclarationSpecifier NodeInfo

-- | Separate the declaration specifiers
--   
--   <tt><b>attribute</b></tt> of a declaration qualify declarations or
--   declarators (but not types), and are therefore separated as well.
partitionDeclSpecs :: [CDeclarationSpecifier a] -> ([CStorageSpecifier a], [CAttribute a], [CTypeQualifier a], [CTypeSpecifier a], [CFunctionSpecifier a], [CAlignmentSpecifier a])

-- | C storage class specifier (and typedefs) (K&amp;R A8.1, C99 6.7.1)
type CStorageSpec = CStorageSpecifier NodeInfo

-- | C type specifier (K&amp;R A8.2, C99 6.7.2)
--   
--   Type specifiers are either basic types such as <tt>char</tt> or
--   <tt>int</tt>, <tt>struct</tt>, <tt>union</tt> or <tt>enum</tt>
--   specifiers or typedef names.
--   
--   As a GNU extension, a <tt>typeof</tt> expression also is a type
--   specifier.
type CTypeSpec = CTypeSpecifier NodeInfo

-- | returns <tt>True</tt> if the given typespec is a struct, union or enum
--   <i>definition</i>
isSUEDef :: CTypeSpecifier a -> Bool

-- | C type qualifiers (K&amp;R A8.2, C99 6.7.3) and attributes.
--   
--   <tt>const</tt>, <tt>volatile</tt> and <tt>restrict</tt> type
--   qualifiers Additionally, <tt><b>attribute</b></tt> annotations for
--   declarations and declarators, and function specifiers
type CTypeQual = CTypeQualifier NodeInfo

-- | C function specifiers (C99 6.7.4)
--   
--   function specifiers <tt>inline</tt> and <tt>_Noreturn</tt>
type CFunSpec = CFunctionSpecifier NodeInfo

-- | C alignment specifiers (C99 6.7.5)
type CAlignSpec = CAlignmentSpecifier NodeInfo

-- | <tt><b>attribute</b></tt> annotations
--   
--   Those are of the form <tt>CAttr attribute-name
--   attribute-parameters</tt>, and serve as generic properties of some
--   syntax tree elements.
type CAttr = CAttribute NodeInfo
data CFunctionSpecifier a
CInlineQual :: a -> CFunctionSpecifier a
CNoreturnQual :: a -> CFunctionSpecifier a
data CDeclarationSpecifier a

-- | storage-class specifier or typedef
CStorageSpec :: (CStorageSpecifier a) -> CDeclarationSpecifier a

-- | type name
CTypeSpec :: (CTypeSpecifier a) -> CDeclarationSpecifier a

-- | type qualifier
CTypeQual :: (CTypeQualifier a) -> CDeclarationSpecifier a

-- | function specifier
CFunSpec :: (CFunctionSpecifier a) -> CDeclarationSpecifier a

-- | alignment specifier
CAlignSpec :: (CAlignmentSpecifier a) -> CDeclarationSpecifier a
data CStorageSpecifier a

-- | auto
CAuto :: a -> CStorageSpecifier a

-- | register
CRegister :: a -> CStorageSpecifier a

-- | static
CStatic :: a -> CStorageSpecifier a

-- | extern
CExtern :: a -> CStorageSpecifier a

-- | typedef
CTypedef :: a -> CStorageSpecifier a

-- | C11/GNUC thread local storage
CThread :: a -> CStorageSpecifier a
data CTypeSpecifier a
CVoidType :: a -> CTypeSpecifier a
CCharType :: a -> CTypeSpecifier a
CShortType :: a -> CTypeSpecifier a
CIntType :: a -> CTypeSpecifier a
CLongType :: a -> CTypeSpecifier a
CFloatType :: a -> CTypeSpecifier a
CFloat128Type :: a -> CTypeSpecifier a
CDoubleType :: a -> CTypeSpecifier a
CSignedType :: a -> CTypeSpecifier a
CUnsigType :: a -> CTypeSpecifier a
CBoolType :: a -> CTypeSpecifier a
CComplexType :: a -> CTypeSpecifier a
CInt128Type :: a -> CTypeSpecifier a

-- | Struct or Union specifier
CSUType :: (CStructureUnion a) -> a -> CTypeSpecifier a

-- | Enumeration specifier
CEnumType :: (CEnumeration a) -> a -> CTypeSpecifier a

-- | Typedef name
CTypeDef :: Ident -> a -> CTypeSpecifier a

-- | <pre>
--   typeof(expr)
--   </pre>
CTypeOfExpr :: (CExpression a) -> a -> CTypeSpecifier a

-- | <pre>
--   typeof(type)
--   </pre>
CTypeOfType :: (CDeclaration a) -> a -> CTypeSpecifier a

-- | <pre>
--   _Atomic(type)
--   </pre>
CAtomicType :: (CDeclaration a) -> a -> CTypeSpecifier a
data CAlignmentSpecifier a

-- | <pre>
--   _Alignas(type)
--   </pre>
CAlignAsType :: (CDeclaration a) -> a -> CAlignmentSpecifier a

-- | <pre>
--   _Alignas(expr)
--   </pre>
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&amp;R A8.5, C99 6.7.5) and abstract declarator
--   (K&amp;R A8.8, C99 6.7.6)
--   
--   A declarator declares a single object, function, or type. It is always
--   associated with a declaration (<a>CDecl</a>), 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 <tt>CDeclr name? indirections asm-name?
--   attrs _</tt>, where <tt>name</tt> is the name of the declared object
--   (missing for abstract declarators), <tt>declquals</tt> is a set of
--   additional declaration specifiers, <tt>asm-name</tt> is the optional
--   assembler name and attributes is a set of attrs is a set of
--   <tt><b>attribute</b></tt> annotations for the declared object.
--   
--   <tt>indirections</tt> is a set of pointer, array and function
--   declarators, which modify the type of the declared object as described
--   below. If the <i>declaration</i> specifies the non-derived type
--   <tt>T</tt>, and we have <tt>indirections = [D1, D2, ..., Dn]</tt> than
--   the declared object has type <tt>(D1 <tt>indirect</tt> (D2
--   <tt>indirect</tt> ... (Dn <tt>indirect</tt> T)))</tt>, where
--   
--   <ul>
--   <li><tt>(CPtrDeclr attrs) <tt>indirect</tt> T</tt> is <i>attributed
--   pointer to T</i></li>
--   <li><tt>(CFunDeclr attrs) <tt>indirect</tt> T</tt> is <i>attributed
--   function returning T</i></li>
--   <li><tt>(CArrayDeclr attrs) <tt>indirect</tt> T</tt> is <i>attributed
--   array of elemements of type T</i></li>
--   </ul>
--   
--   Examples (simplified attributes):
--   
--   <ul>
--   <li><i>x</i> is an int</li>
--   </ul>
--   
--   <pre>
--   int x;
--   CDeclr "x" []
--   </pre>
--   
--   <ul>
--   <li><i>x</i> is a restrict pointer to a const pointer to int</li>
--   </ul>
--   
--   <pre>
--   const int * const * restrict x;
--   CDeclr "x" [CPtrDeclr [restrict], CPtrDeclr [const]]
--   </pre>
--   
--   <ul>
--   <li><i>f</i> is an function return a constant pointer to int</li>
--   </ul>
--   
--   <pre>
--   int* const f();
--   CDeclr "f" [CFunDeclr [],CPtrDeclr [const]]
--   </pre>
--   
--   <ul>
--   <li><i>f</i> is a constant pointer to a function returning int</li>
--   </ul>
--   
--   <pre>
--   int (* const f)(); ==&gt;
--   CDeclr "f" [CPtrDeclr [const], CFunDeclr []]
--   </pre>
type CDeclr = CDeclarator NodeInfo

-- | Derived declarators, see <a>CDeclr</a>
--   
--   Indirections are qualified using type-qualifiers and generic
--   attributes, and additionally
--   
--   <ul>
--   <li>The size of an array is either a constant expression, variable
--   length (<a>*</a>) or missing; in the last case, the type of the array
--   is incomplete. The qualifier static is allowed for function arguments
--   only, indicating that the supplied argument is an array of at least
--   the given size.</li>
--   <li>New style parameter lists have the form <tt>Right (declarations,
--   isVariadic)</tt>, old style parameter lists have the form <tt>Left
--   (parameter-names)</tt></li>
--   </ul>
type CDerivedDeclr = CDerivedDeclarator NodeInfo

-- | Size of an array
type CArrSize = CArraySize NodeInfo
data CDeclarator a
CDeclr :: (Maybe Ident) -> [CDerivedDeclarator a] -> (Maybe (CStringLiteral a)) -> [CAttribute a] -> a -> CDeclarator a
data CDerivedDeclarator a

-- | Pointer declarator <tt>CPtrDeclr tyquals declr</tt>
CPtrDeclr :: [CTypeQualifier a] -> a -> CDerivedDeclarator a

-- | Array declarator <tt>CArrDeclr declr tyquals size-expr?</tt>
CArrDeclr :: [CTypeQualifier a] -> (CArraySize a) -> a -> CDerivedDeclarator a

-- | Function declarator <tt>CFunDeclr declr (old-style-params |
--   new-style-params) c-attrs</tt>
CFunDeclr :: (Either [Ident] ([CDeclaration a], Bool)) -> [CAttribute a] -> a -> CDerivedDeclarator a
data CArraySize a

-- | <pre>
--   CUnknownSize isCompleteType
--   </pre>
CNoArrSize :: Bool -> CArraySize a

-- | <pre>
--   CArrSize isStatic expr
--   </pre>
CArrSize :: Bool -> (CExpression a) -> CArraySize a

-- | C initialization (K&amp;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
--   <tt>(designator-list,initializer)</tt>. The <tt>designator-list</tt>
--   specifies one member of the compound type which is initialized. It is
--   allowed to be empty - in this case the initializer refers to the
--   '<tt>next'</tt> member of the compound type (see C99 6.7.8).
--   
--   Examples (simplified expressions and identifiers):
--   
--   <pre>
--   -- 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]
--   </pre>
--   
--   <pre>
--   -- 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)]
--   </pre>
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 <a>CInitList</a>)
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 <tt>CRangeDesig from to _</tt> (GNU C)
CRangeDesig :: (CExpression a) -> (CExpression a) -> a -> CPartDesignator a

-- | C statement (K&amp;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
--   
--   <pre>
--   CAssemblyStatement type-qual? asm-expr out-ops in-ops clobbers _
--   </pre>
--   
--   is an inline assembler statement. The only type-qualifier (if any)
--   allowed is <i>volatile</i>. <tt>asm-expr</tt> is the actual assembler
--   epxression (a string), <tt>out-ops</tt> and <tt>in-ops</tt> are the
--   input and output operands of the statement. <tt>clobbers</tt> is a
--   list of registers which are clobbered when executing the assembler
--   statement
type CAsmStmt = CAssemblyStatement NodeInfo

-- | Assembler operand
--   
--   <tt>CAsmOperand argName? constraintExpr arg</tt> 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 <tt>case expr : stmt</tt>
CCase :: (CExpression a) -> (CStatement a) -> a -> CStatement a

-- | A case range of the form <tt>case lower ... upper : stmt</tt>
CCases :: (CExpression a) -> (CExpression a) -> (CStatement a) -> a -> CStatement a

-- | The default case <tt>default : stmt</tt>
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 <tt>CCompound localLabels blockItems at</tt>
CCompound :: [Ident] -> [CCompoundBlockItem a] -> a -> CStatement a

-- | conditional statement <tt>CIf ifExpr thenStmt maybeElseStmt at</tt>
CIf :: (CExpression a) -> (CStatement a) -> (Maybe (CStatement a)) -> a -> CStatement a

-- | switch statement <tt>CSwitch selectorExpr switchStmt</tt>, where
--   <tt>switchStmt</tt> usually includes <i>case</i>, <i>break</i> and
--   <i>default</i> statements
CSwitch :: (CExpression a) -> (CStatement a) -> a -> CStatement a

-- | while or do-while statement <tt>CWhile guard stmt isDoWhile at</tt>
CWhile :: (CExpression a) -> (CStatement a) -> Bool -> a -> CStatement a

-- | for statement <tt>CFor init expr-2 expr-3 stmt</tt>, where
--   <tt>init</tt> 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 <tt>CGoto label</tt>
CGoto :: Ident -> a -> CStatement a

-- | computed goto <tt>CGotoPtr labelExpr</tt>
CGotoPtr :: (CExpression a) -> a -> CStatement a

-- | continue statement
CCont :: a -> CStatement a

-- | break statement
CBreak :: a -> CStatement a

-- | return statement <tt>CReturn returnExpr</tt>
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&amp;R A7)
--   
--   <ul>
--   <li>these can be arbitrary expression, as the argument of
--   <tt>sizeof</tt> can be arbitrary, even if appearing in a constant
--   expression</li>
--   <li>GNU C extensions: <tt>alignof</tt>, <tt>__real</tt>,
--   <tt>__imag</tt>, <tt>({ stmt-expr })</tt>, <tt>&amp;&amp; label</tt>
--   and built-ins</li>
--   </ul>
type CExpr = CExpression NodeInfo
data CExpression a
CComma :: [CExpression a] -> a -> CExpression a
CAssign :: CAssignOp -> (CExpression a) -> (CExpression a) -> a -> CExpression a
CCond :: (CExpression a) -> (Maybe (CExpression a)) -> (CExpression a) -> a -> CExpression a
CBinary :: CBinaryOp -> (CExpression a) -> (CExpression a) -> a -> CExpression a
CCast :: (CDeclaration a) -> (CExpression a) -> a -> CExpression a
CUnary :: CUnaryOp -> (CExpression a) -> a -> CExpression a
CSizeofExpr :: (CExpression a) -> a -> CExpression a
CSizeofType :: (CDeclaration a) -> a -> CExpression a
CAlignofExpr :: (CExpression a) -> a -> CExpression a
CAlignofType :: (CDeclaration a) -> a -> CExpression a
CComplexReal :: (CExpression a) -> a -> CExpression a
CComplexImag :: (CExpression a) -> a -> CExpression a
CIndex :: (CExpression a) -> (CExpression a) -> a -> CExpression a
CCall :: (CExpression a) -> [CExpression a] -> a -> CExpression a
CMember :: (CExpression a) -> Ident -> Bool -> a -> CExpression a
CVar :: Ident -> a -> CExpression a

-- | integer, character, floating point and string constants
CConst :: (CConstant a) -> CExpression a

-- | C99 compound literal
CCompoundLit :: (CDeclaration a) -> (CInitializerList a) -> a -> CExpression a

-- | C11 generic selection
CGenericSelection :: (CExpression a) -> [(Maybe (CDeclaration a), CExpression a)] -> a -> CExpression a

-- | GNU C compound statement as expr
CStatExpr :: (CStatement a) -> a -> CExpression a

-- | GNU C address of label
CLabAddrExpr :: Ident -> a -> CExpression a

-- | builtin expressions, see <a>CBuiltin</a>
CBuiltinExpr :: (CBuiltinThing a) -> CExpression a

-- | C assignment operators (K&amp;R A7.17)
data CAssignOp
CAssignOp :: CAssignOp
CMulAssOp :: CAssignOp
CDivAssOp :: CAssignOp

-- | remainder and assignment
CRmdAssOp :: CAssignOp
CAddAssOp :: CAssignOp
CSubAssOp :: CAssignOp
CShlAssOp :: CAssignOp
CShrAssOp :: CAssignOp
CAndAssOp :: CAssignOp
CXorAssOp :: CAssignOp
COrAssOp :: CAssignOp

-- | C binary operators (K&amp;R A7.6-15)
data CBinaryOp
CMulOp :: CBinaryOp
CDivOp :: CBinaryOp

-- | remainder of division
CRmdOp :: CBinaryOp
CAddOp :: CBinaryOp
CSubOp :: CBinaryOp

-- | shift left
CShlOp :: CBinaryOp

-- | shift right
CShrOp :: CBinaryOp

-- | less
CLeOp :: CBinaryOp

-- | greater
CGrOp :: CBinaryOp

-- | less or equal
CLeqOp :: CBinaryOp

-- | greater or equal
CGeqOp :: CBinaryOp

-- | equal
CEqOp :: CBinaryOp

-- | not equal
CNeqOp :: CBinaryOp

-- | bitwise and
CAndOp :: CBinaryOp

-- | exclusive bitwise or
CXorOp :: CBinaryOp

-- | inclusive bitwise or
COrOp :: CBinaryOp

-- | logical and
CLndOp :: CBinaryOp

-- | logical or
CLorOp :: CBinaryOp

-- | C unary operator (K&amp;R A7.3-4)
data CUnaryOp

-- | prefix increment operator
CPreIncOp :: CUnaryOp

-- | prefix decrement operator
CPreDecOp :: CUnaryOp

-- | postfix increment operator
CPostIncOp :: CUnaryOp

-- | postfix decrement operator
CPostDecOp :: CUnaryOp

-- | address operator
CAdrOp :: CUnaryOp

-- | indirection operator
CIndOp :: CUnaryOp

-- | prefix plus
CPlusOp :: CUnaryOp

-- | prefix minus
CMinOp :: CUnaryOp

-- | one's complement
CCompOp :: CUnaryOp

-- | logical negation
CNegOp :: CUnaryOp

-- | GNU Builtins, which cannot be typed in C99
type CBuiltin = CBuiltinThing NodeInfo
data CBuiltinThing a

-- | <pre>
--   (expr, type)
--   </pre>
CBuiltinVaArg :: (CExpression a) -> (CDeclaration a) -> a -> CBuiltinThing a

-- | <pre>
--   (type, designator-list)
--   </pre>
CBuiltinOffsetOf :: (CDeclaration a) -> [CPartDesignator a] -> a -> CBuiltinThing a

-- | <pre>
--   (type,type)
--   </pre>
CBuiltinTypesCompatible :: (CDeclaration a) -> (CDeclaration a) -> a -> CBuiltinThing a

-- | C constant (K&amp;R A2.5 &amp; 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 <tt>ann</tt>, 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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.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 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 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 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 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 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 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 GHC.Base.Functor Language.C.Syntax.AST.CDeclaration
instance GHC.Base.Functor Language.C.Syntax.AST.CDerivedDeclarator
instance GHC.Base.Functor Language.C.Syntax.AST.CStatement
instance GHC.Base.Functor Language.C.Syntax.AST.CInitializer
instance GHC.Base.Functor Language.C.Syntax.AST.CExpression
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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CTranslationUnit
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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CExternalDeclaration
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.Syntax.AST.Annotated 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.Syntax.AST.Annotated Language.C.Syntax.AST.CDeclaration
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.Syntax.AST.Annotated 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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CDerivedDeclarator
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.Syntax.AST.Annotated Language.C.Syntax.AST.CStatement
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.Syntax.AST.Annotated 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.Syntax.AST.Annotated 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.Syntax.AST.Annotated 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.Syntax.AST.Annotated Language.C.Syntax.AST.CDeclarationSpecifier
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
instance Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CStorageSpecifier
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.Syntax.AST.Annotated 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.Syntax.AST.Annotated Language.C.Syntax.AST.CTypeQualifier
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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CFunctionSpecifier
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.Syntax.AST.Annotated 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.Syntax.AST.Annotated 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.Syntax.AST.Annotated 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.Syntax.AST.Annotated Language.C.Syntax.AST.CInitializer
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.Syntax.AST.Annotated 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.Syntax.AST.Annotated 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.Syntax.AST.Annotated Language.C.Syntax.AST.CExpression
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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CBuiltinThing
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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CConstant
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 Language.C.Syntax.AST.Annotated Language.C.Syntax.AST.CStringLiteral

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]


-- | Base type for errors occurring in parsing, analysing and
--   pretty-printing. With ideas from Simon Marlow's "An extensible
--   dynamically-typed hierarchy of execeptions [2006]"
module Language.C.Data.Error

-- | Error levels (severity)
data ErrorLevel
LevelWarn :: ErrorLevel
LevelError :: ErrorLevel
LevelFatal :: ErrorLevel

-- | return <tt>True</tt> when the given error makes it impossible to
--   continue analysis or compilation.
isHardError :: (Error ex) => ex -> Bool

-- | errors in Language.C are instance of <a>Error</a>
class (Typeable e, Show e) => Error e where fromError (CError e) = cast e toError = CError changeErrorLevel e lvl = if errorLevel e == lvl then e else error $ "changeErrorLevel: not possible for " ++ show e

-- | obtain source location etc. of an error
errorInfo :: Error e => e -> ErrorInfo

-- | wrap error in <a>CError</a>
toError :: Error e => e -> CError

-- | try to cast a generic <a>CError</a> to the specific error type
fromError :: Error e => CError -> (Maybe e)

-- | modify the error level
changeErrorLevel :: Error e => e -> ErrorLevel -> e

-- | position of an <tt>Error</tt>
errorPos :: (Error e) => e -> Position

-- | severity level of an <tt>Error</tt>
errorLevel :: (Error e) => e -> ErrorLevel

-- | message lines of an <tt>Error</tt>
errorMsgs :: (Error e) => e -> [String]

-- | <tt>supertype</tt> of all errors
data CError
CError :: err -> CError

-- | information attached to every error in Language.C
data ErrorInfo
ErrorInfo :: ErrorLevel -> Position -> [String] -> ErrorInfo
showError :: (Error e) => String -> e -> String

-- | converts an error into a string using a fixed format
--   
--   <ul>
--   <li>either the lines of the long error message or the short message
--   has to be non-empty</li>
--   <li>the format is</li>
--   </ul>
--   
--   <pre>
--   &lt;fname&gt;:&lt;row&gt;: (column &lt;col&gt;) [&lt;err lvl&gt;]
--     &gt;&gt;&gt; &lt;line_1&gt;
--     &lt;line_2&gt;
--       ...
--     &lt;line_n&gt;
--   </pre>
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 GHC.Show.Show Language.C.Data.Error.ErrorLevel
instance GHC.Show.Show Language.C.Data.Error.ErrorInfo
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 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.UserError
instance GHC.Show.Show Language.C.Data.Error.UserError


-- | 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 <a>InputStream</a>
readInputStream :: FilePath -> IO InputStream

-- | convert <a>InputStream</a> to <a>String</a>
inputStreamToString :: InputStream -> String

-- | convert a <a>String</a> to an <a>InputStream</a>
inputStreamFromString :: String -> InputStream

-- | <tt>(b,is') = takeByte is</tt> reads and removes the first byte
--   <tt>b</tt> from the <a>InputStream</a> <tt>is</tt>
takeByte :: InputStream -> (Word8, InputStream)

-- | <tt>(c,is') = takeChar is</tt> reads and removes the first character
--   <tt>c</tt> from the <a>InputStream</a> <tt>is</tt>
takeChar :: InputStream -> (Char, InputStream)

-- | return <tt>True</tt> if the given input stream is empty
inputStreamEmpty :: InputStream -> Bool

-- | <tt>str = takeChars n is</tt> returns the first <tt>n</tt> characters
--   of the given input stream, without removing them
takeChars :: Int -> InputStream -> [Char]

-- | <tt>countLines</tt> returns the number of text lines in the given
--   <a>InputStream</a>
countLines :: InputStream -> Int


-- | Invoking external preprocessors.
module Language.C.System.Preprocess

-- | <a>Preprocessor</a> encapsulates the abstract interface for invoking C
--   preprocessors
class Preprocessor cpp

-- | parse the given command line arguments, and return a pair of parsed
--   and ignored arguments
parseCPPArgs :: Preprocessor cpp => cpp -> [String] -> Either String (CppArgs, [String])

-- | run the preprocessor
runCPP :: Preprocessor cpp => cpp -> CppArgs -> IO ExitCode

-- | Generic Options for the preprocessor
data CppOption
IncludeDir :: FilePath -> CppOption
Define :: String -> String -> CppOption
Undefine :: String -> CppOption
IncludeFile :: FilePath -> CppOption

-- | Generic arguments for the preprocessor
data CppArgs
CppArgs :: [CppOption] -> [String] -> Maybe FilePath -> FilePath -> Maybe FilePath -> CppArgs
[cppOptions] :: CppArgs -> [CppOption]
[extraOptions] :: CppArgs -> [String]
[cppTmpDir] :: CppArgs -> Maybe FilePath
[inputFile] :: CppArgs -> FilePath
[outputFile] :: CppArgs -> Maybe FilePath

-- | use the given preprocessor arguments without analyzing them
rawCppArgs :: [String] -> FilePath -> CppArgs

-- | add a typed option to the given preprocessor arguments
addCppOption :: CppArgs -> CppOption -> CppArgs

-- | add a string option to the given preprocessor arguments
addExtraOption :: CppArgs -> String -> CppArgs

-- | Cpp arguments that only specify the input file name.
cppFile :: FilePath -> CppArgs

-- | run the preprocessor and return an <a>InputStream</a> if
--   preprocesssing succeeded
runPreprocessor :: (Preprocessor cpp) => cpp -> CppArgs -> IO (Either ExitCode InputStream)

-- | guess whether a file is preprocessed (file end with .i)
isPreprocessed :: FilePath -> Bool


-- | Invoking gcc for preprocessing and compiling.
module Language.C.System.GCC

-- | <tt>GCC</tt> represents a reference to the gcc compiler
data GCC

-- | create a reference to <tt>gcc</tt>
newGCC :: FilePath -> GCC
instance Language.C.System.Preprocess.Preprocessor Language.C.System.GCC.GCC


-- | Syntax of C files: The abstract syntax tree and constants.
module Language.C.Syntax


-- | 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.
--   
--   <ul>
--   <li>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.</li>
--   <li>for reasons of simplicity the complete lexeme is hashed.</li>
--   </ul>
mkIdent :: Position -> String -> Name -> Ident

-- | string of an identifier
identToString :: Ident -> String

-- | returns an <i>internal</i> identifier (has internal position and no
--   unique name)
internalIdent :: String -> Ident

-- | return <tt>True</tt> if the given identifier is <i>internal</i>
isInternalIdent :: Ident -> Bool

-- | returns a <i>builtin</i> identifier (has builtin position and no
--   unique name)
builtinIdent :: String -> Ident

-- | Name is a unique identifier
newtype Name
Name :: Int -> Name
[nameId] :: Name -> Int

-- | return an infinite stream of <a>Name</a>s starting with
--   <tt>nameId</tt> 0
newNameSupply :: [Name]

-- | uniform representation of source file positions
data Position

-- | class of type which aggregate a source code location
class Pos a
posOf :: Pos a => a -> Position

-- | initialize a Position to the start of the translation unit starting in
--   the given file
initPos :: FilePath -> Position

-- | no position (for unknown position information)
nopos :: Position

-- | position attached to built-in objects
builtinPos :: Position

-- | position used for internal errors
internalPos :: Position

-- | returns <tt>True</tt> if the given position refers to an actual source
--   file
isSourcePos :: Position -> Bool

-- | returns <tt>True</tt> if the given position refers to a builtin
--   definition
isBuiltinPos :: Position -> Bool

-- | returns <tt>True</tt> if the given position is internal
isInternalPos :: Position -> Bool

-- | Parsed entity attribute
data NodeInfo
OnlyPos :: Position -> {-# UNPACK #-} !PosLength -> NodeInfo
NodeInfo :: Position -> {-# UNPACK #-} !PosLength -> !Name -> 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

-- | create a node with neither name nor positional information
undefNode :: NodeInfo

-- | | Given only a source position, create a new node attribute
mkNodeInfoOnlyPos :: Position -> NodeInfo

-- | Given a source position and a unique name, create a new attribute
--   identifier
mkNodeInfo :: Position -> Name -> NodeInfo

-- | <i>Deprecated: use undefNode instead</i>
internalNode :: NodeInfo


-- | This module provides a pretty printer for the parse tree (<a>AST</a>).
module Language.C.Pretty

-- | A class of types which can be pretty printed
class Pretty p where pretty = prettyPrec 0 prettyPrec _ = pretty

-- | pretty print the given value
pretty :: Pretty p => p -> Doc

-- | <tt>prettyPrec prec p</tt> pretty prints p assuming that the
--   surrounding context has a precedence of <tt>prec</tt>
prettyPrec :: Pretty p => Int -> p -> Doc

-- | Pretty print the given tranlation unit, but replace declarations from
--   header files with <tt>#include</tt> directives.
--   
--   The resulting file may not compile (because of missing
--   <tt>#define</tt> 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

-- | <tt>parseC input initialPos</tt> 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
--   <a>ParseError</a> if the parser failed, and a pair of result and
--   remaining name supply otherwise
--   
--   Synopsis: <tt>execParser parser inputStream initialPos
--   predefinedTypedefs uniqNameSupply</tt>
execParser :: P a -> InputStream -> Position -> [Ident] -> [Name] -> Either ParseError (a, [Name])

-- | run the given parser using a new name supply and builtin typedefs see
--   <a>execParser</a>
--   
--   Synopsis: <tt>runParser parser inputStream initialPos</tt>
execParser_ :: P a -> InputStream -> Position -> Either ParseError a
builtinTypeNames :: [Ident]

-- | <tt>translUnitP</tt> provides a parser for a complete C translation
--   unit, i.e. a list of external declarations.
translUnitP :: P CTranslUnit

-- | <tt>extDeclP</tt> provides a parser for an external (file-scope)
--   declaration
extDeclP :: P CExtDecl

-- | <tt>statementP</tt> provides a parser for C statements
statementP :: P CStat

-- | <tt>expressionP</tt> 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 <a>AST</a>, 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
--   <tt>Declaration</tt>
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 <tt>Declaration</tt>
declName :: (Declaration n) => n -> VarName

-- | get the type of a <tt>Declaration</tt>
declType :: (Declaration n) => n -> Type

-- | get the declaration attributes of a <tt>Declaration</tt>
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

-- | <tt>splitIdentDecls includeAllDecls</tt> 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
--   <tt>includeAllDecls</tt> is <tt>True</tt> 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 <tt>True</tt> 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

-- | <pre>
--   MemberDecl vardecl bitfieldsize node
--   </pre>
MemberDecl :: VarDecl -> (Maybe Expr) -> NodeInfo -> MemberDecl

-- | <pre>
--   AnonBitField typ size
--   </pre>
AnonBitField :: Type -> Expr -> NodeInfo -> MemberDecl

-- | <tt>typedef</tt> definitions.
--   
--   The identifier is a new name for the given type.
data TypeDef
TypeDef :: Ident -> Type -> Attributes -> NodeInfo -> TypeDef

-- | return the idenitifier of a <tt>typedef</tt>
identOfTypeDef :: TypeDef -> Ident

-- | Generic variable declarations
data VarDecl
VarDecl :: VarName -> DeclAttrs -> Type -> VarDecl

-- | Declaration attributes of the form <tt>DeclAttrs isInlineFunction
--   storage linkage attrs</tt>
--   
--   They specify the storage and linkage of a declared object.
data DeclAttrs

-- | <pre>
--   DeclAttrs fspecs storage attrs
--   </pre>
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 <a>Storage</a> 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 <tt>True</tt> 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 <tt>FunType return-type params
--   isVariadic</tt>.
--   
--   If the parameter types aren't yet known, the function has type
--   <tt>FunTypeIncomplete type attrs</tt>.
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 <i>static</i>. In a
--   function prototype, the size may be `Unspecified variable size'
--   (<tt>[*]</tt>).
data ArraySize

-- | <pre>
--   UnknownArraySize is-starred
--   </pre>
UnknownArraySize :: Bool -> ArraySize

-- | <pre>
--   FixedSizeArray is-static size-expr
--   </pre>
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

-- | 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 <tt>struct</tt> or
--   <tt>union</tt>, see <a>CompType</a>.
data CompTyKind
StructTag :: CompTyKind
UnionTag :: CompTyKind
data EnumTypeRef
EnumTypeRef :: SUERef -> NodeInfo -> EnumTypeRef

-- | Representation of C enumeration types
data EnumType

-- | <pre>
--   EnumType name enumeration-constants attrs node
--   </pre>
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 (<i>&amp;&amp;</i>) two type qualifier sets
mergeTypeQuals :: TypeQuals -> TypeQuals -> TypeQuals

-- | <tt>VarName name assembler-name</tt> 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 <tt>CStrLit</tt>)
type AsmName = CStrLit

-- | <tt><b>attribute</b></tt> annotations
--   
--   Those are of the form <tt>Attr attribute-name
--   attribute-parameters</tt>, and serve as generic properties of some
--   syntax tree elements.
--   
--   Some examples:
--   
--   <ul>
--   <li>labels can be attributed with <i>unused</i> to indicate that their
--   not used</li>
--   <li>struct definitions can be attributed with <i>packed</i> to tell
--   the compiler to use the most compact representation</li>
--   <li>declarations can be attributed with <i>deprecated</i></li>
--   <li>function declarations can be attributes with <i>noreturn</i> to
--   tell the compiler that the function will never return,</li>
--   <li>or with <i>const</i> to indicate that it is a pure function</li>
--   </ul>
--   
--   <i>TODO</i>: ultimatively, we want to parse attributes and represent
--   them in a typed way
data Attr
Attr :: Ident -> [Expr] -> NodeInfo -> Attr
type Attributes = [Attr]

-- | Empty attribute list
noAttributes :: Attributes

-- | Merge attribute lists <i>TODO</i>: currently does not remove
--   duplicates
mergeAttributes :: Attributes -> Attributes -> Attributes

-- | <a>Stmt</a> is an alias for <a>CStat</a> (Syntax)
type Stmt = CStat

-- | <a>Expr</a> is currently an alias for <a>CExpr</a> (Syntax)
type Expr = CExpr

-- | <a>Initializer</a> is currently an alias for <a>CInit</a>.
--   
--   We're planning a normalized representation, but this depends on the
--   implementation of constant expression evaluation
type Initializer = CInit

-- | Top level assembler block (alias for <tt>CStrLit</tt>)
type AsmBlock = CStrLit
instance Data.Data.Data Language.C.Analysis.SemRep.TagDef
instance Data.Data.Data Language.C.Analysis.SemRep.CompType
instance Data.Data.Data Language.C.Analysis.SemRep.MemberDecl
instance Data.Data.Data Language.C.Analysis.SemRep.TypeDef
instance Data.Data.Data Language.C.Analysis.SemRep.IdentDecl
instance Data.Data.Data Language.C.Analysis.SemRep.Decl
instance Data.Data.Data Language.C.Analysis.SemRep.ObjDef
instance Data.Data.Data Language.C.Analysis.SemRep.FunDef
instance Data.Data.Data Language.C.Analysis.SemRep.VarDecl
instance Data.Data.Data Language.C.Analysis.SemRep.ParamDecl
instance Data.Data.Data Language.C.Analysis.SemRep.FunType
instance Data.Data.Data Language.C.Analysis.SemRep.TypeDefRef
instance Data.Data.Data Language.C.Analysis.SemRep.Type
instance Data.Data.Data Language.C.Analysis.SemRep.ArraySize
instance Data.Data.Data Language.C.Analysis.SemRep.EnumType
instance Data.Data.Data Language.C.Analysis.SemRep.Enumerator
instance Data.Data.Data Language.C.Analysis.SemRep.DeclAttrs
instance Data.Data.Data Language.C.Analysis.SemRep.Attr
instance Data.Data.Data Language.C.Analysis.SemRep.VarName
instance Data.Data.Data Language.C.Analysis.SemRep.TypeQuals
instance Data.Data.Data Language.C.Analysis.SemRep.TypeName
instance Data.Data.Data Language.C.Analysis.SemRep.CompTypeRef
instance Data.Data.Data Language.C.Analysis.SemRep.CompTyKind
instance GHC.Classes.Ord Language.C.Analysis.SemRep.CompTyKind
instance GHC.Classes.Eq Language.C.Analysis.SemRep.CompTyKind
instance Data.Data.Data Language.C.Analysis.SemRep.EnumTypeRef
instance GHC.Classes.Ord Language.C.Analysis.SemRep.FloatType
instance GHC.Classes.Eq Language.C.Analysis.SemRep.FloatType
instance Data.Data.Data Language.C.Analysis.SemRep.FloatType
instance GHC.Classes.Ord Language.C.Analysis.SemRep.IntType
instance GHC.Classes.Eq Language.C.Analysis.SemRep.IntType
instance Data.Data.Data Language.C.Analysis.SemRep.IntType
instance Data.Data.Data Language.C.Analysis.SemRep.BuiltinType
instance GHC.Classes.Ord Language.C.Analysis.SemRep.Storage
instance GHC.Classes.Eq Language.C.Analysis.SemRep.Storage
instance GHC.Show.Show Language.C.Analysis.SemRep.Storage
instance Data.Data.Data Language.C.Analysis.SemRep.Storage
instance GHC.Classes.Ord Language.C.Analysis.SemRep.Linkage
instance GHC.Classes.Eq Language.C.Analysis.SemRep.Linkage
instance GHC.Show.Show Language.C.Analysis.SemRep.Linkage
instance Data.Data.Data Language.C.Analysis.SemRep.Linkage
instance Data.Data.Data Language.C.Analysis.SemRep.FunctionAttrs
instance GHC.Classes.Ord Language.C.Analysis.SemRep.FunctionAttrs
instance GHC.Classes.Eq Language.C.Analysis.SemRep.FunctionAttrs
instance Language.C.Analysis.SemRep.HasSUERef Language.C.Analysis.SemRep.TagDef
instance (Language.C.Analysis.SemRep.Declaration a, Language.C.Analysis.SemRep.Declaration b) => Language.C.Analysis.SemRep.Declaration (Data.Either.Either a b)
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.IdentDecl
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.Decl
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.ObjDef
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.FunDef
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.ParamDecl
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.MemberDecl
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.VarDecl
instance GHC.Show.Show Language.C.Analysis.SemRep.IntType
instance GHC.Show.Show Language.C.Analysis.SemRep.FloatType
instance Language.C.Analysis.SemRep.HasSUERef Language.C.Analysis.SemRep.CompTypeRef
instance Language.C.Analysis.SemRep.HasCompTyKind Language.C.Analysis.SemRep.CompTypeRef
instance Language.C.Analysis.SemRep.HasSUERef Language.C.Analysis.SemRep.EnumTypeRef
instance Language.C.Analysis.SemRep.HasSUERef Language.C.Analysis.SemRep.CompType
instance Language.C.Analysis.SemRep.HasCompTyKind Language.C.Analysis.SemRep.CompType
instance GHC.Show.Show Language.C.Analysis.SemRep.CompTyKind
instance Language.C.Analysis.SemRep.HasSUERef Language.C.Analysis.SemRep.EnumType
instance Language.C.Analysis.SemRep.Declaration Language.C.Analysis.SemRep.Enumerator
instance GHC.Classes.Eq Language.C.Analysis.SemRep.TypeQuals
instance GHC.Classes.Ord Language.C.Analysis.SemRep.TypeQuals
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.TagDef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.TagDef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.IdentDecl
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.IdentDecl
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.DeclEvent
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.DeclEvent
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.Decl
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.Decl
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.ObjDef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.ObjDef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.FunDef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.FunDef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.ParamDecl
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.ParamDecl
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.MemberDecl
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.MemberDecl
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.TypeDef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.TypeDef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.TypeDefRef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.TypeDefRef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.CompTypeRef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.CompTypeRef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.EnumTypeRef
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.EnumTypeRef
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.CompType
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.CompType
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.EnumType
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.EnumType
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.Enumerator
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.Enumerator
instance Language.C.Data.Node.CNode Language.C.Analysis.SemRep.Attr
instance Language.C.Data.Position.Pos Language.C.Analysis.SemRep.Attr


-- | Errors in the semantic analysis
module Language.C.Analysis.SemError

-- | InvalidASTError is caused by the violation of an invariant in the AST
newtype InvalidASTError
InvalidAST :: ErrorInfo -> InvalidASTError
invalidAST :: NodeInfo -> String -> InvalidASTError

-- | BadSpecifierError is caused by an invalid combination of specifiers
newtype BadSpecifierError
BadSpecifierError :: ErrorInfo -> BadSpecifierError
badSpecifierError :: NodeInfo -> String -> BadSpecifierError
data TypeMismatch
TypeMismatch :: String -> (NodeInfo, Type) -> (NodeInfo, Type) -> TypeMismatch
typeMismatch :: String -> (NodeInfo, Type) -> (NodeInfo, Type) -> TypeMismatch

-- | RedefError is caused by an invalid redefinition of the same identifier
--   or type
data RedefError
RedefError :: ErrorLevel -> RedefInfo -> RedefError
data RedefInfo
RedefInfo :: String -> RedefKind -> NodeInfo -> NodeInfo -> RedefInfo
data RedefKind
DuplicateDef :: RedefKind
DiffKindRedecl :: RedefKind
ShadowedDef :: RedefKind
DisagreeLinkage :: RedefKind
NoLinkageOld :: RedefKind
redefinition :: ErrorLevel -> String -> RedefKind -> NodeInfo -> NodeInfo -> RedefError
instance Language.C.Data.Error.Error Language.C.Analysis.SemError.InvalidASTError
instance Language.C.Data.Error.Error Language.C.Analysis.SemError.BadSpecifierError
instance GHC.Show.Show Language.C.Analysis.SemError.InvalidASTError
instance GHC.Show.Show Language.C.Analysis.SemError.BadSpecifierError
instance GHC.Show.Show Language.C.Analysis.SemError.TypeMismatch
instance Language.C.Data.Error.Error Language.C.Analysis.SemError.TypeMismatch
instance GHC.Show.Show Language.C.Analysis.SemError.RedefError
instance Language.C.Data.Error.Error Language.C.Analysis.SemError.RedefError

module Language.C.Analysis.TypeUtils

-- | Constructor for a simple integral type.
integral :: IntType -> Type

-- | Constructor for a simple floating-point type.
floating :: FloatType -> Type

-- | A simple pointer with no qualifiers
simplePtr :: Type -> Type

-- | The underlying type for <tt>uint16_t</tt>. For now, this is just
--   <tt>unsigned short</tt>.
uint16_tType :: Type

-- | The underlying type for <tt>uint32_t</tt>. For now, this is just
--   <tt>unsigned int</tt>.
uint32_tType :: Type

-- | The underlying type for <tt>uint64_t</tt>. For now, this is just
--   <tt>unsigned long long</tt>.
uint64_tType :: Type

-- | The type returned by sizeof (size_t). For now, this is just
--   <tt>int</tt>.
size_tType :: Type

-- | The type of pointer differences (ptrdiff_t). For now, this is just
--   <tt>int</tt>.
ptrDiffType :: Type

-- | The type of comparisons/guards. This is always just <tt>int</tt>.
boolType :: Type

-- | Simple <tt>void</tt> type.
voidType :: Type

-- | An unqualified <tt>void</tt> pointer.
voidPtr :: Type

-- | A <tt>const</tt>-qualified <tt>void</tt> pointer.
constVoidPtr :: Type

-- | An unqualified <tt>char</tt> pointer.
charPtr :: Type

-- | A <tt>const</tt>-qualified <tt>char</tt> pointer.
constCharPtr :: Type

-- | The type of a constant string.
stringType :: Type

-- | The builtin type of variable-length argument lists.
valistType :: Type

-- | Check whether a type is an integral type. This includes <tt>enum</tt>
--   types. This function does not attempt to resolve <tt>typedef</tt>
--   types.
isIntegralType :: Type -> Bool

-- | Check whether a type is a floating-point numeric type. This function
--   does not attempt to resolve <tt>typedef</tt> types.
isFloatingType :: Type -> Bool

-- | Check whether a type is an pointer type. This includes array types.
--   This function does not attempt to resolve <tt>typedef</tt> types.
isPointerType :: Type -> Bool

-- | Check whether a type is a scalar type. Scalar types include arithmetic
--   types and pointer types.
isScalarType :: Type -> Bool

-- | return <tt>True</tt> if the given type is a function type
--   
--   Result is undefined in the presence of undefined typeDefs
isFunctionType :: Type -> Bool

-- | Return the qualifiers of a type.
typeQuals :: Type -> TypeQuals
typeQualsUpd :: (TypeQuals -> TypeQuals) -> Type -> Type

-- | Return the attributes of a type.
typeAttrs :: Type -> Attributes
typeAttrsUpd :: (Attributes -> Attributes) -> Type -> Type

-- | Return the base type of a pointer or array type. It is an error to
--   call this function with a type that is not in one of those two
--   categories.
baseType :: Type -> Type

-- | resolve typedefs, if possible
derefTypeDef :: Type -> Type

-- | Attempt to remove all references to <tt>typedef</tt> types from a
--   given type. Note that this does not dereference the types of structure
--   or union fields, so there are still cases where further dereferencing
--   is needed.
deepDerefTypeDef :: Type -> Type
canonicalType :: Type -> Type

-- | Two types denote the same type if they are identical, ignoring type
--   definitions, and neither is a variably modified type.
sameType :: Type -> Type -> Bool
getIntType :: Flags CIntFlag -> IntType
getFloatType :: String -> FloatType


-- | <i>WARNING</i> : This is just an implementation sketch and not very
--   well tested.
--   
--   Export <tt>SemRep</tt> entities to <tt>AST</tt> nodes.
module Language.C.Analysis.Export

-- | Export Declarator
--   
--   Synopsis: <tt>exportDeclr other_specs type attributes
--   variable-name</tt>
exportDeclr :: [CDeclSpec] -> Type -> Attributes -> VarName -> ([CDeclSpec], CDeclr)

-- | Export a type to syntax
exportType :: Type -> ([CDeclSpec], [CDerivedDeclr])
exportTypeDecl :: Type -> CDecl
exportTypeSpec :: TypeName -> [CTypeSpec]
exportTypeDef :: TypeDef -> CDecl
exportCompType :: CompType -> [CTypeSpec]
exportCompTypeDecl :: CompTypeRef -> [CTypeSpec]
exportCompTypeRef :: CompType -> [CTypeSpec]
exportEnumType :: EnumType -> [CTypeSpec]
exportEnumTypeDecl :: EnumTypeRef -> [CTypeSpec]
exportEnumTypeRef :: EnumType -> [CTypeSpec]

module Language.C.Analysis.TypeConversions

-- | For an arithmetic operator, if the arguments are of the given types,
--   return the type of the full expression.
arithmeticConversion :: TypeName -> TypeName -> Maybe TypeName
floatConversion :: FloatType -> FloatType -> FloatType
intConversion :: IntType -> IntType -> IntType


-- | This module manages symbols in local and global scopes.
--   
--   There are four different kind of identifiers: ordinary identifiers
--   (henceforth simply called <tt>identifier</tt>), tag names (names of
--   struct/union/enum types), labels and structure members.
module Language.C.Analysis.DefTable

-- | All ordinary identifiers map to <tt>IdenTyDecl</tt>: either a typedef
--   or a object/function/enumerator
type IdentEntry = Either TypeDef IdentDecl
identOfTyDecl :: IdentEntry -> Ident

-- | Tag names map to forward declarations or definitions of
--   struct/union/enum types
type TagEntry = Either TagFwdDecl TagDef
data TagFwdDecl
CompDecl :: CompTypeRef -> TagFwdDecl
EnumDecl :: EnumTypeRef -> TagFwdDecl

-- | Table holding current definitions
data DefTable
DefTable :: NameSpaceMap Ident IdentEntry -> NameSpaceMap SUERef TagEntry -> NameSpaceMap Ident Ident -> NameSpaceMap Ident MemberDecl -> IntMap Name -> IntMap Type -> DefTable

-- | declared `ordinary identifiers'
[identDecls] :: DefTable -> NameSpaceMap Ident IdentEntry

-- | declared struct<i>union</i>enum tags
[tagDecls] :: DefTable -> NameSpaceMap SUERef TagEntry

-- | defined labels
[labelDefs] :: DefTable -> NameSpaceMap Ident Ident

-- | member declarations (only local)
[memberDecls] :: DefTable -> NameSpaceMap Ident MemberDecl

-- | link names with definitions
[refTable] :: DefTable -> IntMap Name
[typeTable] :: DefTable -> IntMap Type

-- | empty definition table, with all name space maps in global scope
emptyDefTable :: DefTable

-- | get the globally defined entries of a definition table
globalDefs :: DefTable -> GlobalDecls
inFileScope :: DefTable -> Bool

-- | Enter function scope (AND the corresponding block scope)
enterFunctionScope :: DefTable -> DefTable

-- | Leave function scope, and return the associated DefTable. Error if not
--   in function scope.
leaveFunctionScope :: DefTable -> DefTable

-- | Enter new block scope
enterBlockScope :: DefTable -> DefTable

-- | Leave innermost block scope
leaveBlockScope :: DefTable -> DefTable

-- | Enter new member declaration scope
enterMemberDecl :: DefTable -> DefTable

-- | Leave innermost member declaration scope
leaveMemberDecl :: DefTable -> ([MemberDecl], DefTable)

-- | Status of a declaration
data DeclarationStatus t

-- | new entry
NewDecl :: DeclarationStatus t

-- | old def was overwritten
Redeclared :: t -> DeclarationStatus t

-- | new def was discarded
KeepDef :: t -> DeclarationStatus t

-- | new def shadows one in outer scope
Shadowed :: t -> DeclarationStatus t

-- | kind mismatch
KindMismatch :: t -> DeclarationStatus t
declStatusDescr :: DeclarationStatus t -> String
defineTypeDef :: Ident -> TypeDef -> DefTable -> (DeclarationStatus IdentEntry, DefTable)

-- | declare/define a global object/function/typeDef
--   
--   returns <tt>Redeclared def</tt> if there is already an
--   object/function/typeDef in global scope, or <tt>DifferentKindRedec
--   def</tt> if the old declaration is of a different kind.
defineGlobalIdent :: Ident -> IdentDecl -> DefTable -> (DeclarationStatus IdentEntry, DefTable)

-- | declare/define a object/function/typeDef with lexical scope
--   
--   returns <tt>Redeclared def</tt> or <tt>DifferentKindRedec def</tt> if
--   there is already an object/function/typeDef in the same scope.
defineScopedIdent :: Ident -> IdentDecl -> DefTable -> (DeclarationStatus IdentEntry, DefTable)

-- | declare/define a object/function/typeDef with lexical scope, if the
--   given predicate holds on the old entry.
--   
--   returns <tt>Keep old_def</tt> if the old definition shouldn't be
--   overwritten, and otherwise <tt>Redeclared def</tt> or
--   <tt>DifferentKindRedecl def</tt> if there is already an
--   object/function/typeDef in the same scope.
defineScopedIdentWhen :: (IdentDecl -> Bool) -> Ident -> IdentDecl -> DefTable -> (DeclarationStatus IdentEntry, DefTable)

-- | declare a tag (fwd decl in case the struct name isn't defined yet)
declareTag :: SUERef -> TagFwdDecl -> DefTable -> (DeclarationStatus TagEntry, DefTable)

-- | define a tag
defineTag :: SUERef -> TagDef -> DefTable -> (DeclarationStatus TagEntry, DefTable)

-- | define a label Return the old label if it is already defined in this
--   function's scope
defineLabel :: Ident -> DefTable -> (DeclarationStatus Ident, DefTable)

-- | lookup identifier (object, function, typeDef, enumerator)
lookupIdent :: Ident -> DefTable -> Maybe IdentEntry

-- | lookup tag
lookupTag :: SUERef -> DefTable -> Maybe TagEntry

-- | lookup label
lookupLabel :: Ident -> DefTable -> Maybe Ident

-- | lookup an object in the innermost scope
lookupIdentInner :: Ident -> DefTable -> Maybe IdentEntry

-- | lookup an identifier in the innermost scope
lookupTagInner :: SUERef -> DefTable -> Maybe TagEntry

-- | Record the type of a node.
insertType :: DefTable -> Name -> Type -> DefTable

-- | Lookup the type of a node.
lookupType :: DefTable -> Name -> Maybe Type

-- | Merge two DefTables. If both tables contain an entry for a given key,
--   they must agree on its value.
mergeDefTable :: DefTable -> DefTable -> DefTable
instance GHC.Classes.Ord Language.C.Analysis.DefTable.TagEntryKind
instance GHC.Classes.Eq Language.C.Analysis.DefTable.TagEntryKind
instance Data.Data.Data t => Data.Data.Data (Language.C.Analysis.DefTable.DeclarationStatus t)
instance Language.C.Analysis.SemRep.HasSUERef Language.C.Analysis.DefTable.TagFwdDecl
instance Language.C.Data.Node.CNode Language.C.Analysis.DefTable.TagFwdDecl
instance GHC.Show.Show Language.C.Analysis.DefTable.TagEntryKind


-- | Pretty printing the semantic analysis representation. This is
--   currently only intended for debugging purposes.
module Language.C.Analysis.Debug
globalDeclStats :: (FilePath -> Bool) -> GlobalDecls -> [(String, Int)]
prettyAssocs :: (Pretty k, Pretty v) => String -> [(k, v)] -> Doc
prettyAssocsWith :: String -> (k -> Doc) -> (v -> Doc) -> [(k, v)] -> Doc
instance Language.C.Pretty.Pretty Language.C.Analysis.DefTable.DefTable
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.GlobalDecls
instance (Language.C.Pretty.Pretty a, Language.C.Pretty.Pretty b) => Language.C.Pretty.Pretty (Data.Either.Either a b)
instance Language.C.Pretty.Pretty Language.C.Analysis.DefTable.TagFwdDecl
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.CompTyKind
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.CompTypeRef
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.EnumTypeRef
instance Language.C.Pretty.Pretty Language.C.Data.Ident.Ident
instance Language.C.Pretty.Pretty Language.C.Data.Ident.SUERef
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.TagDef
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.IdentDecl
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Decl
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.TypeDef
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.ObjDef
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.FunDef
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.VarDecl
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.ParamDecl
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.DeclAttrs
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Type
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.TypeQuals
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.CompType
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.MemberDecl
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.EnumType
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Enumerator
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.FunctionAttrs
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Storage
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Linkage
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.VarName
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Attributes
instance Language.C.Pretty.Pretty Language.C.Analysis.SemRep.Attr

module Language.C.Analysis.Builtins
builtins :: DefTable


-- | Monad for Traversals of the C AST.
--   
--   For the traversal, we maintain a symboltable and need MonadError and
--   unique name generation facilities. Furthermore, the user may provide
--   callbacks to handle declarations and definitions.
module Language.C.Analysis.TravMonad
class (Monad m) => MonadName m

-- | unique name generation
genName :: MonadName m => m Name
class (Monad m) => MonadSymtab m

-- | return the definition table
getDefTable :: MonadSymtab m => m DefTable

-- | perform an action modifying the definition table
withDefTable :: MonadSymtab m => (DefTable -> (a, DefTable)) -> m a
class (Monad m) => MonadCError m

-- | throw an <a>Error</a>
throwTravError :: (MonadCError m, Error e) => e -> m a

-- | catch an <a>Error</a> (we could implement dynamically-typed catch
--   here)
catchTravError :: MonadCError m => m a -> (CError -> m a) -> m a

-- | remember that an <a>Error</a> occurred (without throwing it)
recordError :: (MonadCError m, Error e) => e -> m ()

-- | return the list of recorded errors
getErrors :: MonadCError m => m [CError]

-- | Traversal monad
class (MonadName m, MonadSymtab m, MonadCError m) => MonadTrav m

-- | handling declarations and definitions
handleDecl :: MonadTrav m => DeclEvent -> m ()

-- | forward declaration of a tag. Only necessary for name analysis, but
--   otherwise no semantic consequences.
handleTagDecl :: (MonadCError m, MonadSymtab m) => TagFwdDecl -> m ()

-- | define the given composite type or enumeration If there is a
--   declaration visible, overwrite it with the definition. Otherwise,
--   enter a new definition in the current namespace. If there is already a
--   definition present, yield an error (redeclaration).
handleTagDef :: (MonadTrav m) => TagDef -> m ()
handleEnumeratorDef :: (MonadCError m, MonadSymtab m) => Enumerator -> m ()
handleTypeDef :: (MonadTrav m) => TypeDef -> m ()

-- | handle object defintions (maybe tentative)
handleObjectDef :: (MonadTrav m) => Bool -> Ident -> ObjDef -> m ()

-- | handle function definitions
handleFunDef :: (MonadTrav m) => Ident -> FunDef -> m ()

-- | handle variable declarations (external object declarations and
--   function prototypes) variable declarations are either function
--   prototypes, or external declarations, and not very interesting on
--   their own. we only put them in the symbol table and call the handle.
--   declarations never override definitions
handleVarDecl :: (MonadTrav m) => Bool -> Decl -> m ()

-- | handle parameter declaration. The interesting part is that parameters
--   can be abstract (if they are part of a type). If they have a name, we
--   enter the name (usually in function prototype or function scope),
--   checking if there are duplicate definitions. FIXME: I think it would
--   be more transparent to handle parameter declarations in a special way
handleParamDecl :: (MonadTrav m) => ParamDecl -> m ()
handleAsmBlock :: (MonadTrav m) => AsmBlock -> m ()
enterPrototypeScope :: (MonadSymtab m) => m ()
leavePrototypeScope :: (MonadSymtab m) => m ()
enterFunctionScope :: (MonadSymtab m) => m ()
leaveFunctionScope :: (MonadSymtab m) => m ()
enterBlockScope :: (MonadSymtab m) => m ()
leaveBlockScope :: (MonadSymtab m) => m ()

-- | lookup a type definition the 'wrong kind of object' is an internal
--   error here, because the parser should distinguish typeDefs and other
--   objects
lookupTypeDef :: (MonadCError m, MonadSymtab m) => Ident -> m Type

-- | lookup an object, function or enumerator
lookupObject :: (MonadCError m, MonadSymtab m) => Ident -> m (Maybe IdentDecl)

-- | create a reference to a struct/union/enum
--   
--   This currently depends on the fact the structs are tagged with unique
--   names. We could use the name generation of TravMonad as well, which
--   might be the better choice when dealing with autogenerated code.
createSUERef :: (MonadCError m, MonadSymtab m) => NodeInfo -> Maybe Ident -> m SUERef

-- | check wheter non-recoverable errors occurred
hadHardErrors :: [CError] -> Bool
handleTravError :: (MonadCError m) => m a -> m (Maybe a)

-- | raise an error based on an Either argument
throwOnLeft :: (MonadCError m, Error e) => Either e a -> m a

-- | raise an error caused by a malformed AST
astError :: (MonadCError m) => NodeInfo -> String -> m a
warn :: (Error e, MonadCError m) => e -> m ()

-- | simple traversal monad, providing user state and callbacks
data Trav s a
runTrav :: forall s a. s -> Trav s a -> Either [CError] (a, TravState s)
runTrav_ :: Trav () a -> Either [CError] (a, [CError])
data TravState s
initTravState :: s -> TravState s
withExtDeclHandler :: Trav s a -> (DeclEvent -> Trav s ()) -> Trav s a
modifyUserState :: (s -> s) -> Trav s ()
userState :: TravState s -> s
getUserState :: Trav s s
data TravOptions
TravOptions :: CLanguage -> TravOptions
[language] :: TravOptions -> CLanguage
modifyOptions :: (TravOptions -> TravOptions) -> Trav s ()
travErrors :: TravState s -> [CError]

-- | The variety of the C language to accept. Note: this is not yet
--   enforced.
data CLanguage
C89 :: CLanguage
C99 :: CLanguage
GNU89 :: CLanguage
GNU99 :: CLanguage
mapMaybeM :: (Monad m) => (Maybe a) -> (a -> m b) -> m (Maybe b)
maybeM :: (Monad m) => (Maybe a) -> (a -> m ()) -> m ()
mapSndM :: (Monad m) => (b -> m c) -> (a, b) -> m (a, c)
concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
instance GHC.Base.Functor (Language.C.Analysis.TravMonad.Trav s)
instance GHC.Base.Applicative (Language.C.Analysis.TravMonad.Trav s)
instance GHC.Base.Monad (Language.C.Analysis.TravMonad.Trav s)
instance Language.C.Analysis.TravMonad.MonadName (Language.C.Analysis.TravMonad.Trav s)
instance Language.C.Analysis.TravMonad.MonadSymtab (Language.C.Analysis.TravMonad.Trav s)
instance Language.C.Analysis.TravMonad.MonadCError (Language.C.Analysis.TravMonad.Trav s)
instance Language.C.Analysis.TravMonad.MonadTrav (Language.C.Analysis.TravMonad.Trav s)


-- | This module performs the analysis of declarations and the translation
--   of type specifications in the AST.
module Language.C.Analysis.DeclAnalysis

-- | get the type of a <i>type declaration</i>
--   
--   A type declaration <tt>T</tt> may appear in thre forms:
--   
--   <ul>
--   <li><pre>typeof(T)</pre></li>
--   <li>as abstract declarator in a function prototype, as in
--   <tt>f(int)</tt></li>
--   <li>in a declaration without declarators, as in <tt>struct x { int a }
--   ;</tt></li>
--   </ul>
--   
--   Currently, <tt>analyseTypeDecl</tt> is exlusively used for analysing
--   types for GNU's <tt>typeof(T)</tt>.
--   
--   We move attributes to the type, as they have no meaning for the
--   abstract declarator
analyseTypeDecl :: (MonadTrav m) => CDecl -> m Type

-- | translate a type
tType :: (MonadTrav m) => Bool -> NodeInfo -> [CTypeQual] -> TypeSpecAnalysis -> [CDerivedDeclr] -> [CDecl] -> m Type

-- | translate a type without (syntactic) indirections Due to the GNU
--   <tt>typeof</tt> extension and typeDefs, this can be an arbitrary type
tDirectType :: (MonadTrav m) => Bool -> NodeInfo -> [CTypeQual] -> TypeSpecAnalysis -> m Type

-- | Mapping from num type specs to C types (C99 6.7.2-2), ignoring the
--   complex qualifier.
tNumType :: (MonadCError m) => NumTypeSpec -> m (Either (FloatType, Bool) IntType)
tArraySize :: (MonadTrav m) => CArrSize -> m ArraySize
tTypeQuals :: (MonadTrav m) => [CTypeQual] -> m (TypeQuals, Attributes)

-- | convert old style parameters
--   
--   This requires matching parameter names and declarations, as in the
--   following example:
--   
--   <pre>
--   int f(d,c,a,b)
--   char a,*b;
--   int c;
--   { }
--   </pre>
--   
--   is converted to
--   
--   <pre>
--   int f(int d, int c, char a, char* b)
--   </pre>
--   
--   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
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 <tt><b>attribute</b></tt> 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 <tt>m</tt> of type <tt>t</tt>
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


-- | Analyse the parse tree
--   
--   Traverses the AST, analyses declarations and invokes handlers.
module Language.C.Analysis.AstAnalysis

-- | Analyse the given AST
--   
--   <tt>analyseAST ast</tt> results in global declaration dictionaries. If
--   you want to perform specific actions on declarations or definitions,
--   you may provide callbacks in the <tt>MonadTrav</tt> <tt>m</tt>.
--   
--   Returns the set of global declarations and definitions which where
--   successfully translated. It is the users responsibility to check
--   whether any hard errors occurred (<tt>runTrav</tt> 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 <tt>void</tt>, 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.
--   
--   <i>NOTE</i> This is an experimental interface, and therefore the API
--   will change in the future.
--   
--   DONE:
--   
--   <ul>
--   <li>Name analysis framework</li>
--   <li>File-scope analysis</li>
--   <li>Declaration analysis</li>
--   </ul>
--   
--   TODO:
--   
--   <ul>
--   <li>Type checking expressions</li>
--   <li>Constant expression evaluation (CEE)</li>
--   <li>Typed representation of attributes (depends on CEE)</li>
--   <li>Normalized representation of initializers</li>
--   <li>Support for analyzing function bodies (depends on CEE)</li>
--   <li>Normalizing expressions and statements</li>
--   <li>Formal rules how to link back to the AST using NodeInfo
--   fields</li>
--   <li>Typed assembler representation</li>
--   </ul>
module Language.C.Analysis


-- | Library for analysing and generating C code.
--   
--   See <a>http://www.sivity.net/projects/language.c</a>
module Language.C

-- | preprocess (if necessary) and parse a C source file
--   
--   <pre>
--   Synopsis: parseCFile preprocesssor tmp-dir? cpp-opts file
--   Example:  parseCFile (newGCC "gcc") Nothing ["-I/usr/include/gtk-2.0"] my-gtk-exts.c
--   </pre>
parseCFile :: (Preprocessor cpp) => cpp -> Maybe FilePath -> [String] -> FilePath -> IO (Either ParseError CTranslUnit)

-- | parse an already preprocessed C file
--   
--   <pre>
--   Synopsis: parseCFilePre file.i
--   </pre>
parseCFilePre :: FilePath -> IO (Either ParseError CTranslUnit)
