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