Article View: comp.sources.mac
Article #52Bison Macintosh Sources (part 6 of 6)
From: Pierce T. Wetter
Date: Thu, 19 May 1988 04:17
Date: Thu, 19 May 1988 04:17
971 lines
31894 bytes
31894 bytes
[Bison Macintosh Sources - part 6 of 6]
---
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# Bison/symtab.c
# Bison/vmsgetargs.c
# Bison/warshall.c
# Bison/file.h
# Bison/gram.h
# Bison/lex.h
# Bison/machine.h
# Bison/new.h
# Bison/state.h
# Bison/symtab.h
# Bison/types.h
# This archive created: Sat May 14 02:42:08 1988
# By: Roger L. Long (bytebug@dhw68k.cts.com)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'symtab.c'" '(2628 characters)'
if test -f 'symtab.c'
then
echo shar: will not over-write existing file "'symtab.c'"
else
sed 's/^X//' << \SHAR_EOF > 'symtab.c'
X/* Symbol table manager for Bison,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X#include <stdio.h>
X#include <strings.h>
X#include "new.h"
X#include "symtab.h"
X#include "gram.h"
X
X
Xbucket **symtab;
Xbucket *firstsymbol;
Xbucket *lastsymbol;
X
X
X
Xint
Xhash(key)
Xchar *key;
X{
X register char *cp;
X register int k;
X
X cp = key;
X k = 0;
X while (*cp)
X k = ((k << 1) ^ (*cp++)) & 0x3fff;
X
X return (k % TABSIZE);
X}
X
X
X
Xchar *
Xcopys(s)
Xchar *s;
X{
X register int i;
X register char *cp;
X register char *result;
X
X i = 1;
X for (cp = s; *cp; cp++)
X i++;
X
X result = allocate((unsigned int)i);
X strcpy(result, s);
X return (result);
X}
X
X
X
Xtabinit()
X{
X/* register int i; JF unused */
X
X symtab = NEW2(TABSIZE, bucket *);
X
X firstsymbol = NULL;
X lastsymbol = NULL;
X}
X
X
X
X
Xbucket *getsym(key)
Xchar *key;
X{
X register int hashval;
X register bucket *bp;
X register int found;
X
X hashval = hash(key);
X bp = symtab[hashval];
X
X found = 0;
X while (bp != NULL && found == 0)
X {
X if (strcmp(key, bp->tag) == 0)
X found = 1;
X else
X bp = bp->link;
X }
X
X if (found == 0)
X {
X nsyms++;
X
X bp = NEW(bucket);
X bp->link = symtab[hashval];
X bp->next = NULL;
X bp->tag = copys(key);
X bp->class = SUNKNOWN;
X
X if (firstsymbol == NULL)
X {
X firstsymbol = bp;
X lastsymbol = bp;
X }
X else
X {
X lastsymbol->next = bp;
X lastsymbol = bp;
X }
X
X symtab[hashval] = bp;
X }
X
X return (bp);
X}
X
X
X
Xfree_symtab()
X{
X register int i;
X register bucket *bp,*bptmp;/* JF don't use ptr after free */
X
X for (i = 0; i < TABSIZE; i++)
X {
X bp = symtab[i];
X while (bp)
X {
X bptmp=bp->link;
X FREE(bp);
X bp = bptmp;
X }
X }
X}
SHAR_EOF
if test 2628 -ne "`wc -c < 'symtab.c'`"
then
echo shar: error transmitting "'symtab.c'" '(should have been 2628 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'vmsgetargs.c'" '(1446 characters)'
if test -f 'vmsgetargs.c'
then
echo shar: will not over-write existing file "'vmsgetargs.c'"
else
sed 's/^X//' << \SHAR_EOF > 'vmsgetargs.c'
X/*
X * VMS version of getargs(): Uses DCL command parsing
X * (argc and argv are ignored)
X */
Xgetargs(argc,argv)
X int argc;
X char *argv[];
X{
X register char *cp;
X static char Input_File[256];
X
X verboseflag = 0;
X definesflag = 0;
X /*
X * Check for /VERBOSE qualifier
X */
X if (cli_present("BISON$VERBOSE")) verboseflag = 1;
X /*
X * Check for /DEFINES qualifier
X */
X if (cli_present("BISON$DEFINES")) definesflag = 1;
X /*
X * Check for /FIXED_OUTFILES qualifier
X */
X if (cli_present("BISON$FIXED_OUTFILES")) fixed_outfiles = 1;
X /*
X * Get the filename
X */
X cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File));
X /*
X * Lowercaseify the input filename
X */
X cp = Input_File;
X while(*cp) {
X if (isupper(*cp)) *cp = tolower(*cp);
X cp++;
X }
X infile = Input_File;
X}
X
X/************ DCL PARSING ROUTINES **********/
X
X/*
X * See if "NAME" is present
X */
Xint
Xcli_present(Name)
X char *Name;
X{
X struct {int Size; char *Ptr;} Descr;
X
X Descr.Ptr = Name;
X Descr.Size = strlen(Name);
X return((cli$present(&Descr) & 1) ? 1 : 0);
X}
X
X/*
X * Get value of "NAME"
X */
Xint
Xcli_get_value(Name,Buffer,Size)
X char *Name;
X char *Buffer;
X{
X struct {int Size; char *Ptr;} Descr1,Descr2;
X
X Descr1.Ptr = Name;
X Descr1.Size = strlen(Name);
X Descr2.Ptr = Buffer;
X Descr2.Size = Size-1;
X if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) {
X Buffer[Descr2.Size] = 0;
X return(1);
X }
X return(0);
X}
X
SHAR_EOF
if test 1446 -ne "`wc -c < 'vmsgetargs.c'`"
then
echo shar: error transmitting "'vmsgetargs.c'" '(should have been 1446 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'warshall.c'" '(2652 characters)'
if test -f 'warshall.c'
then
echo shar: will not over-write existing file "'warshall.c'"
else
sed 's/^X//' << \SHAR_EOF > 'warshall.c'
X/* Generate transitive closure of a matrix,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X#include <stdio.h>
X#include "machine.h"
X
X
X/* given n by n matrix of bits R, modify its contents
X to be the transive closure of what was given. */
X
XTC(R, n)
Xunsigned *R;
Xint n;
X{
X register int rowsize;
X register unsigned mask;
X register unsigned *rowj;
X register unsigned *rp;
X register unsigned *rend;
X register unsigned *ccol;
X
X unsigned *relend;
X unsigned *cword;
X unsigned *rowi;
X
X rowsize = WORDSIZE(n) * sizeof(unsigned);
X relend = (unsigned *) ((char *) R + (n * rowsize));
X
X cword = R;
X mask = 1;
X rowi = R;
X while (rowi < relend)
X {
X ccol = cword;
X rowj = R;
X
X while (rowj < relend)
X {
X if (*ccol & mask)
X {
X rp = rowi;
X rend = (unsigned *) ((char *) rowj + rowsize);
X
X while (rowj < rend)
X *rowj++ |= *rp++;
X }
X else
X {
X rowj = (unsigned *) ((char *) rowj + rowsize);
X }
X
X ccol = (unsigned *) ((char *) ccol + rowsize);
X }
X
X mask <<= 1;
X if (mask == 0)
X {
X mask = 1;
X cword++;
X }
X
X rowi = (unsigned *) ((unsigned) rowi + rowsize);
X }
X}
X
X
X/* Reflexive Transitive Closure. Same as TC
X and then set all the bits on the diagonal of R. */
X
XRTC(R, n)
Xunsigned *R;
Xint n;
X{
X register int rowsize;
X register unsigned mask;
X register unsigned *rp;
X register unsigned *relend;
X
X TC(R, n);
X
X rowsize = WORDSIZE(n) * sizeof(unsigned);
X relend = (unsigned *) ((unsigned) R + n*rowsize);
X
X mask = 1;
X rp = R;
X while (rp < relend)
X {
X *rp |= mask;
X
X mask <<= 1;
X if (mask == 0)
X {
X mask = 1;
X rp++;
X }
X
X rp = (unsigned *) ((unsigned) rp + rowsize);
X }
X}
SHAR_EOF
if test 2652 -ne "`wc -c < 'warshall.c'`"
then
echo shar: error transmitting "'warshall.c'" '(should have been 2652 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'file.h'" '(2374 characters)'
if test -f 'file.h'
then
echo shar: will not over-write existing file "'file.h'"
else
sed 's/^X//' << \SHAR_EOF > 'file.h'
X/* File names and variables for bison,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X/* These two should be pathnames for opening the sample parser files.
X When bison is installed, they should be absolute pathnames.
X XPFILE1 and XPFILE2 normally come from the Makefile. */
X
X#define PFILE "bison.simple" /* Simple parser */
X#define PFILE1 "bison.hairy" /* Semantic parser */
X
Xextern FILE *finput; /* read grammar specifications */
Xextern FILE *foutput; /* optionally output messages describing the actions taken */
Xextern FILE *fdefines; /* optionally output #define's for token numbers. */
Xextern FILE *ftable; /* output the tables and the parser */
Xextern FILE *fattrs; /* if semantic parser, output a .h file that defines YYSTYPE */
X /* and also contains all the %{ ... %} definitions. */
Xextern FILE *fguard; /* if semantic parser, output yyguard, containing all the guard code */
Xextern FILE *faction; /* output all the action code; precise form depends on which parser */
Xextern FILE *fparser; /* read the parser to copy into ftable */
X
X/* File name specified with -o for the output file, or 0 if no -o. */
Xextern char *spec_outfile;
X
Xextern char *infile;
Xextern char *outfile;
Xextern char *defsfile;
Xextern char *tabfile;
Xextern char *attrsfile;
Xextern char *guardfile;
Xextern char *actfile;
X/* JF nobody seems to care about these
Xextern char *pfile;
Xextern char *pfile1; */
SHAR_EOF
if test 2374 -ne "`wc -c < 'file.h'`"
then
echo shar: error transmitting "'file.h'" '(should have been 2374 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'gram.h'" '(4280 characters)'
if test -f 'gram.h'
then
echo shar: will not over-write existing file "'gram.h'"
else
sed 's/^X//' << \SHAR_EOF > 'gram.h'
X/* Data definitions for internal representation of bison's input,
X Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X/* representation of the grammar rules:
X
Xntokens is the number of tokens, and nvars is the number of variables (nonterminals).
Xnsyms is the total number, ntokens + nvars.
X
XEach symbol (either token or variable) receives a symbol number.
XNumbers 0 to ntokens-1 are for tokens, and ntokens to nsyms-1 are for variables.
XSymbol number zero is the end-of-input token. This token is counted in ntokens.
X
XThe rules receive rule numbers 1 to nrules in the order they are written.
XActions and guards are accessed via the rule number.
X
XThe rules themselves are described by three arrays: rrhs, rlhs and ritems.
Xrlhs[r] is the symbol number of the left hand side of rule r.
XThe right hand side is stored as symbol numbers in a portion of ritems.
Xrrhs[r] contains the index in ritems of the beginning of the portion for rule r.
XThe length of the portion is one greater
X than the number of symbols in the rule's right hand side.
XThe last element in the portion contains minus r, which
Xidentifies it as the end of a portion and says which rule it is for.
X
XThe portions of ritems come in order of increasing rule number and are
Xfollowed by an element which is zero to mark the end. nitems is the
Xtotal length of ritems, not counting the final zero. Each element of
Xritems is called an "item" and its index in ritems is an item number.
X
XItem numbers are used in the finite state machine to represent
Xplaces that parsing can get to.
X
XPrecedence levels are recorded in the vectors sprec and rprec.
Xsprec records the precedence level of each symbol,
Xrprec the precedence level of each rule.
X
XPrecedence levels are assigned in increasing order starting with 1
Xso that numerically higher precedence values mean tighter binding
Xas they ought to. Zero as a symbol or rule's precedence means none is assigned.
X
XAssociativities are recorded similarly in rassoc and sassoc. */
X
X
X#define ISTOKEN(s) ((s) < ntokens)
X#define ISVAR(s) ((s) >= ntokens)
X
X
Xextern int nitems;
Xextern int nrules;
Xextern int nsyms;
Xextern int ntokens;
Xextern int nvars;
X
Xextern short *ritem;
Xextern short *rlhs;
Xextern short *rrhs;
Xextern short *rprec;
Xextern short *sprec;
Xextern short *rassoc;
Xextern short *sassoc;
Xextern short *rline; /* Source line number of each rule */
X
Xextern int start_symbol;
X
X
X/* associativity values in elements of rassoc, sassoc. */
X
X#define RIGHT_ASSOC 1
X#define LEFT_ASSOC 2
X#define NON_ASSOC 3
X
X/* token translation table:
Xindexed by a token number as returned by the user's yylex routine,
Xit yields the internal token number used by the parser and throughout bison.
XIf translations is zero, the translation table is not used because
Xthe two kinds of token numbers are the same. */
X
Xextern short *token_translations;
Xextern int translations;
Xextern int max_user_token_number;
X
X/* semantic_parser is nonzero if the input file says to use the hairy parser
Xthat provides for semantic error recovery. If it is zero, the yacc-compatible
Xsimplified parser is used. */
X
Xextern int semantic_parser;
X
X/* pure_parser is nonzero if should generate a parser that is all pure and reentrant. */
X
Xextern int pure_parser;
X
X/* error_token_number is the token number of the error token. */
X
Xextern int error_token_number;
SHAR_EOF
if test 4280 -ne "`wc -c < 'gram.h'`"
then
echo shar: error transmitting "'gram.h'" '(should have been 4280 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'lex.h'" '(1649 characters)'
if test -f 'lex.h'
then
echo shar: will not over-write existing file "'lex.h'"
else
sed 's/^X//' << \SHAR_EOF > 'lex.h'
X/* Token type definitions for bison's input reader,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X#define ENDFILE 0
X#define IDENTIFIER 1
X#define COMMA 2
X#define COLON 3
X#define SEMICOLON 4
X#define BAR 5
X#define LEFT_CURLY 6
X#define TWO_PERCENTS 7
X#define PERCENT_LEFT_CURLY 8
X#define TOKEN 9
X#define NTERM 10
X#define GUARD 11
X#define TYPE 12
X#define UNION 13
X#define START 14
X#define LEFT 15
X#define RIGHT 16
X#define NONASSOC 17
X#define PREC 18
X#define SEMANTIC_PARSER 19
X#define PURE_PARSER 20
X#define TYPENAME 21
X#define NUMBER 22
X#define EXPECT 23
X#define ILLEGAL 24
X
X#define MAXTOKEN 1024
SHAR_EOF
if test 1649 -ne "`wc -c < 'lex.h'`"
then
echo shar: error transmitting "'lex.h'" '(should have been 1649 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'machine.h'" '(1218 characters)'
if test -f 'machine.h'
then
echo shar: will not over-write existing file "'machine.h'"
else
sed 's/^X//' << \SHAR_EOF > 'machine.h'
X/* Define machine-dependencies for bison,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X#define MAXSHORT 32767
X#define MINSHORT -32768
X
X#define BITS_PER_WORD 32
X#define WORDSIZE(n) (((n) + 31) / 32)
X#define SETBIT(x, i) ((x)[(i)>>5] |= (1<<((i) & 31)))
SHAR_EOF
if test 1218 -ne "`wc -c < 'machine.h'`"
then
echo shar: error transmitting "'machine.h'" '(should have been 1218 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'new.h'" '(1246 characters)'
if test -f 'new.h'
then
echo shar: will not over-write existing file "'new.h'"
else
sed 's/^X//' << \SHAR_EOF > 'new.h'
X/* Storage allocation interface for bison,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X#define NEW(t) ((t *) allocate((unsigned) sizeof(t)))
X#define NEW2(n, t) ((t *) allocate((unsigned) ((n) * sizeof(t))))
X
X#define FREE(x) (x && free((char *) (x)))
X
X
Xextern char *allocate();
SHAR_EOF
if test 1246 -ne "`wc -c < 'new.h'`"
then
echo shar: error transmitting "'new.h'" '(should have been 1246 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'state.h'" '(4951 characters)'
if test -f 'state.h'
then
echo shar: will not over-write existing file "'state.h'"
else
sed 's/^X//' << \SHAR_EOF > 'state.h'
X/* Type definitions for nondeterministic finite state machine for bison,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X/* These type definitions are used to represent a nondeterministic
X finite state machine that parses the specified grammar.
X This information is generated by the function generate_states
X in the file LR0.
X
XEach state of the machine is described by a set of items --
Xparticular positions in particular rules -- that are the possible
Xplaces where parsing could continue when the machine is in this state.
XThese symbols at these items are the allowable inputs that can follow now.
X
XA core represents one state. States are numbered in the number field.
XWhen generate_states is finished, the starting state is state 0
Xand nstates is the number of states. (A transition to a state
Xwhose state number is nstates indicates termination.) All the cores
Xare chained together and first_state points to the first one (state 0).
X
XFor each state there is a particular symbol which must have been the
Xlast thing accepted to reach that state. It is the accessing_symbol
Xof the core.
X
XEach core contains a vector of nitems items which are the indices
Xin the ritems vector of the items that are selected in this state.
X
XThe link field is used for chaining buckets that hash states by
Xtheir itemsets. This is for recognizing equivalent states and
Xcombining them when the states are generated.
X
XThe two types of transitions are shifts (push the lookahead token
Xand read another) and reductions (combine the last n things on the
Xstack via a rule, replace them with the symbol that the rule derives,
Xand leave the lookahead token alone). When the states are generated,
Xthese transitions are represented in two other lists.
X
XEach shifts structure describes the possible shift transitions out
Xof one state, the state whose number is in the number field.
XThe shifts structures are linked through next and first_shift points to them.
XEach contains a vector of numbers of the states that shift transitions
Xcan go to. The accessing_symbol fields of those states' cores say what kind
Xof input leads to them.
X
XA shift to state zero should be ignored. Conflict resolution
Xdeletes shifts by changing them to zero.
X
XEach reductions structure describes the possible reductions at the state
Xwhose number is in the number field. The data is a list of nreds rules,
Xrepresented by their rule numbers. first_reduction points to the list
Xof these structures.
X
XConflict resolution can decide that certain tokens in certain
Xstates should explicitly be errors (for implementing %nonassoc).
XFor each state, the tokens that are errors for this reason
Xare recorded in an errs structure, which has the state number
Xin its number field. The rest of the errs structure is full
Xof token numbers.
X
XThere is at least one shift transition present in state zero.
XIt leads to a next-to-final state whose accessing_symbol is
Xthe grammar's start symbol. The next-to-final state has one shift
Xto the final state, whose accessing_symbol is zero (end of input).
XThe final state has one shift, which goes to the termination state
X(whose number is nstates, and for which there is no core structure).
XThe reason for the extra state at the end is to placate the parser's
Xstrategy of making all decisions one token ahead of its actions. */
X
X
Xtypedef
X struct core
X {
X struct core *next;
X struct core *link;
X short number;
X short accessing_symbol;
X short nitems;
X short items[1];
X }
X core;
X
X
X
Xtypedef
X struct shifts
X {
X struct shifts *next;
X short number;
X short nshifts;
X short shifts[1];
X }
X shifts;
X
X
X
Xtypedef
X struct errs
X {
X short nerrs;
X short errs[1];
X }
X errs;
X
X
X
Xtypedef
X struct reductions
X {
X struct reductions *next;
X short number;
X short nreds;
X short rules[1];
X }
X reductions;
X
X
X
Xextern int nstates;
Xextern core *first_state;
Xextern shifts *first_shift;
Xextern reductions *first_reduction;
SHAR_EOF
if test 4951 -ne "`wc -c < 'state.h'`"
then
echo shar: error transmitting "'state.h'" '(should have been 4951 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'symtab.h'" '(1496 characters)'
if test -f 'symtab.h'
then
echo shar: will not over-write existing file "'symtab.h'"
else
sed 's/^X//' << \SHAR_EOF > 'symtab.h'
X/* Definitions for symtab.c and callers, part of bison,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
X#define TABSIZE 1009
X
X
X/* symbol classes */
X
X#define SUNKNOWN 0
X#define STOKEN 1
X#define SNTERM 2
X
X
Xtypedef
X struct bucket
X {
X struct bucket *link;
X struct bucket *next;
X char *tag;
X char *type_name;
X short value;
X short prec;
X short assoc;
X short user_token_number;
X char class;
X }
X bucket;
X
X
Xextern bucket **symtab;
Xextern bucket *firstsymbol;
X
Xextern bucket *getsym();
SHAR_EOF
if test 1496 -ne "`wc -c < 'symtab.h'`"
then
echo shar: error transmitting "'symtab.h'" '(should have been 1496 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'types.h'" '(1179 characters)'
if test -f 'types.h'
then
echo shar: will not over-write existing file "'types.h'"
else
sed 's/^X//' << \SHAR_EOF > 'types.h'
X/* Define data type for representing bison's grammar input as it is parsed,
X Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
X
XBISON is distributed in the hope that it will be useful, but WITHOUT ANY
XWARRANTY. No author or distributor accepts responsibility to anyone
Xfor the consequences of using it or for whether it serves any
Xparticular purpose or works at all, unless he says so in writing.
XRefer to the BISON General Public License for full details.
X
XEveryone is granted permission to copy, modify and redistribute BISON,
Xbut only under the conditions described in the BISON General Public
XLicense. A copy of this license is supposed to have been given to you
Xalong with BISON so you can know your rights and responsibilities. It
Xshould be in a file named COPYING. Among other things, the copyright
Xnotice and this notice must be preserved on all copies.
X
X In other words, you are welcome to use, share and improve this program.
X You are forbidden to forbid anyone else to use, share and improve
X what you give them. Help stamp out software-hoarding! */
X
Xtypedef
X struct shorts
X {
X struct shorts *next;
X short value;
X }
X shorts;
SHAR_EOF
if test 1179 -ne "`wc -c < 'types.h'`"
then
echo shar: error transmitting "'types.h'" '(should have been 1179 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
--- end of part 6 ---
Technical Details
Message-ID:
<8089@dhw68k.cts.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!peregrine!ccicpg!felix!dhw68k!macintoshReferences:
<7986@dhw68k.cts.com> <8002@dhw68k.cts.com> <8034@dhw68k.cts.com> <8052@dhw68k.cts.com> <8064@dhw68k.cts.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!peregrine!ccicpg!felix!dhw68k!macintosh From: wetter@tybalt.caltech.edu (Pierce T. Wetter) Newsgroups: comp.sources.mac Subject: Bison Macintosh Sources (part 6 of 6) Message-ID: <8089@dhw68k.cts.com> Date: 19 May 88 04:17:30 GMT References: <7986@dhw68k.cts.com> <8002@dhw68k.cts.com> <8034@dhw68k.cts.com> <8052@dhw68k.cts.com> <8064@dhw68k.cts.com> Sender: macintosh@dhw68k.cts.com Organization: California Institute of Technology Lines: 971 Approved: bytebug@dhw68k.cts.com (Roger L. Long)