cpphs

What is cpphs?
How do I use it?
Downloads
Recent news
Contacts

What is cpphs?

cpphs is a simplified implementation of cpp, the C pre-processor, in Haskell.

This cut-down version of the C pre-processor is incomplete. For now, it only operates on lines beginning with a #. No attempt is made to expand symbols or parametrised macros within lines (except as required to resolve #if's).

Features that do work:

#ifdef
simple conditional compilation
#if
the full boolean language of defined(), &&, ||, ==, etc.
#elif
chained conditionals
#define
in-line definitions (symbols only, not macros)
#undef
in-line revocation of definitions
#include
file inclusion
#line
line number directives

Numbering of lines in the output is preserved so that any later processor can give meaningful error messages. When a file is #include'd, cpphs inserts #line directives for the same reason.

Any syntax errors in cpp directives, and any failure to find a #include'd file, gives a message to standard error and halts the program.

Features that don't work:

#define
parametrised macro definitions
\
especially those that extend over several lines with line continuation characters

How do I use it?

Usage: cpphs  [ filename | -Dsym | -Dsym=val | -Ipath ]+

You can give any number of filenames on the command-line. The results are catenated on standard output.

Options:

-Dsym
define a symbol
-Dsym=val
define a symbol with a specific value
-Ipath
add a directory to the search path for #include's

There are NO symbols defined by default. Could easily be changed in the source code though.

The search path is searched in order of the -I options, except that the current directory is always searched first.


Downloads

Current version: cpphs-0.1, release date 2004.04.07
By HTTP: .tar.gz, .zip.

To build cpphs, use

    hmake cpphs [-package base]
or
    ghc --make cpphs
or
    runhugs cpphs

Contacts

I am interested in hearing your feedback on cpphs. Bug reports especially welcome, since it is so new. You can send Feature requests too, but I won't guarantee to attend to them, especially if they depart from ordinary cpp's behaviour. Please mail

Copyright: © 2004 Malcolm Wallace, except for ParseLib (Copyright © 1995 Graham Hutton and Erik Meijer)

License: The library modules in cpphs are distributed under the terms of the LGPL (see file LICENSE-LGPL for more details). If that's a problem for you, contact me to make other arrangements.

The application module 'cpphs.hs' itself is trivial (since all the functionality is inside the library) and so is placed into the public domain.

This software comes with no warranty. Use at your own risk.