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