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