neil@beowulf.UUCP (04/06/87)
What follows are diffs to get yacc (4.3BSD distribution) running under MPW C.
The changes are all due to the fact that MPW C only allows 64K of globals.
Most static arrays are now dynamically allocated.
*** dextern Wed Apr 1 10:54:29 1987
--- yacc/dextern Mon Apr 6 12:43:59 1987
***************
*** 159,166
/* token information */
extern int ntokens ; /* number of tokens */
! extern struct toksymb *tokset;
! extern int *toklev; /* vector with the precedence of the terminals */
/* nonterminal information */
--- 159,166 -----
/* token information */
extern int ntokens ; /* number of tokens */
! extern struct toksymb tokset[];
! extern int toklev[]; /* vector with the precedence of the terminals */
/* nonterminal information */
***************
*** 170,177
/* grammar rule information */
extern int nprod ; /* number of productions */
! extern int **prdptr; /* pointers to descriptions of productions */
! extern int *levprd; /* contains production levels to break conflicts */
/* state information */
--- 170,177 -----
/* grammar rule information */
extern int nprod ; /* number of productions */
! extern int *prdptr[]; /* pointers to descriptions of productions */
! extern int levprd[] ; /* contains production levels to break conflicts */
/* state information */
***************
*** 176,187
/* state information */
extern int nstate ; /* number of states */
! extern struct item **pstate; /* pointers to the descriptions of the states */
! extern int *tystate; /* contains type information about the states */
! extern int *defact; /* the default action of the state */
! extern int *tstates; /* the states deriving each token */
! extern int *ntstates; /* the states deriving each nonterminal */
! extern int *mstates; /* the continuation of the chains begun in tstates and ntstates */
/* lookahead set information */
--- 176,187 -----
/* state information */
extern int nstate ; /* number of states */
! extern struct item *pstate[]; /* pointers to the descriptions of the states */
! extern int tystate[]; /* contains type information about the states */
! extern int defact[]; /* the default action of the state */
! extern int tstates[]; /* the states deriving each token */
! extern int ntstates[]; /* the states deriving each nonterminal */
! extern int mstates[]; /* the continuation of the chains begun in tstates and ntstates */
/* lookahead set information */
***************
*** 185,191
/* lookahead set information */
! extern struct looksets *lkst;
extern int nolook; /* flag to turn off lookahead computations */
/* working set information */
--- 185,191 -----
/* lookahead set information */
! extern struct looksets lkst[];
extern int nolook; /* flag to turn off lookahead computations */
/* working set information */
***************
*** 190,196
/* working set information */
! extern struct wset *wsets;
extern struct wset *cwp;
extern int *ggreed;
extern int *pgo;
--- 190,196 -----
/* working set information */
! extern struct wset wsets[];
extern struct wset *cwp;
/* storage for productions */
***************
*** 192,200
extern struct wset *wsets;
extern struct wset *cwp;
- extern int *ggreed;
- extern int *pgo;
- extern int *yypgo;
/* storage for productions */
--- 192,197 -----
extern struct wset wsets[];
extern struct wset *cwp;
/* storage for productions */
***************
*** 198,204
/* storage for productions */
! extern int *mem0;
extern int *mem;
/* storage for action table */
--- 195,201 -----
/* storage for productions */
! extern int mem0[];
extern int *mem;
/* storage for action table */
***************
*** 203,209
/* storage for action table */
! extern int *amem; /* action table storage */
extern int *memp ; /* next free action table position */
extern int *indgo; /* index to the stored goto table */
--- 200,206 -----
/* storage for action table */
! extern int amem[]; /* action table storage */
extern int *memp ; /* next free action table position */
extern int indgo[]; /* index to the stored goto table */
***************
*** 205,211
extern int *amem; /* action table storage */
extern int *memp ; /* next free action table position */
! extern int *indgo; /* index to the stored goto table */
extern int *pmem;
--- 202,208 -----
extern int amem[]; /* action table storage */
extern int *memp ; /* next free action table position */
! extern int indgo[]; /* index to the stored goto table */
/* temporary vector, indexable by states, terms, or ntokens */
***************
*** 207,215
extern int *memp ; /* next free action table position */
extern int *indgo; /* index to the stored goto table */
-
- extern int *pmem;
-
/* temporary vector, indexable by states, terms, or ntokens */
extern int *temp1;
--- 204,209 -----
extern int *memp ; /* next free action table position */
extern int indgo[]; /* index to the stored goto table */
/* temporary vector, indexable by states, terms, or ntokens */
extern int temp1[];
***************
*** 212,218
/* temporary vector, indexable by states, terms, or ntokens */
! extern int *temp1;
extern int lineno; /* current line number */
/* statistics collection variables */
--- 206,212 -----
/* temporary vector, indexable by states, terms, or ntokens */
! extern int temp1[];
extern int lineno; /* current line number */
/* statistics collection variables */
*** y1.c Wed Apr 1 10:23:07 1987
--- yacc/y1.c Mon Apr 6 12:44:00 1987
***************
*** 9,15
/* lookahead computations */
int tbitset; /* size of lookahead sets */
! struct looksets *lkst;
int nlset = 0; /* next lookahead set index */
int nolook = 0; /* flag to suppress lookahead computations */
struct looksets clset; /* temporary storage for lookahead computations */
--- 9,15 -----
/* lookahead computations */
int tbitset; /* size of lookahead sets */
! struct looksets lkst [ LSETSIZE ];
int nlset = 0; /* next lookahead set index */
int nolook = 0; /* flag to suppress lookahead computations */
struct looksets clset; /* temporary storage for lookahead computations */
***************
*** 16,22
/* working set computations */
! struct wset *wsets;
struct wset *cwp;
/* state information */
--- 16,22 -----
/* working set computations */
! struct wset wsets[ WSETSIZE ];
struct wset *cwp;
/* state information */
***************
*** 22,33
/* state information */
int nstate = 0; /* number of states */
! struct item **pstate; /* pointers to the descriptions of the states */
! int *tystate; /* contains type information about the states */
! int *indgo; /* index to the stored goto table */
! int *tstates; /* states generated by terminal gotos */
! int *ntstates; /* states generated by nonterminal gotos */
! int *mstates; /* chain of overflows of term/nonterm generation lists */
/* storage for the actions in the parser */
--- 22,33 -----
/* state information */
int nstate = 0; /* number of states */
! struct item *pstate[NSTATES+2]; /* pointers to the descriptions of the states */
! int tystate[NSTATES]; /* contains type information about the states */
! int indgo[NSTATES]; /* index to the stored goto table */
! int tstates[ NTERMS ]; /* states generated by terminal gotos */
! int ntstates[ NNONTERM ]; /* states generated by nonterminal gotos */
! int mstates[ NSTATES ]; /* chain of overflows of term/nonterm generation lists */
/* storage for the actions in the parser */
***************
*** 31,38
/* storage for the actions in the parser */
! int *amem; /* action table storage */
! int *memp; /* next free action table position */
/* other storage areas */
--- 31,38 -----
/* storage for the actions in the parser */
! int amem[ACTSIZE]; /* action table storage */
! int *memp = amem; /* next free action table position */
/* other storage areas */
***************
*** 36,42
/* other storage areas */
! int *temp1; /* temporary storage, indexed by terms + ntokens or states */
int lineno= 1; /* current input line number */
int fatfl = 1; /* if on, error is fatal */
int nerrors = 0; /* number of errors */
--- 36,42 -----
/* other storage areas */
! int temp1[TEMPSIZE]; /* temporary storage, indexed by terms + ntokens or states */
int lineno= 1; /* current input line number */
int fatfl = 1; /* if on, error is fatal */
int nerrors = 0; /* number of errors */
***************
*** 43,51
/* storage for information about the nonterminals */
! int ***pres; /* vector of pointers to productions yielding each nonterminal */
! struct looksets **pfirst; /* vector of pointers to first sets for each nonterminal */
! int *pempty; /* vector of nonterminals nontrivially deriving e */
main(argc,argv) int argc; char *argv[]; {
--- 43,51 -----
/* storage for information about the nonterminals */
! int **pres[NNONTERM+2]; /* vector of pointers to productions yielding each nonterminal */
! struct looksets *pfirst[NNONTERM+2]; /* vector of pointers to first sets for each nonterminal */
! int pempty[NNONTERM+1]; /* vector of nonterminals nontrivially deriving e */
main(argc,argv) int argc; char *argv[]; {
***************
*** 49,59
main(argc,argv) int argc; char *argv[]; {
- /*XXX */
- void make_arrays();
-
- make_arrays();
- /*XXX*/
setup(argc,argv); /* initialize and read productions */
tbitset = NWORDS(ntokens);
cpres(); /* make table of which productions yield a given nonterminal */
--- 49,54 -----
main(argc,argv) int argc; char *argv[]; {
setup(argc,argv); /* initialize and read productions */
tbitset = NWORDS(ntokens);
cpres(); /* make table of which productions yield a given nonterminal */
***************
*** 157,163
return( cp );
}
! struct wset *zzcwp;
int zzgoent = 0;
int zzgobest = 0;
int zzacent = 0;
--- 152,158 -----
return( cp );
}
! struct wset *zzcwp = wsets;
int zzgoent = 0;
int zzgobest = 0;
int zzacent = 0;
***************
*** 164,170
int zzexcp = 0;
int zzclose = 0;
int zzsrconf = 0;
! int * zzmemsz;
int zzrrconf = 0;
summary(){ /* output the summary on the tty */
--- 159,165 -----
int zzexcp = 0;
int zzclose = 0;
int zzsrconf = 0;
! int * zzmemsz = mem0;
int zzrrconf = 0;
summary(){ /* output the summary on the tty */
***************
*** 660,699
}
return( q );
}
-
- void
- make_arrays()
- {
- lkst = (struct looksets *) malloc(sizeof(struct looksets)*LSETSIZE);
- wsets = (struct wset *) malloc(sizeof(struct wset)*WSETSIZE);
- zzcwp = wsets;
- pstate = (struct item **) malloc(sizeof(struct item *)*(NSTATES+2));
- tystate = (int *) malloc(sizeof(int)*NSTATES);
- indgo = (int *) malloc(sizeof(int)*NSTATES);
- tstates = (int *) malloc(sizeof(int)*NSTATES);
- ntstates = (int *) malloc(sizeof(int)*NNONTERM);
- mstates = (int *) malloc(sizeof(int)*NSTATES);
- amem = (int *) malloc(sizeof(int)*ACTSIZE);
- memp = amem;
- temp1 = (int *) malloc(sizeof(int)*TEMPSIZE);
- pres = (int ***) malloc(sizeof(int **)*(NNONTERM+2));
- pfirst = (struct looksets **)
- malloc(sizeof(struct looksets *)*(NNONTERM+2));
- pempty = (int *) malloc(sizeof(int)*(NNONTERM+1));
- defact = (int *) malloc(sizeof(int)*NSTATES);
- mem0 = (int *) malloc(sizeof(int)*MEMSIZE);
- mem = mem0;
- pmem = mem;
- zzmemsz = mem0;
- prdptr = (int **) malloc(sizeof(int *)*NPROD);
- levprd = (int *) malloc(sizeof(int)*NPROD);
-
- tokset = (struct toksymb *) malloc(sizeof(struct toksymb)*NTERMS);
- toklev = (int *) malloc(sizeof(int)*NTERMS);
- /* nontrst = (struct ntsymb *) malloc(sizeof(struct ntymsb)*NNONTERM);
- */
- ggreed = lkst[0].lset;
- pgo = wsets[0].ws.lset;
- yypgo = &nontrst[0].tvalue;
- }
-
--- 655,657 -----
}
return( q );
}
*** y2.c Wed Apr 1 22:35:39 1987
--- yacc/y2.c Mon Apr 6 12:44:02 1987
***************
*** 39,46
/* symbol tables for tokens and nonterminals */
int ntokens = 0;
! struct toksymb *tokset;
! int *toklev;
int nnonter = -1;
struct ntsymb nontrst[NNONTERM];
int start; /* start symbol */
--- 39,46 -----
/* symbol tables for tokens and nonterminals */
int ntokens = 0;
! struct toksymb tokset[NTERMS];
! int toklev[NTERMS];
int nnonter = -1;
struct ntsymb nontrst[NNONTERM];
int start; /* start symbol */
***************
*** 59,66
/* storage for grammar rules */
! int *mem0 ; /* production storage */
! int *mem;
int nprod= 1; /* number of productions */
int **prdptr; /* pointers to descriptions of productions */
int *levprd ; /* precedence levels for the productions */
--- 59,66 -----
/* storage for grammar rules */
! int mem0[MEMSIZE] ; /* production storage */
! int *mem = mem0;
int nprod= 1; /* number of productions */
int *prdptr[NPROD]; /* pointers to descriptions of productions */
int levprd[NPROD] ; /* precedence levels for the productions */
***************
*** 62,69
int *mem0 ; /* production storage */
int *mem;
int nprod= 1; /* number of productions */
! int **prdptr; /* pointers to descriptions of productions */
! int *levprd ; /* precedence levels for the productions */
setup(argc,argv) int argc; char *argv[];
--- 62,69 -----
int mem0[MEMSIZE] ; /* production storage */
int *mem = mem0;
int nprod= 1; /* number of productions */
! int *prdptr[NPROD]; /* pointers to descriptions of productions */
! int levprd[NPROD] ; /* precedence levels for the productions */
setup(argc,argv) int argc; char *argv[];
*** y3.c Wed Apr 1 22:42:02 1987
--- yacc/y3.c Mon Apr 6 12:44:02 1987
***************
*** 6,12
/* important local variables */
int lastred; /* the number of the last reduction of a state */
! int *defact; /* the default actions of states */
output(){ /* print the output for the states */
--- 6,12 -----
/* important local variables */
int lastred; /* the number of the last reduction of a state */
! int defact[NSTATES]; /* the default actions of states */
output(){ /* print the output for the states */
***************
*** 405,407
levprd[i] = *prdptr[i] - NTBASE;
}
if( j ) fprintf( stdout, "%d rules never reduced\n", j );
--- 405,408 -----
levprd[i] = *prdptr[i] - NTBASE;
}
if( j ) fprintf( stdout, "%d rules never reduced\n", j );
+ }
*** y4.c Wed Apr 1 22:47:23 1987
--- yacc/y4.c Mon Apr 6 12:44:03 1987
***************
*** 10,18
# define yypact temp1
# define greed tystate
! int * ggreed;
! int * pgo;
! int *yypgo;
int maxspr = 0; /* maximum spread of any entry */
int maxoff = 0; /* maximum offset into a array */
--- 10,18 -----
# define yypact temp1
# define greed tystate
! int * ggreed = lkst[0].lset;
! int * pgo = wsets[0].ws.lset;
! int *yypgo = &nontrst[0].tvalue;
int maxspr = 0; /* maximum spread of any entry */
int maxoff = 0; /* maximum offset into a array */
***************
*** 16,22
int maxspr = 0; /* maximum spread of any entry */
int maxoff = 0; /* maximum offset into a array */
! int *pmem;
int *maxa;
# define NOMORE -1000
--- 16,22 -----
int maxspr = 0; /* maximum spread of any entry */
int maxoff = 0; /* maximum offset into a array */
! int *pmem = mem;
int *maxa;
# define NOMORE -1000
Neil Rhodes
UC San Diego
neil@ucsd
{ucbvax,decvax}!sdcsvax!neilchuq@plaid.UUCP (04/07/87)
In article <2960@sdcsvax.UCSD.EDU> neil@beowulf.ucsd.edu (Neil Rhodes) writes: >What follows are diffs to get yacc (4.3BSD distribution) running under MPW C. I hate to rain on people's parades, but I thought I would remind folks that yacc is proprietary to AT&T, and to take the 4.3 version of yacc and run it legally on your Mac, you need to license your Mac for Berkeley Unix, which implies getting a Unix Source License from AT&T. Much as I'd love to have Yacc on my mac, that's a rather expensive piece of software. chuq Chuq Von Rospach chuq@sun.COM [I don't read flames] There is no statute of limitations on stupidity