Annotation of researchv10no/cmd/picasso/dextern, revision 1.1.1.1

1.1       root        1: #ident "@(#)/usr/src/cmd/yacc/dextern  1.4 6/11/85 14:15:01 - Amdahl/UTS"
                      2: /*     @(#)dextern     1.5     */
                      3: # include <stdio.h>
                      4: # include <ctype.h>
                      5: # include "files"
                      6: 
                      7:        /*  MANIFEST CONSTANT DEFINITIONS */
                      8: 
                      9:        /* base of nonterminal internal numbers */
                     10: # define NTBASE 010000
                     11: 
                     12:        /* internal codes for error and accept actions */
                     13: 
                     14: # define ERRCODE  8190
                     15: # define ACCEPTCODE 8191
                     16: 
                     17:        /* sizes and limits */
                     18: 
                     19: # ifdef HUGE
                     20: # define ACTSIZE 12000
                     21: # define MEMSIZE 12000
                     22: # define NSTATES 2000
                     23: # define NTERMS 160
                     24: # define NPROD 600
                     25: # define NNONTERM 450
                     26: # define TEMPSIZE 1500
                     27: # define CNAMSZ 5000
                     28: # define LSETSIZE 800
                     29: # define WSETSIZE 500
                     30: # endif
                     31: 
                     32: # ifdef MEDIUM
                     33: # define ACTSIZE 4000
                     34: # define MEMSIZE 10000
                     35: # define NSTATES 600
                     36: # define NTERMS 160
                     37: # define NPROD 300
                     38: # define NNONTERM 400
                     39: # define TEMPSIZE 800
                     40: # define CNAMSZ 4000
                     41: # define LSETSIZE 450
                     42: # define WSETSIZE 250
                     43: # endif
                     44: 
                     45: # define NAMESIZE 50
                     46: # define NTYPES 63
                     47: 
                     48: # ifdef WORD32
                     49: # define TBITSET ((32+NTERMS)/32)
                     50: 
                     51:        /* bit packing macros (may be machine dependent) */
                     52: # define BIT(a,i) ((a)[(i)>>5] & (1<<((i)&037)))
                     53: # define SETBIT(a,i) ((a)[(i)>>5] |= (1<<((i)&037)))
                     54: 
                     55:        /* number of words needed to hold n+1 bits */
                     56: # define NWORDS(n) (((n)+32)/32)
                     57: 
                     58: # else
                     59: 
                     60: # define TBITSET ((16+NTERMS)/16)
                     61: 
                     62:        /* bit packing macros (may be machine dependent) */
                     63: # define BIT(a,i) ((a)[(i)>>4] & (1<<((i)&017)))
                     64: # define SETBIT(a,i) ((a)[(i)>>4] |= (1<<((i)&017)))
                     65: 
                     66:        /* number of words needed to hold n+1 bits */
                     67: # define NWORDS(n) (((n)+16)/16)
                     68: # endif
                     69: 
                     70:        /* relationships which must hold:
                     71:        TBITSET ints must hold NTERMS+1 bits...
                     72:        WSETSIZE >= NNONTERM
                     73:        LSETSIZE >= NNONTERM
                     74:        TEMPSIZE >= NTERMS + NNONTERMs + 1
                     75:        TEMPSIZE >= NSTATES
                     76:        */
                     77: 
                     78:        /* associativities */
                     79: 
                     80: # define NOASC 0  /* no assoc. */
                     81: # define LASC 1  /* left assoc. */
                     82: # define RASC 2  /* right assoc. */
                     83: # define BASC 3  /* binary assoc. */
                     84: 
                     85:        /* flags for state generation */
                     86: 
                     87: # define DONE 0
                     88: # define MUSTDO 1
                     89: # define MUSTLOOKAHEAD 2
                     90: 
                     91:        /* flags for a rule having an action, and being reduced */
                     92: 
                     93: # define ACTFLAG 04
                     94: # define REDFLAG 010
                     95: 
                     96:        /* output parser flags */
                     97: # define YYFLAG1 (-1000)
                     98: 
                     99:        /* macros for getting associativity and precedence levels */
                    100: 
                    101: # define ASSOC(i) ((i)&03)
                    102: # define PLEVEL(i) (((i)>>4)&077)
                    103: # define TYPE(i)  ((i>>10)&077)
                    104: 
                    105:        /* macros for setting associativity and precedence levels */
                    106: 
                    107: # define SETASC(i,j) i|=j
                    108: # define SETPLEV(i,j) i |= (j<<4)
                    109: # define SETTYPE(i,j) i |= (j<<10)
                    110: 
                    111:        /* looping macros */
                    112: 
                    113: # define TLOOP(i) for(i=1;i<=ntokens;++i)
                    114: # define NTLOOP(i) for(i=0;i<=nnonter;++i)
                    115: # define PLOOP(s,i) for(i=s;i<nprod;++i)
                    116: # define SLOOP(i) for(i=0;i<nstate;++i)
                    117: # define WSBUMP(x) ++x
                    118: # define WSLOOP(s,j) for(j=s;j<cwp;++j)
                    119: # define ITMLOOP(i,p,q) q=pstate[i+1];for(p=pstate[i];p<q;++p)
                    120: # define SETLOOP(i) for(i=0;i<tbitset;++i)
                    121: 
                    122:        /* I/O descriptors */
                    123: 
                    124: extern FILE * finput;          /* input file */
                    125: extern FILE * faction;         /* file for saving actions */
                    126: extern FILE * fdefine;         /* file for # defines */
                    127: extern FILE * ftable;          /* y.tab.c file */
                    128: extern FILE * ftemp;           /* tempfile to pass 2 */
                    129: extern FILE * fdebug;          /* tempfile for two debugging info arrays */
                    130: extern FILE * foutput;         /* y.output file */
                    131: 
                    132:        /* structure declarations */
                    133: 
                    134: struct looksets {
                    135:        int lset[TBITSET];
                    136:        };
                    137: 
                    138: struct item {
                    139:        int *pitem;
                    140:        struct looksets *look;
                    141:        };
                    142: 
                    143: struct toksymb {
                    144:        char *name;
                    145:        int value;
                    146:        };
                    147: 
                    148: struct ntsymb {
                    149:        char *name;
                    150:        int tvalue;
                    151:        };
                    152: 
                    153: struct wset {
                    154:        int *pitem;
                    155:        int flag;
                    156:        struct looksets ws;
                    157:        };
                    158: 
                    159:        /* token information */
                    160: 
                    161: extern int ntokens ;   /* number of tokens */
                    162: extern struct toksymb tokset[];
                    163: extern int toklev[];   /* vector with the precedence of the terminals */
                    164: 
                    165:        /* nonterminal information */
                    166: 
                    167: extern int nnonter ;   /* the number of nonterminals */
                    168: extern struct ntsymb nontrst[];
                    169: 
                    170:        /* grammar rule information */
                    171: 
                    172: extern int nprod ;     /* number of productions */
                    173: extern int *prdptr[];  /* pointers to descriptions of productions */
                    174: extern int levprd[] ;  /* contains production levels to break conflicts */
                    175: extern char had_act[]; /* set if reduction has associated action code */
                    176: 
                    177:        /* state information */
                    178: 
                    179: extern int nstate ;            /* number of states */
                    180: extern struct item *pstate[];  /* pointers to the descriptions of the states */
                    181: extern int tystate[];  /* contains type information about the states */
                    182: extern int defact[];   /* the default action of the state */
                    183: extern int tstates[];  /* the states deriving each token */
                    184: extern int ntstates[]; /* the states deriving each nonterminal */
                    185: extern int mstates[];  /* the continuation of the chains begun in tstates and ntstates */
                    186: 
                    187:        /* lookahead set information */
                    188: 
                    189: extern struct looksets lkst[];
                    190: extern int nolook;  /* flag to turn off lookahead computations */
                    191: 
                    192:        /* working set information */
                    193: 
                    194: extern struct wset wsets[];
                    195: extern struct wset *cwp;
                    196: 
                    197:        /* storage for productions */
                    198: 
                    199: extern int mem0[];
                    200: extern int *mem;
                    201: 
                    202:        /* storage for action table */
                    203: 
                    204: extern int amem[];  /* action table storage */
                    205: extern int *memp ;             /* next free action table position */
                    206: extern int indgo[];            /* index to the stored goto table */
                    207: 
                    208:        /* temporary vector, indexable by states, terms, or ntokens */
                    209: 
                    210: extern int temp1[];
                    211: extern int lineno; /* current line number */
                    212: 
                    213:        /* statistics collection variables */
                    214: 
                    215: extern int zzgoent ;
                    216: extern int zzgobest ;
                    217: extern int zzacent ;
                    218: extern int zzexcp ;
                    219: extern int zzclose ;
                    220: extern int zzrrconf ;
                    221: extern int zzsrconf ;
                    222:        /* define functions with strange types... */
                    223: 
                    224: extern char *cstash();
                    225: extern struct looksets *flset();
                    226: extern char *symnam();
                    227: extern char *writem();
                    228: 
                    229:        /* default settings for a number of macros */
                    230: 
                    231:        /* name of yacc tempfiles */
                    232: 
                    233: # ifndef TEMPNAME
                    234: # define TEMPNAME "yacc.tmp"
                    235: # endif
                    236: 
                    237: # ifndef ACTNAME
                    238: # define ACTNAME "yacc.acts"
                    239: # endif
                    240: 
                    241: # ifndef DEBUGNAME
                    242: # define DEBUGNAME "yacc.debug"
                    243: # endif
                    244: 
                    245:        /* output file name */
                    246: 
                    247: # ifndef OFILE
                    248: # define OFILE "y.tab.c"
                    249: # endif
                    250: 
                    251:        /* user output file name */
                    252: 
                    253: # ifndef FILEU
                    254: # define FILEU "y.output"
                    255: # endif
                    256: 
                    257:        /* output file for # defines */
                    258: 
                    259: # ifndef FILED
                    260: # define FILED "y.tab.h"
                    261: # endif
                    262: 
                    263:        /* command to clobber tempfiles after use */
                    264: 
                    265: # ifndef ZAPFILE
                    266: # define ZAPFILE(x) unlink(x)
                    267: # endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.