HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulecpphs-1.20.9.1Haskell98

Language.Preprocessor.Cpphs

Include the interface that is exported

  • 4 types
  • 24 values
  • Packagecpphs-1.20.9.1
  • Exports28
  • LanguageHaskell98
  • LicenceLicenseRef-LGPL
  • SourceCpphs.hs
valuecppIfdef
  1. :: FilePath

    File for error reports

  2. -> [(String, String)]

    Pre-defined symbols and their values

  3. -> [String]

    Search path for #includes

  4. -> BoolOptions

    Options controlling output style

  5. -> String

    The input file content

  6. -> 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.

valuetokenise :: 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).

datadata 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

Instances2Eq, Show
  • Eq WordStyleDefined in cpphs-1.20.9.1 · Language.Preprocessor.Cpphs.Tokenise
  • Show WordStyleDefined in cpphs-1.20.9.1 · Language.Preprocessor.Cpphs.Tokenise
valuemacroPass
  1. :: [(String, String)]

    Pre-defined symbols and their values

  2. -> BoolOptions

    Options that alter processing style

  3. -> [(Posn, String)]

    The input file content

  4. -> IO String

    The file after processing

#

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

valuemacroPassReturningSymTab
  1. :: [(String, String)]

    Pre-defined symbols and their values

  2. -> BoolOptions

    Options that alter processing style

  3. -> [(Posn, String)]

    The input file content

  4. -> 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.

datadata BoolOptions
#

Options representable as Booleans.

Constructors

Instances1Show
  • Show BoolOptionsDefined in cpphs-1.20.9.1 · Language.Preprocessor.Cpphs.Options
datadata Posn
#

Source positions contain a filename, line, column, and an inclusion point, which is itself another source position, recursively.

Constructors

Instances2Eq, Show
  • Eq PosnDefined in cpphs-1.20.9.1 · Language.Preprocessor.Cpphs.Position
  • Show PosnDefined in cpphs-1.20.9.1 · Language.Preprocessor.Cpphs.Position
valuetab :: Posn -> Posn
#

Increment column number, tab stops are every 8 chars.

valuecleanPath :: FilePath -> FilePath
#

Sigh. Mixing Windows filepaths with unix is bad. Make sure there is a canonical path separator.