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

Copyright | Copyright (c) 2007 Bertram Felgenhauer (c) 2008 Benedikt Huber
License | BSD-style
Maintainer | benedikt.huber@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Language.C.Pretty

Contents

- Pretty Printing
- Testing

Description

This module provides a pretty printer for the parse tree (`AST`).

Synopsis

- class Pretty p where
- prettyUsingInclude :: CTranslUnit -> Doc

# Pretty Printing

class Pretty p where #

A class of types which can be pretty printed

Methods

pretty :: p -> Doc #

pretty print the given value

prettyPrec :: Int -> p -> Doc #

`prettyPrec prec p` pretty prints p assuming that the surrounding context has a precedence of `prec`

Instances

Pretty CUnaryOp # |
Methods pretty :: CUnaryOp -> Doc # prettyPrec :: Int -> CUnaryOp -> Doc #
Pretty CBinaryOp # |
Methods pretty :: CBinaryOp -> Doc # prettyPrec :: Int -> CBinaryOp -> Doc #
Pretty CAssignOp # |
Methods pretty :: CAssignOp -> Doc # prettyPrec :: Int -> CAssignOp -> Doc #
Pretty CStrLit # |
Methods pretty :: CStrLit -> Doc # prettyPrec :: Int -> CStrLit -> Doc #
Pretty CConst # |
Methods pretty :: CConst -> Doc # prettyPrec :: Int -> CConst -> Doc #
Pretty CBuiltin # |
Methods pretty :: CBuiltin -> Doc # prettyPrec :: Int -> CBuiltin -> Doc #
Pretty CExpr # |
Methods pretty :: CExpr -> Doc # prettyPrec :: Int -> CExpr -> Doc #
Pretty CAttr # |
Methods pretty :: CAttr -> Doc # prettyPrec :: Int -> CAttr -> Doc #
Pretty CDesignator # |
Methods pretty :: CDesignator -> Doc # prettyPrec :: Int -> CDesignator -> Doc #
Pretty CInit # |
Methods pretty :: CInit -> Doc # prettyPrec :: Int -> CInit -> Doc #
Pretty CEnum # |
Methods pretty :: CEnum -> Doc # prettyPrec :: Int -> CEnum -> Doc #
Pretty CStructTag # |
Methods pretty :: CStructTag -> Doc # prettyPrec :: Int -> CStructTag -> Doc #
Pretty CStructUnion # |
Methods pretty :: CStructUnion -> Doc # prettyPrec :: Int -> CStructUnion -> Doc #
Pretty CAlignSpec # |
Methods pretty :: CAlignSpec -> Doc # prettyPrec :: Int -> CAlignSpec -> Doc #
Pretty CFunSpec # |
Methods pretty :: CFunSpec -> Doc # prettyPrec :: Int -> CFunSpec -> Doc #
Pretty CTypeQual # |
Methods pretty :: CTypeQual -> Doc # prettyPrec :: Int -> CTypeQual -> Doc #
Pretty CTypeSpec # |
Methods pretty :: CTypeSpec -> Doc # prettyPrec :: Int -> CTypeSpec -> Doc #
Pretty CStorageSpec # |
Methods pretty :: CStorageSpec -> Doc # prettyPrec :: Int -> CStorageSpec -> Doc #
Pretty CDeclSpec # |
Methods pretty :: CDeclSpec -> Doc # prettyPrec :: Int -> CDeclSpec -> Doc #
Pretty CBlockItem # |
Methods pretty :: CBlockItem -> Doc # prettyPrec :: Int -> CBlockItem -> Doc #
Pretty CAsmOperand # |
Methods pretty :: CAsmOperand -> Doc # prettyPrec :: Int -> CAsmOperand -> Doc #
Pretty CAsmStmt # |
Methods pretty :: CAsmStmt -> Doc # prettyPrec :: Int -> CAsmStmt -> Doc #
Pretty CStat # |
Methods pretty :: CStat -> Doc # prettyPrec :: Int -> CStat -> Doc #
Pretty CArrSize # |
Methods pretty :: CArrSize -> Doc # prettyPrec :: Int -> CArrSize -> Doc #
Pretty CDeclr # |
Methods pretty :: CDeclr -> Doc # prettyPrec :: Int -> CDeclr -> Doc #
Pretty CDecl # |
Methods pretty :: CDecl -> Doc # prettyPrec :: Int -> CDecl -> Doc #
Pretty CFunDef # |
Methods pretty :: CFunDef -> Doc # prettyPrec :: Int -> CFunDef -> Doc #
Pretty CExtDecl # |
Methods pretty :: CExtDecl -> Doc # prettyPrec :: Int -> CExtDecl -> Doc #
Pretty CTranslUnit # |
Methods pretty :: CTranslUnit -> Doc # prettyPrec :: Int -> CTranslUnit -> Doc #

# Testing

prettyUsingInclude :: CTranslUnit -> Doc #

Pretty print the given tranlation unit, but replace declarations from header files with `#include` directives.

The resulting file may not compile (because of missing `#define` directives and similar things), but is very useful for testing, as otherwise the pretty printed file will be cluttered with declarations from system headers.