cpphs
Copyright2000-2006 Malcolm Wallace
LicenseLGPL
MaintainerMalcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>
Stabilityexperimental
PortabilityAll
Safe HaskellNone
LanguageHaskell98

Language.Preprocessor.Cpphs

Description

Include the interface that is exported

Synopsis

Documentation

runCpphs :: CpphsOptions -> FilePath -> String -> IO String #

runCpphsPass1 :: CpphsOptions -> FilePath -> String -> IO [(Posn, String)] #

runCpphsPass2 :: BoolOptions -> [(String, String)] -> FilePath -> [(Posn, String)] -> IO String #

runCpphsReturningSymTab :: CpphsOptions -> FilePath -> String -> IO (String, [(String, String)]) #

cppIfdef #

Arguments

:: FilePath

File for error reports

-> [(String, String)]

Pre-defined symbols and their values

-> [String]

Search path for #includes

-> BoolOptions

Options controlling output style

-> String

The input file content

-> IO [(Posn, String)]

The file after processing (in lines)

Run a first pass of cpp, evaluating #ifdef's and processing #include's, whilst taking account of #define's and #undef's as we encounter them.

tokenise :: Bool -> Bool -> Bool -> Bool -> [(Posn, String)] -> [WordStyle] #

tokenise is, broadly-speaking, Prelude.words, except that: * the input is already divided into lines * each word-like "token" is categorised as one of {Ident,Other,Cmd} * #define's are parsed and returned out-of-band using the Cmd variant * All whitespace is preserved intact as tokens. * C-comments are converted to white-space (depending on first param) * Parens and commas are tokens in their own right. * Any cpp line continuations are respected. No errors can be raised. The inverse of tokenise is (concatMap deWordStyle).

data WordStyle #

Each token is classified as one of Ident, Other, or Cmd: * Ident is a word that could potentially match a macro name. * Cmd is a complete cpp directive (#define etc). * Other is anything else.

Constructors

Ident Posn String 
Other String 
Cmd (Maybe HashDefine) 

Instances

Instances details
Eq WordStyle # 
Instance details

Defined in Language.Preprocessor.Cpphs.Tokenise

Methods

(==) :: WordStyle -> WordStyle -> Bool

(/=) :: WordStyle -> WordStyle -> Bool

Show WordStyle # 
Instance details

Defined in Language.Preprocessor.Cpphs.Tokenise

Methods

showsPrec :: Int -> WordStyle -> ShowS

show :: WordStyle -> String

showList :: [WordStyle] -> ShowS

macroPass #

Arguments

:: [(String, String)]

Pre-defined symbols and their values

-> BoolOptions

Options that alter processing style

-> [(Posn, String)]

The input file content

-> IO String

The file after processing

Walk through the document, replacing calls of macros with the expanded RHS.

macroPassReturningSymTab #

Arguments

:: [(String, String)]

Pre-defined symbols and their values

-> BoolOptions

Options that alter processing style

-> [(Posn, String)]

The input file content

-> IO (String, [(String, String)])

The file and symbol table after processing

Walk through the document, replacing calls of macros with the expanded RHS. Additionally returns the active symbol table after processing.

data CpphsOptions #

Cpphs options structure.

Constructors

CpphsOptions 

Fields

Instances

Instances details
Show CpphsOptions # 
Instance details

Defined in Language.Preprocessor.Cpphs.Options

Methods

showsPrec :: Int -> CpphsOptions -> ShowS

show :: CpphsOptions -> String

showList :: [CpphsOptions] -> ShowS

data BoolOptions #

Options representable as Booleans.

Constructors

BoolOptions 

Fields

  • macros :: Bool

    Leave #define and #undef in output of ifdef?

  • locations :: Bool

    Place #line droppings in output?

  • hashline :: Bool

    Write #line or {-# LINE #-} ?

  • pragma :: Bool

    Keep #pragma in final output?

  • stripEol :: Bool

    Remove C eol (//) comments everywhere?

  • stripC89 :: Bool

    Remove C inline (/**/) comments everywhere?

  • lang :: Bool

    Lex input as Haskell code?

  • ansi :: Bool

    Permit stringise # and catenate ## operators?

  • layout :: Bool

    Retain newlines in macro expansions?

  • literate :: Bool

    Remove literate markup?

  • warnings :: Bool

    Issue warnings?

Instances

Instances details
Show BoolOptions # 
Instance details

Defined in Language.Preprocessor.Cpphs.Options

Methods

showsPrec :: Int -> BoolOptions -> ShowS

show :: BoolOptions -> String

showList :: [BoolOptions] -> ShowS

parseOptions :: [String] -> Either String CpphsOptions #

Parse all command-line options.

defaultBoolOptions :: BoolOptions #

Default settings of boolean options.