simple-pp documentation

simple-pp, version 1.2
Dan Wallach <dwallach@cs.rice.edu>

The distribution is available via anonymous ftp
ftp://ftp.cs.princeton.edu/pub/people/dwallach/simple-pp-1.2.tar.gz

simple-pp combines some features of cpp and NoWeb, without generating extraneous #line tags and other junk that clutter the output of cpp.

(yes, those #line directives are useful for a compiler / debugger, but they're not useful for an FAQ posting)


To see how I use simple-pp, check out "sample.xhtml". When you run make, it will create "sample" and "sample.html", in about the same way I create my Typing Injury FAQ.

The Makefile shows how you can use simple-pp in two passes. The first pass generates a temporary file with the news headers, which you don't want messed up by lynx. The second pass puts the header back together with the lynx-formatted text.


Command line options:

simple-pp [-escape char] [-define ... ] ... [-output file] [input1] [input2] ...

-escape character
Changes the "escape" character for simple-pp (default is "#")
-define symbol OR -define symbol=value
Defines a new macro
-output filename
Changes the file output (default is standard output)

Built-in statements:

#ifdef symbol
tests if symbol has been defined, and disables output if it's undefined
#ifndef symbol
tests if symbol has not been defined, and disables output if it's defined
#if expression
treats expression as a Perl expression (passing it to eval) and disabling output if the expression is false
#else and #endif
work just like cpp's statements -- you can safely build nested if/else/endif statements, and it will work fine
#include file
replaces the current line with the contents of file, continuing macro processing on the file
#define macro OR #define macro value
defines the macro to either exist, or exist with a given value
#undefine macro
undefines the macro
#output filename OR #output -
changes the output file of simple-pp to filename
The special filename "-" maps to either stdout or the value passed to the -output command line argument
##
if you put multiple escape characters together, the line is taken to be a comment, and is removed

Pre-defined macros:

_line_
line number in the current input file
_file_
current input file name
_level_
recursion level of #include statements (it starts at 1, then increases)

Macros are used by typing #MACRO_NAME# which is then replaced by the value of the macro.


Dan Wallach, CS Department, Rice University