HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulecpphs-1.20.10Haskell2010

Language.Preprocessor.Cpphs

Include the interface that is exported

Synopsis
  • Packagecpphs-1.20.10
  • Exports28
  • LanguageHaskell2010
  • 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.10 · Language.Preprocessor.Cpphs.Tokenise
  • Show WordStyleDefined in cpphs-1.20.10 · 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.

datadata BoolOptions

Options representable as Booleans.

Constructors

Instances1Show
  • Show BoolOptionsDefined in cpphs-1.20.10 · 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.10 · Language.Preprocessor.Cpphs.Position
  • Show PosnDefined in cpphs-1.20.10 · Language.Preprocessor.Cpphs.Position