pretzel-it(1) use Pretzel to build a prettyprinter


pretzel-it [-iqvdnh] language ppname


Pretzel-it is a shell script that uses pretzel(1) to build a simple prettyprinter executable. It minimizes building a Pretzel prettyprinter to just one shell command. See pretzel(1) for a general overview and a description of the input files.

You have to provide the same two input files to pretzel-it as to pretzel. These two files are called the formatted token file (suffix .ft) and the formatted grammar file (suffix .fg). Both files need to have the same prefix language. From this input, pretzel-it generates an executable prettyprinter called ppname.


Say, you have written two files foo.ft and foo.fg that contain the prettyprinting information for your favourite programming language foo. To get an executable prettyprinter foopp for it, simply type:

pretzel-it foo foopp


Pretzel-it has the following options:
Don't remove intermediate products of pretzeling.
Run quietly.
Verbose mode, print shell commands before invoking (for debugging).
Turn prettyprinter debugging features on by default; also produce a detailed diagnosis file (suffix .output) that contains a detailed analysis of the grammar and possible problems with it (to ease debugging the prettyprinting grammar).
Print full usage message.
Noweb mode. See section Interfacing with noweb(1) below.


The generated executable will be a program that reads source code from the standard input and will write prettyprinted code to the standard output. The prettyprinted code can be typeset using latex together with the pretzel-latex document style.


Say, you have built foopp already and have a scrap of source code in a file Type

foopp < >bar.tex

and the prettyprinter will prettyprint the code and write LaTeX code to bar.tex. To use this code in your documents, simple include the pretzel-latex document style and include the file inside the new ppcode LaTeX environment. Here's a minimal LaTeX file to look at the prettyprinted code:








Using the -n option will produce a prettyprinting filter ppname compatible to Norman Ramsey's noweb(1) literate programming system. The filter can be inserted into the noweb pipeline using noweave's -filter option.

For example, you can build a noweb prettyprinting filter for Pascal by issuing

pretzel-it -n pascal prettypascal

inside the languages/pascal directory, you'll get a prettyprinting filter prettypascal . This filter then can be used within noweave(1) by saying:

noweave -filter prettypascal foo.nw > foo.tex

This will prettyprint all code chunks using the Pascal prettyprinter. You will need to include the pretzel-noweb.sty LaTeX document style after including the noweb.sty ( see nowebstyle(1) ) to get the output typeset correctly by LaTeX.

You can get debugging output from the prettyprinting filter by setting the environment variable PRETZEL_NOWEB_DEBUG to a non-null value, e.g. in the bash(1) shell by saying:


Debug output stops only when the value is explicitly unset (in bash(1) this is the unset builtin command.

The noweb option at present works only for LaTeX as target typesetter. If the prettyprinter experiences problems when prettyprinting a certain code chunk, it automatically switches to standard verbatim output of noweb. Through the inclusion of code within rules of the formatted grammar file it is possible to automate indexing. For more information see chapters 3 and 4 of the Pretzelbook, contained in the Pretzel distribution.


The pretzel-it shell script can only be run if the environment variables PRETZEL_LIBDIR and PRETZEL_INCLUDE are set to the Pretzel library directory (/usr/lib/pretzel on Debian systems) and the Pretzel include directory (/usr/include/pretzel on Debian systems). During execution, pretzel-it might issue warnings that are due to the programs it invokes (pretzel-it invokes pretzel(1), flex(1), bison(1) and the GNU C++ compiler).

The -n (noweb) option works only for LaTeX as target typesetter and is still very much experimental.


pretzel runtime library.
directory for runtime library include files.
template headers for the generated functions.
LaTeX style to typeset Pretzel output.
simple main program linked to the prettyprinter object generated by Pretzel.
simple main program linked to the prettyprinter object generated by Pretzel with debug features. /usr/lib/pretzel/nowebpretzelpp.o main program the interfaces the Preztel prettyprinter with noweb.


Felix Gaertner, email: [email protected]