1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
README.
PP.MOD
PP.EXE
MOD.RES
PAS.RES
Author: Mike Piff <M.Piff@sheffield.ac.uk>
PP is a program that takes a free-standing Modula-2 or Pascal
program, and converts it into a Pretty-Printed \LaTeX/plain \TeX\ file
ready to input into your document. This is more attractive than
a verbatim listing.
Example of Usage
================
As an example, suppose we run PP on the file PP.MOD (with its header
removed), to produce PP.TEX---a file that is both a plain \TeX\ and
\LaTeX\ file:
PP
PP Copyright (C) 1992 by Mike Piff, 10/29/92 01:27pm
Input filename for reserved words
in> MOD.
Give input file: in> PP.MOD
Give output file: out> PP.TEX
Notes
=====
The source code is included in this distribution,
together with an MS-DOS executable.
As Modula-2 is case-sensitive, whereas Pascal is not,
it is necessary to inform the program which language is
being used. Two customization files MOD.RES and PAS.RES
are included. It is possible that customization files
can be built for other languages too---I haven't tried,
but please let me know if you produce any.
The current format of each customization file is
No. of keywords
optional * to indicate case-insensitive
list of keywords
The first thing the program does is prompt for the list of
keywords. After that it asks for an input file and an output
file, and that is it!
...almost. One problem with this kind of listing is that
\TeX\ has trouble breaking a program at a meaningful place,
eg, after declarations. Thus, we need to give it some clues.
A BLANK LINE in the input indicates a good breakpoint, but
DOES NOT result in blank lines in the output. However,
n>1 blank lines result in n-1 blank output lines. Thus,
space your program carefully!
Another problem is the way that Modula-2 and Pascal delimit
comments. Whereas Wirth used [ ] for sets in Pascal,
contrary to all mathematical practices, and { } or (* *)
for comments, in Modula-2 he
reserved { } for sets. Thus, the results will look better
if you use (* *) for comments in Pascal rather than
{ }. Maybe this could be added to the customization file,
but I haven't found the need yet.
To make your comments come out reasonable, assume that you
are in horizontal (text) mode inbetween (* and *). Thus,
write
(* and so $2^n\geq\log m$ *)
rather than
(* and so 2^n>= log m *)
If you want to include a bit of code inside a comment,
precede it and follow it by **. Thus
(* Or use
**
PROCEDURE xxx;FORWARD;
**
if yours is a single pass compiler *)
The output of PP is similar to that of WEB, say, but your
program is free-standing and you do not need to learn to
use WEB. Generally, horizontal spacing is respected in the
output, but you should use spaces rather than tabs for this
to work. I have used := rather than <- for assignments.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Dr M J Piff %% e-mail:
%% Department of Pure Mathematics %%
%% University of Sheffield %% M.Piff@sheffield.ac.uk
%% Hicks Building %% PM1MJP@derwent.shef.ac.uk
%% Hounsfield Road %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SHEFFIELD S3 7RH %% Telephone: (0742) 824431
%% England %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|