Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ucsd!ucsdhub!hp-sdd!hplabs!felix!dhw68k!macintosh From: wetter@tybalt.caltech.edu (Pierce T. Wetter) Newsgroups: comp.sources.mac Subject: Bison Macintosh Sources (part 1 of 6) Message-ID: <7986@dhw68k.cts.com> Date: 14 May 88 10:00:15 GMT Sender: macintosh@dhw68k.cts.com Organization: California Institute of Technology Lines: 1422 Approved: bytebug@dhw68k.cts.com (Roger L. Long) [Bison Macintosh Sources - part 1 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/COPYING # Bison/Makefile # Bison/REFERENCES # Bison/bison.1 # Bison/bison.cld # Bison/bison.hairy # Bison/bison.simple # Bison/build.com # Bison/vmshlp.mar # This archive created: Sat May 14 02:41:40 1988 # By: Roger L. Long (bytebug@dhw68k.cts.com) export PATH; PATH=/bin:$PATH echo shar: extracting "'COPYING'" '(7191 characters)' if test -f 'COPYING' then echo shar: will not over-write existing file "'COPYING'" else sed 's/^X//' << \SHAR_EOF > 'COPYING' X X BISON GENERAL PUBLIC LICENSE X (Clarified 11 Feb 1988) X X Copyright (C) 1988 Richard M. Stallman X Everyone is permitted to copy and distribute verbatim copies X of this license, but changing it is not allowed. You can also X use this wording to make the terms for other programs. X X The license agreements of most software companies keep you at the Xmercy of those companies. By contrast, our general public license is Xintended to give everyone the right to share BISON. To make sure that Xyou get the rights we want you to have, we need to make restrictions Xthat forbid anyone to deny you these rights or to ask you to surrender Xthe rights. Hence this license agreement. X X Specifically, we want to make sure that you have the right to give Xaway copies of BISON, that you receive source code or else can get it Xif you want it, that you can change BISON or use pieces of it in new Xfree programs, and that you know you can do these things. X X To make sure that everyone has such rights, we have to forbid you to Xdeprive anyone else of these rights. For example, if you distribute Xcopies of BISON, you must give the recipients all the rights that you Xhave. You must make sure that they, too, receive or can get the Xsource code. And you must tell them their rights. X X Also, for our own protection, we must make certain that everyone Xfinds out that there is no warranty for BISON. If BISON is modified by Xsomeone else and passed on, we want its recipients to know that what Xthey have is not what we distributed, so that any problems introduced Xby others will not reflect on our reputation. X X Therefore we (Richard Stallman and the Free Software Fundation, XInc.) make the following terms which say what you must do to be Xallowed to distribute or change BISON. X X X COPYING POLICIES X X 1. You may copy and distribute verbatim copies of BISON source code as Xyou receive it, in any medium, provided that you conspicuously and Xappropriately publish on each copy a valid copyright notice "Copyright X(C) 1986 Free Software Foundation, Inc." (or with whatever year is Xappropriate); keep intact the notices on all files that refer Xto this License Agreement and to the absence of any warranty; and give Xany other recipients of the BISON program a copy of this License XAgreement along with the program. X X 2. You may modify your copy or copies of BISON or any portion of it, Xand copy and distribute such modifications under the terms of XParagraph 1 above, provided that you also do the following: X X a) cause the modified files to carry prominent notices stating X that you changed the files and the date of any change; and X X b) cause the whole of any work that you distribute or publish, X that in whole or in part contains or is a derivative of BISON or X any part thereof, to be licensed at no charge to all third X parties on terms identical to those contained in this License X Agreement (except that you may choose to grant more extensive X warranty protection to some or all third parties, at your X option) X X c) You may charge a distribution fee for the physical act of X transferring a copy, and you may at your option offer warranty X protection in exchange for a fee. X XMere aggregation of another unrelated program with this program (or its Xderivative) on a volume of a storage or distribution medium does not bring Xthe other program under the scope of these terms. X X 3. You may copy and distribute BISON (or a portion or derivative of it, Xunder Paragraph 2) in object code or executable form under the terms of XParagraphs 1 and 2 above provided that you also do one of the following: X X a) accompany it with the complete corresponding machine-readable X source code, which must be distributed under the terms of X Paragraphs 1 and 2 above; or, X X b) accompany it with a written offer, valid for at least three X years, to give any third party free (except for a nominal X shipping charge) a complete machine-readable copy of the X corresponding source code, to be distributed under the terms of X Paragraphs 1 and 2 above; or, X X c) accompany it with the information you received as to where the X corresponding source code may be obtained. (This alternative is X allowed only for noncommercial distribution and only if you X received the program in object code or executable form alone.) X XFor an executable file, complete source code means all the source code for Xall modules it contains; but, as a special exception, it need not include Xsource code for modules which are standard libraries that accompany the Xoperating system on which the executable file runs. X X 4. You may not copy, sublicense, distribute or transfer BISON Xexcept as expressly provided under this License Agreement. Any attempt Xotherwise to copy, sublicense, distribute or transfer BISON is void and Xyour rights to use the program under this License agreement shall be Xautomatically terminated. However, parties who have received computer Xsoftware programs from you with this License Agreement will not have Xtheir licenses terminated so long as such parties remain in full compliance. X X 5. If you wish to incorporate parts of GNU CC into other free programs Xwhose distribution conditions are different, write to the Free Software XFoundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked Xout a simple rule that can be stated here, but we will often permit this. XWe will be guided by the two goals of preserving the free status of all Xderivatives of our free software and of promoting the sharing and reuse of Xsoftware. X XYour comments and suggestions about our licensing policies and our Xsoftware are welcome! Please contact the Free Software Foundation, Inc., X675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. X XIn other words, go ahead and share BISON, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X X NO WARRANTY X X BECAUSE BISON IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO XWARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE BISON "AS IS" WITHOUT XWARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT XLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR XA PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND XPERFORMANCE OF BISON IS WITH YOU. SHOULD BISON PROVE DEFECTIVE, YOU XASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. X X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY XWHO MAY MODIFY AND REDISTRIBUTE BISON AS PERMITTED ABOVE, BE LIABLE TO XYOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER XSPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR XINABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA XBEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A XFAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) BISON, EVEN XIF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR XANY CLAIM BY ANY OTHER PARTY. SHAR_EOF if test 7191 -ne "`wc -c < 'COPYING'`" then echo shar: error transmitting "'COPYING'" '(should have been 7191 characters)' fi fi # end of overwriting check echo shar: extracting "'Makefile'" '(1892 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' X# Makefile for bison X XDESTDIR= X# where the installed binary goes XBINDIR = $(DESTDIR)/usr/local X X# where the parsers go XPARSERDIR = $(DESTDIR)/usr/local/lib X X# names of parser files XPFILE = bison.simple XPFILE1 = bison.hairy X X# It is unwise ever to compile a program without symbols. XCFLAGS = -g X XPFILES = -DXPFILE=\"$(PARSERDIR)/$(PFILE)\" \ X -DXPFILE1=\"$(PARSERDIR)/$(PFILE1)\" X XOBJECTS = LR0.o allocate.o closure.o conflicts.o derives.o files.o \ X getargs.o gram.o lalr.o \ X lex.o main.o nullable.o output.o print.o reader.o symtab.o \ X warshall.o X Xstart: bison X Xclean: X rm -f *.o core bison X Xinstall: bison X install bison $(BINDIR) X cp $(PFILE) $(PFILE1) $(PARSERDIR) X Xbison: $(OBJECTS) X $(CC) $(LDFLAGS) -o bison $(OBJECTS) X Xdist: bison-dist.tar bison-dist.tar.Z X Xbison-dist.tar: X tar cvf bison-dist.tar \ X COPYING Makefile REFERENCES bison.1 bison.simple bison.hairy \ X LR0.c allocate.c closure.c conflicts.c \ X derives.c files.c getargs.c gram.c lalr.c lex.c main.c \ X nullable.c output.c print.c reader.c symtab.c warshall.c \ X files.h gram.h lex.h machine.h new.h state.h symtab.h types.h \ X bison.cld build.com vmsgetargs.c vmshlp.mar Xbison-dist.tar.Z: bison-dist.tar X compress < bison-dist.tar > bison-dist.tar.Z X X# This file is different to pass the parser file names X# to the compiler. Xfiles.o: files.c files.h new.h gram.h X $(CC) -c $(CFLAGS) $(PFILES) files.c X XLR0.o: machine.h new.h gram.h state.h Xclosure.o: machine.h new.h gram.h Xconflicts.o: machine.h new.h files.h gram.h state.h Xderives.o: new.h types.h gram.h Xgetargs.o: files.h Xlalr.o: machine.h types.h state.h new.h gram.h Xlex.o: files.h symtab.h lex.h Xmain.o: machine.h Xnullable.o: types.h gram.h new.h Xoutput.o: machine.h new.h files.h gram.h state.h Xprint.o: machine.h new.h files.h gram.h state.h Xreader.o: files.h new.h symtab.h lex.h gram.h Xsymtab.o: new.h symtab.h gram.h Xwarshall.o: machine.h SHAR_EOF if test 1892 -ne "`wc -c < 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 1892 characters)' fi fi # end of overwriting check echo shar: extracting "'REFERENCES'" '(1197 characters)' if test -f 'REFERENCES' then echo shar: will not over-write existing file "'REFERENCES'" else sed 's/^X//' << \SHAR_EOF > 'REFERENCES' XFrom phr Tue Jul 8 10:36:19 1986 XDate: Tue, 8 Jul 86 00:52:24 EDT XFrom: phr (Paul Rubin) XTo: riferguson%watmath.waterloo.edu@CSNET-RELAY.ARPA, tower XSubject: Re: Bison documentation? X XThe main difference between Bison and Yacc that I know of is that XBison supports the @N construction, which gives you access to Xthe starting and ending line number and character number associated Xwith any of the symbols in the current rule. X XAlso, Bison supports the command `%expect N' which says not to mention Xthe conflicts if there are N shift/reduce conflicts and no reduce/reduce Xconflicts. X XThe differences in the algorithms stem mainly from the horrible Xkludges that Johnson had to perpetrate to make Yacc fit in a PDP-11. X XAlso, Bison uses a faster but less space-efficient encoding for the Xparse tables (see Corbett's PhD thesis from Berkeley, "Static XSemantics in Compiler Error Recovery", June 1985, Report No. UCB/CSD X85/251), and more modern technique for generating the lookahead sets. X(See "Efficient Construction of LALR(1) Lookahead Sets" by F. DeRemer Xand A. Pennello, in ACM TOPLS Vol 4 No 4, October 1982. Their Xtechnique is the standard one now.) X X paul rubin X free software foundation X X SHAR_EOF if test 1197 -ne "`wc -c < 'REFERENCES'`" then echo shar: error transmitting "'REFERENCES'" '(should have been 1197 characters)' fi fi # end of overwriting check echo shar: extracting "'bison.1'" '(1136 characters)' if test -f 'bison.1' then echo shar: will not over-write existing file "'bison.1'" else sed 's/^X//' << \SHAR_EOF > 'bison.1' X.TH BISON 1 local X.SH NAME Xbison \- GNU Project parser generator (yacc replacement) X.SH SYNOPSIS X.B bison X[ X.B \-dvy X] file X.SH DESCRIPTION X.I Bison Xis a parser generator in the style of X.IR yacc (1). XIt should be upwardly compatible with input files designed Xfor X.IR yacc . X.PP XInput files should follow the X.I yacc Xconvention of ending in ``.y''. XUnlike X.IR yacc , Xthe generated files do not have fixed names, but instead use the prefix Xof the input file. XFor instance, a grammar description file named X.B parse.y Xwould produce the generated parser in a file named X.BR parse.tab.c , Xinstead of X.IR yacc 's X.BR y.tab.c . X.PP X.I Bison Xtakes three optional flags. X.TP X.B \-d XProduce a X.B .tab.h Xfile, similar to X.IR yacc 's X.B y.tab.h Xfile. X.TP X.B \-v XBe verbose. Analogous to the same flag for X.IR yacc . X.TP X.B \-y XUse fixed output file names. I.e., force the output to be in files X.BR y.tab.c , X.BR y.tab.h , Xand so on. This is for full X.I yacc Xcompatibility. X.SH FILES X/usr/local/lib/bison.simple simple parser X.br X/usr/local/lib/bison.hairy complicated parser X.SH SEE ALSO X.IR yacc (1) X.SH DIAGNOSTICS X``Self explanatory.'' X... ha! SHAR_EOF if test 1136 -ne "`wc -c < 'bison.1'`" then echo shar: error transmitting "'bison.1'" '(should have been 1136 characters)' fi fi # end of overwriting check echo shar: extracting "'bison.cld'" '(301 characters)' if test -f 'bison.cld' then echo shar: will not over-write existing file "'bison.cld'" else sed 's/^X//' << \SHAR_EOF > 'bison.cld' X! X! VMS BISON command definition file X! XDEFINE VERB BISON X IMAGE GNU_BISON:[000000]BISON X X PARAMETER P1,Label=BISON$INFILE,Prompt="File" X value(required,type=$infile) X QUALIFIER VERBOSE,Label=BISON$VERBOSE X QUALIFIER DEFINES,Label=BISON$DEFINES X QUALIFIER FIXED_OUTFILES,Label=BISON$FIXED_OUTFILES SHAR_EOF if test 301 -ne "`wc -c < 'bison.cld'`" then echo shar: error transmitting "'bison.cld'" '(should have been 301 characters)' fi fi # end of overwriting check echo shar: extracting "'bison.hairy'" '(6474 characters)' if test -f 'bison.hairy' then echo shar: will not over-write existing file "'bison.hairy'" else sed 's/^X//' << \SHAR_EOF > 'bison.hairy' X Xextern int timeclock; X X Xint yyerror; /* Yyerror and yycost are set by guards. */ Xint yycost; /* If yyerror is set to a nonzero value by a */ X /* guard, the reduction with which the guard */ X /* is associated is not performed, and the */ X /* error recovery mechanism is invoked. */ X /* Yycost indicates the cost of performing */ X /* the reduction given the attributes of the */ X /* symbols. */ X X X/* YYMAXDEPTH indicates the size of the parser's state and value */ X/* stacks. */ X X#ifndef YYMAXDEPTH X#define YYMAXDEPTH 500 X#endif X X/* YYMAXRULES must be at least as large as the number of rules that */ X/* could be placed in the rule queue. That number could be determined */ X/* from the grammar and the size of the stack, but, as yet, it is not. */ X X#ifndef YYMAXRULES X#define YYMAXRULES 100 X#endif X X#ifndef YYMAXBACKUP X#define YYMAXBACKUP 100 X#endif X X Xshort yyss[YYMAXDEPTH]; /* the state stack */ XYYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */ XYYLTYPE yyls[YYMAXDEPTH]; /* the location stack */ Xshort yyrq[YYMAXRULES]; /* the rule queue */ Xint yychar; /* the lookahead symbol */ X XYYSTYPE yylval; /* the semantic value of the */ X /* lookahead symbol */ X XYYSTYPE yytval; /* the semantic value for the state */ X /* at the top of the state stack. */ X XYYSTYPE yyval; /* the variable used to return */ X /* semantic values from the action */ X /* routines */ X XYYLTYPE yylloc; /* location data for the lookahead */ X /* symbol */ X XYYLTYPE yytloc; /* location data for the state at the */ X /* top of the state stack */ X X Xint yynunlexed; Xshort yyunchar[YYMAXBACKUP]; XYYSTYPE yyunval[YYMAXBACKUP]; XYYLTYPE yyunloc[YYMAXBACKUP]; X Xshort *yygssp; /* a pointer to the top of the state */ X /* stack; only set during error */ X /* recovery. */ X XYYSTYPE *yygvsp; /* a pointer to the top of the value */ X /* stack; only set during error */ X /* recovery. */ X XYYLTYPE *yyglsp; /* a pointer to the top of the */ X /* location stack; only set during */ X /* error recovery. */ X X X/* Yyget is an interface between the parser and the lexical analyzer. */ X/* It is costly to provide such an interface, but it avoids requiring */ X/* the lexical analyzer to be able to back up the scan. */ X Xyyget() X{ X if (yynunlexed > 0) X { X yynunlexed--; X yychar = yyunchar[yynunlexed]; X yylval = yyunval[yynunlexed]; X yylloc = yyunloc[yynunlexed]; X } X else if (yychar <= 0) X yychar = 0; X else X { X yychar = yylex(); X if (yychar < 0) X yychar = 0; X else yychar = YYTRANSLATE(yychar); X } X} X X X Xyyunlex(chr, val, loc) Xint chr; XYYSTYPE val; XYYLTYPE loc; X{ X yyunchar[yynunlexed] = chr; X yyunval[yynunlexed] = val; X yyunloc[yynunlexed] = loc; X yynunlexed++; X} X X X Xyyrestore(first, last) Xregister short *first; Xregister short *last; X{ X register short *ssp; X register short *rp; X register int symbol; X register int state; X register int tvalsaved; X X ssp = yygssp; X yyunlex(yychar, yylval, yylloc); X X tvalsaved = 0; X while (first != last) X { X symbol = yystos[*ssp]; X if (symbol < YYNTBASE) X { X yyunlex(symbol, yytval, yytloc); X tvalsaved = 1; X ssp--; X } X X ssp--; X X if (first == yyrq) X first = yyrq + YYMAXRULES; X X first--; X X for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++) X { X if (symbol < YYNTBASE) X state = yytable[yypact[*ssp] + symbol]; X else X { X state = yypgoto[symbol - YYNTBASE] + *ssp; X X if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp) X state = yytable[state]; X else X state = yydefgoto[symbol - YYNTBASE]; X } X X *++ssp = state; X } X } X X if ( ! tvalsaved && ssp > yyss) X { X yyunlex(yystos[*ssp], yytval, yytloc); X ssp--; X } X X yygssp = ssp; X} X X X Xint Xyyparse() X{ X register int yystate; X register int yyn; X register short *yyssp; X register short *yyrq0; X register short *yyptr; X register YYSTYPE *yyvsp; X X int yylen; X YYLTYPE *yylsp; X short *yyrq1; X short *yyrq2; X X yystate = 0; X yyssp = yyss - 1; X yyvsp = yyvs - 1; X yylsp = yyls - 1; X yyrq0 = yyrq; X yyrq1 = yyrq0; X yyrq2 = yyrq0; X X yychar = yylex(); X if (yychar < 0) X yychar = 0; X else yychar = YYTRANSLATE(yychar); X Xyynewstate: X X if (yyssp >= yyss + YYMAXDEPTH - 1) X { X yyabort("Parser Stack Overflow"); X YYABORT; X } X X *++yyssp = yystate; X Xyyresume: X X yyn = yypact[yystate]; X if (yyn == YYFLAG) X goto yydefault; X X yyn += yychar; X if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar) X goto yydefault; X X yyn = yytable[yyn]; X if (yyn < 0) X { X yyn = -yyn; X goto yyreduce; X } X else if (yyn == 0) X goto yyerrlab; X X yystate = yyn; X X yyptr = yyrq2; X while (yyptr != yyrq1) X { X yyn = *yyptr++; X yylen = yyr2[yyn]; X yyvsp -= yylen; X yylsp -= yylen; X X yyguard(yyn, yyvsp, yylsp); X if (yyerror) X goto yysemerr; X X yyaction(yyn, yyvsp, yylsp); X *++yyvsp = yyval; X X yylsp++; X if (yylen == 0) X { X yylsp->timestamp = timeclock; X yylsp->first_line = yytloc.first_line; X yylsp->first_column = yytloc.first_column; X yylsp->last_line = (yylsp-1)->last_line; X yylsp->last_column = (yylsp-1)->last_column; X yylsp->text = 0; X } X else X { X yylsp->last_line = (yylsp+yylen-1)->last_line; X yylsp->last_column = (yylsp+yylen-1)->last_column; X } X X if (yyptr == yyrq + YYMAXRULES) X yyptr = yyrq; X } X X if (yystate == YYFINAL) X YYACCEPT; X X yyrq2 = yyptr; X yyrq1 = yyrq0; X X *++yyvsp = yytval; X *++yylsp = yytloc; X yytval = yylval; X yytloc = yylloc; X yyget(); X X goto yynewstate; X Xyydefault: X X yyn = yydefact[yystate]; X if (yyn == 0) X goto yyerrlab; X Xyyreduce: X X *yyrq0++ = yyn; X X if (yyrq0 == yyrq + YYMAXRULES) X yyrq0 = yyrq; X X if (yyrq0 == yyrq2) X { X yyabort("Parser Rule Queue Overflow"); X YYABORT; X } X X yyssp -= yyr2[yyn]; X yyn = yyr1[yyn]; X X yystate = yypgoto[yyn - YYNTBASE] + *yyssp; X if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) X yystate = yytable[yystate]; X else X yystate = yydefgoto[yyn - YYNTBASE]; X X goto yynewstate; X Xyysemerr: X *--yyptr = yyn; X yyrq2 = yyptr; X yyvsp += yyr2[yyn]; X Xyyerrlab: X X yygssp = yyssp; X yygvsp = yyvsp; X yyglsp = yylsp; X yyrestore(yyrq0, yyrq2); X yyrecover(); X yystate = *yygssp; X yyssp = yygssp; X yyvsp = yygvsp; X yyrq0 = yyrq; X yyrq1 = yyrq0; X yyrq2 = yyrq0; X goto yyresume; X} SHAR_EOF if test 6474 -ne "`wc -c < 'bison.hairy'`" then echo shar: error transmitting "'bison.hairy'" '(should have been 6474 characters)' fi fi # end of overwriting check echo shar: extracting "'bison.simple'" '(15842 characters)' if test -f 'bison.simple' then echo shar: will not over-write existing file "'bison.simple'" else sed 's/^X//' << \SHAR_EOF > 'bison.simple' X#line 2 "bison.simple" X X/* Skeleton output parser for bison, X copyright (C) 1984 Bob Corbett and Richard Stallman X X NO WARRANTY X X BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS" XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND XFITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY XAND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR XCORRECTION. X X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. X X GENERAL PUBLIC LICENSE TO COPY X X 1. You may copy and distribute verbatim copies of this source file Xas you receive it, in any medium, provided that you conspicuously and Xappropriately publish on each copy a valid copyright notice "Copyright X(C) 1985 Free Software Foundation, Inc."; and include following the Xcopyright notice a verbatim copy of the above disclaimer of warranty Xand of this License. You may charge a distribution fee for the Xphysical act of transferring a copy. X X 2. You may modify your copy or copies of this source file or Xany portion of it, and copy and distribute such modifications under Xthe terms of Paragraph 1 above, provided that you also do the following: X X a) cause the modified files to carry prominent notices stating X that you changed the files and the date of any change; and X X b) cause the whole of any work that you distribute or publish, X that in whole or in part contains or is a derivative of this X program or any part thereof, to be licensed at no charge to all X third parties on terms identical to those contained in this X License Agreement (except that you may choose to grant more extensive X warranty protection to some or all third parties, at your option). X X c) You may charge a distribution fee for the physical act of X transferring a copy, and you may at your option offer warranty X protection in exchange for a fee. X XMere aggregation of another unrelated program with this program (or its Xderivative) on a volume of a storage or distribution medium does not bring Xthe other program under the scope of these terms. X X 3. You may copy and distribute this program (or a portion or derivative Xof it, under Paragraph 2) in object code or executable form under the terms Xof Paragraphs 1 and 2 above provided that you also do one of the following: X X a) accompany it with the complete corresponding machine-readable X source code, which must be distributed under the terms of X Paragraphs 1 and 2 above; or, X X b) accompany it with a written offer, valid for at least three X years, to give any third party free (except for a nominal X shipping charge) a complete machine-readable copy of the X corresponding source code, to be distributed under the terms of X Paragraphs 1 and 2 above; or, X X c) accompany it with the information you received as to where the X corresponding source code may be obtained. (This alternative is X allowed only for noncommercial distribution and only if you X received the program in object code or executable form alone.) X XFor an executable file, complete source code means all the source code for Xall modules it contains; but, as a special exception, it need not include Xsource code for modules which are standard libraries that accompany the Xoperating system on which the executable file runs. X X 4. You may not copy, sublicense, distribute or transfer this program Xexcept as expressly provided under this License Agreement. Any attempt Xotherwise to copy, sublicense, distribute or transfer this program is void and Xyour rights to use the program under this License agreement shall be Xautomatically terminated. However, parties who have received computer Xsoftware programs from you with this License Agreement will not have Xtheir licenses terminated so long as such parties remain in full compliance. X X 5. If you wish to incorporate parts of this program into other free Xprograms whose distribution conditions are different, write to the Free XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet Xworked out a simple rule that can be stated here, but we will often permit Xthis. We will be guided by the two goals of preserving the free status of Xall derivatives of our free software and of promoting the sharing and reuse of Xsoftware. X X XIn other words, you are welcome to use, share and improve this program. XYou are forbidden to forbid anyone else to use, share and improve Xwhat you give them. Help stamp out software-hoarding! */ X X/* This is the parser code that is written into each bison parser X when the %semantic_parser declaration is not specified in the grammar. X It was written by Richard Stallman by simplifying the hairy parser X used when %semantic_parser is specified. */ X X/* Note: there must be only one dollar sign in this file. X It is replaced by the list of actions, each action X as one case of the switch. */ X X#define yyerrok (yyerrstatus = 0) X#define yyclearin (yychar = YYEMPTY) X#define YYEMPTY -2 X#define YYEOF 0 X#define YYFAIL goto yyerrlab; X X#define YYTERROR 1 X X#ifndef YYIMPURE X#define YYLEX yylex() X#endif X X#ifndef YYPURE X#define YYLEX yylex(&yylval, &yylloc) X#endif X X/* If nonreentrant, generate the variables here */ X X#ifndef YYIMPURE X Xint yychar; /* the lookahead symbol */ XYYSTYPE yylval; /* the semantic value of the */ X /* lookahead symbol */ X XYYLTYPE yylloc; /* location data for the lookahead */ X /* symbol */ X X#ifdef YYDEBUG Xint yydebug = 0; /* nonzero means print parse trace */ X#endif X X#endif /* YYIMPURE */ X X X/* YYMAXDEPTH indicates the initial size of the parser's stacks */ X X#ifndef YYMAXDEPTH X#define YYMAXDEPTH 200 X#endif X X/* YYMAXLIMIT is the maximum size the stacks can grow to X (effective only if the built-in stack extension method is used). */ X X#ifndef YYMAXLIMIT X#define YYMAXLIMIT 10000 X#endif X X X#line 87 "bison.simple" Xint Xyyparse() X{ X register int yystate; X register int yyn; X register short *yyssp; X register YYSTYPE *yyvsp; X YYLTYPE *yylsp; X int yyerrstatus; /* number of tokens to shift before error messages enabled */ X int yychar1; /* lookahead token as an internal (translated) token number */ X X short yyssa[YYMAXDEPTH]; /* the state stack */ X YYSTYPE yyvsa[YYMAXDEPTH]; /* the semantic value stack */ X YYLTYPE yylsa[YYMAXDEPTH]; /* the location stack */ X X short *yyss = yyssa; /* refer to the stacks thru separate pointers */ X YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ X YYLTYPE *yyls = yylsa; X X int yymaxdepth = YYMAXDEPTH; X X#ifndef YYPURE X X int yychar; X YYSTYPE yylval; X YYLTYPE yylloc; X X#ifdef YYDEBUG X extern int yydebug; X#endif X X#endif X X X YYSTYPE yyval; /* the variable used to return */ X /* semantic values from the action */ X /* routines */ X X int yylen; X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Starting parse\n"); X#endif X X yystate = 0; X yyerrstatus = 0; X yychar = YYEMPTY; /* Cause a token to be read. */ X X /* Initialize stack pointers. X Waste one element of value and location stack X so that they stay on the same level as the state stack. */ X X yyssp = yyss - 1; X yyvsp = yyvs; X yylsp = yyls; X X/* Push a new state, which is found in yystate . */ X/* In all cases, when you get here, the value and location stacks X have just been pushed. so pushing a state here evens the stacks. */ Xyynewstate: X X *++yyssp = yystate; X X if (yyssp >= yyss + yymaxdepth - 1) X { X /* Give user a chance to reallocate the stack */ X /* Use copies of these so that the &'s don't force the real ones into memory. */ X YYSTYPE *yyvs1 = yyvs; X YYLTYPE *yyls1 = yyls; X short *yyss1 = yyss; X X /* Get the current used size of the three stacks, in elements. */ X int size = yyssp - yyss + 1; X X#ifdef yyoverflow X /* Each stack pointer address is followed by the size of X the data in use in that stack, in bytes. */ X yyoverflow("parser stack overflow", X &yyss1, size * sizeof (*yyssp), X &yyvs1, size * sizeof (*yyvsp), X &yyls1, size * sizeof (*yylsp), X &yymaxdepth); X X yyss = yyss1; yyvs = yyvs1; yyls = yyls1; X#else /* no yyoverflow */ X /* Extend the stack our own way. */ X if (yymaxdepth >= YYMAXLIMIT) X yyerror("parser stack overflow"); X yymaxdepth *= 2; X if (yymaxdepth > YYMAXLIMIT) X yymaxdepth = YYMAXLIMIT; X yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp)); X bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); X yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp)); X bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); X yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp)); X bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); X#endif /* no yyoverflow */ X X yyssp = yyss + size - 1; X yylsp = yyls + size - 1; X yyvsp = yyvs + size - 1; X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Stack size increased to %d\n", yymaxdepth); X#endif X X if (yyssp >= yyss + yymaxdepth - 1) X YYERROR; X } X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Entering state %d\n", yystate); X#endif X X/* Do appropriate processing given the current state. */ X/* Read a lookahead token if we need one and don't already have one. */ Xyyresume: X X /* First try to decide what to do without reference to lookahead token. */ X X yyn = yypact[yystate]; X if (yyn == YYFLAG) X goto yydefault; X X /* Not known => get a lookahead token if don't already have one. */ X X /* yychar is either YYEMPTY or YYEOF X or a valid token in external form. */ X X if (yychar == YYEMPTY) X { X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Reading a token: "); X#endif X yychar = YYLEX; X } X X /* Convert token to internal form (in yychar1) for indexing tables with */ X X if (yychar <= 0) /* This means end of input. */ X { X yychar1 = 0; X yychar = YYEOF; /* Don't call YYLEX any more */ X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Now at end of input.\n"); X#endif X } X else X { X yychar1 = YYTRANSLATE(yychar); X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]); X#endif X } X X yyn += yychar1; X if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) X goto yydefault; X X yyn = yytable[yyn]; X X /* yyn is what to do for this token type in this state. X Negative => reduce, -yyn is rule number. X Positive => shift, yyn is new state. X New state is final state => don't bother to shift, X just return success. X 0, or most negative number => error. */ X X if (yyn < 0) X { X if (yyn == YYFLAG) X goto yyerrlab; X yyn = -yyn; X goto yyreduce; X } X else if (yyn == 0) X goto yyerrlab; X X if (yyn == YYFINAL) X YYACCEPT; X X /* Shift the lookahead token. */ X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); X#endif X X /* Discard the token being shifted unless it is eof. */ X if (yychar != YYEOF) X yychar = YYEMPTY; X X *++yyvsp = yylval; X *++yylsp = yylloc; X X /* count tokens shifted since error; after three, turn off error status. */ X if (yyerrstatus) yyerrstatus--; X X yystate = yyn; X goto yynewstate; X X/* Do the default action for the current state. */ Xyydefault: X X yyn = yydefact[yystate]; X if (yyn == 0) X goto yyerrlab; X X/* Do a reduction. yyn is the number of a rule to reduce with. */ Xyyreduce: X yylen = yyr2[yyn]; X yyval = yyvsp[1-yylen]; /* implement default value of the action */ X X#ifdef YYDEBUG X if (yydebug) X { X if (yylen == 1) X fprintf (stderr, "Reducing 1 value via line %d, ", X yyrline[yyn]); X else X fprintf (stderr, "Reducing %d values via line %d, ", X yylen, yyrline[yyn]); X } X#endif X X$ /* the action file gets copied in in place of this dollarsign */ X#line 303 "bison.simple" X X yyvsp -= yylen; X yylsp -= yylen; X yyssp -= yylen; X X#ifdef YYDEBUG X if (yydebug) X { X short *ssp1 = yyss - 1; X fprintf (stderr, "state stack now", yyssp-yyss); X while (ssp1 != yyssp) X fprintf (stderr, " %d", *++ssp1); X fprintf (stderr, "\n"); X } X#endif X X *++yyvsp = yyval; X X yylsp++; X if (yylen == 0) X { X yylsp->first_line = yylloc.first_line; X yylsp->first_column = yylloc.first_column; X yylsp->last_line = (yylsp-1)->last_line; X yylsp->last_column = (yylsp-1)->last_column; X yylsp->text = 0; X } X else X { X yylsp->last_line = (yylsp+yylen-1)->last_line; X yylsp->last_column = (yylsp+yylen-1)->last_column; X } X X /* Now "shift" the result of the reduction. X Determine what state that goes to, X based on the state we popped back to X and the rule number reduced by. */ X X yyn = yyr1[yyn]; X X yystate = yypgoto[yyn - YYNTBASE] + *yyssp; X if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) X yystate = yytable[yystate]; X else X yystate = yydefgoto[yyn - YYNTBASE]; X X goto yynewstate; X Xyyerrlab: /* here on detecting error */ X X if (! yyerrstatus) X /* If not already recovering from an error, report this error. */ X { X yyerror("parse error"); X } X X if (yyerrstatus == 3) X { X /* if just tried and failed to reuse lookahead token after an error, discard it. */ X X /* return failure if at end of input */ X if (yychar == YYEOF) X YYERROR; X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); X#endif X X yychar = YYEMPTY; X } X X /* Else will try to reuse lookahead token X after shifting the error token. */ X X yyerrstatus = 3; /* Each real token shifted decrements this */ X X goto yyerrhandle; X Xyyerrdefault: /* current state does not do anything special for the error token. */ X X#if 0 X /* This is wrong; only states that explicitly want error tokens X should shift them. */ X yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ X if (yyn) goto yydefault; X#endif X Xyyerrpop: /* pop the current state because it cannot handle the error token */ X X if (yyssp == yyss) YYERROR; X yyvsp--; X yylsp--; X yystate = *--yyssp; X X#ifdef YYDEBUG X if (yydebug) X { X short *ssp1 = yyss - 1; X fprintf (stderr, "Error: state stack now", yyssp-yyss); X while (ssp1 != yyssp) X fprintf (stderr, " %d", *++ssp1); X fprintf (stderr, "\n"); X } X#endif X Xyyerrhandle: X X yyn = yypact[yystate]; X if (yyn == YYFLAG) X goto yyerrdefault; X X yyn += YYTERROR; X if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) X goto yyerrdefault; X X yyn = yytable[yyn]; X if (yyn < 0) X { X if (yyn == YYFLAG) X goto yyerrpop; X yyn = -yyn; X goto yyreduce; X } X else if (yyn == 0) X goto yyerrpop; X X if (yyn == YYFINAL) X YYACCEPT; X X#ifdef YYDEBUG X if (yydebug) X fprintf(stderr, "Shifting error token, "); X#endif X X *++yyvsp = yylval; X *++yylsp = yylloc; X X yystate = yyn; X goto yynewstate; X} SHAR_EOF if test 15842 -ne "`wc -c < 'bison.simple'`" then echo shar: error transmitting "'bison.simple'" '(should have been 15842 characters)' fi fi # end of overwriting check echo shar: extracting "'build.com'" '(2196 characters)' if test -f 'build.com' then echo shar: will not over-write existing file "'build.com'" else sed 's/^X//' << \SHAR_EOF > 'build.com' X$! X$! This command procedure compiles and links BISON for VMS. X$! BISON has been tested with VAXC version 2.3 and VMS version 4.5 X$! and on VMS 4.5 with GCC 1.12. X$! X$! Bj|rn Larsen blarsen@ifi.uio.no X$! With some contributions by Gabor Karsai, X$! KARSAIG1%VUENGVAX.BITNET@jade.berkeley.edu X$! All merged and cleaned by RMS. X$! X$! Adapted for both VAX-11 "C" and VMS/GCC compilation by X$! David L. Kashtan kashtan.iu.ai.sri.com X$! X$! Uncomment the appropriate compilation command (CC=VAX-11 "C", GCC=VMS/GCC) X$ cc_command:="CC" X$! cc_command:="GCC" X$! X$! Note: Change the directories immediately below to whereever X$! you have placed bison.simple & hairy X$! X$ if "''cc_command'" .nes. "CC" then goto Try_GCC X$ cc_options:="/NOLIST/define=(""index=strchr"",""rindex=strrchr"",""XPFILE=""""DISK_USE:[BISON]bison.simple"""""",""XPFILE1=""""DISK_USE:[BISON]bison.hairy"""""")" X$ extra_linker_files:="VMSHLP," X$ goto Compile X$! X$! VMS/GCC compilation: X$! X$ Try_GCC: X$ if "''cc_command'" .nes. "GCC" then goto Fail X$ cc_options:="/DEBUG" X$ extra_linker_files:="GNU_CC:[000000]GCCLIB/LIB," X$ goto Compile X$! X$! Unknown compiler type X$! X$ Fail: X$ write sys$output "Unknown compiler type: ''cc_command'" X$ exit X$! X$! Do the compilation (compiler type is all set up) X$! X$ Compile: X$ if "''p1'" .eqs. "LINK" then goto Link X$ 'cc_command' 'cc_options' files.c X$ 'cc_command' 'cc_options' LR0.C X$ 'cc_command' 'cc_options' ALLOCATE.C X$ 'cc_command' 'cc_options' CLOSURE.C X$ 'cc_command' 'cc_options' CONFLICTS.C X$ 'cc_command' 'cc_options' DERIVES.C X$ 'cc_command' 'cc_options' VMSGETARGS.C X$ 'cc_command' 'cc_options' GRAM.C X$ 'cc_command' 'cc_options' LALR.C X$ 'cc_command' 'cc_options' LEX.C X$ 'cc_command' 'cc_options' MAIN.C X$ 'cc_command' 'cc_options' NULLABLE.C X$ 'cc_command' 'cc_options' OUTPUT.C X$ 'cc_command' 'cc_options' PRINT.C X$ 'cc_command' 'cc_options' READER.C X$ 'cc_command' 'cc_options' SYMTAB.C X$ 'cc_command' 'cc_options' WARSHALL.C X$ if "''cc_command'" .eqs. "CC" then macro vmshlp.mar X$ Link: X$ link/exec=bison main,LR0,allocate,closure,conflicts,derives,files,- Xvmsgetargs,gram,lalr,lex,nullable,output,print,reader,symtab,warshall,- X'extra_linker_files'sys$library:vaxcrtl/lib SHAR_EOF if test 2196 -ne "`wc -c < 'build.com'`" then echo shar: error transmitting "'build.com'" '(should have been 2196 characters)' fi fi # end of overwriting check echo shar: extracting "'vmshlp.mar'" '(1524 characters)' if test -f 'vmshlp.mar' then echo shar: will not over-write existing file "'vmshlp.mar'" else sed 's/^X//' << \SHAR_EOF > 'vmshlp.mar' X;/* Macro help routines for the BISON/VMS program X; Gabor Karsai, Vanderbilt University X; X;BISON is distributed in the hope that it will be useful, but WITHOUT ANY X;WARRANTY. No author or distributor accepts responsibility to anyone X;for the consequences of using it or for whether it serves any X;particular purpose or works at all, unless he says so in writing. X;Refer to the BISON General Public License for full details. X; X;Everyone is granted permission to copy, modify and redistribute BISON, X;but only under the conditions described in the BISON General Public X;License. A copy of this license is supposed to have been given to you X;along with BISON so you can know your rights and responsibilities. It X;should be in a file named COPYING. Among other things, the copyright X;notice 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 .psect vmshlp pic,usr,rel,ovr,shr,long,exe,nowrt X Xalloca:: X .word 0 X subl2 ^X4(ap),sp X movl ^X10(fp),r1 X movq ^X8(fp),ap X bicl2 #03,sp X addl2 #^X1c,sp X movl sp,r0 X jmp (r1) X Xbcopy:: X .word ^X0e00 X movl ^X04(ap),r11 X movl ^X08(ap),r10 X movl ^X0c(ap),r9 X brb 1$ X2$: movb (r10)+,(r11)+ X1$: sobgeq r9,2$ X ret X .end SHAR_EOF if test 1524 -ne "`wc -c < 'vmshlp.mar'`" then echo shar: error transmitting "'vmshlp.mar'" '(should have been 1524 characters)' fi fi # end of overwriting check # End of shell archive exit 0 --- end of part 1 ---