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

Copyright(c) 2008 Benedikt Huber
LicenseBSD-style
Maintainerbenedikt.huber@gmail.com
Stabilityexperimental
Portabilityghc
Safe HaskellNone
LanguageHaskell98

Language.C.Data

Contents

Description

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

Synopsis

Input stream

Identifiers

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

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

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

build an identifier from a string.

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

identToString :: Ident -> String Source

string of an identifier

internalIdent :: String -> Ident Source

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

isInternalIdent :: Ident -> Bool Source

return True if the given identifier is internal

builtinIdent :: String -> Ident Source

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

Unqiue names

newtype Name Source

Name is a unique identifier

Constructors

Name 

Fields

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

class of type which aggregate a source code location

Methods

posOf :: a -> Position Source

initPos :: FilePath -> Position Source

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

nopos :: Position Source

no position (for unknown position information)

builtinPos :: Position Source

position attached to built-in objects

internalPos :: Position Source

position used for internal errors

isSourcePos :: Position -> Bool Source

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

isBuiltinPos :: Position -> Bool Source

returns True if the given position refers to a builtin definition

isInternalPos :: Position -> Bool Source

returns True if the given position is internal

Syntax tree nodes

class CNode a where Source

a class for convenient access to the attributes of an attributed object

Methods

nodeInfo :: a -> NodeInfo Source

Instances

CNode NodeInfo Source 
CNode Ident Source 
CNode Attr Source 
CNode Enumerator Source 
CNode EnumType Source 
CNode CompType Source 
CNode EnumTypeRef Source 
CNode CompTypeRef Source 
CNode TypeDefRef Source 
CNode TypeDef Source 
CNode MemberDecl Source 
CNode ParamDecl Source 
CNode FunDef Source 
CNode ObjDef Source 
CNode Decl Source 
CNode DeclEvent Source 
CNode IdentDecl Source 
CNode TagDef Source 
CNode TagFwdDecl Source 
CNode t1 => CNode (CStringLiteral t1) Source 
CNode t1 => CNode (CConstant t1) Source 
CNode t1 => CNode (CBuiltinThing t1) Source 
CNode t1 => CNode (CExpression t1) Source 
CNode t1 => CNode (CAttribute t1) Source 
CNode t1 => CNode (CPartDesignator t1) Source 
CNode t1 => CNode (CInitializer t1) Source 
CNode t1 => CNode (CEnumeration t1) Source 
CNode t1 => CNode (CStructureUnion t1) Source 
CNode t1 => CNode (CTypeQualifier t1) Source 
CNode t1 => CNode (CTypeSpecifier t1) Source 
CNode t1 => CNode (CStorageSpecifier t1) Source 
CNode t1 => CNode (CDeclarationSpecifier t1) Source 
CNode t1 => CNode (CCompoundBlockItem t1) Source 
CNode t1 => CNode (CAssemblyOperand t1) Source 
CNode t1 => CNode (CAssemblyStatement t1) Source 
CNode t1 => CNode (CStatement t1) Source 
CNode t1 => CNode (CDerivedDeclarator t1) Source 
CNode t1 => CNode (CDeclarator t1) Source 
CNode t1 => CNode (CDeclaration t1) Source 
CNode t1 => CNode (CFunctionDef t1) Source 
CNode t1 => CNode (CExternalDeclaration t1) Source 
CNode t1 => CNode (CTranslationUnit t1) Source 
(CNode a, CNode b) => CNode (Either a b) Source 

undefNode :: NodeInfo Source

create a node with neither name nor positional information

mkNodeInfoOnlyPos :: Position -> NodeInfo Source

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

mkNodeInfo :: Position -> Name -> NodeInfo Source

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

internalNode :: NodeInfo Source

Deprecated: use undefNode instead

Extensible errors