1733Speter /* Copyright (c) 1979 Regents of the University of California */ 2733Speter 3*14750Sthien /* static char sccsid[] = "@(#)0.h 1.21 08/19/83"; */ 4733Speter 5733Speter #define DEBUG 63071Smckusic #define CONSETS 7733Speter #define CHAR 8733Speter #define STATIC 9733Speter #define hp21mx 0 10733Speter 11733Speter #include <stdio.h> 12733Speter #include <sys/types.h> 13733Speter 143071Smckusic typedef enum {FALSE, TRUE} bool; 15733Speter 16733Speter /* 17733Speter * Option flags 18733Speter * 19733Speter * The following options are recognized in the text of the program 20733Speter * and also on the command line: 21733Speter * 22733Speter * b block buffer the file output 23733Speter * 24733Speter * i make a listing of the procedures and functions in 25733Speter * the following include files 26733Speter * 27733Speter * l make a listing of the program 28733Speter * 29733Speter * n place each include file on a new page with a header 30733Speter * 31733Speter * p disable post mortem and statement limit counting 32733Speter * 33733Speter * t disable run-time tests 34733Speter * 35733Speter * u card image mode; only first 72 chars of input count 36733Speter * 37733Speter * w suppress special diagnostic warnings 38733Speter * 39733Speter * z generate counters for an execution profile 40733Speter */ 41733Speter #ifdef DEBUG 42733Speter bool fulltrace, errtrace, testtrace, yyunique; 43733Speter #endif DEBUG 44733Speter 45733Speter /* 46733Speter * Each option has a stack of 17 option values, with opts giving 47733Speter * the current, top value, and optstk the value beneath it. 48733Speter * One refers to option `l' as, e.g., opt('l') in the text for clarity. 49733Speter */ 50733Speter char opts[ 'z' - 'A' + 1]; 51733Speter short optstk[ 'z' - 'A' + 1]; 52733Speter 53733Speter #define opt(c) opts[c-'A'] 54733Speter 55733Speter /* 56733Speter * Monflg is set when we are generating 57733Speter * a pxp profile. this is set by the -z command line option. 58733Speter */ 59733Speter bool monflg; 60733Speter 61733Speter /* 62733Speter * profflag is set when we are generating a prof profile. 63733Speter * this is set by the -p command line option. 64733Speter */ 65*14750Sthien #ifdef PC 66733Speter bool profflag; 67*14750Sthien #endif 68733Speter 69733Speter 70733Speter /* 71733Speter * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES 72733Speter * 73733Speter * Pi uses expandable tables for 74733Speter * its namelist (symbol table), string table 75733Speter * hash table, and parse tree space. The following 76733Speter * definitions specify the size of the increments 77733Speter * for these items in fundamental units so that 78733Speter * each uses approximately 1024 bytes. 79733Speter */ 80733Speter 81733Speter #define STRINC 1024 /* string space increment */ 82733Speter #define TRINC 512 /* tree space increment */ 83733Speter #define HASHINC 509 /* hash table size in words, each increment */ 84733Speter #define NLINC 56 /* namelist increment size in nl structs */ 85733Speter 86733Speter /* 87733Speter * The initial sizes of the structures. 88733Speter * These should be large enough to compile 89733Speter * an "average" sized program so as to minimize 90733Speter * storage requests. 91733Speter * On a small system or and 11/34 or 11/40 92733Speter * these numbers can be trimmed to make the 93733Speter * compiler smaller. 94733Speter */ 95733Speter #define ITREE 2000 96733Speter #define INL 200 97733Speter #define IHASH 509 98733Speter 99733Speter /* 100733Speter * The following limits on hash and tree tables currently 101733Speter * allow approximately 1200 symbols and 20k words of tree 102733Speter * space. The fundamental limit of 64k total data space 103733Speter * should be exceeded well before these are full. 104733Speter */ 105733Speter /* 106733Speter * TABLE_MULTIPLIER is for uniformly increasing the sizes of the tables 107733Speter */ 10810658Speter #ifdef ADDR32 109733Speter #define TABLE_MULTIPLIER 8 11010658Speter #endif ADDR32 11110658Speter #ifdef ADDR16 1123071Smckusic #define TABLE_MULTIPLIER 1 11310658Speter #endif ADDR16 114733Speter #define MAXHASH (4 * TABLE_MULTIPLIER) 115733Speter #define MAXNL (12 * TABLE_MULTIPLIER) 116733Speter #define MAXTREE (30 * TABLE_MULTIPLIER) 117733Speter /* 118733Speter * MAXDEPTH is the depth of the parse stack. 119733Speter * STACK_MULTIPLIER is for increasing its size. 120733Speter */ 12110658Speter #ifdef ADDR32 122733Speter #define STACK_MULTIPLIER 8 12310658Speter #endif ADDR32 12410658Speter #ifdef ADDR16 1253071Smckusic #define STACK_MULTIPLIER 1 12610658Speter #endif ADDR16 127733Speter #define MAXDEPTH ( 150 * STACK_MULTIPLIER ) 128733Speter 129733Speter /* 130733Speter * ERROR RELATED DEFINITIONS 131733Speter */ 132733Speter 133733Speter /* 134733Speter * Exit statuses to pexit 135733Speter * 136733Speter * AOK 137733Speter * ERRS Compilation errors inhibit obj productin 138733Speter * NOSTART Errors before we ever got started 139733Speter * DIED We ran out of memory or some such 140733Speter */ 141733Speter #define AOK 0 142733Speter #define ERRS 1 143733Speter #define NOSTART 2 144733Speter #define DIED 3 145733Speter 146733Speter bool Recovery; 147733Speter 148*14750Sthien #define eholdnl() Eholdnl = TRUE 149*14750Sthien #define nocascade() Enocascade = TRUE 150733Speter 151733Speter bool Eholdnl, Enocascade; 152733Speter 153733Speter 154733Speter /* 155733Speter * The flag eflg is set whenever we have a hard error. 156733Speter * The character in errpfx will precede the next error message. 157733Speter * When cgenflg is set code generation is suppressed. 158733Speter * This happens whenver we have an error (i.e. if eflg is set) 159733Speter * and when we are walking the tree to determine types only. 160733Speter */ 161733Speter bool eflg; 162733Speter char errpfx; 163733Speter 164733Speter #define setpfx(x) errpfx = x 165733Speter 166733Speter #define standard() setpfx('s') 167733Speter #define warning() setpfx('w') 168733Speter #define recovered() setpfx('e') 1696358Speter #define continuation() setpfx(' ') 170733Speter 1713071Smckusic int cgenflg; 172733Speter 173733Speter 174733Speter /* 175733Speter * The flag syneflg is used to suppress the diagnostics of the form 176733Speter * E 10 a, defined in someprocedure, is neither used nor set 177733Speter * when there were syntax errors in "someprocedure". 178733Speter * In this case, it is likely that these warinings would be spurious. 179733Speter */ 180733Speter bool syneflg; 181733Speter 182733Speter /* 183733Speter * The compiler keeps its error messages in a file. 184733Speter * The variable efil is the unit number on which 185733Speter * this file is open for reading of error message text. 186733Speter * Similarly, the file ofil is the unit of the file 187733Speter * "obj" where we write the interpreter code. 188733Speter */ 189733Speter short efil; 190*14750Sthien 191*14750Sthien #ifdef OBJ 192733Speter short ofil; 193*14750Sthien 194733Speter short obuf[518]; 195*14750Sthien #endif 196733Speter 1973071Smckusic bool Enoline; 1983071Smckusic #define elineoff() Enoline = TRUE 1993071Smckusic #define elineon() Enoline = FALSE 200733Speter 201733Speter 202733Speter /* 203733Speter * SYMBOL TABLE STRUCTURE DEFINITIONS 204733Speter * 205733Speter * The symbol table is henceforth referred to as the "namelist". 206733Speter * It consists of a number of structures of the form "nl" below. 207733Speter * These are contained in a number of segments of the symbol 208733Speter * table which are dynamically allocated as needed. 209733Speter * The major namelist manipulation routines are contained in the 210733Speter * file "nl.c". 211733Speter * 212733Speter * The major components of a namelist entry are the "symbol", giving 213733Speter * a pointer into the string table for the string associated with this 214733Speter * entry and the "class" which tells which of the (currently 19) 215733Speter * possible types of structure this is. 216733Speter * 217733Speter * Many of the classes use the "type" field for a pointer to the type 218733Speter * which the entry has. 219733Speter * 220733Speter * Other pieces of information in more than one class include the block 221733Speter * in which the symbol is defined, flags indicating whether the symbol 222733Speter * has been used and whether it has been assigned to, etc. 223733Speter * 224733Speter * A more complete discussion of the features of the namelist is impossible 225733Speter * here as it would be too voluminous. Refer to the "PI 1.0 Implementation 226733Speter * Notes" for more details. 227733Speter */ 228733Speter 229733Speter /* 230733Speter * The basic namelist structure. 2317915Smckusick * There is a union of data types defining the stored information 2327915Smckusick * as pointers, integers, longs, or a double. 233733Speter * 234733Speter * The array disptab defines the hash header for the symbol table. 235733Speter * Symbols are hashed based on the low 6 bits of their pointer into 236733Speter * the string table; see the routines in the file "lookup.c" and also "fdec.c" 237733Speter * especially "funcend". 238733Speter */ 2393220Smckusic extern int pnumcnt; 2403220Smckusic 241733Speter struct nl { 242733Speter char *symbol; 2437915Smckusick char info[4]; 244733Speter struct nl *type; 245733Speter struct nl *chain, *nl_next; 2467915Smckusick union { 247*14750Sthien struct nl *un_ptr[5]; 248*14750Sthien int un_value[5]; 249*14750Sthien long un_range[2]; 250*14750Sthien double un_real; 2517915Smckusick } nl_un; 252733Speter # ifdef PTREE 253733Speter pPointer inTree; 254733Speter # endif PTREE 2557915Smckusick }; 256733Speter 2578680Speter #define class info[0] 2588680Speter #define nl_flags info[1] 2598680Speter #define nl_block info[1] 2608680Speter #define extra_flags info[2] 2618680Speter #define align_info info[3] 262733Speter 2638680Speter #define range nl_un.un_range 2648680Speter #define value nl_un.un_value 2658680Speter #define ptr nl_un.un_ptr 2668680Speter #define real nl_un.un_real 267733Speter 2687915Smckusick extern struct nl *nlp, *disptab[077+1], *Fp; 2697915Smckusick extern struct nl nl[INL]; 270733Speter 2713370Speter 272733Speter /* 273733Speter * NL FLAGS BITS 274733Speter * 275733Speter * Definitions of the usage of the bits in 276733Speter * the nl_flags byte. Note that the low 5 bits of the 277733Speter * byte are the "nl_block" and that some classes make use 278733Speter * of this byte as a "width". 279733Speter * 280733Speter * The only non-obvious bit definition here is "NFILES" 281733Speter * which records whether a structure contains any files. 282733Speter * Such structures are not allowed to be dynamically allocated. 283733Speter */ 2843370Speter 2853370Speter #define BLOCKNO( flag ) ( flag & 037 ) 2863370Speter #define NLFLAGS( flag ) ( flag &~ 037 ) 2873370Speter 288733Speter #define NUSED 0100 289733Speter #define NMOD 0040 290733Speter #define NFORWD 0200 291733Speter #define NFILES 0200 292733Speter #ifdef PC 293733Speter #define NEXTERN 0001 /* flag used to mark external funcs and procs */ 2943823Speter #define NLOCAL 0002 /* variable is a local */ 2953823Speter #define NPARAM 0004 /* variable is a parameter */ 2963823Speter #define NGLOBAL 0010 /* variable is a global */ 2973823Speter #define NREGVAR 0020 /* or'ed in if variable is in a register */ 2989126Smckusick #define NNLOCAL 0040 /* named local variable, not used in symbol table */ 2993823Speter #endif PC 3003370Speter 3013540Speter /* 3023540Speter * used to mark value[ NL_FORV ] for loop variables 3033540Speter */ 3043540Speter #define FORVAR 1 305733Speter 306733Speter /* 307733Speter * Definition of the commonly used "value" fields. 308733Speter * The most important one is NL_OFFS which gives 309733Speter * the offset of a variable in its stack mark. 310733Speter */ 311733Speter #define NL_OFFS 0 312733Speter 313733Speter #define NL_CNTR 1 3143296Smckusic #define NL_NLSTRT 2 3153296Smckusic #define NL_LINENO 3 316733Speter #define NL_FVAR 3 3177915Smckusick #define NL_ENTLOC 4 /* FUNC, PROC - entry point */ 3187915Smckusick #define NL_FCHAIN 4 /* FFUNC, FPROC - ptr to formals */ 319733Speter 320733Speter #define NL_GOLEV 2 321733Speter #define NL_GOLINE 3 322733Speter #define NL_FORV 1 323733Speter 3248680Speter /* 3258680Speter * nlp -> nl_un.un_ptr[] subscripts for records 3268680Speter * NL_FIELDLIST the chain of fixed fields of a record, in order. 3278680Speter * the fields are also chained through ptr[NL_FIELDLIST]. 3288680Speter * this does not include the tag, or fields of variants. 3298680Speter * NL_VARNT pointer to the variants of a record, 3308680Speter * these are then chained through the .chain field. 3318680Speter * NL_VTOREC pointer from a VARNT to the RECORD that is the variant. 3328680Speter * NL_TAG pointer from a RECORD to the tagfield 3338680Speter * if there are any variants. 3348680Speter * align_info the alignment of a RECORD is in info[3]. 3358680Speter */ 3368680Speter #define NL_FIELDLIST 1 3378680Speter #define NL_VARNT 2 3388680Speter #define NL_VTOREC 2 3398680Speter #define NL_TAG 3 3408680Speter /* and align_info is info[3]. #defined above */ 341733Speter 3427915Smckusick #define NL_ELABEL 4 /* SCAL - ptr to definition of enums */ 343733Speter 344733Speter /* 345733Speter * For BADUSE nl structures, NL_KINDS is a bit vector 346733Speter * indicating the kinds of illegal usages complained about 347733Speter * so far. For kind of bad use "kind", "1 << kind" is set. 348733Speter * The low bit is reserved as ISUNDEF to indicate whether 349733Speter * this identifier is totally undefined. 350733Speter */ 351733Speter #define NL_KINDS 0 352733Speter 353733Speter #define ISUNDEF 1 3543275Smckusic 3553823Speter /* 3563823Speter * variables come in three flavors: globals, parameters, locals; 3573823Speter * they can also hide in registers, but that's a different flag 3583823Speter */ 3593275Smckusic #define PARAMVAR 1 3603275Smckusic #define LOCALVAR 2 3613823Speter #define GLOBALVAR 3 3629126Smckusick #define NAMEDLOCALVAR 4 363733Speter 364733Speter /* 365733Speter * NAMELIST CLASSES 366733Speter * 367733Speter * The following are the namelist classes. 368733Speter * Different classes make use of the value fields 369733Speter * of the namelist in different ways. 370733Speter * 371733Speter * The namelist should be redesigned by providing 372733Speter * a number of structure definitions with one corresponding 373733Speter * to each namelist class, ala a variant record in Pascal. 374733Speter */ 375733Speter #define BADUSE 0 376733Speter #define CONST 1 377733Speter #define TYPE 2 378733Speter #define VAR 3 379733Speter #define ARRAY 4 380733Speter #define PTRFILE 5 381733Speter #define RECORD 6 382733Speter #define FIELD 7 383733Speter #define PROC 8 384733Speter #define FUNC 9 385733Speter #define FVAR 10 386733Speter #define REF 11 387733Speter #define PTR 12 388733Speter #define FILET 13 389733Speter #define SET 14 390733Speter #define RANGE 15 391733Speter #define LABEL 16 392733Speter #define WITHPTR 17 393733Speter #define SCAL 18 394733Speter #define STR 19 395733Speter #define PROG 20 396733Speter #define IMPROPER 21 397733Speter #define VARNT 22 3981194Speter #define FPROC 23 3991194Speter #define FFUNC 24 400733Speter 401733Speter /* 402733Speter * Clnames points to an array of names for the 403733Speter * namelist classes. 404733Speter */ 405733Speter char **clnames; 406733Speter 407733Speter /* 408733Speter * PRE-DEFINED NAMELIST OFFSETS 409733Speter * 410733Speter * The following are the namelist offsets for the 411733Speter * primitive types. The ones which are negative 412733Speter * don't actually exist, but are generated and tested 413733Speter * internally. These definitions are sensitive to the 414733Speter * initializations in nl.c. 415733Speter */ 416733Speter #define TFIRST -7 417733Speter #define TFILE -7 418733Speter #define TREC -6 419733Speter #define TARY -5 420733Speter #define TSCAL -4 421733Speter #define TPTR -3 422733Speter #define TSET -2 423733Speter #define TSTR -1 424733Speter #define NIL 0 425733Speter #define TBOOL 1 426733Speter #define TCHAR 2 427733Speter #define TINT 3 428733Speter #define TDOUBLE 4 429733Speter #define TNIL 5 430733Speter #define T1INT 6 431733Speter #define T2INT 7 432733Speter #define T4INT 8 433733Speter #define T1CHAR 9 434733Speter #define T1BOOL 10 435733Speter #define T8REAL 11 436733Speter #define TLAST 11 437733Speter 438733Speter /* 439733Speter * SEMANTIC DEFINITIONS 440733Speter */ 441733Speter 442733Speter /* 443733Speter * NOCON and SAWCON are flags in the tree telling whether 444733Speter * a constant set is part of an expression. 4453314Speter * these are no longer used, 4463314Speter * since we now do constant sets at compile time. 447733Speter */ 448733Speter #define NOCON 0 449733Speter #define SAWCON 1 450733Speter 451733Speter /* 452733Speter * The variable cbn gives the current block number, 453733Speter * the variable bn is set as a side effect of a call to 454733Speter * lookup, and is the block number of the variable which 455733Speter * was found. 456733Speter */ 457733Speter short bn, cbn; 458733Speter 459733Speter /* 460733Speter * The variable line is the current semantic 461733Speter * line and is set in stat.c from the numbers 462733Speter * embedded in statement type tree nodes. 463733Speter */ 464733Speter short line; 465733Speter 466733Speter /* 467733Speter * The size of the display 468733Speter * which defines the maximum nesting 469733Speter * of procedures and functions allowed. 470733Speter * Because of the flags in the current namelist 471733Speter * this must be no greater than 32. 472733Speter */ 473733Speter #define DSPLYSZ 20 474733Speter 475733Speter /* 476733Speter * the following structure records whether a level declares 477733Speter * any variables which are (or contain) files. 478733Speter * this so that the runtime routines for file cleanup can be invoked. 479733Speter */ 480733Speter bool dfiles[ DSPLYSZ ]; 481733Speter 482733Speter /* 483733Speter * Structure recording information about a constant 484733Speter * declaration. It is actually the return value from 485733Speter * the routine "gconst", but since C doesn't support 486733Speter * record valued functions, this is more convenient. 487733Speter */ 488733Speter struct { 489733Speter struct nl *ctype; 490733Speter short cival; 491733Speter double crval; 492*14750Sthien char *cpval; /* note used to be int * */ 493733Speter } con; 494733Speter 495733Speter /* 496733Speter * The set structure records the lower bound 497733Speter * and upper bound with the lower bound normalized 498733Speter * to zero when working with a set. It is set by 499733Speter * the routine setran in var.c. 500733Speter */ 501733Speter struct { 502733Speter short lwrb, uprbp; 503733Speter } set; 504733Speter 505733Speter /* 506733Speter * structures of this kind are filled in by precset and used by postcset 507733Speter * to indicate things about constant sets. 508733Speter */ 509733Speter struct csetstr { 510733Speter struct nl *csettype; 511733Speter long paircnt; 512733Speter long singcnt; 513733Speter bool comptime; 514733Speter }; 515733Speter /* 516733Speter * The following flags are passed on calls to lvalue 517733Speter * to indicate how the reference is to affect the usage 518733Speter * information for the variable being referenced. 519733Speter * MOD is used to set the NMOD flag in the namelist 520733Speter * entry for the variable, ASGN permits diagnostics 521733Speter * to be formed when a for variable is assigned to in 522733Speter * the range of the loop. 523733Speter */ 524733Speter #define NOFLAGS 0 525733Speter #define MOD 01 526733Speter #define ASGN 02 527733Speter #define NOUSE 04 528733Speter 529733Speter /* 530733Speter * the following flags are passed to lvalue and rvalue 531733Speter * to tell them whether an lvalue or rvalue is required. 532733Speter * the semantics checking is done according to the function called, 533733Speter * but for pc, lvalue may put out an rvalue by indirecting afterwards, 534733Speter * and rvalue may stop short of putting out the indirection. 535733Speter */ 536733Speter #define LREQ 01 537733Speter #define RREQ 02 538733Speter 539733Speter double MAXINT; 540733Speter double MININT; 541733Speter 542733Speter /* 543733Speter * Variables for generation of profile information. 544733Speter * Monflg is set when we want to generate a profile. 545733Speter * Gocnt record the total number of goto's and 546733Speter * cnts records the current counter for generating 547733Speter * COUNT operators. 548733Speter */ 549733Speter short gocnt; 550733Speter short cnts; 551733Speter 552733Speter /* 553733Speter * Most routines call "incompat" rather than asking "!compat" 554733Speter * for historical reasons. 555733Speter */ 556733Speter #define incompat !compat 557733Speter 558733Speter /* 559733Speter * Parts records which declaration parts have been seen. 560833Speter * The grammar allows the "label" "const" "type" "var" and routine 561733Speter * parts to be repeated and to be in any order, so that 562733Speter * they can be detected semantically to give better 563733Speter * error diagnostics. 5649126Smckusick * 5659126Smckusick * The flag NONLOCALVAR indicates that a non-local var has actually 5669126Smckusick * been used hence the display must be saved; NONLOCALGOTO indicates 5679126Smckusick * that a non-local goto has been done hence that a setjmp must be done. 568733Speter */ 569833Speter int parts[ DSPLYSZ ]; 570733Speter 5719126Smckusick #define LPRT 0x0001 5729126Smckusick #define CPRT 0x0002 5739126Smckusick #define TPRT 0x0004 5749126Smckusick #define VPRT 0x0008 5759126Smckusick #define RPRT 0x0010 576733Speter 5779126Smckusick #define NONLOCALVAR 0x0020 5789126Smckusick #define NONLOCALGOTO 0x0040 5799126Smckusick 580733Speter /* 581733Speter * Flags for the "you used / instead of div" diagnostic 582733Speter */ 583733Speter bool divchk; 584733Speter bool divflg; 585733Speter 5863071Smckusic bool errcnt[DSPLYSZ]; 587733Speter 588733Speter /* 589733Speter * Forechain links those types which are 590733Speter * ^ sometype 591733Speter * so that they can be evaluated later, permitting 592733Speter * circular, recursive list structures to be defined. 593733Speter */ 594733Speter struct nl *forechain; 595733Speter 596733Speter /* 597733Speter * Withlist links all the records which are currently 598733Speter * opened scopes because of with statements. 599733Speter */ 600733Speter struct nl *withlist; 601733Speter 602733Speter struct nl *intset; 603733Speter struct nl *input, *output; 604733Speter struct nl *program; 605733Speter 606733Speter /* progseen flag used by PC to determine if 607733Speter * a routine segment is being compiled (and 608733Speter * therefore no program statement seen) 609733Speter */ 610733Speter bool progseen; 611733Speter 612733Speter 613733Speter /* 614733Speter * STRUCTURED STATEMENT GOTO CHECKING 615733Speter * 616733Speter * The variable level keeps track of the current 617733Speter * "structured statement level" when processing the statement 618733Speter * body of blocks. This is used in the detection of goto's into 619733Speter * structured statements in a block. 620733Speter * 621733Speter * Each label's namelist entry contains two pieces of information 622733Speter * related to this check. The first `NL_GOLEV' either contains 623733Speter * the level at which the label was declared, `NOTYET' if the label 624733Speter * has not yet been declared, or `DEAD' if the label is dead, i.e. 625733Speter * if we have exited the level in which the label was defined. 626733Speter * 627733Speter * When we discover a "goto" statement, if the label has not 628733Speter * been defined yet, then we record the current level and the current line 629733Speter * for a later error check. If the label has been already become "DEAD" 630733Speter * then a reference to it is an error. Now the compiler maintains, 631733Speter * for each block, a linked list of the labels headed by "gotos[bn]". 632733Speter * When we exit a structured level, we perform the routine 633733Speter * ungoto in stat.c. It notices labels whose definition levels have been 634733Speter * exited and makes them be dead. For labels which have not yet been 635733Speter * defined, ungoto will maintain NL_GOLEV as the minimum structured level 636733Speter * since the first usage of the label. It is not hard to see that the label 637733Speter * must eventually be declared at this level or an outer level to this 638733Speter * one or a goto into a structured statement will exist. 639733Speter */ 640733Speter short level; 641733Speter struct nl *gotos[DSPLYSZ]; 642733Speter 643733Speter #define NOTYET 10000 644733Speter #define DEAD 10000 645733Speter 646733Speter /* 647733Speter * Noreach is true when the next statement will 648733Speter * be unreachable unless something happens along 649733Speter * (like exiting a looping construct) to save 650733Speter * the day. 651733Speter */ 652733Speter bool noreach; 653733Speter 654733Speter /* 655733Speter * UNDEFINED VARIABLE REFERENCE STRUCTURES 656733Speter */ 657733Speter struct udinfo { 658733Speter int ud_line; 659733Speter struct udinfo *ud_next; 660733Speter char nullch; 661733Speter }; 662733Speter 663733Speter /* 664733Speter * CODE GENERATION DEFINITIONS 665733Speter */ 666733Speter 667733Speter /* 668733Speter * NSTAND is or'ed onto the abstract machine opcode 669733Speter * for non-standard built-in procedures and functions. 670733Speter */ 671733Speter #define NSTAND 0400 672733Speter 673733Speter #define codeon() cgenflg++ 674733Speter #define codeoff() --cgenflg 6753314Speter #define CGENNING ( cgenflg >= 0 ) 676733Speter 677733Speter /* 678733Speter * Codeline is the last lino output in the code generator. 679733Speter * It used to be used to suppress LINO operators but no 680733Speter * more since we now count statements. 681733Speter * Lc is the intepreter code location counter. 682733Speter * 683733Speter short codeline; 684733Speter */ 685*14750Sthien #ifdef OBJ 686733Speter char *lc; 687*14750Sthien #endif 688733Speter 689733Speter 690733Speter /* 691733Speter * Routines which need types 692733Speter * other than "integer" to be 693733Speter * assumed by the compiler. 694733Speter */ 695733Speter double atof(); 696733Speter long lwidth(); 6973071Smckusic long leven(); 698733Speter long aryconst(); 699733Speter long a8tol(); 7003071Smckusic long roundup(); 7013823Speter struct nl *tmpalloc(); 702733Speter struct nl *lookup(); 703733Speter double atof(); 704733Speter int *hash(); 705733Speter char *alloc(); 706*14750Sthien int *pcalloc(); 707733Speter char *savestr(); 708*14750Sthien char *esavestr(); 7093283Smckusic char *parnam(); 710*14750Sthien char *malloc(); 711*14750Sthien char *getlab(); 712*14750Sthien char *getnext(); 713*14750Sthien char *skipbl(); 714*14750Sthien char *nameof(); 715*14750Sthien char *pstrcpy(); 716*14750Sthien char *myctime(); 717*14750Sthien char *putlab(); 7183283Smckusic bool fcompat(); 719*14750Sthien bool constval(); 720*14750Sthien bool precset(); 721*14750Sthien bool nilfnil(); 722*14750Sthien struct nl *funccod(); 723*14750Sthien struct nl *pcfunccod(); 724733Speter struct nl *lookup1(); 725733Speter struct nl *hdefnl(); 726733Speter struct nl *defnl(); 727*14750Sthien struct nl *flvalue(); 728*14750Sthien struct nl *plist(); 729733Speter struct nl *enter(); 730733Speter struct nl *nlcopy(); 7318680Speter struct nl *tyrec(); 732733Speter struct nl *tyary(); 733*14750Sthien struct nl *tyrang(); 734*14750Sthien struct nl *tyscal(); 735733Speter struct nl *deffld(); 736*14750Sthien struct nl *stklval(); 737*14750Sthien struct nl *scalar(); 738*14750Sthien struct nl *gen(); 739*14750Sthien struct nl *stkrval(); 740*14750Sthien struct nl *funcext(); 741*14750Sthien struct nl *funchdr(); 742*14750Sthien struct nl *funcbody(); 743*14750Sthien struct nl *yybaduse(); 744*14750Sthien struct nl *stackRV(); 745733Speter struct nl *defvnt(); 746733Speter struct nl *tyrec1(); 747733Speter struct nl *reclook(); 748733Speter struct nl *asgnop1(); 749733Speter struct nl *gtype(); 750733Speter struct nl *call(); 751733Speter struct nl *lvalue(); 752*14750Sthien struct nl *pclvalue(); 753733Speter struct nl *rvalue(); 754733Speter struct nl *cset(); 755*14750Sthien struct tnode *newlist(); 756*14750Sthien struct tnode *addlist(); 757*14750Sthien struct tnode *fixlist(); 758*14750Sthien struct tnode *setupvar(); 759*14750Sthien struct tnode *setuptyrec(); 760*14750Sthien struct tnode *setupfield(); 761*14750Sthien struct tnode *tree(); 762*14750Sthien struct tnode *tree1(); 763*14750Sthien struct tnode *tree2(); 764*14750Sthien struct tnode *tree3(); 765*14750Sthien struct tnode *tree4(); 766*14750Sthien struct tnode *tree5(); 767733Speter 768733Speter /* 769733Speter * type cast NIL to keep lint happy (which is not so bad) 770733Speter */ 771733Speter #define NLNIL ( (struct nl *) NIL ) 772*14750Sthien #define TR_NIL ( (struct tnode *) NIL) 773733Speter 774733Speter /* 775733Speter * Funny structures to use 776733Speter * pointers in wild and wooly ways 777733Speter */ 778*14750Sthien struct cstruct{ 779733Speter char pchar; 780733Speter }; 781733Speter struct { 782733Speter short pint; 783733Speter short pint2; 784733Speter }; 785*14750Sthien struct lstruct { 786733Speter long plong; 787733Speter }; 788733Speter struct { 789733Speter double pdouble; 790733Speter }; 791733Speter 792733Speter #define OCT 1 793733Speter #define HEX 2 794733Speter 795733Speter /* 796733Speter * MAIN PROGRAM VARIABLES, MISCELLANY 797733Speter */ 798733Speter 799733Speter /* 800733Speter * Variables forming a data base referencing 801733Speter * the command line arguments with the "i" option, e.g. 802733Speter * in "pi -i scanner.i compiler.p". 803733Speter */ 804733Speter char **pflist; 805733Speter short pflstc; 806733Speter short pfcnt; 807733Speter 808733Speter char *filename; /* current source file name */ 809733Speter long tvec; 810733Speter extern char *snark; /* SNARK */ 811733Speter extern char *classes[ ]; /* maps namelist classes to string names */ 812733Speter 813733Speter #define derror error 814733Speter 815733Speter #ifdef PC 816733Speter 817733Speter /* 818733Speter * the current function number, for [ lines 819733Speter */ 820733Speter int ftnno; 821733Speter 822733Speter /* 823733Speter * the pc output stream 824733Speter */ 825733Speter FILE *pcstream; 826733Speter 827733Speter #endif PC 828