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

Copyright | (c) 2008 Benedikt Huber
License | BSD-style
Maintainer | benedikt.huber@gmail.com
Stability | alpha
Portability | ghc
Safe Haskell | None
Language | Haskell2010

Language.C.Analysis.AstAnalysis

Contents

- Top-level analysis
- Building blocks for additional analyses
- Type checking

Description

Analyse the parse tree

Traverses the AST, analyses declarations and invokes handlers.

Synopsis

- analyseAST :: MonadTrav m => CTranslUnit -> m GlobalDecls
- analyseExt :: MonadTrav m => CExtDecl -> m ()
- analyseFunDef :: MonadTrav m => CFunDef -> m ()
- 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
  - | RValue
- tStmt :: MonadTrav m => [StmtCtx] -> CStat -> m Type
- data StmtCtx
  - = FunCtx VarDecl
  - | LoopCtx
  - | SwitchCtx
- tDesignator :: MonadTrav m => Type -> [CDesignator] -> m Type
- defaultMD :: MachineDesc

# Top-level analysis

analyseAST :: MonadTrav m => CTranslUnit -> m GlobalDecls Source #

Analyse the given AST

`analyseAST ast` results in global declaration dictionaries. If you want to perform specific actions on declarations or definitions, you may provide callbacks in the `MonadTrav` `m`.

Returns the set of global declarations and definitions which where successfully translated. It is the users responsibility to check whether any hard errors occurred (`runTrav` does this for you).

analyseExt :: MonadTrav m => CExtDecl -> m () Source #

Analyse an top-level declaration

analyseFunDef :: MonadTrav m => CFunDef -> m () Source #

Analyse a function definition

analyseDecl :: MonadTrav m => Bool -> CDecl -> m () Source #

Analyse a declaration other than a function definition

Note: static assertions are not analysed

# Building blocks for additional analyses

analyseFunctionBody :: MonadTrav m => NodeInfo -> VarDecl -> CStat -> m Stmt Source #

defineParams :: MonadTrav m => NodeInfo -> VarDecl -> m () Source #

# Type checking

tExpr :: MonadTrav m => [StmtCtx] -> ExprSide -> CExpr -> m Type Source #

data ExprSide Source #

Constructors

LValue |
RValue |

#### Instances

Instances details

Show ExprSide Source # |
Instance details Defined in Language.C.Analysis.AstAnalysis Methods showsPrec :: Int -> ExprSide -> ShowS Source # show :: ExprSide -> String Source # showList :: [ExprSide] -> ShowS Source #
Eq ExprSide Source # |
Instance details Defined in Language.C.Analysis.AstAnalysis Methods (==) :: ExprSide -> ExprSide -> Bool Source # (/=) :: ExprSide -> ExprSide -> Bool Source #

tStmt :: MonadTrav m => [StmtCtx] -> CStat -> m Type Source #

Typecheck a statement, given a statement context. The type of a statement is usually `void`, but expression statements and blocks can sometimes have other types.

data StmtCtx Source #

Constructors

FunCtx VarDecl |
LoopCtx |
SwitchCtx |

tDesignator :: MonadTrav m => Type -> [CDesignator] -> m Type Source #

defaultMD :: MachineDesc Source #