Portability | ghc |
---|---|
Stability | experimental |
Maintainer | benedikt.huber@gmail.com |
Common data types for Language.C: Identifiers, unique names, source code locations, ast node attributes and extensible errors.
- module Language.C.Data.InputStream
- data SUERef
- isAnonymousRef :: SUERef -> Bool
- data Ident
- mkIdent :: Position -> String -> Name -> Ident
- identToString :: Ident -> String
- internalIdent :: String -> Ident
- isInternalIdent :: Ident -> Bool
- builtinIdent :: String -> Ident
- newtype Name = Name {}
- namesStartingFrom :: Int -> [Name]
- data Position = Position String !Int !Int
- class Pos a where
- posFile :: Position -> String
- posRow :: Position -> Int
- posColumn :: Position -> Int
- nopos :: Position
- builtinPos :: Position
- internalPos :: Position
- isSourcePos :: Position -> Bool
- isBuiltinPos :: Position -> Bool
- isInternalPos :: Position -> Bool
- data NodeInfo
- class CNode a where
- fileOfNode :: CNode a => a -> FilePath
- posOfNode :: NodeInfo -> Position
- nameOfNode :: NodeInfo -> Maybe Name
- internalNode :: NodeInfo
- mkNodeInfoOnlyPos :: Position -> NodeInfo
- mkNodeInfo :: Position -> Name -> NodeInfo
- module Language.C.Data.Error
Input stream
module Language.C.Data.InputStream
Identifiers
References uniquely determining a struct, union or enum type. Those are either identified by an string identifier, or by a unique name (anonymous types).
isAnonymousRef :: SUERef -> BoolSource
Return true if the struct/union/enum reference is anonymous.
C identifiers
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
Name is a unique identifier
namesStartingFrom :: Int -> [Name]Source
get the infinite stream of unique names starting from the given integer
Source code positions
uniform representation of source file positions; the order of the arguments is important as it leads to the desired ordering of source positions
class of type which aggregate a source code location
Pos NodeInfo | |
Pos Ident | |
Pos CStrLit | |
Pos CConst | |
Pos CBuiltin | |
Pos CExpr | |
Pos CAttr | |
Pos CDesignator | |
Pos CInit | |
Pos CEnum | |
Pos CStructUnion | |
Pos CTypeQual | |
Pos CTypeSpec | |
Pos CStorageSpec | |
Pos CDeclSpec | |
Pos CBlockItem | |
Pos CAsmOperand | |
Pos CAsmStmt | |
Pos CStat | |
Pos CDerivedDeclr | |
Pos CDeclr | |
Pos CDecl | |
Pos CFunDef | |
Pos CExtDecl | |
Pos CTranslUnit | |
Pos CToken | |
Pos Attr | |
Pos Enumerator | |
Pos EnumType | |
Pos CompType | |
Pos EnumTypeRef | |
Pos CompTypeRef | |
Pos TypeDefRef | |
Pos TypeDef | |
Pos MemberDecl | |
Pos ParamDecl | |
Pos FunDef | |
Pos ObjDef | |
Pos Decl | |
Pos DeclEvent | |
Pos IdentDecl | |
Pos TagDef | |
Pos a => Pos [a] | |
Pos a => Pos (Reversed a) | |
Pos (Located a) |
posFile :: Position -> StringSource
get the source file of the specified position. Fails unless isSourcePos pos
.
posRow :: Position -> IntSource
get the line number of the specified position. Fails unless isSourcePos pos
posColumn :: Position -> IntSource
get the column of the specified position. Fails unless isSourcePos pos
position attached to built-in objects
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
Parsed entity attribute
a class for convenient access to the attributes of an attributed object
fileOfNode :: CNode a => a -> FilePathSource
nameOfNode :: NodeInfo -> Maybe NameSource
mkNodeInfoOnlyPos :: Position -> NodeInfoSource
Given only a source position, create a new attribute identifier
mkNodeInfo :: Position -> Name -> NodeInfoSource
Given a source position and a unique name, create a new attribute identifier
Extensible errors
module Language.C.Data.Error