nl.c becomes common with pi/pc0.
[unix-history] / usr / src / usr.bin / pascal / pxp / 0.h
CommitLineData
8e0d201e 1/* static char *sccsid = "@(#)0.h 1.4 (Berkeley) %G%";*/
5912a8dc
PK
2/* Copyright (c) 1979 Regents of the University of California */
3/* #define DEBUG */
4#define CHAR
5#define STATIC
6/*
7 * pxp - Pascal execution profiler
8 *
9 * Bill Joy
10 * University of California, Berkeley (UCB)
11 * Version 1.1 February 1978
12 */
13
14/*
15 * Option flags
16 *
17 * The following options are recognized on the command line by pxp.
18 * Only the u, w, and z options here have effect in comments in the
19 * program; the others are command line only, and unrelated
20 * to the options with the same designations in comments.
21 *
22 * a Print all routines in a profile; normally, routines
23 * which have never been executed have their bodies suppressed.
24 *
25 * c Extract profile data from the file core, or the file
26 * named after the last argument rather than the file 'pmon.out'.
27 * Must be used with z to have an effect.
28 *
29 * d Suppress declarations
30 *
31 * f Fully parenthesize expressions.
32 *
33 * j Left justify all procedures and functions rather than
34 * indenting them.
35 *
36 * n Eject a new page in the listing as each 'include' file
37 * is incorporated into the profile.
38 *
39 * o Put output prettyprint in first argument file
40 *
41 * p Pretty print a main program without processing
42 * the include statements.
43 *
44 * t Print a table summarizing procedure and function call counts.
45 *
46 * u Card image mode; only the first 72 chars on a line count.
47 *
48 * w Suppress certain warning diagnostics.
49 *
50 * z Generate an execution profile of the program.
51 * May also be followed by a list of procedure and function
52 * names mixed, if desired, with include file names.
53 * Only these procedures and functions, and the contents
54 * of the specified include files will then be profiled.
55 *
56 * [23456789] Use the specified number of spaces for the basic
57 * indenting unit in the program.
58 *
59 * _ Underline keywords in the output.
8e0d201e
PK
60 *
61 * O remove `others'. if an `others' label is found in a
62 * case statement the case statement (minus the others case)
63 * is printed as a guarded case statement, and the others case
64 * is the else branch of the guard. this transformation
65 * causes the case selector to be evaluated twice, a lose
66 * if the selector has side-effects. this option is only
67 * available if pxp is compiled with RMOTHERS defined.
5912a8dc
PK
68 */
69
70char all, core, nodecl, full, justify, pmain, stripcomm, table, underline;
71char profile, onefile;
8e0d201e
PK
72#ifdef RMOTHERS
73char rmothers;
74#endif RMOTHERS
5912a8dc
PK
75char *firstname, *stdoutn;
76#ifdef DEBUG
77char fulltrace, errtrace, testtrace, yyunique, typetest;
78#endif
79int unit;
80
81/*
82 * The flag nojunk means that header lines
83 * of procedures and functions are to be suppressed
84 * when the z option is off.
85 * It is the default when command line z option
86 * control is specified.
87 *
88 * The flag noinclude indicates that include statements are not
89 * to be processed since we are pretty-printing the contents
90 * of a single file.
91 *
92 * The flag bracket indicates that the source code should be
93 * bracketed with lines of the form
94 * program x(output);
95 * and
96 * begin end.
97 * so that an include will pretty print without syntax errors.
98 */
99char nojunk, noinclude, bracket;
100
101/*
102 * IMPORTANT NOTE
103 *
104 * Many of the following globals are shared by pi and pxp.
105 * For more discussion of these see the available documentation
106 * on the structure of pi.
107 */
108
109/*
110 * Each option has a stack of 17 option values, with opts giving
111 * the current, top value, and optstk the value beneath it.
112 * One refers to option `l' as, e.g., opt('l') in the text for clarity.
113 */
114char opts[26];
115int optstk[26];
116
117#define opt(c) opts[c-'a']
118\f
119/*
120 * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
121 *
122 * Pxp uses expandable tables for its string table
123 * hash table, and parse tree space. The following
124 * definitions specify the size of the increments
125 * for these items in fundamental units so that
126 * each uses approximately 1024 bytes.
127 */
128
129#define STRINC 1024 /* string space increment */
130#define TRINC 512 /* tree space increment */
131#define HASHINC 509 /* hash table size in words, each increment */
132
133/*
134 * The initial sizes of the structures.
135 * These should be large enough to profile
136 * an "average" sized program so as to minimize
137 * storage requests.
138 * On a small system or and 11/34 or 11/40
139 * these numbers can be trimmed to make the
140 * profiler smaller.
141 */
142#define ITREE 2000
143#define IHASH 509
144
145/*
146 * The following limits on hash and tree tables currently
147 * allow approximately 1200 symbols and 20k words of tree
148 * space. The fundamental limit of 64k total data space
149 * should be exceeded well before these are full.
150 */
151#define MAXHASH 4
152#define MAXTREE 30
153#define MAXDEPTH 150
154\f
155/*
156 * ERROR RELATED DEFINITIONS
157 */
158
159/*
160 * Exit statuses to pexit
161 *
162 * AOK
163 * ERRS Compilation errors inhibit obj productin
164 * NOSTART Errors before we ever got started
165 * DIED We ran out of memory or some such
166 */
167#define AOK 0
168#define ERRS 1
169#define NOSTART 2
170#define DIED 3
171
172char Recovery;
173/*
174 * The flag eflg is set whenever we have a hard error.
175 * The character in errpfx will precede the next error message.
176 */
177int eflg;
178char errpfx;
179
180#define setpfx(x) errpfx = x
181
182#define standard() setpfx('s')
183#define warning() setpfx('w')
184#define recovered() setpfx('e')
185#define quit() setpfx('Q')
289fd223 186#define continuation() setpfx(' ')
5912a8dc
PK
187\f
188/*
189 * SEMANTIC DEFINITIONS
190 */
191
192#define NIL 0
193
194/*
195 * NOCON and SAWCON are flags in the tree telling whether
196 * a constant set is part of an expression.
197 */
198#define NOCON 0
199#define SAWCON 1
200
201/*
202 * The variable cbn gives the current block number.
203 * The variable lastbn gives the block number before
204 * it last changed and is used to know that we were
205 * in a nested procedure so that we can print
206 * begin { solve }
207 * when solve has nested procedures or functions in it.
208 */
209int cbn, lastbn;
210
211/*
212 * The variable line is the current semantic
213 * line and is set in stat.c from the numbers
214 * embedded in statement type tree nodes.
215 */
216int line;
217
218/*
219 * The size of the display
220 * which defines the maximum nesting
221 * of procedures and functions allowed.
222 */
223#define DSPLYSZ 20
224\f
225/*
226 * Routines which need types
227 * other than "integer" to be
228 * assumed by the compiler.
229 */
230int *tree();
231int *hash();
232char *alloc();
233long cntof();
234long nowcnt();
235
236/*
237 * Funny structures to use
238 * pointers in wild and wooly ways
239 */
240struct {
241 char pchar;
242};
243struct {
244 int pint;
245 int pint2;
246};
247struct {
248 long plong;
249};
250struct {
251 double pdouble;
252};
253
254#define OCT 1
255#define HEX 2
256\f
257/*
258 * MAIN PROGRAM GLOBALS, MISCELLANY
259 */
260
261/*
262 * Variables forming a data base referencing
263 * the command line arguments with the "z" option.
264 */
265char **pflist;
266int pflstc;
267int pfcnt;
268
269char *filename; /* current source file name */
270char *lastname; /* last file name printed */
271long tvec; /* mod time of the source file */
272long ptvec; /* time profiled */
273char printed; /* current file has been printed */
274char hadsome; /* had some output */
275\f
276/*
277 * PROFILING AND FORMATTING DEFINITIONS
278 */
279
280/*
281 * The basic counter information recording structure.
282 * This is global only because people outside
283 * the cluster in pmon.c need to know its size.
284 */
285struct pxcnt {
286 long ntimes; /* the count this structure is all about */
287 int counter; /* a unique counter number for us */
288 int gos; /* global goto count when we hatched */
289 int printed; /* are we considered to have been printed? */
290} pfcnts[DSPLYSZ];
291
292/*
293 * The pieces we divide the output line indents into:
294 * line# PRFN label: STAT 999.---| DECL text
295 */
296#define STAT 0
297#define DECL 1
298#define PRFN 2
299
300/*
301 * Gocnt records the total number of goto's and
302 * cnts records the current counter for generating
303 * COUNT operators.
304 */
305int gocnt;
306int cnts;
307
308#include <stdio.h>
309
88b1f2d9
KM
310typedef enum {FALSE, TRUE} bool;
311
5912a8dc 312#undef putchar