xref: /csrg-svn/usr.bin/pascal/src/0.h (revision 10658)
1733Speter /* Copyright (c) 1979 Regents of the University of California */
2733Speter 
3*10658Speter /* static char sccsid[] = "@(#)0.h 1.18 02/01/83"; */
4733Speter 
5733Speter #define DEBUG
63071Smckusic #define CONSETS
7733Speter #define	CHAR
8733Speter #define	STATIC
9733Speter #define hp21mx 0
10733Speter 
11733Speter #include	<stdio.h>
12733Speter #include	<sys/types.h>
13733Speter 
143071Smckusic typedef enum {FALSE, TRUE} bool;
15733Speter 
16733Speter /*
17733Speter  * Option flags
18733Speter  *
19733Speter  * The following options are recognized in the text of the program
20733Speter  * and also on the command line:
21733Speter  *
22733Speter  *	b	block buffer the file output
23733Speter  *
24733Speter  *	i	make a listing of the procedures and functions in
25733Speter  *		the following include files
26733Speter  *
27733Speter  *	l	make a listing of the program
28733Speter  *
29733Speter  *	n	place each include file on a new page with a header
30733Speter  *
31733Speter  *	p	disable post mortem and statement limit counting
32733Speter  *
33733Speter  *	t	disable run-time tests
34733Speter  *
35733Speter  *	u	card image mode; only first 72 chars of input count
36733Speter  *
37733Speter  *	w	suppress special diagnostic warnings
38733Speter  *
39733Speter  *	z	generate counters for an execution profile
40733Speter  */
41733Speter #ifdef DEBUG
42733Speter bool	fulltrace, errtrace, testtrace, yyunique;
43733Speter #endif DEBUG
44733Speter 
45733Speter /*
46733Speter  * Each option has a stack of 17 option values, with opts giving
47733Speter  * the current, top value, and optstk the value beneath it.
48733Speter  * One refers to option `l' as, e.g., opt('l') in the text for clarity.
49733Speter  */
50733Speter char	opts[ 'z' - 'A' + 1];
51733Speter short	optstk[ 'z' - 'A' + 1];
52733Speter 
53733Speter #define opt(c) opts[c-'A']
54733Speter 
55733Speter /*
56733Speter  * Monflg is set when we are generating
57733Speter  * a pxp profile.  this is set by the -z command line option.
58733Speter  */
59733Speter bool	monflg;
60733Speter 
61733Speter     /*
62733Speter      *	profflag is set when we are generating a prof profile.
63733Speter      *	this is set by the -p command line option.
64733Speter      */
65733Speter bool	profflag;
66733Speter 
67733Speter 
68733Speter /*
69733Speter  * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
70733Speter  *
71733Speter  * Pi uses expandable tables for
72733Speter  * its namelist (symbol table), string table
73733Speter  * hash table, and parse tree space.  The following
74733Speter  * definitions specify the size of the increments
75733Speter  * for these items in fundamental units so that
76733Speter  * each uses approximately 1024 bytes.
77733Speter  */
78733Speter 
79733Speter #define	STRINC	1024		/* string space increment */
80733Speter #define	TRINC	512		/* tree space increment */
81733Speter #define	HASHINC	509		/* hash table size in words, each increment */
82733Speter #define	NLINC	56		/* namelist increment size in nl structs */
83733Speter 
84733Speter /*
85733Speter  * The initial sizes of the structures.
86733Speter  * These should be large enough to compile
87733Speter  * an "average" sized program so as to minimize
88733Speter  * storage requests.
89733Speter  * On a small system or and 11/34 or 11/40
90733Speter  * these numbers can be trimmed to make the
91733Speter  * compiler smaller.
92733Speter  */
93733Speter #define	ITREE	2000
94733Speter #define	INL	200
95733Speter #define	IHASH	509
96733Speter 
97733Speter /*
98733Speter  * The following limits on hash and tree tables currently
99733Speter  * allow approximately 1200 symbols and 20k words of tree
100733Speter  * space.  The fundamental limit of 64k total data space
101733Speter  * should be exceeded well before these are full.
102733Speter  */
103733Speter /*
104733Speter  * TABLE_MULTIPLIER is for uniformly increasing the sizes of the tables
105733Speter  */
106*10658Speter #ifdef ADDR32
107733Speter #define TABLE_MULTIPLIER	8
108*10658Speter #endif ADDR32
109*10658Speter #ifdef ADDR16
1103071Smckusic #define TABLE_MULTIPLIER	1
111*10658Speter #endif ADDR16
112733Speter #define	MAXHASH	(4 * TABLE_MULTIPLIER)
113733Speter #define	MAXNL	(12 * TABLE_MULTIPLIER)
114733Speter #define	MAXTREE	(30 * TABLE_MULTIPLIER)
115733Speter /*
116733Speter  * MAXDEPTH is the depth of the parse stack.
117733Speter  * STACK_MULTIPLIER is for increasing its size.
118733Speter  */
119*10658Speter #ifdef ADDR32
120733Speter #define	STACK_MULTIPLIER	8
121*10658Speter #endif ADDR32
122*10658Speter #ifdef ADDR16
1233071Smckusic #define	STACK_MULTIPLIER	1
124*10658Speter #endif ADDR16
125733Speter #define	MAXDEPTH ( 150 * STACK_MULTIPLIER )
126733Speter 
127733Speter /*
128733Speter  * ERROR RELATED DEFINITIONS
129733Speter  */
130733Speter 
131733Speter /*
132733Speter  * Exit statuses to pexit
133733Speter  *
134733Speter  * AOK
135733Speter  * ERRS		Compilation errors inhibit obj productin
136733Speter  * NOSTART	Errors before we ever got started
137733Speter  * DIED		We ran out of memory or some such
138733Speter  */
139733Speter #define	AOK	0
140733Speter #define	ERRS	1
141733Speter #define	NOSTART	2
142733Speter #define	DIED	3
143733Speter 
144733Speter bool	Recovery;
145733Speter 
146733Speter #define	eholdnl()	Eholdnl = 1
147733Speter #define	nocascade()	Enocascade = 1
148733Speter 
149733Speter bool	Eholdnl, Enocascade;
150733Speter 
151733Speter 
152733Speter /*
153733Speter  * The flag eflg is set whenever we have a hard error.
154733Speter  * The character in errpfx will precede the next error message.
155733Speter  * When cgenflg is set code generation is suppressed.
156733Speter  * This happens whenver we have an error (i.e. if eflg is set)
157733Speter  * and when we are walking the tree to determine types only.
158733Speter  */
159733Speter bool	eflg;
160733Speter char	errpfx;
161733Speter 
162733Speter #define	setpfx(x)	errpfx = x
163733Speter 
164733Speter #define	standard()	setpfx('s')
165733Speter #define	warning()	setpfx('w')
166733Speter #define	recovered()	setpfx('e')
1676358Speter #define	continuation()	setpfx(' ')
168733Speter 
1693071Smckusic int	cgenflg;
170733Speter 
171733Speter 
172733Speter /*
173733Speter  * The flag syneflg is used to suppress the diagnostics of the form
174733Speter  *	E 10 a, defined in someprocedure, is neither used nor set
175733Speter  * when there were syntax errors in "someprocedure".
176733Speter  * In this case, it is likely that these warinings would be spurious.
177733Speter  */
178733Speter bool	syneflg;
179733Speter 
180733Speter /*
181733Speter  * The compiler keeps its error messages in a file.
182733Speter  * The variable efil is the unit number on which
183733Speter  * this file is open for reading of error message text.
184733Speter  * Similarly, the file ofil is the unit of the file
185733Speter  * "obj" where we write the interpreter code.
186733Speter  */
187733Speter short	efil;
188733Speter short	ofil;
189733Speter short	obuf[518];
190733Speter 
1913071Smckusic bool	Enoline;
1923071Smckusic #define	elineoff()	Enoline = TRUE
1933071Smckusic #define	elineon()	Enoline = FALSE
194733Speter 
195733Speter 
196733Speter /*
197733Speter  * SYMBOL TABLE STRUCTURE DEFINITIONS
198733Speter  *
199733Speter  * The symbol table is henceforth referred to as the "namelist".
200733Speter  * It consists of a number of structures of the form "nl" below.
201733Speter  * These are contained in a number of segments of the symbol
202733Speter  * table which are dynamically allocated as needed.
203733Speter  * The major namelist manipulation routines are contained in the
204733Speter  * file "nl.c".
205733Speter  *
206733Speter  * The major components of a namelist entry are the "symbol", giving
207733Speter  * a pointer into the string table for the string associated with this
208733Speter  * entry and the "class" which tells which of the (currently 19)
209733Speter  * possible types of structure this is.
210733Speter  *
211733Speter  * Many of the classes use the "type" field for a pointer to the type
212733Speter  * which the entry has.
213733Speter  *
214733Speter  * Other pieces of information in more than one class include the block
215733Speter  * in which the symbol is defined, flags indicating whether the symbol
216733Speter  * has been used and whether it has been assigned to, etc.
217733Speter  *
218733Speter  * A more complete discussion of the features of the namelist is impossible
219733Speter  * here as it would be too voluminous.  Refer to the "PI 1.0 Implementation
220733Speter  * Notes" for more details.
221733Speter  */
222733Speter 
223733Speter /*
224733Speter  * The basic namelist structure.
2257915Smckusick  * There is a union of data types defining the stored information
2267915Smckusick  * as pointers, integers, longs, or a double.
227733Speter  *
228733Speter  * The array disptab defines the hash header for the symbol table.
229733Speter  * Symbols are hashed based on the low 6 bits of their pointer into
230733Speter  * the string table; see the routines in the file "lookup.c" and also "fdec.c"
231733Speter  * especially "funcend".
232733Speter  */
2333220Smckusic extern int	pnumcnt;
2343220Smckusic 
235733Speter #ifdef PTREE
236733Speter #   include	"pTree.h"
237733Speter #endif PTREE
238733Speter struct	nl {
239733Speter 	char	*symbol;
2407915Smckusick 	char	info[4];
241733Speter 	struct	nl *type;
242733Speter 	struct	nl *chain, *nl_next;
2437915Smckusick 	union {
2447915Smckusick 		int	*un_ptr[5];
2457915Smckusick 		int	un_value[5];
2467915Smckusick 		long	un_range[2];
2477915Smckusick 		double	un_real;
2487915Smckusick 	} nl_un;
249733Speter #	ifdef PTREE
250733Speter 	    pPointer	inTree;
251733Speter #	endif PTREE
2527915Smckusick };
253733Speter 
2548680Speter #define class		info[0]
2558680Speter #define nl_flags	info[1]
2568680Speter #define nl_block	info[1]
2578680Speter #define extra_flags	info[2]
2588680Speter #define align_info	info[3]
259733Speter 
2608680Speter #define range	nl_un.un_range
2618680Speter #define value	nl_un.un_value
2628680Speter #define ptr	nl_un.un_ptr
2638680Speter #define real	nl_un.un_real
264733Speter 
2657915Smckusick extern struct nl *nlp, *disptab[077+1], *Fp;
2667915Smckusick extern struct nl nl[INL];
267733Speter 
2683370Speter 
269733Speter /*
270733Speter  * NL FLAGS BITS
271733Speter  *
272733Speter  * Definitions of the usage of the bits in
273733Speter  * the nl_flags byte. Note that the low 5 bits of the
274733Speter  * byte are the "nl_block" and that some classes make use
275733Speter  * of this byte as a "width".
276733Speter  *
277733Speter  * The only non-obvious bit definition here is "NFILES"
278733Speter  * which records whether a structure contains any files.
279733Speter  * Such structures are not allowed to be dynamically allocated.
280733Speter  */
2813370Speter 
2823370Speter #define	BLOCKNO( flag )	( flag & 037 )
2833370Speter #define NLFLAGS( flag ) ( flag &~ 037 )
2843370Speter 
285733Speter #define	NUSED	0100
286733Speter #define	NMOD	0040
287733Speter #define	NFORWD	0200
288733Speter #define	NFILES	0200
289733Speter #ifdef PC
290733Speter #define NEXTERN 0001	/* flag used to mark external funcs and procs */
2913823Speter #define	NLOCAL	0002	/* variable is a local */
2923823Speter #define	NPARAM	0004	/* variable is a parameter */
2933823Speter #define	NGLOBAL	0010	/* variable is a global */
2943823Speter #define	NREGVAR	0020	/* or'ed in if variable is in a register */
2959126Smckusick #define NNLOCAL 0040	/* named local variable, not used in symbol table */
2963823Speter #endif PC
2973370Speter 
2983540Speter /*
2993540Speter  * used to mark value[ NL_FORV ] for loop variables
3003540Speter  */
3013540Speter #define	FORVAR		1
302733Speter 
303733Speter /*
304733Speter  * Definition of the commonly used "value" fields.
305733Speter  * The most important one is NL_OFFS which gives
306733Speter  * the offset of a variable in its stack mark.
307733Speter  */
308733Speter #define NL_OFFS	0
309733Speter 
310733Speter #define	NL_CNTR	1
3113296Smckusic #define NL_NLSTRT 2
3123296Smckusic #define	NL_LINENO 3
313733Speter #define	NL_FVAR	3
3147915Smckusick #define	NL_ENTLOC 4	/* FUNC, PROC - entry point */
3157915Smckusick #define	NL_FCHAIN 4	/* FFUNC, FPROC - ptr to formals */
316733Speter 
317733Speter #define NL_GOLEV 2
318733Speter #define NL_GOLINE 3
319733Speter #define NL_FORV 1
320733Speter 
3218680Speter     /*
3228680Speter      *	nlp -> nl_un.un_ptr[] subscripts for records
3238680Speter      *	NL_FIELDLIST	the chain of fixed fields of a record, in order.
3248680Speter      *			the fields are also chained through ptr[NL_FIELDLIST].
3258680Speter      *			this does not include the tag, or fields of variants.
3268680Speter      *	NL_VARNT	pointer to the variants of a record,
3278680Speter      *			these are then chained through the .chain field.
3288680Speter      *	NL_VTOREC	pointer from a VARNT to the RECORD that is the variant.
3298680Speter      *	NL_TAG		pointer from a RECORD to the tagfield
3308680Speter      *			if there are any variants.
3318680Speter      *	align_info	the alignment of a RECORD is in info[3].
3328680Speter      */
3338680Speter #define	NL_FIELDLIST	1
3348680Speter #define	NL_VARNT	2
3358680Speter #define	NL_VTOREC	2
3368680Speter #define	NL_TAG		3
3378680Speter /* and align_info is info[3].  #defined above */
338733Speter 
3397915Smckusick #define	NL_ELABEL 4	/* SCAL - ptr to definition of enums */
340733Speter 
341733Speter /*
342733Speter  * For BADUSE nl structures, NL_KINDS is a bit vector
343733Speter  * indicating the kinds of illegal usages complained about
344733Speter  * so far.  For kind of bad use "kind", "1 << kind" is set.
345733Speter  * The low bit is reserved as ISUNDEF to indicate whether
346733Speter  * this identifier is totally undefined.
347733Speter  */
348733Speter #define	NL_KINDS	0
349733Speter 
350733Speter #define	ISUNDEF		1
3513275Smckusic 
3523823Speter     /*
3533823Speter      *	variables come in three flavors: globals, parameters, locals;
3543823Speter      *	they can also hide in registers, but that's a different flag
3553823Speter      */
3563275Smckusic #define PARAMVAR	1
3573275Smckusic #define LOCALVAR	2
3583823Speter #define	GLOBALVAR	3
3599126Smckusick #define	NAMEDLOCALVAR	4
360733Speter 
361733Speter /*
362733Speter  * NAMELIST CLASSES
363733Speter  *
364733Speter  * The following are the namelist classes.
365733Speter  * Different classes make use of the value fields
366733Speter  * of the namelist in different ways.
367733Speter  *
368733Speter  * The namelist should be redesigned by providing
369733Speter  * a number of structure definitions with one corresponding
370733Speter  * to each namelist class, ala a variant record in Pascal.
371733Speter  */
372733Speter #define	BADUSE	0
373733Speter #define	CONST	1
374733Speter #define	TYPE	2
375733Speter #define	VAR	3
376733Speter #define	ARRAY	4
377733Speter #define	PTRFILE	5
378733Speter #define	RECORD	6
379733Speter #define	FIELD	7
380733Speter #define	PROC	8
381733Speter #define	FUNC	9
382733Speter #define	FVAR	10
383733Speter #define	REF	11
384733Speter #define	PTR	12
385733Speter #define	FILET	13
386733Speter #define	SET	14
387733Speter #define	RANGE	15
388733Speter #define	LABEL	16
389733Speter #define	WITHPTR 17
390733Speter #define	SCAL	18
391733Speter #define	STR	19
392733Speter #define	PROG	20
393733Speter #define	IMPROPER 21
394733Speter #define	VARNT	22
3951194Speter #define	FPROC	23
3961194Speter #define	FFUNC	24
397733Speter 
398733Speter /*
399733Speter  * Clnames points to an array of names for the
400733Speter  * namelist classes.
401733Speter  */
402733Speter char	**clnames;
403733Speter 
404733Speter /*
405733Speter  * PRE-DEFINED NAMELIST OFFSETS
406733Speter  *
407733Speter  * The following are the namelist offsets for the
408733Speter  * primitive types. The ones which are negative
409733Speter  * don't actually exist, but are generated and tested
410733Speter  * internally. These definitions are sensitive to the
411733Speter  * initializations in nl.c.
412733Speter  */
413733Speter #define	TFIRST -7
414733Speter #define	TFILE  -7
415733Speter #define	TREC   -6
416733Speter #define	TARY   -5
417733Speter #define	TSCAL  -4
418733Speter #define	TPTR   -3
419733Speter #define	TSET   -2
420733Speter #define	TSTR   -1
421733Speter #define	NIL	0
422733Speter #define	TBOOL	1
423733Speter #define	TCHAR	2
424733Speter #define	TINT	3
425733Speter #define	TDOUBLE	4
426733Speter #define	TNIL	5
427733Speter #define	T1INT	6
428733Speter #define	T2INT	7
429733Speter #define	T4INT	8
430733Speter #define	T1CHAR	9
431733Speter #define	T1BOOL	10
432733Speter #define	T8REAL	11
433733Speter #define TLAST	11
434733Speter 
435733Speter /*
436733Speter  * SEMANTIC DEFINITIONS
437733Speter  */
438733Speter 
439733Speter /*
440733Speter  * NOCON and SAWCON are flags in the tree telling whether
441733Speter  * a constant set is part of an expression.
4423314Speter  *	these are no longer used,
4433314Speter  *	since we now do constant sets at compile time.
444733Speter  */
445733Speter #define NOCON	0
446733Speter #define SAWCON	1
447733Speter 
448733Speter /*
449733Speter  * The variable cbn gives the current block number,
450733Speter  * the variable bn is set as a side effect of a call to
451733Speter  * lookup, and is the block number of the variable which
452733Speter  * was found.
453733Speter  */
454733Speter short	bn, cbn;
455733Speter 
456733Speter /*
457733Speter  * The variable line is the current semantic
458733Speter  * line and is set in stat.c from the numbers
459733Speter  * embedded in statement type tree nodes.
460733Speter  */
461733Speter short	line;
462733Speter 
463733Speter /*
464733Speter  * The size of the display
465733Speter  * which defines the maximum nesting
466733Speter  * of procedures and functions allowed.
467733Speter  * Because of the flags in the current namelist
468733Speter  * this must be no greater than 32.
469733Speter  */
470733Speter #define	DSPLYSZ 20
471733Speter 
472733Speter /*
473733Speter  * The following structure is used
474733Speter  * to keep track of the amount of variable
475733Speter  * storage required by each block.
476733Speter  * "Max" is the high water mark, "off"
477733Speter  * the current need. Temporaries for "for"
478733Speter  * loops and "with" statements are allocated
479733Speter  * in the local variable area and these
480733Speter  * numbers are thereby changed if necessary.
481733Speter  */
482733Speter struct om {
483733Speter 	long	om_max;
4843220Smckusic 	long	reg_max;
4853220Smckusic 	struct tmps {
4863220Smckusic 		long	om_off;
4873220Smckusic 		long	reg_off;
4883220Smckusic 	} curtmps;
489733Speter } sizes[DSPLYSZ];
4903220Smckusic #define NOREG 0
4913220Smckusic #define REGOK 1
492733Speter 
493733Speter     /*
494733Speter      *	the following structure records whether a level declares
495733Speter      *	any variables which are (or contain) files.
496733Speter      *	this so that the runtime routines for file cleanup can be invoked.
497733Speter      */
498733Speter bool	dfiles[ DSPLYSZ ];
499733Speter 
500733Speter /*
501733Speter  * Structure recording information about a constant
502733Speter  * declaration.  It is actually the return value from
503733Speter  * the routine "gconst", but since C doesn't support
504733Speter  * record valued functions, this is more convenient.
505733Speter  */
506733Speter struct {
507733Speter 	struct nl	*ctype;
508733Speter 	short		cival;
509733Speter 	double		crval;
510733Speter 	int		*cpval;
511733Speter } con;
512733Speter 
513733Speter /*
514733Speter  * The set structure records the lower bound
515733Speter  * and upper bound with the lower bound normalized
516733Speter  * to zero when working with a set. It is set by
517733Speter  * the routine setran in var.c.
518733Speter  */
519733Speter struct {
520733Speter 	short	lwrb, uprbp;
521733Speter } set;
522733Speter 
523733Speter     /*
524733Speter      *	structures of this kind are filled in by precset and used by postcset
525733Speter      *	to indicate things about constant sets.
526733Speter      */
527733Speter struct csetstr {
528733Speter     struct nl	*csettype;
529733Speter     long	paircnt;
530733Speter     long	singcnt;
531733Speter     bool	comptime;
532733Speter };
533733Speter /*
534733Speter  * The following flags are passed on calls to lvalue
535733Speter  * to indicate how the reference is to affect the usage
536733Speter  * information for the variable being referenced.
537733Speter  * MOD is used to set the NMOD flag in the namelist
538733Speter  * entry for the variable, ASGN permits diagnostics
539733Speter  * to be formed when a for variable is assigned to in
540733Speter  * the range of the loop.
541733Speter  */
542733Speter #define	NOFLAGS	0
543733Speter #define	MOD	01
544733Speter #define	ASGN	02
545733Speter #define	NOUSE	04
546733Speter 
547733Speter     /*
548733Speter      *	the following flags are passed to lvalue and rvalue
549733Speter      *	to tell them whether an lvalue or rvalue is required.
550733Speter      *	the semantics checking is done according to the function called,
551733Speter      *	but for pc, lvalue may put out an rvalue by indirecting afterwards,
552733Speter      *	and rvalue may stop short of putting out the indirection.
553733Speter      */
554733Speter #define	LREQ	01
555733Speter #define	RREQ	02
556733Speter 
557733Speter double	MAXINT;
558733Speter double	MININT;
559733Speter 
560733Speter /*
561733Speter  * Variables for generation of profile information.
562733Speter  * Monflg is set when we want to generate a profile.
563733Speter  * Gocnt record the total number of goto's and
564733Speter  * cnts records the current counter for generating
565733Speter  * COUNT operators.
566733Speter  */
567733Speter short	gocnt;
568733Speter short	cnts;
569733Speter 
570733Speter /*
571733Speter  * Most routines call "incompat" rather than asking "!compat"
572733Speter  * for historical reasons.
573733Speter  */
574733Speter #define incompat 	!compat
575733Speter 
576733Speter /*
577733Speter  * Parts records which declaration parts have been seen.
578833Speter  * The grammar allows the "label" "const" "type" "var" and routine
579733Speter  * parts to be repeated and to be in any order, so that
580733Speter  * they can be detected semantically to give better
581733Speter  * error diagnostics.
5829126Smckusick  *
5839126Smckusick  * The flag NONLOCALVAR indicates that a non-local var has actually
5849126Smckusick  * been used hence the display must be saved; NONLOCALGOTO indicates
5859126Smckusick  * that a non-local goto has been done hence that a setjmp must be done.
586733Speter  */
587833Speter int	parts[ DSPLYSZ ];
588733Speter 
5899126Smckusick #define	LPRT		0x0001
5909126Smckusick #define	CPRT		0x0002
5919126Smckusick #define	TPRT		0x0004
5929126Smckusick #define	VPRT		0x0008
5939126Smckusick #define	RPRT		0x0010
594733Speter 
5959126Smckusick #define	NONLOCALVAR	0x0020
5969126Smckusick #define	NONLOCALGOTO	0x0040
5979126Smckusick 
598733Speter /*
599733Speter  * Flags for the "you used / instead of div" diagnostic
600733Speter  */
601733Speter bool	divchk;
602733Speter bool	divflg;
603733Speter 
6043071Smckusic bool	errcnt[DSPLYSZ];
605733Speter 
606733Speter /*
607733Speter  * Forechain links those types which are
608733Speter  *	^ sometype
609733Speter  * so that they can be evaluated later, permitting
610733Speter  * circular, recursive list structures to be defined.
611733Speter  */
612733Speter struct	nl *forechain;
613733Speter 
614733Speter /*
615733Speter  * Withlist links all the records which are currently
616733Speter  * opened scopes because of with statements.
617733Speter  */
618733Speter struct	nl *withlist;
619733Speter 
620733Speter struct	nl *intset;
621733Speter struct	nl *input, *output;
622733Speter struct	nl *program;
623733Speter 
624733Speter /* progseen flag used by PC to determine if
625733Speter  * a routine segment is being compiled (and
626733Speter  * therefore no program statement seen)
627733Speter  */
628733Speter bool	progseen;
629733Speter 
630733Speter 
631733Speter /*
632733Speter  * STRUCTURED STATEMENT GOTO CHECKING
633733Speter  *
634733Speter  * The variable level keeps track of the current
635733Speter  * "structured statement level" when processing the statement
636733Speter  * body of blocks.  This is used in the detection of goto's into
637733Speter  * structured statements in a block.
638733Speter  *
639733Speter  * Each label's namelist entry contains two pieces of information
640733Speter  * related to this check. The first `NL_GOLEV' either contains
641733Speter  * the level at which the label was declared, `NOTYET' if the label
642733Speter  * has not yet been declared, or `DEAD' if the label is dead, i.e.
643733Speter  * if we have exited the level in which the label was defined.
644733Speter  *
645733Speter  * When we discover a "goto" statement, if the label has not
646733Speter  * been defined yet, then we record the current level and the current line
647733Speter  * for a later error check.  If the label has been already become "DEAD"
648733Speter  * then a reference to it is an error.  Now the compiler maintains,
649733Speter  * for each block, a linked list of the labels headed by "gotos[bn]".
650733Speter  * When we exit a structured level, we perform the routine
651733Speter  * ungoto in stat.c. It notices labels whose definition levels have been
652733Speter  * exited and makes them be dead. For labels which have not yet been
653733Speter  * defined, ungoto will maintain NL_GOLEV as the minimum structured level
654733Speter  * since the first usage of the label. It is not hard to see that the label
655733Speter  * must eventually be declared at this level or an outer level to this
656733Speter  * one or a goto into a structured statement will exist.
657733Speter  */
658733Speter short	level;
659733Speter struct	nl *gotos[DSPLYSZ];
660733Speter 
661733Speter #define	NOTYET	10000
662733Speter #define	DEAD	10000
663733Speter 
664733Speter /*
665733Speter  * Noreach is true when the next statement will
666733Speter  * be unreachable unless something happens along
667733Speter  * (like exiting a looping construct) to save
668733Speter  * the day.
669733Speter  */
670733Speter bool	noreach;
671733Speter 
672733Speter /*
673733Speter  * UNDEFINED VARIABLE REFERENCE STRUCTURES
674733Speter  */
675733Speter struct	udinfo {
676733Speter 	int	ud_line;
677733Speter 	struct	udinfo *ud_next;
678733Speter 	char	nullch;
679733Speter };
680733Speter 
681733Speter /*
682733Speter  * CODE GENERATION DEFINITIONS
683733Speter  */
684733Speter 
685733Speter /*
686733Speter  * NSTAND is or'ed onto the abstract machine opcode
687733Speter  * for non-standard built-in procedures and functions.
688733Speter  */
689733Speter #define	NSTAND	0400
690733Speter 
691733Speter #define	codeon()	cgenflg++
692733Speter #define	codeoff()	--cgenflg
6933314Speter #define	CGENNING	( cgenflg >= 0 )
694733Speter 
695733Speter /*
696733Speter  * Codeline is the last lino output in the code generator.
697733Speter  * It used to be used to suppress LINO operators but no
698733Speter  * more since we now count statements.
699733Speter  * Lc is the intepreter code location counter.
700733Speter  *
701733Speter short	codeline;
702733Speter  */
703733Speter char	*lc;
704733Speter 
705733Speter 
706733Speter /*
707733Speter  * Routines which need types
708733Speter  * other than "integer" to be
709733Speter  * assumed by the compiler.
710733Speter  */
711733Speter double		atof();
712733Speter long		lwidth();
7133071Smckusic long		leven();
714733Speter long		aryconst();
715733Speter long		a8tol();
7163071Smckusic long		roundup();
7173823Speter struct nl 	*tmpalloc();
718733Speter struct nl 	*lookup();
719733Speter double		atof();
720733Speter int		*tree();
721733Speter int		*hash();
722733Speter char		*alloc();
723733Speter int		*calloc();
724733Speter char		*savestr();
7253283Smckusic char		*parnam();
7263283Smckusic bool		fcompat();
727733Speter struct nl	*lookup1();
728733Speter struct nl	*hdefnl();
729733Speter struct nl	*defnl();
730733Speter struct nl	*enter();
731733Speter struct nl	*nlcopy();
7328680Speter struct nl	*tyrec();
733733Speter struct nl	*tyary();
734733Speter struct nl	*deffld();
735733Speter struct nl	*defvnt();
736733Speter struct nl	*tyrec1();
737733Speter struct nl	*reclook();
738733Speter struct nl	*asgnop1();
739733Speter struct nl	*gtype();
740733Speter struct nl	*call();
741733Speter struct nl	*lvalue();
742733Speter struct nl	*rvalue();
743733Speter struct nl	*cset();
744733Speter 
745733Speter /*
746733Speter  * type cast NIL to keep lint happy (which is not so bad)
747733Speter  */
748733Speter #define		NLNIL	( (struct nl *) NIL )
749733Speter 
750733Speter /*
751733Speter  * Funny structures to use
752733Speter  * pointers in wild and wooly ways
753733Speter  */
754733Speter struct {
755733Speter 	char	pchar;
756733Speter };
757733Speter struct {
758733Speter 	short	pint;
759733Speter 	short	pint2;
760733Speter };
761733Speter struct {
762733Speter 	long	plong;
763733Speter };
764733Speter struct {
765733Speter 	double	pdouble;
766733Speter };
767733Speter 
768733Speter #define	OCT	1
769733Speter #define	HEX	2
770733Speter 
771733Speter /*
772733Speter  * MAIN PROGRAM VARIABLES, MISCELLANY
773733Speter  */
774733Speter 
775733Speter /*
776733Speter  * Variables forming a data base referencing
777733Speter  * the command line arguments with the "i" option, e.g.
778733Speter  * in "pi -i scanner.i compiler.p".
779733Speter  */
780733Speter char	**pflist;
781733Speter short	pflstc;
782733Speter short	pfcnt;
783733Speter 
784733Speter char	*filename;		/* current source file name */
785733Speter long	tvec;
786733Speter extern char	*snark;		/* SNARK */
787733Speter extern char	*classes[ ];	/* maps namelist classes to string names */
788733Speter 
789733Speter #define	derror error
790733Speter 
791733Speter #ifdef	PC
792733Speter 
793733Speter     /*
794733Speter      *	the current function number, for [ lines
795733Speter      */
796733Speter     int	ftnno;
797733Speter 
798733Speter     /*
799733Speter      *	the pc output stream
800733Speter      */
801733Speter     FILE *pcstream;
802733Speter 
803733Speter #endif PC
804