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





Common data types for Language.C: Identifiers, unique names, source code locations, ast node attributes and extensible errors.


Input stream


data SUERef Source

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

isAnonymousRef :: SUERef -> BoolSource

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

mkIdent :: Position -> String -> Name -> IdentSource

build an identifier from a string.

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

identToString :: Ident -> StringSource

string of an identifier

internalIdent :: String -> IdentSource

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

isInternalIdent :: Ident -> BoolSource

return True if the given identifier is internal

builtinIdent :: String -> IdentSource

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

Unqiue names

newtype Name Source

Name is a unique identifier




nameId :: Int

newNameSupply :: [Name]Source

return an infinite stream of Names starting with nameId 0

Source code positions

data Position Source

uniform representation of source file positions

class Pos a whereSource

class of type which aggregate a source code location


posOf :: a -> PositionSource

initPos :: FilePath -> PositionSource

initialize a Position to the start of the translation unit starting in the given file

nopos :: PositionSource

no position (for unknown position information)

builtinPos :: PositionSource

position attached to built-in objects

internalPos :: PositionSource

position used for internal errors

isSourcePos :: Position -> BoolSource

returns True if the given position refers to an actual source file

isBuiltinPos :: Position -> BoolSource

returns True if the given position refers to a builtin definition

isInternalPos :: Position -> BoolSource

returns True if the given position is internal

Syntax tree nodes

undefNode :: NodeInfoSource

create a node with neither name nor positional information

mkNodeInfoOnlyPos :: Position -> NodeInfoSource

| Given only a source position, create a new node attribute

mkNodeInfo :: Position -> Name -> NodeInfoSource

Given a source position and a unique name, create a new attribute identifier

Extensible errors