home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / pascal / src / 0.h next >
Encoding:
C/C++ Source or Header  |  1991-04-16  |  21.7 KB  |  863 lines

  1. /*-
  2.  * Copyright (c) 1980 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)0.h    5.4 (Berkeley) 4/16/91
  34.  */
  35.  
  36. #define DEBUG
  37. #define CONSETS
  38. #define    CHAR
  39. #define    STATIC
  40. #define hp21mx 0
  41.  
  42. #include    <stdio.h>
  43. #include    <stdlib.h>
  44. #include    <sys/types.h>
  45. #undef roundup
  46.  
  47. typedef enum {FALSE, TRUE} bool;
  48.  
  49. /*
  50.  * Option flags
  51.  *
  52.  * The following options are recognized in the text of the program
  53.  * and also on the command line:
  54.  *
  55.  *    b    block buffer the file output
  56.  *
  57.  *    i    make a listing of the procedures and functions in
  58.  *        the following include files
  59.  *
  60.  *    l    make a listing of the program
  61.  *
  62.  *    n    place each include file on a new page with a header
  63.  *
  64.  *    p    disable post mortem and statement limit counting
  65.  *
  66.  *    t    disable run-time tests
  67.  *
  68.  *    u    card image mode; only first 72 chars of input count
  69.  *
  70.  *    w    suppress special diagnostic warnings
  71.  *
  72.  *    z    generate counters for an execution profile
  73.  */
  74. #ifdef DEBUG
  75. bool    fulltrace, errtrace, testtrace, yyunique;
  76. #endif DEBUG
  77.  
  78. /*
  79.  * Each option has a stack of 17 option values, with opts giving
  80.  * the current, top value, and optstk the value beneath it.
  81.  * One refers to option `l' as, e.g., opt('l') in the text for clarity.
  82.  */
  83. char    opts[ 'z' - 'A' + 1];
  84. short    optstk[ 'z' - 'A' + 1];
  85.  
  86. #define opt(c) opts[c-'A']
  87.  
  88. /*
  89.  * Monflg is set when we are generating
  90.  * a pxp profile.  this is set by the -z command line option.
  91.  */
  92. bool    monflg;
  93.  
  94.     /*
  95.      *    profflag is set when we are generating a prof profile.
  96.      *    this is set by the -p command line option.
  97.      */
  98. #ifdef PC
  99. bool    profflag;
  100. #endif
  101.  
  102.  
  103. /*
  104.  * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
  105.  *
  106.  * Pi uses expandable tables for
  107.  * its namelist (symbol table), string table
  108.  * hash table, and parse tree space.  The following
  109.  * definitions specify the size of the increments
  110.  * for these items in fundamental units so that
  111.  * each uses approximately 1024 bytes.
  112.  */
  113.  
  114. #define    STRINC    1024        /* string space increment */
  115. #define    TRINC    1024        /* tree space increment */
  116. #define    HASHINC    509        /* hash table size in words, each increment */
  117. #define    NLINC    56        /* namelist increment size in nl structs */
  118.  
  119. /*
  120.  * The initial sizes of the structures.
  121.  * These should be large enough to compile
  122.  * an "average" sized program so as to minimize
  123.  * storage requests.
  124.  * On a small system or and 11/34 or 11/40
  125.  * these numbers can be trimmed to make the
  126.  * compiler smaller.
  127.  */
  128. #define    ITREE    2000
  129. #define    INL    200
  130. #define    IHASH    509
  131.  
  132. /*
  133.  * The following limits on hash and tree tables currently
  134.  * allow approximately 1200 symbols and 20k words of tree
  135.  * space.  The fundamental limit of 64k total data space
  136.  * should be exceeded well before these are full.
  137.  */
  138. /*
  139.  * TABLE_MULTIPLIER is for uniformly increasing the sizes of the tables
  140.  */
  141. #ifdef ADDR32
  142. #define TABLE_MULTIPLIER    8
  143. #endif ADDR32
  144. #ifdef ADDR16
  145. #define TABLE_MULTIPLIER    1
  146. #endif ADDR16
  147. #define    MAXHASH    (4 * TABLE_MULTIPLIER)
  148. #define    MAXNL    (12 * TABLE_MULTIPLIER)
  149. #define    MAXTREE    (40 * TABLE_MULTIPLIER)
  150. /*
  151.  * MAXDEPTH is the depth of the parse stack.
  152.  * STACK_MULTIPLIER is for increasing its size.
  153.  */
  154. #ifdef ADDR32
  155. #define    STACK_MULTIPLIER    8
  156. #endif ADDR32
  157. #ifdef ADDR16
  158. #define    STACK_MULTIPLIER    1
  159. #endif ADDR16
  160. #define    MAXDEPTH ( 150 * STACK_MULTIPLIER )
  161.  
  162. /*
  163.  * ERROR RELATED DEFINITIONS
  164.  */
  165.  
  166. /*
  167.  * Exit statuses to pexit
  168.  *
  169.  * AOK
  170.  * ERRS        Compilation errors inhibit obj productin
  171.  * NOSTART    Errors before we ever got started
  172.  * DIED        We ran out of memory or some such
  173.  */
  174. #define    AOK    0
  175. #define    ERRS    1
  176. #define    NOSTART    2
  177. #define    DIED    3
  178.  
  179. bool    Recovery;
  180.  
  181. #define    eholdnl()    Eholdnl = TRUE
  182. #define    nocascade()    Enocascade = TRUE
  183.  
  184. bool    Eholdnl, Enocascade;
  185.  
  186.  
  187. /*
  188.  * The flag eflg is set whenever we have a hard error.
  189.  * The character in errpfx will precede the next error message.
  190.  * When cgenflg is set code generation is suppressed.
  191.  * This happens whenver we have an error (i.e. if eflg is set)
  192.  * and when we are walking the tree to determine types only.
  193.  */
  194. bool    eflg;
  195. char    errpfx;
  196.  
  197. #define    setpfx(x)    errpfx = x
  198.  
  199. #define    standard()    setpfx('s')
  200. #define    warning()    setpfx('w')
  201. #define    recovered()    setpfx('e')
  202. #define    continuation()    setpfx(' ')
  203.  
  204. int    cgenflg;
  205.  
  206.  
  207. /*
  208.  * The flag syneflg is used to suppress the diagnostics of the form
  209.  *    E 10 a, defined in someprocedure, is neither used nor set
  210.  * when there were syntax errors in "someprocedure".
  211.  * In this case, it is likely that these warinings would be spurious.
  212.  */
  213. bool    syneflg;
  214.  
  215. /*
  216.  * The compiler keeps its error messages in a file.
  217.  * The variable efil is the unit number on which
  218.  * this file is open for reading of error message text.
  219.  * Similarly, the file ofil is the unit of the file
  220.  * "obj" where we write the interpreter code.
  221.  */
  222. short    efil;
  223.  
  224. #ifdef OBJ
  225. short    ofil;
  226.  
  227. short    obuf[518];
  228. #endif
  229.  
  230. bool    Enoline;
  231. #define    elineoff()    Enoline = TRUE
  232. #define    elineon()    Enoline = FALSE
  233.  
  234.  
  235. /*
  236.  * SYMBOL TABLE STRUCTURE DEFINITIONS
  237.  *
  238.  * The symbol table is henceforth referred to as the "namelist".
  239.  * It consists of a number of structures of the form "nl" below.
  240.  * These are contained in a number of segments of the symbol
  241.  * table which are dynamically allocated as needed.
  242.  * The major namelist manipulation routines are contained in the
  243.  * file "nl.c".
  244.  *
  245.  * The major components of a namelist entry are the "symbol", giving
  246.  * a pointer into the string table for the string associated with this
  247.  * entry and the "class" which tells which of the (currently 19)
  248.  * possible types of structure this is.
  249.  *
  250.  * Many of the classes use the "type" field for a pointer to the type
  251.  * which the entry has.
  252.  *
  253.  * Other pieces of information in more than one class include the block
  254.  * in which the symbol is defined, flags indicating whether the symbol
  255.  * has been used and whether it has been assigned to, etc.
  256.  *
  257.  * A more complete discussion of the features of the namelist is impossible
  258.  * here as it would be too voluminous.  Refer to the "PI 1.0 Implementation
  259.  * Notes" for more details.
  260.  */
  261.  
  262. /*
  263.  * The basic namelist structure.
  264.  * There is a union of data types defining the stored information
  265.  * as pointers, integers, longs, or a double.
  266.  *
  267.  * The array disptab defines the hash header for the symbol table.
  268.  * Symbols are hashed based on the low 6 bits of their pointer into
  269.  * the string table; see the routines in the file "lookup.c" and also "fdec.c"
  270.  * especially "funcend".
  271.  */
  272. extern int    pnumcnt;
  273.  
  274. struct    nl {
  275.     char    *symbol;
  276.     char    info[4];
  277.     struct    nl *type;
  278.     struct    nl *chain, *nl_next;
  279.     union {
  280.         struct nl *un_ptr[5];
  281.         int       un_value[5];
  282.         long       un_range[2];
  283.         double       un_real;
  284.         struct nl  *un_nptr[5];    /* Points to conformant array bounds */
  285.     } nl_un;
  286. #    ifdef PTREE
  287.         pPointer    inTree;
  288. #    endif PTREE
  289. };
  290.  
  291. #define class        info[0]
  292. #define nl_flags    info[1]
  293. #define nl_block    info[1]
  294. #define extra_flags    info[2]
  295. #define align_info    info[3]
  296.  
  297. #define range    nl_un.un_range
  298. #define value    nl_un.un_value
  299. #define ptr    nl_un.un_ptr
  300. #define real    nl_un.un_real
  301. #define nptr    nl_un.un_nptr    
  302.  
  303. extern struct nl *nlp, *disptab[077+1], *Fp;
  304. extern struct nl nl[INL];
  305.  
  306.  
  307. /*
  308.  * NL FLAGS BITS
  309.  *
  310.  * Definitions of the usage of the bits in
  311.  * the nl_flags byte. Note that the low 5 bits of the
  312.  * byte are the "nl_block" and that some classes make use
  313.  * of this byte as a "width".
  314.  *
  315.  * The only non-obvious bit definition here is "NFILES"
  316.  * which records whether a structure contains any files.
  317.  * Such structures are not allowed to be dynamically allocated.
  318.  */
  319.  
  320. #define    BLOCKNO( flag )    ( flag & 037 )
  321. #define NLFLAGS( flag ) ( flag &~ 037 )
  322.  
  323. #define    NUSED    0100
  324. #define    NMOD    0040
  325. #define    NFORWD    0200
  326. #define    NFILES    0200
  327. #ifdef PC
  328. #define NEXTERN 0001    /* flag used to mark external funcs and procs */
  329. #define    NLOCAL    0002    /* variable is a local */
  330. #define    NPARAM    0004    /* variable is a parameter */
  331. #define    NGLOBAL    0010    /* variable is a global */
  332. #define    NREGVAR    0020    /* or'ed in if variable is in a register */
  333. #define NNLOCAL 0040    /* named local variable, not used in symbol table */
  334. #endif PC
  335.  
  336. /*
  337.  * used to mark value[ NL_FORV ] for loop variables
  338.  */
  339. #define    FORVAR        1
  340.  
  341. /*
  342.  * Definition of the commonly used "value" fields.
  343.  * The most important one is NL_OFFS which gives
  344.  * the offset of a variable in its stack mark.
  345.  */
  346. #define NL_OFFS    0
  347.  
  348. #define    NL_CNTR    1
  349. #define NL_NLSTRT 2
  350. #define    NL_LINENO 3
  351. #define    NL_FVAR    3
  352. #define    NL_ENTLOC 4    /* FUNC, PROC - entry point */
  353. #define    NL_FCHAIN 4    /* FFUNC, FPROC - ptr to formals */
  354.  
  355. #define NL_GOLEV 2
  356. #define NL_GOLINE 3
  357. #define NL_FORV 1
  358.  
  359.     /*
  360.      *    nlp -> nl_un.un_ptr[] subscripts for records
  361.      *    NL_FIELDLIST    the chain of fixed fields of a record, in order.
  362.      *            the fields are also chained through ptr[NL_FIELDLIST].
  363.      *            this does not include the tag, or fields of variants.
  364.      *    NL_VARNT    pointer to the variants of a record,
  365.      *            these are then chained through the .chain field.
  366.      *    NL_VTOREC    pointer from a VARNT to the RECORD that is the variant.
  367.      *    NL_TAG        pointer from a RECORD to the tagfield
  368.      *            if there are any variants.
  369.      *    align_info    the alignment of a RECORD is in info[3].
  370.      */
  371. #define    NL_FIELDLIST    1
  372. #define    NL_VARNT    2
  373. #define    NL_VTOREC    2
  374. #define    NL_TAG        3
  375. /* and align_info is info[3].  #defined above */
  376.  
  377. #define    NL_ELABEL 4    /* SCAL - ptr to definition of enums */
  378.  
  379. /*
  380.  * For BADUSE nl structures, NL_KINDS is a bit vector
  381.  * indicating the kinds of illegal usages complained about
  382.  * so far.  For kind of bad use "kind", "1 << kind" is set.
  383.  * The low bit is reserved as ISUNDEF to indicate whether
  384.  * this identifier is totally undefined.
  385.  */
  386. #define    NL_KINDS    0
  387.  
  388. #define    ISUNDEF        1
  389.  
  390.     /*
  391.      *    variables come in three flavors: globals, parameters, locals;
  392.      *    they can also hide in registers, but that's a different flag
  393.      */
  394. #define PARAMVAR    1
  395. #define LOCALVAR    2
  396. #define    GLOBALVAR    3
  397. #define    NAMEDLOCALVAR    4
  398.  
  399. /*
  400.  * NAMELIST CLASSES
  401.  *
  402.  * The following are the namelist classes.
  403.  * Different classes make use of the value fields
  404.  * of the namelist in different ways.
  405.  *
  406.  * The namelist should be redesigned by providing
  407.  * a number of structure definitions with one corresponding
  408.  * to each namelist class, ala a variant record in Pascal.
  409.  */
  410. #define    BADUSE    0
  411. #define    CONST    1
  412. #define    TYPE    2
  413. #define    VAR    3
  414. #define    ARRAY    4
  415. #define    PTRFILE    5
  416. #define    RECORD    6
  417. #define    FIELD    7
  418. #define    PROC    8
  419. #define    FUNC    9
  420. #define    FVAR    10
  421. #define    REF    11
  422. #define    PTR    12
  423. #define    FILET    13
  424. #define    SET    14
  425. #define    RANGE    15
  426. #define    LABEL    16
  427. #define    WITHPTR 17
  428. #define    SCAL    18
  429. #define    STR    19
  430. #define    PROG    20
  431. #define    IMPROPER 21
  432. #define    VARNT    22
  433. #define    FPROC    23
  434. #define    FFUNC    24
  435. #define CRANGE    25
  436.  
  437. /*
  438.  * Clnames points to an array of names for the
  439.  * namelist classes.
  440.  */
  441. char    **clnames;
  442.  
  443. /*
  444.  * PRE-DEFINED NAMELIST OFFSETS
  445.  *
  446.  * The following are the namelist offsets for the
  447.  * primitive types. The ones which are negative
  448.  * don't actually exist, but are generated and tested
  449.  * internally. These definitions are sensitive to the
  450.  * initializations in nl.c.
  451.  */
  452. #define    TFIRST -7
  453. #define    TFILE  -7
  454. #define    TREC   -6
  455. #define    TARY   -5
  456. #define    TSCAL  -4
  457. #define    TPTR   -3
  458. #define    TSET   -2
  459. #define    TSTR   -1
  460. #define    NIL    0
  461. #define    TBOOL    1
  462. #define    TCHAR    2
  463. #define    TINT    3
  464. #define    TDOUBLE    4
  465. #define    TNIL    5
  466. #define    T1INT    6
  467. #define    T2INT    7
  468. #define    T4INT    8
  469. #define    T1CHAR    9
  470. #define    T1BOOL    10
  471. #define    T8REAL    11
  472. #define TLAST    11
  473.  
  474. /*
  475.  * SEMANTIC DEFINITIONS
  476.  */
  477.  
  478. /*
  479.  * NOCON and SAWCON are flags in the tree telling whether
  480.  * a constant set is part of an expression.
  481.  *    these are no longer used,
  482.  *    since we now do constant sets at compile time.
  483.  */
  484. #define NOCON    0
  485. #define SAWCON    1
  486.  
  487. /*
  488.  * The variable cbn gives the current block number,
  489.  * the variable bn is set as a side effect of a call to
  490.  * lookup, and is the block number of the variable which
  491.  * was found.
  492.  */
  493. short    bn, cbn;
  494.  
  495. /*
  496.  * The variable line is the current semantic
  497.  * line and is set in stat.c from the numbers
  498.  * embedded in statement type tree nodes.
  499.  */
  500. short    line;
  501.  
  502. /*
  503.  * The size of the display
  504.  * which defines the maximum nesting
  505.  * of procedures and functions allowed.
  506.  * Because of the flags in the current namelist
  507.  * this must be no greater than 32.
  508.  */
  509. #define    DSPLYSZ 20
  510.  
  511.     /*
  512.      *    the following structure records whether a level declares
  513.      *    any variables which are (or contain) files.
  514.      *    this so that the runtime routines for file cleanup can be invoked.
  515.      */
  516. bool    dfiles[ DSPLYSZ ];
  517.  
  518. /*
  519.  * Structure recording information about a constant
  520.  * declaration.  It is actually the return value from
  521.  * the routine "gconst", but since C doesn't support
  522.  * record valued functions, this is more convenient.
  523.  */
  524. struct {
  525.     struct nl    *ctype;
  526.     short        cival;
  527.     double        crval;
  528.     char        *cpval;    /* note used to be int * */
  529. } con;
  530.  
  531. /*
  532.  * The set structure records the lower bound
  533.  * and upper bound with the lower bound normalized
  534.  * to zero when working with a set. It is set by
  535.  * the routine setran in var.c.
  536.  */
  537. struct {
  538.     short    lwrb, uprbp;
  539. } set;
  540.  
  541.     /*
  542.      *    structures of this kind are filled in by precset and used by postcset
  543.      *    to indicate things about constant sets.
  544.      */
  545. struct csetstr {
  546.     struct nl    *csettype;
  547.     long    paircnt;
  548.     long    singcnt;
  549.     bool    comptime;
  550. };
  551. /*
  552.  * The following flags are passed on calls to lvalue
  553.  * to indicate how the reference is to affect the usage
  554.  * information for the variable being referenced.
  555.  * MOD is used to set the NMOD flag in the namelist
  556.  * entry for the variable, ASGN permits diagnostics
  557.  * to be formed when a for variable is assigned to in
  558.  * the range of the loop.
  559.  */
  560. #define    NOFLAGS    0
  561. #define    MOD    01
  562. #define    ASGN    02
  563. #define    NOUSE    04
  564.  
  565.     /*
  566.      *    the following flags are passed to lvalue and rvalue
  567.      *    to tell them whether an lvalue or rvalue is required.
  568.      *    the semantics checking is done according to the function called,
  569.      *    but for pc, lvalue may put out an rvalue by indirecting afterwards,
  570.      *    and rvalue may stop short of putting out the indirection.
  571.      */
  572. #define    LREQ    01
  573. #define    RREQ    02
  574.  
  575. double    MAXINT;
  576. double    MININT;
  577.  
  578. /*
  579.  * Variables for generation of profile information.
  580.  * Monflg is set when we want to generate a profile.
  581.  * Gocnt record the total number of goto's and
  582.  * cnts records the current counter for generating
  583.  * COUNT operators.
  584.  */
  585. short    gocnt;
  586. short    cnts;
  587.  
  588. /*
  589.  * Most routines call "incompat" rather than asking "!compat"
  590.  * for historical reasons.
  591.  */
  592. #define incompat     !compat
  593.  
  594. /*
  595.  * Parts records which declaration parts have been seen.
  596.  * The grammar allows the "label" "const" "type" "var" and routine
  597.  * parts to be repeated and to be in any order, so that
  598.  * they can be detected semantically to give better
  599.  * error diagnostics.
  600.  *
  601.  * The flag NONLOCALVAR indicates that a non-local var has actually
  602.  * been used hence the display must be saved; NONLOCALGOTO indicates
  603.  * that a non-local goto has been done hence that a setjmp must be done.
  604.  */
  605. int    parts[ DSPLYSZ ];
  606.  
  607. #define    LPRT        0x0001
  608. #define    CPRT        0x0002
  609. #define    TPRT        0x0004
  610. #define    VPRT        0x0008
  611. #define    RPRT        0x0010
  612.  
  613. #define    NONLOCALVAR    0x0020
  614. #define    NONLOCALGOTO    0x0040
  615.  
  616. /*
  617.  * Flags for the "you used / instead of div" diagnostic
  618.  */
  619. bool    divchk;
  620. bool    divflg;
  621.  
  622. bool    errcnt[DSPLYSZ];
  623.  
  624. /*
  625.  * Forechain links those types which are
  626.  *    ^ sometype
  627.  * so that they can be evaluated later, permitting
  628.  * circular, recursive list structures to be defined.
  629.  */
  630. struct    nl *forechain;
  631.  
  632. /*
  633.  * Withlist links all the records which are currently
  634.  * opened scopes because of with statements.
  635.  */
  636. struct    nl *withlist;
  637.  
  638. struct    nl *intset;
  639. struct    nl *input, *output;
  640. struct    nl *program;
  641.  
  642. /* progseen flag used by PC to determine if
  643.  * a routine segment is being compiled (and
  644.  * therefore no program statement seen)
  645.  */
  646. bool    progseen;
  647.  
  648.  
  649. /*
  650.  * STRUCTURED STATEMENT GOTO CHECKING
  651.  *
  652.  * The variable level keeps track of the current
  653.  * "structured statement level" when processing the statement
  654.  * body of blocks.  This is used in the detection of goto's into
  655.  * structured statements in a block.
  656.  *
  657.  * Each label's namelist entry contains two pieces of information
  658.  * related to this check. The first `NL_GOLEV' either contains
  659.  * the level at which the label was declared, `NOTYET' if the label
  660.  * has not yet been declared, or `DEAD' if the label is dead, i.e.
  661.  * if we have exited the level in which the label was defined.
  662.  *
  663.  * When we discover a "goto" statement, if the label has not
  664.  * been defined yet, then we record the current level and the current line
  665.  * for a later error check.  If the label has been already become "DEAD"
  666.  * then a reference to it is an error.  Now the compiler maintains,
  667.  * for each block, a linked list of the labels headed by "gotos[bn]".
  668.  * When we exit a structured level, we perform the routine
  669.  * ungoto in stat.c. It notices labels whose definition levels have been
  670.  * exited and makes them be dead. For labels which have not yet been
  671.  * defined, ungoto will maintain NL_GOLEV as the minimum structured level
  672.  * since the first usage of the label. It is not hard to see that the label
  673.  * must eventually be declared at this level or an outer level to this
  674.  * one or a goto into a structured statement will exist.
  675.  */
  676. short    level;
  677. struct    nl *gotos[DSPLYSZ];
  678.  
  679. #define    NOTYET    10000
  680. #define    DEAD    10000
  681.  
  682. /*
  683.  * Noreach is true when the next statement will
  684.  * be unreachable unless something happens along
  685.  * (like exiting a looping construct) to save
  686.  * the day.
  687.  */
  688. bool    noreach;
  689.  
  690. /*
  691.  * UNDEFINED VARIABLE REFERENCE STRUCTURES
  692.  */
  693. struct    udinfo {
  694.     int    ud_line;
  695.     struct    udinfo *ud_next;
  696.     char    nullch;
  697. };
  698.  
  699. /*
  700.  * CODE GENERATION DEFINITIONS
  701.  */
  702.  
  703. /*
  704.  * NSTAND is or'ed onto the abstract machine opcode
  705.  * for non-standard built-in procedures and functions.
  706.  */
  707. #define    NSTAND    0400
  708.  
  709. #define    codeon()    cgenflg++
  710. #define    codeoff()    --cgenflg
  711. #define    CGENNING    ( cgenflg >= 0 )
  712.  
  713. /*
  714.  * Codeline is the last lino output in the code generator.
  715.  * It used to be used to suppress LINO operators but no
  716.  * more since we now count statements.
  717.  * Lc is the intepreter code location counter.
  718.  *
  719. short    codeline;
  720.  */
  721. #ifdef OBJ
  722. char    *lc;
  723. #endif
  724.  
  725.  
  726. /*
  727.  * Routines which need types
  728.  * other than "integer" to be
  729.  * assumed by the compiler.
  730.  */
  731. long        lwidth();
  732. long        leven();
  733. long        aryconst();
  734. long        a8tol();
  735. long        roundup();
  736. struct nl     *tmpalloc();
  737. struct nl     *lookup();
  738. int        *hash();
  739. char        *alloc();
  740. int        *pcalloc();
  741. char        *savestr();
  742. char         *esavestr();
  743. char        *parnam();
  744. char        *getlab();
  745. char        *getnext();
  746. char        *skipbl();
  747. char        *nameof();
  748. char         *pstrcpy();
  749. char        *myctime();
  750. char        *putlab();
  751. bool        fcompat();
  752. bool         constval();
  753. bool        precset();
  754. bool        nilfnil();
  755. struct nl    *funccod();
  756. struct nl    *pcfunccod();
  757. struct nl    *lookup1();
  758. struct nl    *hdefnl();
  759. struct nl    *defnl();
  760. struct nl    *flvalue();
  761. struct nl    *plist();
  762. struct nl    *enter();
  763. struct nl    *nlcopy();
  764. struct nl    *tyrec();
  765. struct nl    *tyary();
  766. struct nl    *tyrang();
  767. struct nl    *tyscal();
  768. struct nl    *deffld();
  769. struct nl    *stklval();
  770. struct nl    *scalar();
  771. struct nl    *gen();
  772. struct nl    *stkrval();
  773. struct nl    *funcext();
  774. struct nl    *funchdr();
  775. struct nl    *funcbody();
  776. struct nl     *yybaduse();
  777. struct nl    *stackRV();
  778. struct nl    *defvnt();
  779. struct nl    *tyrec1();
  780. struct nl    *reclook();
  781. struct nl    *asgnop1();
  782. struct nl    *pcasgconf();
  783. struct nl    *gtype();
  784. struct nl    *call();
  785. struct nl    *lvalue();
  786. struct nl    *pclvalue();
  787. struct nl    *rvalue();
  788. struct nl    *cset();
  789. struct nl    *tycrang();
  790. struct tnode    *newlist();
  791. struct tnode    *addlist();
  792. struct tnode    *fixlist();
  793. struct tnode    *setupvar();
  794. struct tnode    *setuptyrec();
  795. struct tnode    *setupfield();
  796. struct tnode    *tree();
  797. struct tnode    *tree1();
  798. struct tnode    *tree2();
  799. struct tnode    *tree3();
  800. struct tnode    *tree4();
  801. struct tnode    *tree5();
  802.  
  803. /*
  804.  * type cast NIL to keep lint happy (which is not so bad)
  805.  */
  806. #define        NLNIL    ( (struct nl *) NIL )
  807. #define        TR_NIL    ( (struct tnode *) NIL)
  808.  
  809. /*
  810.  * Funny structures to use
  811.  * pointers in wild and wooly ways
  812.  */
  813. struct cstruct{
  814.     char    pchar;
  815. };
  816. struct {
  817.     short    pint;
  818.     short    pint2;
  819. };
  820. struct lstruct {
  821.     long    plong;
  822. };
  823. struct {
  824.     double    pdouble;
  825. };
  826.  
  827. #define    OCT    1
  828. #define    HEX    2
  829.  
  830. /*
  831.  * MAIN PROGRAM VARIABLES, MISCELLANY
  832.  */
  833.  
  834. /*
  835.  * Variables forming a data base referencing
  836.  * the command line arguments with the "i" option, e.g.
  837.  * in "pi -i scanner.i compiler.p".
  838.  */
  839. char    **pflist;
  840. short    pflstc;
  841. short    pfcnt;
  842.  
  843. char    *filename;        /* current source file name */
  844. long    tvec;
  845. extern char    *snark;        /* SNARK */
  846. extern char    *classes[ ];    /* maps namelist classes to string names */
  847.  
  848. #define    derror error
  849.  
  850. #ifdef    PC
  851.  
  852.     /*
  853.      *    the current function number, for [ lines
  854.      */
  855.     int    ftnno;
  856.  
  857.     /*
  858.      *    the pc output stream
  859.      */
  860.     FILE *pcstream;
  861.  
  862. #endif PC
  863.