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

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

Language.C.System.Preprocess

Description

Invoking external preprocessors.

Synopsis

- class Preprocessor cpp where
- data CppOption
  - = IncludeDir FilePath
  - | Define String String
  - | Undefine String
  - | IncludeFile FilePath
- data CppArgs = CppArgs {
  - cppOptions :: [CppOption]
  - extraOptions :: [String]
  - cppTmpDir :: Maybe FilePath
  - inputFile :: FilePath
  - outputFile :: Maybe FilePath
  }
- rawCppArgs :: [String] -> FilePath -> CppArgs
- addCppOption :: CppArgs -> CppOption -> CppArgs
- addExtraOption :: CppArgs -> String -> CppArgs
- cppFile :: FilePath -> CppArgs
- runPreprocessor :: Preprocessor cpp => cpp -> CppArgs -> IO (Either ExitCode InputStream)
- isPreprocessed :: FilePath -> Bool

# Documentation

class Preprocessor cpp where #

`Preprocessor` encapsulates the abstract interface for invoking C preprocessors

Minimal complete definition

parseCPPArgs, runCPP

Methods

parseCPPArgs :: cpp -> [String] -> Either String (CppArgs, [String]) #

parse the given command line arguments, and return a pair of parsed and ignored arguments

runCPP :: cpp -> CppArgs -> IO ExitCode #

run the preprocessor

Instances

Preprocessor GCC # |
Methods parseCPPArgs :: GCC -> [String] -> Either String (CppArgs, [String]) # runCPP :: GCC -> CppArgs -> IO ExitCode #

data CppOption #

Generic Options for the preprocessor

Constructors

IncludeDir FilePath |
Define String String |
Undefine String |
IncludeFile FilePath |

data CppArgs #

Generic arguments for the preprocessor

Constructors

CppArgs |
Fields cppOptions :: [CppOption] extraOptions :: [String] cppTmpDir :: Maybe FilePath inputFile :: FilePath outputFile :: Maybe FilePath

rawCppArgs :: [String] -> FilePath -> CppArgs #

use the given preprocessor arguments without analyzing them

addCppOption :: CppArgs -> CppOption -> CppArgs #

add a typed option to the given preprocessor arguments

addExtraOption :: CppArgs -> String -> CppArgs #

add a string option to the given preprocessor arguments

cppFile :: FilePath -> CppArgs #

Cpp arguments that only specify the input file name.

runPreprocessor :: Preprocessor cpp => cpp -> CppArgs -> IO (Either ExitCode InputStream) #

run the preprocessor and return an `InputStream` if preprocesssing succeeded

isPreprocessed :: FilePath -> Bool #

guess whether a file is preprocessed (file end with .i)