xref: /csrg-svn/usr.bin/pascal/src/0.h (revision 23619)
122218Sdist /*
222218Sdist  * Copyright (c) 1980 Regents of the University of California.
322218Sdist  * All rights reserved.  The Berkeley software License Agreement
422218Sdist  * specifies the terms and conditions for redistribution.
522218Sdist  *
6*23619Smckusick  *	@(#)0.h	5.2 (Berkeley) 06/20/85
722218Sdist  */
8733Speter 
9733Speter #define DEBUG
103071Smckusic #define CONSETS
11733Speter #define	CHAR
12733Speter #define	STATIC
13733Speter #define hp21mx 0
14733Speter 
15733Speter #include	<stdio.h>
16733Speter #include	<sys/types.h>
17*23619Smckusick #undef roundup
18733Speter 
193071Smckusic typedef enum {FALSE, TRUE} bool;
20733Speter 
21733Speter /*
22733Speter  * Option flags
23733Speter  *
24733Speter  * The following options are recognized in the text of the program
25733Speter  * and also on the command line:
26733Speter  *
27733Speter  *	b	block buffer the file output
28733Speter  *
29733Speter  *	i	make a listing of the procedures and functions in
30733Speter  *		the following include files
31733Speter  *
32733Speter  *	l	make a listing of the program
33733Speter  *
34733Speter  *	n	place each include file on a new page with a header
35733Speter  *
36733Speter  *	p	disable post mortem and statement limit counting
37733Speter  *
38733Speter  *	t	disable run-time tests
39733Speter  *
40733Speter  *	u	card image mode; only first 72 chars of input count
41733Speter  *
42733Speter  *	w	suppress special diagnostic warnings
43733Speter  *
44733Speter  *	z	generate counters for an execution profile
45733Speter  */
46733Speter #ifdef DEBUG
47733Speter bool	fulltrace, errtrace, testtrace, yyunique;
48733Speter #endif DEBUG
49733Speter 
50733Speter /*
51733Speter  * Each option has a stack of 17 option values, with opts giving
52733Speter  * the current, top value, and optstk the value beneath it.
53733Speter  * One refers to option `l' as, e.g., opt('l') in the text for clarity.
54733Speter  */
55733Speter char	opts[ 'z' - 'A' + 1];
56733Speter short	optstk[ 'z' - 'A' + 1];
57733Speter 
58733Speter #define opt(c) opts[c-'A']
59733Speter 
60733Speter /*
61733Speter  * Monflg is set when we are generating
62733Speter  * a pxp profile.  this is set by the -z command line option.
63733Speter  */
64733Speter bool	monflg;
65733Speter 
66733Speter     /*
67733Speter      *	profflag is set when we are generating a prof profile.
68733Speter      *	this is set by the -p command line option.
69733Speter      */
7014750Sthien #ifdef PC
71733Speter bool	profflag;
7214750Sthien #endif
73733Speter 
74733Speter 
75733Speter /*
76733Speter  * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
77733Speter  *
78733Speter  * Pi uses expandable tables for
79733Speter  * its namelist (symbol table), string table
80733Speter  * hash table, and parse tree space.  The following
81733Speter  * definitions specify the size of the increments
82733Speter  * for these items in fundamental units so that
83733Speter  * each uses approximately 1024 bytes.
84733Speter  */
85733Speter 
86733Speter #define	STRINC	1024		/* string space increment */
8720193Smckusick #define	TRINC	1024		/* tree space increment */
88733Speter #define	HASHINC	509		/* hash table size in words, each increment */
89733Speter #define	NLINC	56		/* namelist increment size in nl structs */
90733Speter 
91733Speter /*
92733Speter  * The initial sizes of the structures.
93733Speter  * These should be large enough to compile
94733Speter  * an "average" sized program so as to minimize
95733Speter  * storage requests.
96733Speter  * On a small system or and 11/34 or 11/40
97733Speter  * these numbers can be trimmed to make the
98733Speter  * compiler smaller.
99733Speter  */
100733Speter #define	ITREE	2000
101733Speter #define	INL	200
102733Speter #define	IHASH	509
103733Speter 
104733Speter /*
105733Speter  * The following limits on hash and tree tables currently
106733Speter  * allow approximately 1200 symbols and 20k words of tree
107733Speter  * space.  The fundamental limit of 64k total data space
108733Speter  * should be exceeded well before these are full.
109733Speter  */
110733Speter /*
111733Speter  * TABLE_MULTIPLIER is for uniformly increasing the sizes of the tables
112733Speter  */
11310658Speter #ifdef ADDR32
114733Speter #define TABLE_MULTIPLIER	8
11510658Speter #endif ADDR32
11610658Speter #ifdef ADDR16
1173071Smckusic #define TABLE_MULTIPLIER	1
11810658Speter #endif ADDR16
119733Speter #define	MAXHASH	(4 * TABLE_MULTIPLIER)
120733Speter #define	MAXNL	(12 * TABLE_MULTIPLIER)
12120193Smckusick #define	MAXTREE	(40 * TABLE_MULTIPLIER)
122733Speter /*
123733Speter  * MAXDEPTH is the depth of the parse stack.
124733Speter  * STACK_MULTIPLIER is for increasing its size.
125733Speter  */
12610658Speter #ifdef ADDR32
127733Speter #define	STACK_MULTIPLIER	8
12810658Speter #endif ADDR32
12910658Speter #ifdef ADDR16
1303071Smckusic #define	STACK_MULTIPLIER	1
13110658Speter #endif ADDR16
132733Speter #define	MAXDEPTH ( 150 * STACK_MULTIPLIER )
133733Speter 
134733Speter /*
135733Speter  * ERROR RELATED DEFINITIONS
136733Speter  */
137733Speter 
138733Speter /*
139733Speter  * Exit statuses to pexit
140733Speter  *
141733Speter  * AOK
142733Speter  * ERRS		Compilation errors inhibit obj productin
143733Speter  * NOSTART	Errors before we ever got started
144733Speter  * DIED		We ran out of memory or some such
145733Speter  */
146733Speter #define	AOK	0
147733Speter #define	ERRS	1
148733Speter #define	NOSTART	2
149733Speter #define	DIED	3
150733Speter 
151733Speter bool	Recovery;
152733Speter 
15314750Sthien #define	eholdnl()	Eholdnl = TRUE
15414750Sthien #define	nocascade()	Enocascade = TRUE
155733Speter 
156733Speter bool	Eholdnl, Enocascade;
157733Speter 
158733Speter 
159733Speter /*
160733Speter  * The flag eflg is set whenever we have a hard error.
161733Speter  * The character in errpfx will precede the next error message.
162733Speter  * When cgenflg is set code generation is suppressed.
163733Speter  * This happens whenver we have an error (i.e. if eflg is set)
164733Speter  * and when we are walking the tree to determine types only.
165733Speter  */
166733Speter bool	eflg;
167733Speter char	errpfx;
168733Speter 
169733Speter #define	setpfx(x)	errpfx = x
170733Speter 
171733Speter #define	standard()	setpfx('s')
172733Speter #define	warning()	setpfx('w')
173733Speter #define	recovered()	setpfx('e')
1746358Speter #define	continuation()	setpfx(' ')
175733Speter 
1763071Smckusic int	cgenflg;
177733Speter 
178733Speter 
179733Speter /*
180733Speter  * The flag syneflg is used to suppress the diagnostics of the form
181733Speter  *	E 10 a, defined in someprocedure, is neither used nor set
182733Speter  * when there were syntax errors in "someprocedure".
183733Speter  * In this case, it is likely that these warinings would be spurious.
184733Speter  */
185733Speter bool	syneflg;
186733Speter 
187733Speter /*
188733Speter  * The compiler keeps its error messages in a file.
189733Speter  * The variable efil is the unit number on which
190733Speter  * this file is open for reading of error message text.
191733Speter  * Similarly, the file ofil is the unit of the file
192733Speter  * "obj" where we write the interpreter code.
193733Speter  */
194733Speter short	efil;
19514750Sthien 
19614750Sthien #ifdef OBJ
197733Speter short	ofil;
19814750Sthien 
199733Speter short	obuf[518];
20014750Sthien #endif
201733Speter 
2023071Smckusic bool	Enoline;
2033071Smckusic #define	elineoff()	Enoline = TRUE
2043071Smckusic #define	elineon()	Enoline = FALSE
205733Speter 
206733Speter 
207733Speter /*
208733Speter  * SYMBOL TABLE STRUCTURE DEFINITIONS
209733Speter  *
210733Speter  * The symbol table is henceforth referred to as the "namelist".
211733Speter  * It consists of a number of structures of the form "nl" below.
212733Speter  * These are contained in a number of segments of the symbol
213733Speter  * table which are dynamically allocated as needed.
214733Speter  * The major namelist manipulation routines are contained in the
215733Speter  * file "nl.c".
216733Speter  *
217733Speter  * The major components of a namelist entry are the "symbol", giving
218733Speter  * a pointer into the string table for the string associated with this
219733Speter  * entry and the "class" which tells which of the (currently 19)
220733Speter  * possible types of structure this is.
221733Speter  *
222733Speter  * Many of the classes use the "type" field for a pointer to the type
223733Speter  * which the entry has.
224733Speter  *
225733Speter  * Other pieces of information in more than one class include the block
226733Speter  * in which the symbol is defined, flags indicating whether the symbol
227733Speter  * has been used and whether it has been assigned to, etc.
228733Speter  *
229733Speter  * A more complete discussion of the features of the namelist is impossible
230733Speter  * here as it would be too voluminous.  Refer to the "PI 1.0 Implementation
231733Speter  * Notes" for more details.
232733Speter  */
233733Speter 
234733Speter /*
235733Speter  * The basic namelist structure.
2367915Smckusick  * There is a union of data types defining the stored information
2377915Smckusick  * as pointers, integers, longs, or a double.
238733Speter  *
239733Speter  * The array disptab defines the hash header for the symbol table.
240733Speter  * Symbols are hashed based on the low 6 bits of their pointer into
241733Speter  * the string table; see the routines in the file "lookup.c" and also "fdec.c"
242733Speter  * especially "funcend".
243733Speter  */
2443220Smckusic extern int	pnumcnt;
2453220Smckusic 
246733Speter struct	nl {
247733Speter 	char	*symbol;
2487915Smckusick 	char	info[4];
249733Speter 	struct	nl *type;
250733Speter 	struct	nl *chain, *nl_next;
2517915Smckusick 	union {
25214750Sthien 		struct nl *un_ptr[5];
25314750Sthien 		int	   un_value[5];
25414750Sthien 		long	   un_range[2];
25514750Sthien 		double	   un_real;
25615972Smckusick 		struct nl  *un_nptr[5];	/* Points to conformant array bounds */
2577915Smckusick 	} nl_un;
258733Speter #	ifdef PTREE
259733Speter 	    pPointer	inTree;
260733Speter #	endif PTREE
2617915Smckusick };
262733Speter 
2638680Speter #define class		info[0]
2648680Speter #define nl_flags	info[1]
2658680Speter #define nl_block	info[1]
2668680Speter #define extra_flags	info[2]
2678680Speter #define align_info	info[3]
268733Speter 
2698680Speter #define range	nl_un.un_range
2708680Speter #define value	nl_un.un_value
2718680Speter #define ptr	nl_un.un_ptr
2728680Speter #define real	nl_un.un_real
27315972Smckusick #define nptr	nl_un.un_nptr
274733Speter 
2757915Smckusick extern struct nl *nlp, *disptab[077+1], *Fp;
2767915Smckusick extern struct nl nl[INL];
277733Speter 
2783370Speter 
279733Speter /*
280733Speter  * NL FLAGS BITS
281733Speter  *
282733Speter  * Definitions of the usage of the bits in
283733Speter  * the nl_flags byte. Note that the low 5 bits of the
284733Speter  * byte are the "nl_block" and that some classes make use
285733Speter  * of this byte as a "width".
286733Speter  *
287733Speter  * The only non-obvious bit definition here is "NFILES"
288733Speter  * which records whether a structure contains any files.
289733Speter  * Such structures are not allowed to be dynamically allocated.
290733Speter  */
2913370Speter 
2923370Speter #define	BLOCKNO( flag )	( flag & 037 )
2933370Speter #define NLFLAGS( flag ) ( flag &~ 037 )
2943370Speter 
295733Speter #define	NUSED	0100
296733Speter #define	NMOD	0040
297733Speter #define	NFORWD	0200
298733Speter #define	NFILES	0200
299733Speter #ifdef PC
300733Speter #define NEXTERN 0001	/* flag used to mark external funcs and procs */
3013823Speter #define	NLOCAL	0002	/* variable is a local */
3023823Speter #define	NPARAM	0004	/* variable is a parameter */
3033823Speter #define	NGLOBAL	0010	/* variable is a global */
3043823Speter #define	NREGVAR	0020	/* or'ed in if variable is in a register */
3059126Smckusick #define NNLOCAL 0040	/* named local variable, not used in symbol table */
3063823Speter #endif PC
3073370Speter 
3083540Speter /*
3093540Speter  * used to mark value[ NL_FORV ] for loop variables
3103540Speter  */
3113540Speter #define	FORVAR		1
312733Speter 
313733Speter /*
314733Speter  * Definition of the commonly used "value" fields.
315733Speter  * The most important one is NL_OFFS which gives
316733Speter  * the offset of a variable in its stack mark.
317733Speter  */
318733Speter #define NL_OFFS	0
319733Speter 
320733Speter #define	NL_CNTR	1
3213296Smckusic #define NL_NLSTRT 2
3223296Smckusic #define	NL_LINENO 3
323733Speter #define	NL_FVAR	3
3247915Smckusick #define	NL_ENTLOC 4	/* FUNC, PROC - entry point */
3257915Smckusick #define	NL_FCHAIN 4	/* FFUNC, FPROC - ptr to formals */
326733Speter 
327733Speter #define NL_GOLEV 2
328733Speter #define NL_GOLINE 3
329733Speter #define NL_FORV 1
330733Speter 
3318680Speter     /*
3328680Speter      *	nlp -> nl_un.un_ptr[] subscripts for records
3338680Speter      *	NL_FIELDLIST	the chain of fixed fields of a record, in order.
3348680Speter      *			the fields are also chained through ptr[NL_FIELDLIST].
3358680Speter      *			this does not include the tag, or fields of variants.
3368680Speter      *	NL_VARNT	pointer to the variants of a record,
3378680Speter      *			these are then chained through the .chain field.
3388680Speter      *	NL_VTOREC	pointer from a VARNT to the RECORD that is the variant.
3398680Speter      *	NL_TAG		pointer from a RECORD to the tagfield
3408680Speter      *			if there are any variants.
3418680Speter      *	align_info	the alignment of a RECORD is in info[3].
3428680Speter      */
3438680Speter #define	NL_FIELDLIST	1
3448680Speter #define	NL_VARNT	2
3458680Speter #define	NL_VTOREC	2
3468680Speter #define	NL_TAG		3
3478680Speter /* and align_info is info[3].  #defined above */
348733Speter 
3497915Smckusick #define	NL_ELABEL 4	/* SCAL - ptr to definition of enums */
350733Speter 
351733Speter /*
352733Speter  * For BADUSE nl structures, NL_KINDS is a bit vector
353733Speter  * indicating the kinds of illegal usages complained about
354733Speter  * so far.  For kind of bad use "kind", "1 << kind" is set.
355733Speter  * The low bit is reserved as ISUNDEF to indicate whether
356733Speter  * this identifier is totally undefined.
357733Speter  */
358733Speter #define	NL_KINDS	0
359733Speter 
360733Speter #define	ISUNDEF		1
3613275Smckusic 
3623823Speter     /*
3633823Speter      *	variables come in three flavors: globals, parameters, locals;
3643823Speter      *	they can also hide in registers, but that's a different flag
3653823Speter      */
3663275Smckusic #define PARAMVAR	1
3673275Smckusic #define LOCALVAR	2
3683823Speter #define	GLOBALVAR	3
3699126Smckusick #define	NAMEDLOCALVAR	4
370733Speter 
371733Speter /*
372733Speter  * NAMELIST CLASSES
373733Speter  *
374733Speter  * The following are the namelist classes.
375733Speter  * Different classes make use of the value fields
376733Speter  * of the namelist in different ways.
377733Speter  *
378733Speter  * The namelist should be redesigned by providing
379733Speter  * a number of structure definitions with one corresponding
380733Speter  * to each namelist class, ala a variant record in Pascal.
381733Speter  */
382733Speter #define	BADUSE	0
383733Speter #define	CONST	1
384733Speter #define	TYPE	2
385733Speter #define	VAR	3
386733Speter #define	ARRAY	4
387733Speter #define	PTRFILE	5
388733Speter #define	RECORD	6
389733Speter #define	FIELD	7
390733Speter #define	PROC	8
391733Speter #define	FUNC	9
392733Speter #define	FVAR	10
393733Speter #define	REF	11
394733Speter #define	PTR	12
395733Speter #define	FILET	13
396733Speter #define	SET	14
397733Speter #define	RANGE	15
398733Speter #define	LABEL	16
399733Speter #define	WITHPTR 17
400733Speter #define	SCAL	18
401733Speter #define	STR	19
402733Speter #define	PROG	20
403733Speter #define	IMPROPER 21
404733Speter #define	VARNT	22
4051194Speter #define	FPROC	23
4061194Speter #define	FFUNC	24
40715972Smckusick #define CRANGE	25
408733Speter 
409733Speter /*
410733Speter  * Clnames points to an array of names for the
411733Speter  * namelist classes.
412733Speter  */
413733Speter char	**clnames;
414733Speter 
415733Speter /*
416733Speter  * PRE-DEFINED NAMELIST OFFSETS
417733Speter  *
418733Speter  * The following are the namelist offsets for the
419733Speter  * primitive types. The ones which are negative
420733Speter  * don't actually exist, but are generated and tested
421733Speter  * internally. These definitions are sensitive to the
422733Speter  * initializations in nl.c.
423733Speter  */
424733Speter #define	TFIRST -7
425733Speter #define	TFILE  -7
426733Speter #define	TREC   -6
427733Speter #define	TARY   -5
428733Speter #define	TSCAL  -4
429733Speter #define	TPTR   -3
430733Speter #define	TSET   -2
431733Speter #define	TSTR   -1
432733Speter #define	NIL	0
433733Speter #define	TBOOL	1
434733Speter #define	TCHAR	2
435733Speter #define	TINT	3
436733Speter #define	TDOUBLE	4
437733Speter #define	TNIL	5
438733Speter #define	T1INT	6
439733Speter #define	T2INT	7
440733Speter #define	T4INT	8
441733Speter #define	T1CHAR	9
442733Speter #define	T1BOOL	10
443733Speter #define	T8REAL	11
444733Speter #define TLAST	11
445733Speter 
446733Speter /*
447733Speter  * SEMANTIC DEFINITIONS
448733Speter  */
449733Speter 
450733Speter /*
451733Speter  * NOCON and SAWCON are flags in the tree telling whether
452733Speter  * a constant set is part of an expression.
4533314Speter  *	these are no longer used,
4543314Speter  *	since we now do constant sets at compile time.
455733Speter  */
456733Speter #define NOCON	0
457733Speter #define SAWCON	1
458733Speter 
459733Speter /*
460733Speter  * The variable cbn gives the current block number,
461733Speter  * the variable bn is set as a side effect of a call to
462733Speter  * lookup, and is the block number of the variable which
463733Speter  * was found.
464733Speter  */
465733Speter short	bn, cbn;
466733Speter 
467733Speter /*
468733Speter  * The variable line is the current semantic
469733Speter  * line and is set in stat.c from the numbers
470733Speter  * embedded in statement type tree nodes.
471733Speter  */
472733Speter short	line;
473733Speter 
474733Speter /*
475733Speter  * The size of the display
476733Speter  * which defines the maximum nesting
477733Speter  * of procedures and functions allowed.
478733Speter  * Because of the flags in the current namelist
479733Speter  * this must be no greater than 32.
480733Speter  */
481733Speter #define	DSPLYSZ 20
482733Speter 
483733Speter     /*
484733Speter      *	the following structure records whether a level declares
485733Speter      *	any variables which are (or contain) files.
486733Speter      *	this so that the runtime routines for file cleanup can be invoked.
487733Speter      */
488733Speter bool	dfiles[ DSPLYSZ ];
489733Speter 
490733Speter /*
491733Speter  * Structure recording information about a constant
492733Speter  * declaration.  It is actually the return value from
493733Speter  * the routine "gconst", but since C doesn't support
494733Speter  * record valued functions, this is more convenient.
495733Speter  */
496733Speter struct {
497733Speter 	struct nl	*ctype;
498733Speter 	short		cival;
499733Speter 	double		crval;
50014750Sthien 	char		*cpval;	/* note used to be int * */
501733Speter } con;
502733Speter 
503733Speter /*
504733Speter  * The set structure records the lower bound
505733Speter  * and upper bound with the lower bound normalized
506733Speter  * to zero when working with a set. It is set by
507733Speter  * the routine setran in var.c.
508733Speter  */
509733Speter struct {
510733Speter 	short	lwrb, uprbp;
511733Speter } set;
512733Speter 
513733Speter     /*
514733Speter      *	structures of this kind are filled in by precset and used by postcset
515733Speter      *	to indicate things about constant sets.
516733Speter      */
517733Speter struct csetstr {
518733Speter     struct nl	*csettype;
519733Speter     long	paircnt;
520733Speter     long	singcnt;
521733Speter     bool	comptime;
522733Speter };
523733Speter /*
524733Speter  * The following flags are passed on calls to lvalue
525733Speter  * to indicate how the reference is to affect the usage
526733Speter  * information for the variable being referenced.
527733Speter  * MOD is used to set the NMOD flag in the namelist
528733Speter  * entry for the variable, ASGN permits diagnostics
529733Speter  * to be formed when a for variable is assigned to in
530733Speter  * the range of the loop.
531733Speter  */
532733Speter #define	NOFLAGS	0
533733Speter #define	MOD	01
534733Speter #define	ASGN	02
535733Speter #define	NOUSE	04
536733Speter 
537733Speter     /*
538733Speter      *	the following flags are passed to lvalue and rvalue
539733Speter      *	to tell them whether an lvalue or rvalue is required.
540733Speter      *	the semantics checking is done according to the function called,
541733Speter      *	but for pc, lvalue may put out an rvalue by indirecting afterwards,
542733Speter      *	and rvalue may stop short of putting out the indirection.
543733Speter      */
544733Speter #define	LREQ	01
545733Speter #define	RREQ	02
546733Speter 
547733Speter double	MAXINT;
548733Speter double	MININT;
549733Speter 
550733Speter /*
551733Speter  * Variables for generation of profile information.
552733Speter  * Monflg is set when we want to generate a profile.
553733Speter  * Gocnt record the total number of goto's and
554733Speter  * cnts records the current counter for generating
555733Speter  * COUNT operators.
556733Speter  */
557733Speter short	gocnt;
558733Speter short	cnts;
559733Speter 
560733Speter /*
561733Speter  * Most routines call "incompat" rather than asking "!compat"
562733Speter  * for historical reasons.
563733Speter  */
564733Speter #define incompat 	!compat
565733Speter 
566733Speter /*
567733Speter  * Parts records which declaration parts have been seen.
568833Speter  * The grammar allows the "label" "const" "type" "var" and routine
569733Speter  * parts to be repeated and to be in any order, so that
570733Speter  * they can be detected semantically to give better
571733Speter  * error diagnostics.
5729126Smckusick  *
5739126Smckusick  * The flag NONLOCALVAR indicates that a non-local var has actually
5749126Smckusick  * been used hence the display must be saved; NONLOCALGOTO indicates
5759126Smckusick  * that a non-local goto has been done hence that a setjmp must be done.
576733Speter  */
577833Speter int	parts[ DSPLYSZ ];
578733Speter 
5799126Smckusick #define	LPRT		0x0001
5809126Smckusick #define	CPRT		0x0002
5819126Smckusick #define	TPRT		0x0004
5829126Smckusick #define	VPRT		0x0008
5839126Smckusick #define	RPRT		0x0010
584733Speter 
5859126Smckusick #define	NONLOCALVAR	0x0020
5869126Smckusick #define	NONLOCALGOTO	0x0040
5879126Smckusick 
588733Speter /*
589733Speter  * Flags for the "you used / instead of div" diagnostic
590733Speter  */
591733Speter bool	divchk;
592733Speter bool	divflg;
593733Speter 
5943071Smckusic bool	errcnt[DSPLYSZ];
595733Speter 
596733Speter /*
597733Speter  * Forechain links those types which are
598733Speter  *	^ sometype
599733Speter  * so that they can be evaluated later, permitting
600733Speter  * circular, recursive list structures to be defined.
601733Speter  */
602733Speter struct	nl *forechain;
603733Speter 
604733Speter /*
605733Speter  * Withlist links all the records which are currently
606733Speter  * opened scopes because of with statements.
607733Speter  */
608733Speter struct	nl *withlist;
609733Speter 
610733Speter struct	nl *intset;
611733Speter struct	nl *input, *output;
612733Speter struct	nl *program;
613733Speter 
614733Speter /* progseen flag used by PC to determine if
615733Speter  * a routine segment is being compiled (and
616733Speter  * therefore no program statement seen)
617733Speter  */
618733Speter bool	progseen;
619733Speter 
620733Speter 
621733Speter /*
622733Speter  * STRUCTURED STATEMENT GOTO CHECKING
623733Speter  *
624733Speter  * The variable level keeps track of the current
625733Speter  * "structured statement level" when processing the statement
626733Speter  * body of blocks.  This is used in the detection of goto's into
627733Speter  * structured statements in a block.
628733Speter  *
629733Speter  * Each label's namelist entry contains two pieces of information
630733Speter  * related to this check. The first `NL_GOLEV' either contains
631733Speter  * the level at which the label was declared, `NOTYET' if the label
632733Speter  * has not yet been declared, or `DEAD' if the label is dead, i.e.
633733Speter  * if we have exited the level in which the label was defined.
634733Speter  *
635733Speter  * When we discover a "goto" statement, if the label has not
636733Speter  * been defined yet, then we record the current level and the current line
637733Speter  * for a later error check.  If the label has been already become "DEAD"
638733Speter  * then a reference to it is an error.  Now the compiler maintains,
639733Speter  * for each block, a linked list of the labels headed by "gotos[bn]".
640733Speter  * When we exit a structured level, we perform the routine
641733Speter  * ungoto in stat.c. It notices labels whose definition levels have been
642733Speter  * exited and makes them be dead. For labels which have not yet been
643733Speter  * defined, ungoto will maintain NL_GOLEV as the minimum structured level
644733Speter  * since the first usage of the label. It is not hard to see that the label
645733Speter  * must eventually be declared at this level or an outer level to this
646733Speter  * one or a goto into a structured statement will exist.
647733Speter  */
648733Speter short	level;
649733Speter struct	nl *gotos[DSPLYSZ];
650733Speter 
651733Speter #define	NOTYET	10000
652733Speter #define	DEAD	10000
653733Speter 
654733Speter /*
655733Speter  * Noreach is true when the next statement will
656733Speter  * be unreachable unless something happens along
657733Speter  * (like exiting a looping construct) to save
658733Speter  * the day.
659733Speter  */
660733Speter bool	noreach;
661733Speter 
662733Speter /*
663733Speter  * UNDEFINED VARIABLE REFERENCE STRUCTURES
664733Speter  */
665733Speter struct	udinfo {
666733Speter 	int	ud_line;
667733Speter 	struct	udinfo *ud_next;
668733Speter 	char	nullch;
669733Speter };
670733Speter 
671733Speter /*
672733Speter  * CODE GENERATION DEFINITIONS
673733Speter  */
674733Speter 
675733Speter /*
676733Speter  * NSTAND is or'ed onto the abstract machine opcode
677733Speter  * for non-standard built-in procedures and functions.
678733Speter  */
679733Speter #define	NSTAND	0400
680733Speter 
681733Speter #define	codeon()	cgenflg++
682733Speter #define	codeoff()	--cgenflg
6833314Speter #define	CGENNING	( cgenflg >= 0 )
684733Speter 
685733Speter /*
686733Speter  * Codeline is the last lino output in the code generator.
687733Speter  * It used to be used to suppress LINO operators but no
688733Speter  * more since we now count statements.
689733Speter  * Lc is the intepreter code location counter.
690733Speter  *
691733Speter short	codeline;
692733Speter  */
69314750Sthien #ifdef OBJ
694733Speter char	*lc;
69514750Sthien #endif
696733Speter 
697733Speter 
698733Speter /*
699733Speter  * Routines which need types
700733Speter  * other than "integer" to be
701733Speter  * assumed by the compiler.
702733Speter  */
703733Speter double		atof();
704733Speter long		lwidth();
7053071Smckusic long		leven();
706733Speter long		aryconst();
707733Speter long		a8tol();
7083071Smckusic long		roundup();
7093823Speter struct nl 	*tmpalloc();
710733Speter struct nl 	*lookup();
711733Speter double		atof();
712733Speter int		*hash();
713733Speter char		*alloc();
71414750Sthien int		*pcalloc();
715733Speter char		*savestr();
71614750Sthien char 		*esavestr();
7173283Smckusic char		*parnam();
71814750Sthien char		*malloc();
71914750Sthien char		*getlab();
72014750Sthien char		*getnext();
72114750Sthien char		*skipbl();
72214750Sthien char		*nameof();
72314750Sthien char 		*pstrcpy();
72414750Sthien char		*myctime();
72514750Sthien char		*putlab();
7263283Smckusic bool		fcompat();
72714750Sthien bool 		constval();
72814750Sthien bool		precset();
72914750Sthien bool		nilfnil();
73014750Sthien struct nl	*funccod();
73114750Sthien struct nl	*pcfunccod();
732733Speter struct nl	*lookup1();
733733Speter struct nl	*hdefnl();
734733Speter struct nl	*defnl();
73514750Sthien struct nl	*flvalue();
73614750Sthien struct nl	*plist();
737733Speter struct nl	*enter();
738733Speter struct nl	*nlcopy();
7398680Speter struct nl	*tyrec();
740733Speter struct nl	*tyary();
74114750Sthien struct nl	*tyrang();
74214750Sthien struct nl	*tyscal();
743733Speter struct nl	*deffld();
74414750Sthien struct nl	*stklval();
74514750Sthien struct nl	*scalar();
74614750Sthien struct nl	*gen();
74714750Sthien struct nl	*stkrval();
74814750Sthien struct nl	*funcext();
74914750Sthien struct nl	*funchdr();
75014750Sthien struct nl	*funcbody();
75114750Sthien struct nl 	*yybaduse();
75214750Sthien struct nl	*stackRV();
753733Speter struct nl	*defvnt();
754733Speter struct nl	*tyrec1();
755733Speter struct nl	*reclook();
756733Speter struct nl	*asgnop1();
75715983Saoki struct nl	*pcasgconf();
758733Speter struct nl	*gtype();
759733Speter struct nl	*call();
760733Speter struct nl	*lvalue();
76114750Sthien struct nl	*pclvalue();
762733Speter struct nl	*rvalue();
763733Speter struct nl	*cset();
76415983Saoki struct nl	*tycrang();
76514750Sthien struct tnode	*newlist();
76614750Sthien struct tnode	*addlist();
76714750Sthien struct tnode	*fixlist();
76814750Sthien struct tnode	*setupvar();
76914750Sthien struct tnode	*setuptyrec();
77014750Sthien struct tnode	*setupfield();
77114750Sthien struct tnode	*tree();
77214750Sthien struct tnode	*tree1();
77314750Sthien struct tnode	*tree2();
77414750Sthien struct tnode	*tree3();
77514750Sthien struct tnode	*tree4();
77614750Sthien struct tnode	*tree5();
777733Speter 
778733Speter /*
779733Speter  * type cast NIL to keep lint happy (which is not so bad)
780733Speter  */
781733Speter #define		NLNIL	( (struct nl *) NIL )
78214750Sthien #define		TR_NIL	( (struct tnode *) NIL)
783733Speter 
784733Speter /*
785733Speter  * Funny structures to use
786733Speter  * pointers in wild and wooly ways
787733Speter  */
78814750Sthien struct cstruct{
789733Speter 	char	pchar;
790733Speter };
791733Speter struct {
792733Speter 	short	pint;
793733Speter 	short	pint2;
794733Speter };
79514750Sthien struct lstruct {
796733Speter 	long	plong;
797733Speter };
798733Speter struct {
799733Speter 	double	pdouble;
800733Speter };
801733Speter 
802733Speter #define	OCT	1
803733Speter #define	HEX	2
804733Speter 
805733Speter /*
806733Speter  * MAIN PROGRAM VARIABLES, MISCELLANY
807733Speter  */
808733Speter 
809733Speter /*
810733Speter  * Variables forming a data base referencing
811733Speter  * the command line arguments with the "i" option, e.g.
812733Speter  * in "pi -i scanner.i compiler.p".
813733Speter  */
814733Speter char	**pflist;
815733Speter short	pflstc;
816733Speter short	pfcnt;
817733Speter 
818733Speter char	*filename;		/* current source file name */
819733Speter long	tvec;
820733Speter extern char	*snark;		/* SNARK */
821733Speter extern char	*classes[ ];	/* maps namelist classes to string names */
822733Speter 
823733Speter #define	derror error
824733Speter 
825733Speter #ifdef	PC
826733Speter 
827733Speter     /*
828733Speter      *	the current function number, for [ lines
829733Speter      */
830733Speter     int	ftnno;
831733Speter 
832733Speter     /*
833733Speter      *	the pc output stream
834733Speter      */
835733Speter     FILE *pcstream;
836733Speter 
837733Speter #endif PC
838