hpp is a Haskell pre-processor that is also a
C89/C90-compatible pre-processor (with the addition of a
--cpp flag). It is packaged as both a library and
an executable.
To use as a Haskell preprocessor for resolving #ifdef
conditionals and simple macro expansion while still
allowing multi-line string literals, an invocation might
look like,
hpp -DDEBUG Foo.hs
To use as a C preprocessor, an invocation might look
like,
hpp -DDEBUG --cpp foo.c
To have GHC use hpp as the C pre-processor, add this
line to the top of a Haskell source file that makes use
of the CPPLANGUAGE pragma.
{-# OPTIONS_GHC -cpp -pgmPhpp -optP--cpp #-}
Changes
0.3
Switch to a stream processing model.
This library is designed to have minimal dependencies, so we now have
a bespoke implementation of a cross between the pipes and machines
libraries included.
This change was done to make some parsing
operations easier, believe it or not. For example, most pre-processing
is done on a line-by-line basis, but we must also support macro
function applications that cross line boundaries. Thus the expansion
logic can not merely be given one line at a time from an input
file. Previously, a heuristic tried to combine consecutive lines
before the parsing stage. Now, the parser itself is able to pull
tokens in across lines when necessary.
TL;DR: The upshot is that processing /usr/include/stdio.h on OS X (a
surprisingly complicated file!) now uses 78% of the time and 0.38%
the memory of previous versions of hpp.