Import NetBSD byacc
This commit is contained in:
2
external/bsd/Makefile
vendored
2
external/bsd/Makefile
vendored
@@ -1,3 +1,3 @@
|
||||
.include <bsd.own.mk>
|
||||
SUBDIR=mdocml file
|
||||
SUBDIR=byacc file mdocml
|
||||
.include <bsd.subdir.mk>
|
||||
|
||||
5
external/bsd/byacc/Makefile
vendored
Normal file
5
external/bsd/byacc/Makefile
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# $NetBSD: Makefile,v 1.1 2009/10/29 00:56:35 christos Exp $
|
||||
|
||||
SUBDIR= bin
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
14
external/bsd/byacc/Makefile.inc
vendored
Normal file
14
external/bsd/byacc/Makefile.inc
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# $NetBSD: Makefile.inc,v 1.2 2011/09/16 16:41:20 joerg Exp $
|
||||
|
||||
WARNS=4
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
BINDIR?= /usr/bin
|
||||
|
||||
IDIST= ${NETBSDSRCDIR}/external/bsd/byacc/dist
|
||||
|
||||
CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR}/../include -I${IDIST}
|
||||
CWARNFLAGS+= -Wno-missing-noreturn
|
||||
|
||||
.PATH: ${IDIST}
|
||||
14
external/bsd/byacc/bin/Makefile
vendored
Normal file
14
external/bsd/byacc/bin/Makefile
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# $NetBSD: Makefile,v 1.3 2011/08/14 13:29:26 christos Exp $
|
||||
|
||||
.include "bsd.own.mk"
|
||||
|
||||
PROG= yacc
|
||||
SRCS= closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \
|
||||
skeleton.c symtab.c verbose.c warshall.c graph.c
|
||||
|
||||
CPPFLAGS+= -DGCC_NORETURN=__dead
|
||||
|
||||
COPTS.output.c += -Wno-format-nonliteral
|
||||
COPTS.reader.c += -Wno-format-nonliteral
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
272
external/bsd/byacc/bin/yacc.1
vendored
Normal file
272
external/bsd/byacc/bin/yacc.1
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:38:59 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1990 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" Robert Paul Corbett.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)yacc.1 5.7 (Berkeley) 7/30/91
|
||||
.\" from: Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
|
||||
.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:38:59 christos Exp $
|
||||
.\"
|
||||
.Dd September 7, 2011
|
||||
.Dt YACC 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm yacc
|
||||
.Nd an
|
||||
.Tn LALR(1)
|
||||
parser generator
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl dgilPrtVv
|
||||
.Op Fl b Ar prefix
|
||||
.Op Fl o Ar outputfile
|
||||
.Op Fl p Ar symbol_prefix
|
||||
.Ar filename
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
reads the grammar specification in the file
|
||||
.Ar filename
|
||||
and generates an
|
||||
.Tn LALR(1)
|
||||
parser for it.
|
||||
The parsers consist of a set of
|
||||
.Tn LALR(1)
|
||||
parsing tables and a driver routine
|
||||
written in the C programming language.
|
||||
.Nm
|
||||
normally writes the parse tables and the driver routine to the file
|
||||
.Pa y.tab.c .
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width Ar
|
||||
.It Fl b Ar prefix
|
||||
The
|
||||
.Fl b
|
||||
option changes the prefix prepended to the output file names to
|
||||
the string denoted by
|
||||
.Ar prefix .
|
||||
The default prefix is the character
|
||||
.Ar y .
|
||||
.It Fl d
|
||||
The
|
||||
.Fl d
|
||||
option causes the header file
|
||||
.Pa y.tab.h
|
||||
to be written.
|
||||
It contains #define's for the token identifiers.
|
||||
.It Fl g
|
||||
The
|
||||
.Fl g
|
||||
option causes a graphical description of the generated
|
||||
.Tn LALR(1)
|
||||
parser to be written to the file
|
||||
.Pa y.dot
|
||||
in graphviz format, ready to be processed by
|
||||
.Xr dot 1 .
|
||||
.It Fl i
|
||||
The
|
||||
.Fl i
|
||||
option causes a supplementary header file
|
||||
.Pa y.tab.i
|
||||
to be written.
|
||||
It contains extern declarations
|
||||
and supplementary #define's as needed to map the conventional
|
||||
.Nm
|
||||
yy-prefixed names to whatever the
|
||||
.Fl p
|
||||
option may specify.
|
||||
The code file, e.g.,
|
||||
.Pa y.tab.c
|
||||
is modified to #include this file
|
||||
as well as the
|
||||
.Pa y.tab.h
|
||||
file, enforcing consistent usage of the symbols defined in those files.
|
||||
The supplementary header file makes it simpler to separate compilation
|
||||
of lex- and yacc-files.
|
||||
.It Fl l
|
||||
If the
|
||||
.Fl l
|
||||
option is not specified,
|
||||
.Nm
|
||||
will insert #line directives in the generated code.
|
||||
The #line directives let the C compiler relate errors in the
|
||||
generated code to the user's original code.
|
||||
If the
|
||||
.Fl l
|
||||
option is specified,
|
||||
.Nm
|
||||
will not insert the #line directives.
|
||||
#line directives specified by the user will be retained.
|
||||
.It Fl o Ar outputfile
|
||||
The
|
||||
.Fl o
|
||||
option specifies an explicit output file name should be used instead
|
||||
of the default.
|
||||
.It Fl P
|
||||
The
|
||||
.Fl P
|
||||
options instructs
|
||||
.Nm
|
||||
to create a reentrant parser, like
|
||||
.Dq %pure-parser
|
||||
does.
|
||||
.It Fl p Ar symbol_prefix
|
||||
The
|
||||
.Fl p
|
||||
option changes the prefix prepended to yacc-generated symbols to
|
||||
the string denoted by
|
||||
.Ar symbol_prefix .
|
||||
The default prefix is the string
|
||||
.Ar yy .
|
||||
.It Fl r
|
||||
The
|
||||
.Fl r
|
||||
option causes
|
||||
.Nm
|
||||
to produce separate files for code and tables.
|
||||
The code file is named
|
||||
.Pa y.code.c ,
|
||||
and the tables file is named
|
||||
.Pa y.tab.c .
|
||||
.It Fl t
|
||||
The
|
||||
.Fl t
|
||||
option changes the preprocessor directives generated by
|
||||
.Nm
|
||||
so that debugging statements will be incorporated in the compiled code.
|
||||
.It Fl V
|
||||
The
|
||||
.Fl V
|
||||
option prints the version number to the standard output.
|
||||
.It Fl v
|
||||
The
|
||||
.Fl v
|
||||
option causes a human-readable description of the generated parser to
|
||||
be written to the file
|
||||
.Pa y.output .
|
||||
.El
|
||||
.Sh EXTENSIONS
|
||||
.Nm
|
||||
provides some extensions for compatibility with
|
||||
.Xr bison 1
|
||||
and other implementations
|
||||
of
|
||||
.Nm :
|
||||
.Pp
|
||||
.Bl -tag -width "%expect-rr number" -compact
|
||||
.It Dv %expect Ar number
|
||||
Tell
|
||||
.Nm
|
||||
the expected number of shift/reduce conflicts.
|
||||
That makes it only report the number if it differs.
|
||||
.It Dv %expect-rr Ar number
|
||||
Tell
|
||||
.Nm
|
||||
the expected number of reduce/reduce conflicts.
|
||||
That makes it only report the number if it differs.
|
||||
This is (unlike
|
||||
.Xr bison 1 )
|
||||
allowable in
|
||||
.Tn LALR(1)
|
||||
parsers.
|
||||
.It Dv %lex-param Ar { Ar argument-declaration Ar }
|
||||
By default, the lexer accepts no parameters, e.g.,
|
||||
.Fn yylex .
|
||||
Use this directive to add parameter declarations for your customized lexer.
|
||||
.It Dv %parse-param Ar { Ar argument-declaration Ar }
|
||||
By default, the parser accepts no parameters, e.g.,
|
||||
.Fn yyparse .
|
||||
Use this directive to add parameter declarations for your customized parser.
|
||||
.It Dv %pure-parser
|
||||
Most variables (other than
|
||||
.Fa yydebug
|
||||
and
|
||||
.Fa yynerrs )
|
||||
are allocated on the stack within
|
||||
.Fn yyparse ,
|
||||
making the parser reasonably reentrant.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variable is referenced by
|
||||
.Nm :
|
||||
.Bl -tag -width TMPDIR
|
||||
.It Ev TMPDIR
|
||||
If the environment variable
|
||||
.Ev TMPDIR
|
||||
is set, the string denoted by
|
||||
.Ev TMPDIR
|
||||
will be used as the name of the directory where the temporary
|
||||
files are created.
|
||||
.El
|
||||
.Sh TABLES
|
||||
The names of the tables generated by this version of
|
||||
.Nm
|
||||
are
|
||||
.Dq yylhs ,
|
||||
.Dq yylen ,
|
||||
.Dq yydefred ,
|
||||
.Dq yydgoto ,
|
||||
.Dq yysindex ,
|
||||
.Dq yyrindex ,
|
||||
.Dq yygindex ,
|
||||
.Dq yytable ,
|
||||
and
|
||||
.Dq yycheck .
|
||||
Two additional tables,
|
||||
.Dq yyname
|
||||
and
|
||||
.Dq yyrule ,
|
||||
are created if
|
||||
.Dv YYDEBUG
|
||||
is defined and non-zero.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /tmp/yacc.uXXXXXXXX -compact
|
||||
.It Pa y.code.c
|
||||
.It Pa y.tab.c
|
||||
.It Pa y.tab.h
|
||||
.It Pa y.output
|
||||
.It Pa /tmp/yacc.aXXXXXX
|
||||
.It Pa /tmp/yacc.tXXXXXX
|
||||
.It Pa /tmp/yacc.uXXXXXX
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
If there are rules that are never reduced, the number of such rules is
|
||||
written to the standard error.
|
||||
If there are any
|
||||
.Tn LALR(1)
|
||||
conflicts, the number of conflicts is also written
|
||||
to the standard error.
|
||||
.\" .Sh SEE ALSO
|
||||
.\" .Xr yyfix 1
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility conforms to
|
||||
.St -p1003.2 .
|
||||
125
external/bsd/byacc/byacc2netbsd
vendored
Executable file
125
external/bsd/byacc/byacc2netbsd
vendored
Executable file
@@ -0,0 +1,125 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# $NetBSD: byacc2netbsd,v 1.4 2011/10/08 19:28:39 christos Exp $
|
||||
#
|
||||
# Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# byacc2netbsd: convert a byacc tree into a
|
||||
# netbsd byacc source tree, under src/external/bsd/byacc/dist,
|
||||
# based on byacc2netbsd by Bernd Ernesti and changes by Simon Burge
|
||||
#
|
||||
# Rough instructions for importing new byacc release:
|
||||
#
|
||||
# $ cd /some/where/temporary
|
||||
# $ tar xpfz /new/byacc/release/tar/file
|
||||
# $ sh /usr/src/external/bsd/byacc/dist/byacc2netbsd byacc-YYYYMMDD `pwd`
|
||||
# $ cd src/external/bsd/byacc/dist
|
||||
# $ cvs import -m "Import byacc YYYYMMDD" src/external/bsd/byacc/dist DICKEY byacc-YYYYMMDD
|
||||
# $ cd ../../../../../byacc-YYYYMMDD
|
||||
# $ run ./configure
|
||||
# $ run make
|
||||
# check the config file and copy it to /usr/src/external/bsd/byacc/include
|
||||
# remove the version from SYSTEM_NAME
|
||||
# check the manual page against our copy if there are new options and
|
||||
# update
|
||||
|
||||
if [ $# -ne 2 ]; then echo "byacc2netbsd src dest"; exit 1; fi
|
||||
|
||||
r=$1
|
||||
d=$2/src/external/bsd/byacc/dist
|
||||
|
||||
case "$d" in
|
||||
/*)
|
||||
;;
|
||||
*)
|
||||
d=`/bin/pwd`/$d
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$r" in
|
||||
/*)
|
||||
;;
|
||||
*)
|
||||
r=`/bin/pwd`/$r
|
||||
;;
|
||||
esac
|
||||
|
||||
echo preparing directory $d
|
||||
rm -rf $d
|
||||
mkdir -p $d
|
||||
|
||||
### Copy the files and directories
|
||||
echo copying $r to $d
|
||||
cd $r
|
||||
pax -rw * $d
|
||||
|
||||
### Remove the $'s around RCS tags
|
||||
cleantags $d
|
||||
|
||||
### Add our NetBSD RCS Id
|
||||
find $d -type f -name '*.[chly]' -print | while read c; do
|
||||
sed 1q < $c | grep -q '\$NetBSD' || (
|
||||
echo "/* \$NetBSD\$ */" >/tmp/byacc3n$$
|
||||
echo "" >>/tmp/byacc3n$$
|
||||
cat $c >> /tmp/byacc3n$$
|
||||
mv /tmp/byacc3n$$ $c && echo added NetBSD RCS tag to $c
|
||||
)
|
||||
done
|
||||
|
||||
find $d -type f -name '*.[0-9]' -print | while read m; do
|
||||
sed 1q < $m | grep -q '\$NetBSD' || (
|
||||
echo ".\\\" \$NetBSD\$" >/tmp/byacc2m$$
|
||||
echo ".\\\"" >>/tmp/byacc2m$$
|
||||
cat $m >> /tmp/byacc2m$$
|
||||
mv /tmp/byacc2m$$ $m && echo added NetBSD RCS tag to $m
|
||||
)
|
||||
done
|
||||
|
||||
find $d -type f -name '*.texi' -print | while read t; do
|
||||
sed "2 s/^/@c \$NetBSD\$\\
|
||||
/" < $t > /tmp/byacc4t$$
|
||||
mv /tmp/byacc4t$$ $t && echo added NetBSD RCS tag to $t
|
||||
done
|
||||
|
||||
echo done
|
||||
|
||||
### Clean up any CVS directories that might be around.
|
||||
echo "cleaning up CVS residue."
|
||||
(
|
||||
cd $d
|
||||
find . -type d -name "CVS" -print | xargs rm -r
|
||||
)
|
||||
echo done
|
||||
|
||||
### Fixing file and directory permissions.
|
||||
echo "Fixing file/directory permissions."
|
||||
(
|
||||
cd $d
|
||||
find . -type f -print | xargs chmod u+rw,go+r
|
||||
find . -type d -print | xargs chmod u+rwx,go+rx
|
||||
)
|
||||
echo done
|
||||
|
||||
exit 0
|
||||
25
external/bsd/byacc/dist/ACKNOWLEDGEMENTS
vendored
Normal file
25
external/bsd/byacc/dist/ACKNOWLEDGEMENTS
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Berkeley Yacc owes much to the unflagging efforts of Keith Bostic.
|
||||
His badgering kept me working on it long after I was ready to quit.
|
||||
|
||||
Berkeley Yacc is based on the excellent algorithm for computing LALR(1)
|
||||
lookaheads developed by Tom Pennello and Frank DeRemer. The algorithm is
|
||||
described in their almost impenetrable article in TOPLAS 4,4.
|
||||
|
||||
Finally, much of the credit for the latest version must go to those
|
||||
who pointed out deficiencies of my earlier releases. Among the most
|
||||
prolific contributors were
|
||||
|
||||
Benson I. Margulies
|
||||
Dave Gentzel
|
||||
Antoine Verheijen
|
||||
Peter S. Housel
|
||||
Dale Smith
|
||||
Ozan Yigit
|
||||
John Campbell
|
||||
Bill Sommerfeld
|
||||
Paul Hilfinger
|
||||
Gary Bridgewater
|
||||
Dave Bakken
|
||||
Dan Lanciani
|
||||
Richard Sargent
|
||||
Parag Patel
|
||||
7
external/bsd/byacc/dist/AUTHORS
vendored
Normal file
7
external/bsd/byacc/dist/AUTHORS
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Id: AUTHORS,v 1.1 2010/06/06 20:31:51 tom Exp
|
||||
-- vile:txtmode
|
||||
-- This file is used by a script that collects contributor information and
|
||||
-- resolves nicknames vs fullnames.
|
||||
dickey Thomas Dickey
|
||||
schmitz Sylvain Schmitz
|
||||
unknown Robert Corbett
|
||||
996
external/bsd/byacc/dist/CHANGES
vendored
Normal file
996
external/bsd/byacc/dist/CHANGES
vendored
Normal file
@@ -0,0 +1,996 @@
|
||||
2011-09-08 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
* output.c:
|
||||
fix some more interaction between -i and -d flags to ensure YYERRCODE
|
||||
and YYSTYPE are declared, tested with cproto.
|
||||
|
||||
2011-09-07 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* yacc.1: document "-i" option.
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
* output.c: fix an interaction between -i and -d
|
||||
|
||||
* test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c:
|
||||
regen - changes for "-i" option move the global/impure variables near the
|
||||
macros that may add a prefix, etc.
|
||||
|
||||
* skeleton.c, output.c, defs.h: changes to support "-i" option.
|
||||
|
||||
2011-09-06 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* reader.c: pass explicit file-pointer to write_section()
|
||||
|
||||
* main.c:
|
||||
add "-i" option, to generate interface-file (suggested by Denis M. Wilson)
|
||||
|
||||
2011-09-05 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* configure: regen
|
||||
|
||||
* aclocal.m4:
|
||||
resync with my-autoconf: CF_ANSI_CC_CHECK (check for $CFLAGS in $CC)
|
||||
and CF_XOPEN_SOURCE (update aix, cygwin and netbsd checks)
|
||||
|
||||
* defs.h, error.c, reader.c:
|
||||
add check for missing "}" on %parse-param and %lex-param lines (report by Denis M Wilson)
|
||||
|
||||
2011-04-01 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: 2011-04-01
|
||||
|
||||
2011-02-02 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.guess: 2011-01-01
|
||||
|
||||
2010-12-29 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* defs.h, skeleton.c:
|
||||
add const qualifier to skeleton data, per NetBSD changes (report by Christos Zoulas)
|
||||
|
||||
* defs.h:
|
||||
mark all of the error-functions as non-returning (report by Christos Zoulas)
|
||||
|
||||
* test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c:
|
||||
regen
|
||||
|
||||
* skeleton.c:
|
||||
use only realloc() rather than realloc+malloc, agree that systems needing this
|
||||
are very rare (prompted by NetBSD change).
|
||||
|
||||
* test/ftp.tab.c: regen
|
||||
|
||||
2010-12-29 Christos.Zoulas
|
||||
|
||||
* test/ftp.y:
|
||||
improve example, which was stuck in 19XX and assumed file sizes were longs.
|
||||
|
||||
2010-12-29 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
|
||||
regen
|
||||
|
||||
* test/pure_error.y, test/pure_calc.y, test/ftp.y, test/error.y, test/code_error.y, test/code_calc.y, test/calc.y, test/calc3.y, test/calc2.y, test/calc1.y:
|
||||
use byacc's YYLEX_DECL/YYERROR_DECL symbols to prototype yylex/yyerror
|
||||
|
||||
* skeleton.c:
|
||||
remove explicit prototype for yylex() via YYLEX_DECL() macro, since that
|
||||
would prevent declaring yylex() static (request by Christos Zoulas).
|
||||
|
||||
* test/calc2.tab.c, test/calc3.tab.c: regen
|
||||
|
||||
2010-12-29 Christos.Zoulas
|
||||
|
||||
* output.c: correct definition for YYERROR_DECL()
|
||||
|
||||
2010-12-29 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
2010-12-26 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* defs.h, main.c:
|
||||
change return-type of allocate() to avoid warnings of alignment problems
|
||||
|
||||
* main.c: Solaris declares chmod() in <sys/stat.h>
|
||||
|
||||
* configure: regen
|
||||
|
||||
* main.c: ifdef'd use of fcntl.h
|
||||
|
||||
* configure.in: add configure checks for fcntl.h, atexit and mkstemp
|
||||
|
||||
* main.c: for cases where mkstemp() is not available, use tempnam/open
|
||||
|
||||
* aclocal.m4: add CF_MKSTEMP
|
||||
|
||||
* aclocal.m4:
|
||||
improve quoting, deprecate ${name-value} in favor of standard ${name:-value}
|
||||
|
||||
2010-12-25 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* main.c:
|
||||
start revising use of tmpfile(), to make this work with MinGW. Start by
|
||||
implementing a mkstemp() alternative - noting that mkstemp() also is broken
|
||||
for MinGW.
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
2010-11-27 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/byacc.spec, package/debian/changelog, VERSION: bump
|
||||
|
||||
* test/calc2.tab.c, test/calc3.tab.c: regen
|
||||
|
||||
* output.c:
|
||||
corrected use of %parse-param value in yyerror(); it doesn't use &yylval
|
||||
(report by Clifford Yapp)
|
||||
|
||||
2010-11-26 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* skeleton.c: typo
|
||||
|
||||
* output.c:
|
||||
correct line-numbering when "-r" option is used; the 'outline' variable
|
||||
should only be incremented when writing to the code-file.
|
||||
|
||||
* test/code_calc.code.c, test/code_error.code.c: regen
|
||||
|
||||
* yacc.1: bump date
|
||||
|
||||
* yacc.1: comment on -b option vs -r
|
||||
|
||||
* test/calc2.tab.c, test/calc2.y, test/calc3.tab.c, test/calc3.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
|
||||
regen
|
||||
|
||||
* output.c:
|
||||
improve on YYERROR_DECL(), adding dummy params which can be used for the
|
||||
actual function declaration. Also add YYERROR_CALL(). The two macros
|
||||
simplify maintaining sets of grammars which may/may not be pure.
|
||||
|
||||
* test/calc1.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
|
||||
regen
|
||||
|
||||
* output.c: generate yyerror() calls in output.c
|
||||
This is for compatibility with bison, which passes the yylval to yyerror
|
||||
when the %parse-param feature is used.
|
||||
|
||||
* skeleton.c, defs.h: generate yyerror() calls in output.c
|
||||
|
||||
* output.c: simplified a little, using putc_code() and putl_code()
|
||||
|
||||
* test/calc1.tab.h: regen
|
||||
|
||||
* reader.c:
|
||||
improve ifdef for YYSTYPE union declaration (report by Clifford Yapp)
|
||||
|
||||
* reader.c:
|
||||
accept underscore as a replacement for dash in command names, e.g.,
|
||||
"%pure_parser" vs "%pure-parser".
|
||||
|
||||
* test/calc1.tab.c: regen
|
||||
|
||||
* output.c, reader.c:
|
||||
also ifdef YYSTYPE declaration in the generated code (report by Clifford Yapp)
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
2010-11-24 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* main.c, defs.h, symtab.c, error.c: reduce global variables
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
* reader.c:
|
||||
amend fix for Redhat #112617 to still call default_action_warning() for
|
||||
empty rules (report by Bruce Cran).
|
||||
|
||||
2010-11-22 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* output.c:
|
||||
add ifdef to guard against redefinition of YYSTYPE union (request by Clifford Yapp).
|
||||
|
||||
* test/calc1.tab.c: regen
|
||||
|
||||
* test/calc1.y: cleanup compiler warnings
|
||||
|
||||
* test/grammar.y: add "%expect"
|
||||
|
||||
* test/calc1.tab.h: regen
|
||||
|
||||
* test/calc1.output, test/calc1.tab.c, test/calc1.tab.h: RCS_BASE
|
||||
|
||||
* test/calc2.tab.c, test/calc3.tab.c: regen
|
||||
|
||||
* test/calc1.y:
|
||||
advanced example from Steve Johnson's paper, uses unions
|
||||
|
||||
* test/calc3.y, test/calc2.y: init 'base', so examples can run
|
||||
|
||||
* test/ftp.tab.c, test/ftp.y: tweaks to compile with g++
|
||||
|
||||
* output.c: compensate for fix in reader.c
|
||||
|
||||
* reader.c:
|
||||
add/use putc_both() and puts_both(), incidentally fixing a place where
|
||||
a union copied to the union_file may be missing the end of the last line.
|
||||
|
||||
* package/debian/changelog, package/byacc.spec, VERSION: bump
|
||||
|
||||
2010-09-28 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.guess: 2010-09-24
|
||||
|
||||
2010-09-10 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: 2010-09-11
|
||||
|
||||
2010-06-10 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* yacc.1, package/debian/changelog, package/byacc.spec, VERSION:
|
||||
bump to 2010/06/10
|
||||
|
||||
2010-06-09 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* reader.c: free declarations in leak-testing code.
|
||||
|
||||
* main.c: close code_file if -r option used, for leak-testing
|
||||
|
||||
* defs.h, reader.c:
|
||||
improve %lex-param / %parse-param implementation by allowing for arrays to
|
||||
be passed as parameters, e.g., "int regs[26]".
|
||||
|
||||
* test/calc3.tab.c, test/calc3.y, test/calc3.output, test/calc3.tab.h, test/calc2.tab.c, test/calc2.y, test/calc2.tab.h, test/calc2.output:
|
||||
RCS_BASE
|
||||
|
||||
* output.c:
|
||||
improve %lex-param / %parse-param implementation by allowing for arrays to
|
||||
be passed as parameters, e.g., "int regs[26]".
|
||||
|
||||
* test/calc.tab.c, test/calc.y:
|
||||
test-cases and reference files for %lex-param / %parse-param
|
||||
|
||||
* makefile.in: add docs-rule, for html/pdf/txt form of manpage
|
||||
|
||||
* configure: regen
|
||||
|
||||
* aclocal.m4: add CF_XOPEN_SOURCE, etc.
|
||||
|
||||
* configure.in:
|
||||
use CF_XOPEN_SOURCE check to ensure that strdup is in scope, e.g., for c89
|
||||
|
||||
* test/ftp.tab.c, test/ftp.y, reader.c, symtab.c, verbose.c, lr0.c, main.c, mkpar.c, output.c, defs.h, closure.c:
|
||||
fix warnings from clang --analyze
|
||||
|
||||
2010-06-08 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* output.c: fix to build with c89, etc.
|
||||
|
||||
* reader.c: gcc warning
|
||||
|
||||
* test/ftp.tab.c, test/ftp.y, test/calc.tab.c, test/code_calc.code.c, test/code_error.code.c, test/code_error.y, test/code_calc.y, test/calc.y, test/pure_error.tab.c, test/error.tab.c, test/error.y, test/pure_error.y, test/pure_calc.tab.c, test/pure_calc.y:
|
||||
modified test-cases to allow them to compile, to validate pure-parser changes.
|
||||
updated reference files to match.
|
||||
|
||||
* output.c:
|
||||
move call for output_stype() earlier since it is used in pure-parser declarations
|
||||
|
||||
* test/grammar.tab.c, test/grammar.y:
|
||||
modified test-cases to allow them to compile, to validate pure-parser changes.
|
||||
updated reference files to match.
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
|
||||
regen
|
||||
|
||||
* yacc.1: document %lex-param and %parse-param
|
||||
|
||||
* test/run_lint.sh, test/run_make.sh: RCS_BASE
|
||||
|
||||
* test/run_test.sh:
|
||||
further modify to allow build-directory to be in a different location by
|
||||
passing this directory's location as a parameter to the script.
|
||||
|
||||
* makefile.in:
|
||||
add check_make and check_lint rules to help validate the generated files
|
||||
in the test-directory
|
||||
|
||||
2010-06-07 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/pure_calc.tab.c, test/pure_error.tab.c: RCS_BASE
|
||||
|
||||
* test/run_test.sh:
|
||||
provide for testing -r and -P options by checking if the ".y" filename
|
||||
begins with "code_" or "pure_", respectively.
|
||||
|
||||
* test/code_error.code.c, test/code_error.tab.c, test/code_error.tab.h, test/code_calc.code.c, test/code_calc.tab.c, test/code_calc.tab.h, test/pure_calc.output, test/pure_calc.tab.h, test/pure_error.output, test/pure_error.tab.h, test/code_calc.output, test/code_error.output:
|
||||
RCS_BASE
|
||||
|
||||
* test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: regen
|
||||
|
||||
* test/run_test.sh:
|
||||
changes to support running "make check" in a separate build-tree
|
||||
|
||||
* main.c: add "-P" to usage message
|
||||
|
||||
* reader.c: use UCH() macro to hide casts.
|
||||
|
||||
2010-06-07 Andres.Mejia
|
||||
|
||||
* main.c, output.c, reader.c, defs.h, skeleton.c:
|
||||
Fix the output order of the generated parse code file. This allows for
|
||||
the use of YYPARSE_PARAM, by having the output that checks for
|
||||
YYPARSE_PARAM to be defined come after the C code block in the
|
||||
definitions section of a yacc file.
|
||||
|
||||
Implement support for YYLEX_PARAM, similar to bison. This is useful for
|
||||
support for building reentrant lexers with flex.
|
||||
|
||||
Fix a compatibility issue with bison's pure-parser option. Bison
|
||||
defines yylex as sending at least one parameter, &yylval, as the first
|
||||
parameter and doesn't seem to have an easy way to remove that parameter.
|
||||
This on the other hand is rather convenient to support saving to yylval
|
||||
from flex when building reentrant lexers and parsers.
|
||||
|
||||
Add support for the %parse-param and %lex-param directives used in
|
||||
bison. This change bears some similarity to NetBSD's changes to byacc
|
||||
at http://www.mail-archive.com/source-changes-full@netbsd.org/msg08143.html
|
||||
|
||||
Bison allows for POSIX yacc emulation via a yacc directive in the yacc
|
||||
file, and also via a command line switch. Implement this feature as a
|
||||
no-op for byacc, since byacc is designed to be POSIX yacc compatible
|
||||
anyway. This allows for better compatibility with yacc sources written
|
||||
for bison.
|
||||
|
||||
2010-06-07 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* VERSION: bump to 2010/06/07
|
||||
|
||||
2010-06-06 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/calc.tab.c, configure: regen
|
||||
|
||||
* skeleton.c:
|
||||
move #include's down into the generated code, to allow user-defined code
|
||||
to override feature definitions, particularly with stdlib.h (request by
|
||||
Marcus Kool).
|
||||
|
||||
* lr0.c, error.c, reader.c, defs.h:
|
||||
strict gcc 3.4.6 warnings on 64-bit platform
|
||||
|
||||
* aclocal.m4, configure.in: add check for lint
|
||||
|
||||
* makefile.in: add lint rule
|
||||
|
||||
* defs.h, closure.c, lr0.c, warshall.c, main.c:
|
||||
fix gcc warnings, mostly for 64-bit platform
|
||||
|
||||
* aclocal.m4:
|
||||
add macros for checking ctags/etags, e.g., to work with NetBSD pkgsrc
|
||||
|
||||
* makefile.in: add etags/TAGS if available
|
||||
|
||||
* configure.in: add configure check for actual ctags and etags programs
|
||||
|
||||
* package/debian/copyright: add copyright notices for non-PD files
|
||||
|
||||
* package/debian/changelog:
|
||||
incorporated scripts in upstream to use for test-builds
|
||||
|
||||
* makefile.in: drop mkdirs.sh, just use "mkdir -p"
|
||||
|
||||
* AUTHORS: nicknames for some contributors (see CHANGES for details)
|
||||
|
||||
* package/byacc.spec: RPM file for byacc
|
||||
|
||||
* VERSION: bump to 2010/06/06
|
||||
|
||||
* aclocal.m4: add copyright notice, from "my-autoconf" macros
|
||||
http://invisible-island.net/autoconf/autoconf.html
|
||||
|
||||
* package/RCS, package/debian/RCS, package/debian/source/RCS, package/pkgsrc/RCS:
|
||||
PERMIT FILE
|
||||
|
||||
* aclocal.m4: resync with my-autoconf. summary of changes:
|
||||
a) CF_ADD_CFLAGS, etc., improve quoting of ifelse() parameter
|
||||
b) CF_DISABLE_ECHO, change indent-convention for substituted makefile
|
||||
c) CF_GCC_VERSION, ignore stderr
|
||||
d) CF_GCC_WARNINGS, adjust options to work with c89 wrapper of gcc
|
||||
|
||||
2010-04-20 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/debian/changelog, package/debian/compat, package/debian/control, package/debian/copyright, package/debian/docs, package/debian/postinst, package/debian/prerm, package/debian/rules, package/debian/watch:
|
||||
scripts from Debian package
|
||||
|
||||
2010-02-16 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* yacc.1: document -P and bison-extensions
|
||||
|
||||
* test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c:
|
||||
regen
|
||||
|
||||
* output.c: implement %pure-parser
|
||||
|
||||
* skeleton.c:
|
||||
implement %pure-parser, like bison. To help with this, changed the stack
|
||||
variables, putting them into a struct.
|
||||
|
||||
* reader.c: implement %pure-parser
|
||||
|
||||
* defs.h: modified skeleton to support %pure-parser feature
|
||||
|
||||
* main.c: add -P option to set %pure-parser
|
||||
|
||||
* output.c:
|
||||
make -r and -p options work together. The -r option splits the generated
|
||||
parser into code/table files; for this case we cannot use static data.
|
||||
Also, we have to repeat the #define's used for prefix (-p) as well as the
|
||||
redeclaration of yyparse(). Finally, allow any of the prefixed names to
|
||||
be overridden, e.g., by passing a -D option to the compiler. Make that
|
||||
a little more readable by putting a blank line before each chunk.
|
||||
|
||||
* defs.h: add definitions for %pure-parser
|
||||
|
||||
* skeleton.c:
|
||||
put blank line before/after the redeclaration of yyparse()
|
||||
|
||||
* output.c: allow for other program redefining yylex()
|
||||
|
||||
* skeleton.c:
|
||||
split-off xdecls[] array, to move declaration of yyparse() after #define's
|
||||
|
||||
* defs.h: split-out xdecls[]
|
||||
|
||||
* VERSION: bump
|
||||
|
||||
* configure: regen
|
||||
|
||||
* aclocal.m4: add CF_REMOVE_DEFINE, needed by CF_ADD_CFLAGS
|
||||
|
||||
* aclocal.m4:
|
||||
resync with my-autoconf CF_ADD_CFLAGS and CF_DISABLE_ECHO changes.
|
||||
|
||||
2010-02-16 Ostap.Cherkashi
|
||||
|
||||
* skeleton.c: fix a memory leak in the generated skeleton
|
||||
|
||||
2010-01-01 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/debian/source/format: scripts from Debian package
|
||||
|
||||
2009-12-31 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.guess: 2009-12-30
|
||||
|
||||
* config.sub: 2009-12-31
|
||||
|
||||
2009-10-27 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* VERSION: 20091027
|
||||
|
||||
* output.c, mkpar.c, defs.h, lalr.c, closure.c, graph.c, lr0.c, verbose.c, main.c, reader.c:
|
||||
strict compiler warnings
|
||||
|
||||
2009-10-26 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c:
|
||||
resync
|
||||
|
||||
* main.c, defs.h: introduce some typedefs for portability, etc.
|
||||
|
||||
* makefile.in:
|
||||
don't remove "*.log" in mostlyclean rule since it interferes with regression
|
||||
script.
|
||||
|
||||
* configure: regen
|
||||
|
||||
* aclocal.m4: resync with my-autoconf
|
||||
|
||||
2009-08-25 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.guess, config.sub: 2009-08-19
|
||||
|
||||
2009-02-21 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* VERSION: bump
|
||||
|
||||
* output.c: restore "yylval" symbol, omitted in cleanup on 2008/8/25
|
||||
|
||||
2008-12-26 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* configure: regen with autoconf-2.52 (patched)
|
||||
|
||||
2008-12-25 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c:
|
||||
regenerated
|
||||
|
||||
2008-12-24 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* VERSION: bump
|
||||
|
||||
* skeleton.c:
|
||||
remove ifdef-lint from goto yyerrlab, to quiet gcc warning
|
||||
|
||||
2008-11-26 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* verbose.c, main.c, defs.h, mkpar.c, reader.c:
|
||||
completed implementation of "%expect" (report by Perry E. Metzger).
|
||||
add "%expect-rr", which is (unlike bison) allowable in LALR parsers.
|
||||
|
||||
2008-11-24 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* closure.c, defs.h, error.c, graph.c, lalr.c, lr0.c, main.c, mkpar.c, output.c, reader.c, skeleton.c, symtab.c, verbose.c, warshall.c:
|
||||
change indent-style (request by Perry E. Metzger)
|
||||
|
||||
2008-08-27 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
|
||||
better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro
|
||||
|
||||
* VERSION: bump
|
||||
|
||||
* skeleton.c:
|
||||
better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, skeleton.c:
|
||||
change YYRECOVERING to YYRECOVERING(), for compatibility with other yacc's.
|
||||
|
||||
* configure: regen'd
|
||||
|
||||
* configure.in: add -Wwrite-strings to warnings
|
||||
|
||||
* test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c:
|
||||
add YYPARSE_PARAM and YYPARSE_PARAM_TYPE
|
||||
|
||||
* skeleton.c:
|
||||
add YYPARSE_PARAM (bison) and YYPARSE_PARAM_TYPE (FreeBSD) features.
|
||||
|
||||
* main.c, defs.h, output.c, skeleton.c, symtab.c, error.c, reader.c:
|
||||
fixes for gcc -Wwrite-strings
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
|
||||
generate the tables as static-const (this is an interface change)
|
||||
|
||||
* output.c: realign columns in start_table()
|
||||
|
||||
* output.c:
|
||||
generate the tables as static-const (this is an interface change)
|
||||
|
||||
* output.c: reorder functions to eliminate forward-references
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
|
||||
remove 'register' keywords
|
||||
|
||||
2008-08-26 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* warshall.c, verbose.c, symtab.c, skeleton.c, reader.c, output.c, mkpar.c, main.c, lr0.c, lalr.c, graph.c, error.c, closure.c:
|
||||
remove 'register' keywords
|
||||
|
||||
2008-08-25 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/ftp.tab.c: regen'd
|
||||
|
||||
* reader.c:
|
||||
improve the left-curly fix by testing after blanks, to avoid having a
|
||||
" {" at the beginning of a line.
|
||||
|
||||
* test/error.tab.c, test/grammar.tab.c: regen'd
|
||||
|
||||
* output.c:
|
||||
move the remaining newline-counting into write_XXX functions.
|
||||
|
||||
* test/calc.tab.c: regen'd
|
||||
|
||||
* output.c:
|
||||
simplify part of the output_file formatting using new functions, e.g.,
|
||||
start_int_table(), output_newline().
|
||||
|
||||
* reader.c:
|
||||
modify copy_action() to indent the first character, it if is is left-curly
|
||||
brace. That makes the output look more like the original, as well as makes
|
||||
it simpler to edit (not confuse editors which look for a left-curly in the
|
||||
first column as if it were the beginning of a function).
|
||||
|
||||
* skeleton.c: minor fixes to avoid gcc -Wconversion warnings
|
||||
|
||||
* output.c: align the #define's produced for "-p" option
|
||||
|
||||
* test/run_test.sh: use the "-p" option for better coverage.
|
||||
|
||||
* output.c: simplify output_prefix() with new define_prefixed()
|
||||
|
||||
* skeleton.c: include string.h, for memset()
|
||||
change stack size to unsigned to fix gcc -Wconversion warnings.
|
||||
|
||||
* VERSION: bump to 2008/8/25
|
||||
|
||||
* makefile.in: add dependency on VERSION file.
|
||||
|
||||
2008-08-24 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* VERSION: bump
|
||||
|
||||
* lalr.c: improved memory-leak checking by freeing data in includes[]
|
||||
|
||||
* test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c:
|
||||
update to match skeleton-change
|
||||
|
||||
* configure: regen'd
|
||||
|
||||
* skeleton.c: Add fix for stack discussed
|
||||
http://undeadly.org/cgi?action=article&sid=20080708155228
|
||||
and applied
|
||||
http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/yacc/skeleton.c.diff?r1=1.28&r2=1.29
|
||||
|
||||
* aclocal.m4: resync with my-autoconf (no major changes)
|
||||
|
||||
2008-07-24 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/pkgsrc/Makefile, package/pkgsrc/distinfo:
|
||||
scripts from NetBSD pkgsrc, for test-builds
|
||||
|
||||
2008-03-14 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: update to 2008-03-08
|
||||
|
||||
* config.guess: update to 2008-03-12
|
||||
|
||||
2007-05-09 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* main.c: close graph, verbose files if opened, on exit.
|
||||
|
||||
* main.c:
|
||||
audit memory leaks - valgrind reported some memory still in use on exit.
|
||||
|
||||
* lalr.c, output.c, reader.c, mkpar.c, lr0.c:
|
||||
add hook for auditing memory leaks
|
||||
|
||||
* defs.h: add hooks for auditing memory leaks
|
||||
|
||||
* configure: regen'd
|
||||
|
||||
* configure.in:
|
||||
use CF_DISABLE_LEAKS, which combines --disable-leaks, --with-valgrind,
|
||||
--with-dbmalloc and --with-dmalloc
|
||||
|
||||
* aclocal.m4: add CF_DISABLE_LEAKS and CF_WITH_VALGRIND
|
||||
|
||||
* aclocal.m4: improve version-checking in CF_GCC_VERSION
|
||||
rework dbmalloc/dmalloc options using CF_NO_LEAKS_OPTION macro
|
||||
|
||||
* VERSION: 2007/5/9
|
||||
|
||||
* main.c: file_prefix did not always have a trailing null.
|
||||
|
||||
2007-03-25 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* mkdirs.sh: improved version for "make -j"
|
||||
|
||||
2006-12-22 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.guess: 2006/12/22
|
||||
|
||||
2006-12-08 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: 2006/12/08
|
||||
|
||||
2005-08-13 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* main.c: add -V to usage message
|
||||
|
||||
* makefile.in: remove -t option from ctags
|
||||
|
||||
* VERSION: 2005/8/13
|
||||
|
||||
2005-08-13 schmitz
|
||||
|
||||
* main.c: Sylvain Schmitz:
|
||||
modify the '-o' option to work like bison's, which sets the file-prefix.
|
||||
|
||||
2005-08-13 Matt.Kraai
|
||||
|
||||
* output.c:
|
||||
Debian #322858 (don't close union_file, which contained data).
|
||||
This feature is used in groff.
|
||||
|
||||
2005-08-13 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* configure: regenerated
|
||||
|
||||
* aclocal.m4: improve checks for Intel compiler warnings
|
||||
|
||||
2005-06-25 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: 2005/6/2
|
||||
|
||||
* config.guess: 2005/5/27
|
||||
|
||||
2005-05-05 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* defs.h: add a fallback for GCC_UNUSED
|
||||
|
||||
2005-05-04 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* makefile.in: add "." to include-path to pickup config.h
|
||||
|
||||
* reader.c:
|
||||
apply fix suggested by Steve Dum for end_rule() in Redhat Bugzilla #112617.
|
||||
|
||||
* output.c:
|
||||
correct a limit check in pack_vector() - report/analysis by William Evans
|
||||
|
||||
* main.c:
|
||||
exit after printing version. Otherwise "yacc -V" will exit with an erro
|
||||
after printing the usage message.
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
|
||||
regenerated after skeleton-changes
|
||||
|
||||
* skeleton.c: replace a few -1's with YYEMPTY
|
||||
|
||||
* skeleton.c:
|
||||
delete yynewerror (no one uses it any more, and it just makes compiler warnings)
|
||||
|
||||
* skeleton.c: adapt yygrowstack() and related definitions from FreeBSD
|
||||
|
||||
* test/run_test.sh:
|
||||
filter out lines with YYPATCH, since that will change with each update
|
||||
|
||||
* yacc.1: add -V option
|
||||
|
||||
* main.c: add -V option to print the version.
|
||||
simplify option-parsing by moving the duplicate logic for setting flags into
|
||||
new function setflag().
|
||||
|
||||
* skeleton.c:
|
||||
move the actual definition of YYMAJOR and YYMINOR to defs.h (as numbers).
|
||||
add YYPATCH here so it can be tested by applications.
|
||||
|
||||
* defs.h:
|
||||
add macros to define VERSION in terms of the (numeric) YYMAJOR, YYMINOR and
|
||||
YYPATCH symbols.
|
||||
|
||||
* lalr.c, lr0.c, mkpar.c, defs.h, closure.c, warshall.c, output.c, verbose.c, graph.c, reader.c, main.c, symtab.c:
|
||||
reduce externs by making static the procedures that are not referenced outside
|
||||
the module in which they are defined.
|
||||
|
||||
* makefile.in:
|
||||
the VERSION file holds the patch-date. Define YYPATCH, so this will be
|
||||
compiled into the skeleton.
|
||||
|
||||
* VERSION: patch-level for byacc
|
||||
|
||||
* main.c:
|
||||
add "-o" to usage message. It is too long for a single line; rewrite usage()
|
||||
to show one option per line.
|
||||
|
||||
2005-05-03 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* main.c: add -o option, to work with scripts that assume bison.
|
||||
simplify create_file_names() with a macro.
|
||||
simplify done() with a macro.
|
||||
adapt fix from FreeBSD for signal race, e.g., if done() is interrupted by
|
||||
onintr(), do not flush output via exit(), but use _exit() instead.
|
||||
|
||||
* defs.h: remove unnecessary externs for main.c
|
||||
|
||||
* yacc.1: add -o option
|
||||
|
||||
* graph.c: remove unused parameter
|
||||
|
||||
* mkpar.c, defs.h, reader.c:
|
||||
add support for "%expect", a bison feature from FreeBSD sources
|
||||
|
||||
* lr0.c, reader.c, main.c, skeleton.c, graph.c, symtab.c, closure.c, mkpar.c, lalr.c, error.c, warshall.c, verbose.c, output.c:
|
||||
indent'd
|
||||
|
||||
* configure: regenerated for 2005/5/5
|
||||
|
||||
* aclocal.m4: miscellaneous updates (adds CF_INTEL_COMPILER)
|
||||
|
||||
2005-04-27 schmitz
|
||||
|
||||
* defs.h, graph.c, lr0.c, main.c, makefile.in, reader.c, yacc.1:
|
||||
Sylvain Schmitz <schmitz@i3s.unice.fr>:
|
||||
add graphical output of the LALR(1) automaton for graphviz,
|
||||
associated with command-line option `-g'
|
||||
|
||||
2005-04-16 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: 2005/2/10
|
||||
|
||||
* config.guess: 2005/3/24
|
||||
|
||||
2005-04-13 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/pkgsrc/PLIST: scripts from NetBSD pkgsrc, for test-builds
|
||||
|
||||
2005-03-21 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* package/pkgsrc/DESCR: scripts from NetBSD pkgsrc, for test-builds
|
||||
|
||||
2004-03-28 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
|
||||
updates due to adding yyparse() prototype
|
||||
|
||||
* configure: RCS_BASE
|
||||
|
||||
* configure.in:
|
||||
add AC_ARG_PROGRAM to make --program-prefix, etc., work.
|
||||
|
||||
* makefile.in: first cut of script to support --program-prefix
|
||||
|
||||
* configure.in:
|
||||
reorder AC_INIT/AC_CONFIG_HEADER to make this "work" with autoconf 2.52
|
||||
|
||||
* makefile.in: modify so DESTDIR works
|
||||
|
||||
* makefile.in: use EXEEXT and OBJEXT
|
||||
|
||||
* configure.in: use CF_PROG_EXT
|
||||
generate a config.h
|
||||
|
||||
* defs.h: make this use the generated config.h
|
||||
|
||||
* skeleton.c: add a forward-reference for yyparse()
|
||||
|
||||
* aclocal.m4: add CF_CHECK_CACHE, needed for CF_PROG_EXT
|
||||
|
||||
* yacc.1: remove the discussion of TMPDIR since it is obsolete
|
||||
|
||||
* skeleton.c: fix a couple of minor compiler-warnings in the skeleton
|
||||
|
||||
* defs.h: remove action_file_name, etc., since we use tmpfile() now.
|
||||
|
||||
* main.c:
|
||||
use tmpfile() for opening the working files. This quiets a warning
|
||||
advising the use of mkstemp().
|
||||
|
||||
* output.c:
|
||||
Do not close temporary-files here, since they are opened with tmpfile().
|
||||
Just rewind them, and they're ready to read back the data stored in them.
|
||||
|
||||
* test/grammar.output, test/grammar.tab.c, test/grammar.tab.h: RCS_BASE
|
||||
|
||||
* makefile.in: turn on "make check" rule
|
||||
|
||||
* test/calc.output, test/run_test.sh, test/calc.tab.h: RCS_BASE
|
||||
|
||||
* test/ftp.tab.c: yyparse() is now yyparse(void)
|
||||
|
||||
* test/calc.tab.c: RCS_BASE
|
||||
|
||||
* test/error.tab.c: yyparse() is now yyparse(void)
|
||||
|
||||
* test/README: RCS_BASE
|
||||
|
||||
* yacc.1: various typography fixes prompted by Debian #100947
|
||||
|
||||
* aclocal.m4, makefile.in, configure.in: RCS_BASE
|
||||
|
||||
* README: updated to note that this is not the original
|
||||
|
||||
2004-03-24 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/grammar.y: RCS_BASE
|
||||
|
||||
2004-02-23 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.sub: RCS_BASE
|
||||
|
||||
2004-02-17 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config.guess: RCS_BASE
|
||||
|
||||
2003-11-29 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* install-sh: improved quoting
|
||||
|
||||
2002-06-29 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* mkdirs.sh:
|
||||
don't use character range, since some locales don't work as expected
|
||||
|
||||
2001-06-22 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* install-sh: RCS_BASE
|
||||
|
||||
2000-11-20 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/calc.y: RCS_BASE
|
||||
|
||||
* test/code_calc.y, test/pure_calc.y: copy of calc.y
|
||||
|
||||
* vmsbuild.com: original version
|
||||
|
||||
2000-02-23 Thomas E. Dickey <dickey@invisible-island.net>
|
||||
|
||||
* test/RCS, RCS: PERMIT FILE
|
||||
|
||||
2000-02-14 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* main.c: fix for VMS port - making pathname for temp-file
|
||||
|
||||
* descrip.mms: original version
|
||||
|
||||
2000-02-13 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* defs.h, verbose.c, reader.c, main.c, skeleton.c, warshall.c, symtab.c, closure.c, mkpar.c, lalr.c, lr0.c, output.c, error.c:
|
||||
ansify
|
||||
|
||||
1999-11-30 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* mkdirs.sh: RCS_BASE
|
||||
|
||||
1995-01-01 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* config_h.in: RCS_BASE
|
||||
|
||||
1993-12-23 unknown
|
||||
|
||||
* README.DOS, main.c: MSDOS-port
|
||||
|
||||
1993-12-22 unknown
|
||||
|
||||
* reader.c, defs.h: MSDOS-port
|
||||
|
||||
1993-03-02 unknown
|
||||
|
||||
* README: original version
|
||||
|
||||
1993-02-22 unknown
|
||||
|
||||
* test/ftp.output, test/ftp.tab.c, test/ftp.tab.h, test/error.output, test/error.tab.c, test/error.tab.h:
|
||||
RCS_BASE
|
||||
|
||||
* skeleton.c, warshall.c, main.c, output.c, reader.c, closure.c, NOTES:
|
||||
original version
|
||||
|
||||
1992-10-12 unknown
|
||||
|
||||
* yacc.1: original version
|
||||
|
||||
1992-10-11 unknown
|
||||
|
||||
* defs.h: original version
|
||||
|
||||
1991-01-20 unknown
|
||||
|
||||
* mkpar.c, verbose.c: original version
|
||||
|
||||
1991-01-14 unknown
|
||||
|
||||
* lr0.c, Makefile, Makefile.old: original version
|
||||
|
||||
1990-07-16 unknown
|
||||
|
||||
* NEW_FEATURES: original version
|
||||
|
||||
1990-06-03 unknown
|
||||
|
||||
* ACKNOWLEDGEMENTS: original version
|
||||
|
||||
1990-02-05 unknown
|
||||
|
||||
* symtab.c, lalr.c, error.c: original version
|
||||
|
||||
1990-01-16 Thomas E. Dickey <tom@invisible-island.net>
|
||||
|
||||
* test/code_error.y, test/pure_error.y: RCS_BASE
|
||||
|
||||
1990-01-16 unknown
|
||||
|
||||
* test/error.y: RCS_BASE
|
||||
|
||||
1989-11-22 unknown
|
||||
|
||||
* NO_WARRANTY: original version
|
||||
|
||||
1989-09-23 unknown
|
||||
|
||||
* test/ftp.y: RCS_BASE
|
||||
|
||||
46
external/bsd/byacc/dist/NEW_FEATURES
vendored
Normal file
46
external/bsd/byacc/dist/NEW_FEATURES
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
The -r option has been implemented. The -r option tells Yacc to
|
||||
put the read-only tables in y.tab.c and the code and variables in
|
||||
y.code.c. Keith Bostic asked for this option so that :yyfix could be
|
||||
eliminated.
|
||||
|
||||
The -l and -t options have been implemented. The -l option tells
|
||||
Yacc not to include #line directives in the code it produces. The -t
|
||||
option causes debugging code to be included in the compiled parser.
|
||||
|
||||
The code for error recovery has been changed to implement the same
|
||||
algorithm as AT&T Yacc. There will still be differences in the way
|
||||
error recovery works because AT&T Yacc uses more default reductions
|
||||
than Berkeley Yacc.
|
||||
|
||||
The environment variable TMPDIR determines the directory where
|
||||
temporary files will be created. If TMPDIR is defined, temporary files
|
||||
will be created in the directory whose pathname is the value of TMPDIR.
|
||||
By default, temporary files are created in /tmp.
|
||||
|
||||
The keywords are now case-insensitive. For example, %nonassoc,
|
||||
%NONASSOC, %NonAssoc, and %nOnAsSoC are all equivalent.
|
||||
|
||||
Commas and semicolons that are not part of C code are treated as
|
||||
commentary.
|
||||
|
||||
Line-end comments, as in BCPL, are permitted. Line-end comments
|
||||
begin with // and end at the next end-of-line. Line-end comments are
|
||||
permitted in C code; they are converted to C comments on output.
|
||||
|
||||
The form of y.output files has been changed to look more like
|
||||
those produced by AT&T Yacc.
|
||||
|
||||
A new kind of declaration has been added. The form of the declaration
|
||||
is
|
||||
|
||||
%ident string
|
||||
|
||||
where string is a sequence of characters begining with a double quote
|
||||
and ending with either a double quote or the next end-of-line, whichever
|
||||
comes first. The declaration will cause a #ident directive to be written
|
||||
near the start of the output file.
|
||||
|
||||
If a parser has been compiled with debugging code, that code can be
|
||||
enabled by setting an environment variable. If the environment variable
|
||||
YYDEBUG is set to 0, debugging output is suppressed. If it is set to 1,
|
||||
debugging output is written to standard output.
|
||||
21
external/bsd/byacc/dist/NOTES
vendored
Normal file
21
external/bsd/byacc/dist/NOTES
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
$NetBSD: NOTES,v 1.2 2009/10/29 00:56:19 christos Exp $
|
||||
|
||||
Berkeley Yacc reflects its origins. The reason so many routines
|
||||
use exactly six register variables is that Berkeley Yacc was
|
||||
developed on a VAX using PCC. PCC placed at most six variables
|
||||
in registers. I went to considerable effort to find which six
|
||||
variables most belonged in registers. Changes in machines and
|
||||
compilers make that effort worthless, perhaps even harmful.
|
||||
|
||||
[Given the previous paragraph, and the fact that GCC does not respect
|
||||
register declarations, and the fact that much of the rest of the
|
||||
4.4lite2 release had "register" declarations extirpated, I've removed
|
||||
most of the register declarations from the code. I left them in the
|
||||
generated skeleton code "for the hell of it" but they probably should
|
||||
go from there, too. -- pm, July 1997]
|
||||
|
||||
[I totally removed the register stuff; we've deprecated it elsewhere
|
||||
in the tree now -- lukem, October 1997]
|
||||
|
||||
The code contains many instances where address calculations are
|
||||
performed in particular ways to optimize the code for the VAX.
|
||||
3
external/bsd/byacc/dist/NO_WARRANTY
vendored
Normal file
3
external/bsd/byacc/dist/NO_WARRANTY
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Berkeley Yacc is distributed with no warranty whatever. The author
|
||||
and any other contributors take no responsibility for the consequences of
|
||||
its use.
|
||||
29
external/bsd/byacc/dist/README
vendored
Normal file
29
external/bsd/byacc/dist/README
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
-- Id: README,v 1.2 2004/03/28 17:24:53 tom Exp
|
||||
|
||||
The original README is below. I've updated this version of Berkeley Yacc
|
||||
to make it ANSI C compliant - Thomas Dickey
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made
|
||||
as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input
|
||||
specification that conforms to the AT&T Yacc documentation. Specifications
|
||||
that take advantage of undocumented features of AT&T Yacc will probably be
|
||||
rejected.
|
||||
|
||||
Berkeley Yacc is distributed with no warranty whatever. The code is certain
|
||||
to contain errors. Neither the author nor any contributor takes responsibility
|
||||
for any consequences of its use.
|
||||
|
||||
Berkeley Yacc is in the public domain. The data structures and algorithms
|
||||
used in Berkeley Yacc are all either taken from documents available to the
|
||||
general public or are inventions of the author. Anyone may freely distribute
|
||||
source or binary forms of Berkeley Yacc whether unchanged or modified.
|
||||
Distributers may charge whatever fees they can obtain for Berkeley Yacc.
|
||||
Programs generated by Berkeley Yacc may be distributed freely.
|
||||
|
||||
Please report bugs to
|
||||
|
||||
robert.corbett@eng.Sun.COM
|
||||
|
||||
Include a small example if possible. Please include the banner string from
|
||||
skeleton.c with the bug report. Do not expect rapid responses.
|
||||
1
external/bsd/byacc/dist/VERSION
vendored
Normal file
1
external/bsd/byacc/dist/VERSION
vendored
Normal file
@@ -0,0 +1 @@
|
||||
20110908
|
||||
1092
external/bsd/byacc/dist/aclocal.m4
vendored
Normal file
1092
external/bsd/byacc/dist/aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
256
external/bsd/byacc/dist/closure.c
vendored
Normal file
256
external/bsd/byacc/dist/closure.c
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
/* $NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
|
||||
|
||||
/* Id: closure.c,v 1.9 2010/06/09 08:21:47 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
Value_t *itemset;
|
||||
Value_t *itemsetend;
|
||||
unsigned *ruleset;
|
||||
|
||||
static unsigned *first_derives;
|
||||
static unsigned *EFF;
|
||||
|
||||
static void
|
||||
set_EFF(void)
|
||||
{
|
||||
unsigned *row;
|
||||
int symbol;
|
||||
short *sp;
|
||||
int rowsize;
|
||||
int i;
|
||||
int rule;
|
||||
|
||||
rowsize = WORDSIZE(nvars);
|
||||
EFF = NEW2(nvars * rowsize, unsigned);
|
||||
|
||||
row = EFF;
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
sp = derives[i];
|
||||
for (rule = *sp; rule > 0; rule = *++sp)
|
||||
{
|
||||
symbol = ritem[rrhs[rule]];
|
||||
if (ISVAR(symbol))
|
||||
{
|
||||
symbol -= start_symbol;
|
||||
SETBIT(row, symbol);
|
||||
}
|
||||
}
|
||||
row += rowsize;
|
||||
}
|
||||
|
||||
reflexive_transitive_closure(EFF, nvars);
|
||||
|
||||
#ifdef DEBUG
|
||||
print_EFF();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
set_first_derives(void)
|
||||
{
|
||||
unsigned *rrow;
|
||||
unsigned *vrow;
|
||||
int j;
|
||||
unsigned k;
|
||||
unsigned cword = 0;
|
||||
short *rp;
|
||||
|
||||
int rule;
|
||||
int i;
|
||||
int rulesetsize;
|
||||
int varsetsize;
|
||||
|
||||
rulesetsize = WORDSIZE(nrules);
|
||||
varsetsize = WORDSIZE(nvars);
|
||||
first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize;
|
||||
|
||||
set_EFF();
|
||||
|
||||
rrow = first_derives + ntokens * rulesetsize;
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
vrow = EFF + ((i - ntokens) * varsetsize);
|
||||
k = BITS_PER_WORD;
|
||||
for (j = start_symbol; j < nsyms; k++, j++)
|
||||
{
|
||||
if (k >= BITS_PER_WORD)
|
||||
{
|
||||
cword = *vrow++;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (cword & (unsigned)(1 << k))
|
||||
{
|
||||
rp = derives[j];
|
||||
while ((rule = *rp++) >= 0)
|
||||
{
|
||||
SETBIT(rrow, rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rrow += rulesetsize;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
print_first_derives();
|
||||
#endif
|
||||
|
||||
FREE(EFF);
|
||||
}
|
||||
|
||||
void
|
||||
closure(short *nucleus, int n)
|
||||
{
|
||||
unsigned ruleno;
|
||||
unsigned word;
|
||||
unsigned i;
|
||||
Value_t *csp;
|
||||
unsigned *dsp;
|
||||
unsigned *rsp;
|
||||
int rulesetsize;
|
||||
|
||||
Value_t *csend;
|
||||
unsigned *rsend;
|
||||
int symbol;
|
||||
Value_t itemno;
|
||||
|
||||
rulesetsize = WORDSIZE(nrules);
|
||||
rsend = ruleset + rulesetsize;
|
||||
for (rsp = ruleset; rsp < rsend; rsp++)
|
||||
*rsp = 0;
|
||||
|
||||
csend = nucleus + n;
|
||||
for (csp = nucleus; csp < csend; ++csp)
|
||||
{
|
||||
symbol = ritem[*csp];
|
||||
if (ISVAR(symbol))
|
||||
{
|
||||
dsp = first_derives + symbol * rulesetsize;
|
||||
rsp = ruleset;
|
||||
while (rsp < rsend)
|
||||
*rsp++ |= *dsp++;
|
||||
}
|
||||
}
|
||||
|
||||
ruleno = 0;
|
||||
itemsetend = itemset;
|
||||
csp = nucleus;
|
||||
for (rsp = ruleset; rsp < rsend; ++rsp)
|
||||
{
|
||||
word = *rsp;
|
||||
if (word)
|
||||
{
|
||||
for (i = 0; i < BITS_PER_WORD; ++i)
|
||||
{
|
||||
if (word & (unsigned)(1 << i))
|
||||
{
|
||||
itemno = rrhs[ruleno + i];
|
||||
while (csp < csend && *csp < itemno)
|
||||
*itemsetend++ = *csp++;
|
||||
*itemsetend++ = itemno;
|
||||
while (csp < csend && *csp == itemno)
|
||||
++csp;
|
||||
}
|
||||
}
|
||||
}
|
||||
ruleno += BITS_PER_WORD;
|
||||
}
|
||||
|
||||
while (csp < csend)
|
||||
*itemsetend++ = *csp++;
|
||||
|
||||
#ifdef DEBUG
|
||||
print_closure(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
finalize_closure(void)
|
||||
{
|
||||
FREE(itemset);
|
||||
FREE(ruleset);
|
||||
FREE(first_derives + ntokens * WORDSIZE(nrules));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
void
|
||||
print_closure(int n)
|
||||
{
|
||||
short *isp;
|
||||
|
||||
printf("\n\nn = %d\n\n", n);
|
||||
for (isp = itemset; isp < itemsetend; isp++)
|
||||
printf(" %d\n", *isp);
|
||||
}
|
||||
|
||||
void
|
||||
print_EFF(void)
|
||||
{
|
||||
int i, j;
|
||||
unsigned *rowp;
|
||||
unsigned word;
|
||||
unsigned k;
|
||||
|
||||
printf("\n\nEpsilon Free Firsts\n");
|
||||
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
printf("\n%s", symbol_name[i]);
|
||||
rowp = EFF + ((i - start_symbol) * WORDSIZE(nvars));
|
||||
word = *rowp++;
|
||||
|
||||
k = BITS_PER_WORD;
|
||||
for (j = 0; j < nvars; k++, j++)
|
||||
{
|
||||
if (k >= BITS_PER_WORD)
|
||||
{
|
||||
word = *rowp++;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (word & (1 << k))
|
||||
printf(" %s", symbol_name[start_symbol + j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
print_first_derives(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
unsigned *rp;
|
||||
unsigned cword = 0;
|
||||
unsigned k;
|
||||
|
||||
printf("\n\n\nFirst Derives\n");
|
||||
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
printf("\n%s derives\n", symbol_name[i]);
|
||||
rp = first_derives + i * WORDSIZE(nrules);
|
||||
k = BITS_PER_WORD;
|
||||
for (j = 0; j <= nrules; k++, j++)
|
||||
{
|
||||
if (k >= BITS_PER_WORD)
|
||||
{
|
||||
cword = *rp++;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (cword & (1 << k))
|
||||
printf(" %d\n", j);
|
||||
}
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#endif
|
||||
1511
external/bsd/byacc/dist/config.guess
vendored
Executable file
1511
external/bsd/byacc/dist/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1760
external/bsd/byacc/dist/config.sub
vendored
Executable file
1760
external/bsd/byacc/dist/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
3
external/bsd/byacc/dist/config_h.in
vendored
Normal file
3
external/bsd/byacc/dist/config_h.in
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/* @configure_input@ */
|
||||
/* Id: config_h.in,v 1.1 1995/01/01 19:34:59 tom Exp */
|
||||
@DEFS@
|
||||
5453
external/bsd/byacc/dist/configure
vendored
Executable file
5453
external/bsd/byacc/dist/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
30
external/bsd/byacc/dist/configure.in
vendored
Normal file
30
external/bsd/byacc/dist/configure.in
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
dnl Process this file with 'autoconf' to produce a 'configure' script
|
||||
dnl Id: configure.in,v 1.10 2010/12/26 19:10:21 tom Exp
|
||||
AC_PREREQ(2.13.20020210)
|
||||
AC_REVISION(Revision: 1.10)
|
||||
AC_INIT(main.c)
|
||||
AC_CONFIG_HEADER(config.h:config_h.in)
|
||||
|
||||
CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
|
||||
|
||||
AC_ARG_PROGRAM
|
||||
AC_PROG_CC
|
||||
AC_CONST
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_INSTALL
|
||||
CF_MAKE_TAGS
|
||||
CF_PROG_LINT
|
||||
|
||||
CF_ANSI_CC_REQD
|
||||
CF_XOPEN_SOURCE
|
||||
AC_CHECK_HEADERS(fcntl.h)
|
||||
AC_CHECK_FUNCS(atexit)
|
||||
CF_MKSTEMP
|
||||
|
||||
CF_WITH_WARNINGS(Wwrite-strings)
|
||||
CF_DISABLE_ECHO
|
||||
CF_PROG_EXT
|
||||
CF_DISABLE_LEAKS
|
||||
|
||||
### output makefile
|
||||
AC_OUTPUT(makefile,,,cat)
|
||||
443
external/bsd/byacc/dist/defs.h
vendored
Normal file
443
external/bsd/byacc/dist/defs.h
vendored
Normal file
@@ -0,0 +1,443 @@
|
||||
/* $NetBSD: defs.h,v 1.5 2011/09/10 21:29:04 christos Exp $ */
|
||||
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
/* Id: defs.h,v 1.35 2011/09/07 08:55:03 tom Exp */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define CONCAT(first,second) first #second
|
||||
#define CONCAT1(string,number) CONCAT(string, number)
|
||||
#define CONCAT2(first,second) #first "." #second
|
||||
|
||||
#ifdef YYPATCH
|
||||
#define VSTRING(a,b) CONCAT2(a,b) CONCAT1(" ",YYPATCH)
|
||||
#else
|
||||
#define VSTRING(a,b) CONCAT2(a,b)
|
||||
#endif
|
||||
|
||||
#define VERSION VSTRING(YYMAJOR, YYMINOR)
|
||||
|
||||
/* machine-dependent definitions */
|
||||
/* the following definitions are for the Tahoe */
|
||||
/* they might have to be changed for other machines */
|
||||
|
||||
/* MAXCHAR is the largest unsigned character value */
|
||||
/* MAXSHORT is the largest value of a C short */
|
||||
/* MINSHORT is the most negative value of a C short */
|
||||
/* MAXTABLE is the maximum table size */
|
||||
/* BITS_PER_WORD is the number of bits in a C unsigned */
|
||||
/* WORDSIZE computes the number of words needed to */
|
||||
/* store n bits */
|
||||
/* BIT returns the value of the n-th bit starting */
|
||||
/* from r (0-indexed) */
|
||||
/* SETBIT sets the n-th bit starting from r */
|
||||
|
||||
#define MAXCHAR 255
|
||||
#define MAXSHORT 32767
|
||||
#define MINSHORT -32768
|
||||
#define MAXTABLE 32500
|
||||
#define BITS_PER_WORD 32
|
||||
#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
|
||||
#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1)
|
||||
#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31)))
|
||||
|
||||
/* character names */
|
||||
|
||||
#define NUL '\0' /* the null character */
|
||||
#define NEWLINE '\n' /* line feed */
|
||||
#define SP ' ' /* space */
|
||||
#define BS '\b' /* backspace */
|
||||
#define HT '\t' /* horizontal tab */
|
||||
#define VT '\013' /* vertical tab */
|
||||
#define CR '\r' /* carriage return */
|
||||
#define FF '\f' /* form feed */
|
||||
#define QUOTE '\'' /* single quote */
|
||||
#define DOUBLE_QUOTE '\"' /* double quote */
|
||||
#define BACKSLASH '\\' /* backslash */
|
||||
|
||||
#define UCH(c) (unsigned char)(c)
|
||||
|
||||
/* defines for constructing filenames */
|
||||
|
||||
#if defined(VMS)
|
||||
#define CODE_SUFFIX "_code.c"
|
||||
#define DEFINES_SUFFIX "_tab.h"
|
||||
#define EXTERNS_SUFFIX "_tab.i"
|
||||
#define OUTPUT_SUFFIX "_tab.c"
|
||||
#else
|
||||
#define CODE_SUFFIX ".code.c"
|
||||
#define DEFINES_SUFFIX ".tab.h"
|
||||
#define EXTERNS_SUFFIX ".tab.i"
|
||||
#define OUTPUT_SUFFIX ".tab.c"
|
||||
#endif
|
||||
#define VERBOSE_SUFFIX ".output"
|
||||
#define GRAPH_SUFFIX ".dot"
|
||||
|
||||
/* keyword codes */
|
||||
|
||||
#define TOKEN 0
|
||||
#define LEFT 1
|
||||
#define RIGHT 2
|
||||
#define NONASSOC 3
|
||||
#define MARK 4
|
||||
#define TEXT 5
|
||||
#define TYPE 6
|
||||
#define START 7
|
||||
#define UNION 8
|
||||
#define IDENT 9
|
||||
#define EXPECT 10
|
||||
#define EXPECT_RR 11
|
||||
#define PURE_PARSER 12
|
||||
#define PARSE_PARAM 13
|
||||
#define LEX_PARAM 14
|
||||
#define POSIX_YACC 15
|
||||
|
||||
/* symbol classes */
|
||||
|
||||
#define UNKNOWN 0
|
||||
#define TERM 1
|
||||
#define NONTERM 2
|
||||
|
||||
/* the undefined value */
|
||||
|
||||
#define UNDEFINED (-1)
|
||||
|
||||
/* action codes */
|
||||
|
||||
#define SHIFT 1
|
||||
#define REDUCE 2
|
||||
|
||||
/* character macros */
|
||||
|
||||
#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
|
||||
#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
|
||||
#define NUMERIC_VALUE(c) ((c) - '0')
|
||||
|
||||
/* symbol macros */
|
||||
|
||||
#define ISTOKEN(s) ((s) < start_symbol)
|
||||
#define ISVAR(s) ((s) >= start_symbol)
|
||||
|
||||
/* storage allocation macros */
|
||||
|
||||
#define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n)))
|
||||
#define FREE(x) (free((char*)(x)))
|
||||
#define MALLOC(n) (malloc((size_t)(n)))
|
||||
#define NEW(t) ((t*)allocate(sizeof(t)))
|
||||
#define NEW2(n,t) ((t*)allocate(((size_t)(n)*sizeof(t))))
|
||||
#define REALLOC(p,n) (realloc((char*)(p),(size_t)(n)))
|
||||
|
||||
#define DO_FREE(x) if (x) { FREE(x); x = 0; }
|
||||
|
||||
#define NO_SPACE(p) if (p == 0) no_space(); assert(p != 0)
|
||||
|
||||
/* messages */
|
||||
#define PLURAL(n) ((n) > 1 ? "s" : "")
|
||||
|
||||
typedef char Assoc_t;
|
||||
typedef char Class_t;
|
||||
typedef short Index_t;
|
||||
typedef short Value_t;
|
||||
|
||||
/* the structure of a symbol table entry */
|
||||
|
||||
typedef struct bucket bucket;
|
||||
struct bucket
|
||||
{
|
||||
struct bucket *link;
|
||||
struct bucket *next;
|
||||
char *name;
|
||||
char *tag;
|
||||
Value_t value;
|
||||
Index_t index;
|
||||
Value_t prec;
|
||||
Class_t class;
|
||||
Assoc_t assoc;
|
||||
};
|
||||
|
||||
/* the structure of the LR(0) state machine */
|
||||
|
||||
typedef struct core core;
|
||||
struct core
|
||||
{
|
||||
struct core *next;
|
||||
struct core *link;
|
||||
Value_t number;
|
||||
Value_t accessing_symbol;
|
||||
Value_t nitems;
|
||||
Value_t items[1];
|
||||
};
|
||||
|
||||
/* the structure used to record shifts */
|
||||
|
||||
typedef struct shifts shifts;
|
||||
struct shifts
|
||||
{
|
||||
struct shifts *next;
|
||||
Value_t number;
|
||||
Value_t nshifts;
|
||||
Value_t shift[1];
|
||||
};
|
||||
|
||||
/* the structure used to store reductions */
|
||||
|
||||
typedef struct reductions reductions;
|
||||
struct reductions
|
||||
{
|
||||
struct reductions *next;
|
||||
Value_t number;
|
||||
Value_t nreds;
|
||||
Value_t rules[1];
|
||||
};
|
||||
|
||||
/* the structure used to represent parser actions */
|
||||
|
||||
typedef struct action action;
|
||||
struct action
|
||||
{
|
||||
struct action *next;
|
||||
Value_t symbol;
|
||||
Value_t number;
|
||||
Value_t prec;
|
||||
char action_code;
|
||||
Assoc_t assoc;
|
||||
char suppressed;
|
||||
};
|
||||
|
||||
/* the structure used to store parse/lex parameters */
|
||||
typedef struct param param;
|
||||
struct param
|
||||
{
|
||||
struct param *next;
|
||||
char *name; /* parameter name */
|
||||
char *type; /* everything before parameter name */
|
||||
char *type2; /* everything after parameter name */
|
||||
};
|
||||
|
||||
/* global variables */
|
||||
|
||||
extern char dflag;
|
||||
extern char gflag;
|
||||
extern char iflag;
|
||||
extern char lflag;
|
||||
extern char rflag;
|
||||
extern char tflag;
|
||||
extern char vflag;
|
||||
extern const char *symbol_prefix;
|
||||
|
||||
extern const char *myname;
|
||||
extern char *cptr;
|
||||
extern char *line;
|
||||
extern int lineno;
|
||||
extern int outline;
|
||||
extern int exit_code;
|
||||
extern int pure_parser;
|
||||
|
||||
extern const char *const banner[];
|
||||
extern const char *const xdecls[];
|
||||
extern const char *const tables[];
|
||||
extern const char *const global_vars[];
|
||||
extern const char *const impure_vars[];
|
||||
extern const char *const hdr_defs[];
|
||||
extern const char *const hdr_vars[];
|
||||
extern const char *const body_1[];
|
||||
extern const char *const body_vars[];
|
||||
extern const char *const body_2[];
|
||||
extern const char *const body_3[];
|
||||
extern const char *const trailer[];
|
||||
extern const char *const trailer_2[];
|
||||
|
||||
extern char *code_file_name;
|
||||
extern char *input_file_name;
|
||||
extern char *defines_file_name;
|
||||
extern char *externs_file_name;
|
||||
|
||||
extern FILE *action_file;
|
||||
extern FILE *code_file;
|
||||
extern FILE *defines_file;
|
||||
extern FILE *externs_file;
|
||||
extern FILE *input_file;
|
||||
extern FILE *output_file;
|
||||
extern FILE *text_file;
|
||||
extern FILE *union_file;
|
||||
extern FILE *verbose_file;
|
||||
extern FILE *graph_file;
|
||||
|
||||
extern int nitems;
|
||||
extern int nrules;
|
||||
extern int nsyms;
|
||||
extern int ntokens;
|
||||
extern int nvars;
|
||||
extern int ntags;
|
||||
|
||||
extern char unionized;
|
||||
extern char line_format[];
|
||||
|
||||
extern Value_t start_symbol;
|
||||
extern char **symbol_name;
|
||||
extern char **symbol_pname;
|
||||
extern Value_t *symbol_value;
|
||||
extern Value_t *symbol_prec;
|
||||
extern char *symbol_assoc;
|
||||
|
||||
extern Value_t *ritem;
|
||||
extern Value_t *rlhs;
|
||||
extern Value_t *rrhs;
|
||||
extern Value_t *rprec;
|
||||
extern Assoc_t *rassoc;
|
||||
|
||||
extern Value_t **derives;
|
||||
extern char *nullable;
|
||||
|
||||
extern bucket *first_symbol;
|
||||
extern bucket *last_symbol;
|
||||
|
||||
extern int pure_parser;
|
||||
extern int nstates;
|
||||
extern core *first_state;
|
||||
extern shifts *first_shift;
|
||||
extern reductions *first_reduction;
|
||||
extern Value_t *accessing_symbol;
|
||||
extern core **state_table;
|
||||
extern shifts **shift_table;
|
||||
extern reductions **reduction_table;
|
||||
extern unsigned *LA;
|
||||
extern Value_t *LAruleno;
|
||||
extern Value_t *lookaheads;
|
||||
extern Value_t *goto_map;
|
||||
extern Value_t *from_state;
|
||||
extern Value_t *to_state;
|
||||
|
||||
extern action **parser;
|
||||
extern int SRexpect;
|
||||
extern int RRexpect;
|
||||
extern int SRtotal;
|
||||
extern int RRtotal;
|
||||
extern Value_t *SRconflicts;
|
||||
extern Value_t *RRconflicts;
|
||||
extern Value_t *defred;
|
||||
extern Value_t *rules_used;
|
||||
extern Value_t nunused;
|
||||
extern Value_t final_state;
|
||||
|
||||
extern Value_t *itemset;
|
||||
extern Value_t *itemsetend;
|
||||
extern unsigned *ruleset;
|
||||
|
||||
extern param *lex_param;
|
||||
extern param *parse_param;
|
||||
|
||||
/* global functions */
|
||||
|
||||
extern bucket *lookup(const char *);
|
||||
extern bucket *make_bucket(const char *);
|
||||
|
||||
#ifndef GCC_NORETURN
|
||||
#define GCC_NORETURN /* nothing */
|
||||
#endif
|
||||
|
||||
#ifndef GCC_UNUSED
|
||||
#define GCC_UNUSED /* nothing */
|
||||
#endif
|
||||
|
||||
/* closure.c */
|
||||
extern void closure(Value_t * nucleus, int n);
|
||||
extern void finalize_closure(void);
|
||||
extern void set_first_derives(void);
|
||||
|
||||
/* error.c */
|
||||
extern void default_action_warning(void);
|
||||
extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN;
|
||||
extern void dollar_warning(int a_lineno, int i);
|
||||
extern void fatal(const char *msg) GCC_NORETURN;
|
||||
extern void illegal_character(char *c_cptr) GCC_NORETURN;
|
||||
extern void illegal_tag(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN;
|
||||
extern void missing_brace(void) GCC_NORETURN;
|
||||
extern void no_grammar(void) GCC_NORETURN;
|
||||
extern void no_space(void) GCC_NORETURN;
|
||||
extern void open_error(const char *filename) GCC_NORETURN;
|
||||
extern void over_unionized(char *u_cptr) GCC_NORETURN;
|
||||
extern void prec_redeclared(void);
|
||||
extern void reprec_warning(char *s);
|
||||
extern void restarted_warning(void);
|
||||
extern void retyped_warning(char *s);
|
||||
extern void revalued_warning(char *s);
|
||||
extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN;
|
||||
extern void terminal_lhs(int s_lineno) GCC_NORETURN;
|
||||
extern void terminal_start(char *s) GCC_NORETURN;
|
||||
extern void tokenized_start(char *s) GCC_NORETURN;
|
||||
extern void undefined_goal(char *s) GCC_NORETURN;
|
||||
extern void undefined_symbol_warning(char *s);
|
||||
extern void unexpected_EOF(void) GCC_NORETURN;
|
||||
extern void unknown_rhs(int i) GCC_NORETURN;
|
||||
extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN;
|
||||
extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN;
|
||||
extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN;
|
||||
extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN;
|
||||
extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN;
|
||||
extern void untyped_lhs(void) GCC_NORETURN;
|
||||
extern void untyped_rhs(int i, char *s) GCC_NORETURN;
|
||||
extern void used_reserved(char *s) GCC_NORETURN;
|
||||
|
||||
/* graph.c */
|
||||
extern void graph(void);
|
||||
|
||||
/* lalr.c */
|
||||
extern void create_symbol_table(void);
|
||||
extern void free_symbol_table(void);
|
||||
extern void free_symbols(void);
|
||||
|
||||
/* lalr.c */
|
||||
extern void lalr(void);
|
||||
|
||||
/* lr0.c */
|
||||
extern void lr0(void);
|
||||
extern void show_cores(void);
|
||||
extern void show_ritems(void);
|
||||
extern void show_rrhs(void);
|
||||
extern void show_shifts(void);
|
||||
|
||||
/* main.c */
|
||||
extern void *allocate(size_t n);
|
||||
extern void done(int k) GCC_NORETURN;
|
||||
|
||||
/* mkpar.c */
|
||||
extern void free_parser(void);
|
||||
extern void make_parser(void);
|
||||
|
||||
/* output.c */
|
||||
extern void output(void);
|
||||
|
||||
/* reader.c */
|
||||
extern void reader(void);
|
||||
|
||||
/* skeleton.c */
|
||||
extern void write_section(FILE *fp, const char *const section[]);
|
||||
|
||||
/* verbose.c */
|
||||
extern void verbose(void);
|
||||
|
||||
/* warshall.c */
|
||||
extern void reflexive_transitive_closure(unsigned *R, int n);
|
||||
|
||||
#ifdef NO_LEAKS
|
||||
extern void lr0_leaks(void);
|
||||
extern void lalr_leaks(void);
|
||||
extern void mkpar_leaks(void);
|
||||
extern void output_leaks(void);
|
||||
extern void reader_leaks(void);
|
||||
#endif
|
||||
37
external/bsd/byacc/dist/descrip.mms
vendored
Normal file
37
external/bsd/byacc/dist/descrip.mms
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
CFLAGS = /decc $(CC_OPTIONS)/Diagnostics /Define=(NDEBUG) /Object=$@ /Include=([])
|
||||
|
||||
LINKFLAGS = /map=$(MMS$TARGET_NAME)/cross_reference/exec=$(MMS$TARGET_NAME).exe
|
||||
|
||||
LINKER = cc
|
||||
|
||||
OBJS = closure.obj, \
|
||||
error.obj, \
|
||||
lalr.obj, \
|
||||
lr0.obj, \
|
||||
main.obj, \
|
||||
mkpar.obj, \
|
||||
output.obj, \
|
||||
reader.obj, \
|
||||
skeleton.obj, \
|
||||
symtab.obj, \
|
||||
verbose.obj, \
|
||||
warshall.obj
|
||||
|
||||
PROGRAM = yacc.exe
|
||||
|
||||
all : $(PROGRAM)
|
||||
|
||||
$(PROGRAM) : $(OBJS)
|
||||
@ write sys$output "Loading $(PROGRAM) ... "
|
||||
@ $(LINK) $(LINKFLAGS) $(OBJS)
|
||||
@ write sys$output "done"
|
||||
|
||||
clean :
|
||||
@- if f$search("*.obj") .nes. "" then delete *.obj;*
|
||||
@- if f$search("*.lis") .nes. "" then delete *.lis;*
|
||||
@- if f$search("*.log") .nes. "" then delete *.log;*
|
||||
|
||||
clobber : clean
|
||||
@- if f$search("*.exe") .nes. "" then delete *.exe;*
|
||||
|
||||
$(OBJS) : defs.h
|
||||
292
external/bsd/byacc/dist/error.c
vendored
Normal file
292
external/bsd/byacc/dist/error.c
vendored
Normal file
@@ -0,0 +1,292 @@
|
||||
/* $NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
/* routines for printing error messages */
|
||||
|
||||
__dead void
|
||||
fatal(const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s: f - %s\n", myname, msg);
|
||||
done(2);
|
||||
}
|
||||
|
||||
__dead void
|
||||
no_space(void)
|
||||
{
|
||||
fprintf(stderr, "%s: f - out of space\n", myname);
|
||||
done(2);
|
||||
}
|
||||
|
||||
__dead void
|
||||
open_error(const char *filename)
|
||||
{
|
||||
fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
|
||||
done(2);
|
||||
}
|
||||
|
||||
void
|
||||
missing_brace(void)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", missing '}'\n",
|
||||
myname, lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
unexpected_EOF(void)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
|
||||
myname, lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
static void
|
||||
print_pos(char *st_line, char *st_cptr)
|
||||
{
|
||||
char *s;
|
||||
|
||||
if (st_line == 0)
|
||||
return;
|
||||
for (s = st_line; *s != '\n'; ++s)
|
||||
{
|
||||
if (isprint(UCH(*s)) || *s == '\t')
|
||||
putc(*s, stderr);
|
||||
else
|
||||
putc('?', stderr);
|
||||
}
|
||||
putc('\n', stderr);
|
||||
for (s = st_line; s < st_cptr; ++s)
|
||||
{
|
||||
if (*s == '\t')
|
||||
putc('\t', stderr);
|
||||
else
|
||||
putc(' ', stderr);
|
||||
}
|
||||
putc('^', stderr);
|
||||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
__dead void
|
||||
syntax_error(int st_lineno, char *st_line, char *st_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
|
||||
myname, st_lineno, input_file_name);
|
||||
print_pos(st_line, st_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
unterminated_comment(int c_lineno, char *c_line, char *c_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
|
||||
myname, c_lineno, input_file_name);
|
||||
print_pos(c_line, c_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
unterminated_string(int s_lineno, char *s_line, char *s_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
|
||||
myname, s_lineno, input_file_name);
|
||||
print_pos(s_line, s_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
unterminated_text(int t_lineno, char *t_line, char *t_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
|
||||
myname, t_lineno, input_file_name);
|
||||
print_pos(t_line, t_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
unterminated_union(int u_lineno, char *u_line, char *u_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
|
||||
declaration\n", myname, u_lineno, input_file_name);
|
||||
print_pos(u_line, u_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
over_unionized(char *u_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
|
||||
declarations\n", myname, lineno, input_file_name);
|
||||
print_pos(line, u_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
illegal_tag(int t_lineno, char *t_line, char *t_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
|
||||
myname, t_lineno, input_file_name);
|
||||
print_pos(t_line, t_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
illegal_character(char *c_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
|
||||
myname, lineno, input_file_name);
|
||||
print_pos(line, c_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
used_reserved(char *s)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: e - line %d of \"%s\", illegal use of reserved symbol \
|
||||
%s\n", myname, lineno, input_file_name, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
tokenized_start(char *s)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: e - line %d of \"%s\", the start symbol %s cannot be \
|
||||
declared to be a token\n", myname, lineno, input_file_name, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
retyped_warning(char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
|
||||
redeclared\n", myname, lineno, input_file_name, s);
|
||||
}
|
||||
|
||||
void
|
||||
reprec_warning(char *s)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: w - line %d of \"%s\", the precedence of %s has been \
|
||||
redeclared\n", myname, lineno, input_file_name, s);
|
||||
}
|
||||
|
||||
void
|
||||
revalued_warning(char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
|
||||
redeclared\n", myname, lineno, input_file_name, s);
|
||||
}
|
||||
|
||||
void
|
||||
terminal_start(char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
|
||||
token\n", myname, lineno, input_file_name, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
restarted_warning(void)
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
|
||||
redeclared\n", myname, lineno, input_file_name);
|
||||
}
|
||||
|
||||
void
|
||||
no_grammar(void)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
|
||||
specified\n", myname, lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
terminal_lhs(int s_lineno)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
|
||||
of a production\n", myname, s_lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
prec_redeclared(void)
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
|
||||
specifiers\n", myname, lineno, input_file_name);
|
||||
}
|
||||
|
||||
void
|
||||
unterminated_action(int a_lineno, char *a_line, char *a_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
|
||||
myname, a_lineno, input_file_name);
|
||||
print_pos(a_line, a_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
dollar_warning(int a_lineno, int i)
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
|
||||
end of the current rule\n", myname, a_lineno, input_file_name, i);
|
||||
}
|
||||
|
||||
__dead void
|
||||
dollar_error(int a_lineno, char *a_line, char *a_cptr)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
|
||||
myname, a_lineno, input_file_name);
|
||||
print_pos(a_line, a_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
untyped_lhs(void)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
|
||||
myname, lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
untyped_rhs(int i, char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
|
||||
myname, lineno, input_file_name, i, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
__dead void
|
||||
unknown_rhs(int i)
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
|
||||
myname, lineno, input_file_name, i);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
default_action_warning(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: w - line %d of \"%s\", the default action assigns an \
|
||||
undefined value to $$\n", myname, lineno, input_file_name);
|
||||
}
|
||||
|
||||
void
|
||||
undefined_goal(char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
void
|
||||
undefined_symbol_warning(char *s)
|
||||
{
|
||||
fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
|
||||
}
|
||||
116
external/bsd/byacc/dist/graph.c
vendored
Normal file
116
external/bsd/byacc/dist/graph.c
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/* $NetBSD: graph.c,v 1.4 2010/12/25 23:43:30 christos Exp $ */
|
||||
/* Id: graph.c,v 1.7 2009/10/27 09:25:20 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: graph.c,v 1.4 2010/12/25 23:43:30 christos Exp $");
|
||||
|
||||
static void graph_state(int stateno);
|
||||
static void graph_LA(int ruleno);
|
||||
|
||||
static unsigned int larno;
|
||||
|
||||
void
|
||||
graph(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
shifts *sp;
|
||||
int sn;
|
||||
int as;
|
||||
|
||||
if (!gflag)
|
||||
return;
|
||||
|
||||
for (i = 0; i < nstates; ++i)
|
||||
{
|
||||
closure(state_table[i]->items, state_table[i]->nitems);
|
||||
graph_state(i);
|
||||
}
|
||||
|
||||
fprintf(graph_file, "\n\n");
|
||||
for (i = 0; i < nstates; ++i)
|
||||
{
|
||||
|
||||
sp = shift_table[i];
|
||||
if (sp)
|
||||
for (j = 0; j < sp->nshifts; ++j)
|
||||
{
|
||||
sn = sp->shift[j];
|
||||
as = accessing_symbol[sn];
|
||||
fprintf(graph_file,
|
||||
"\tq%d -> q%d [label=\"%s\"];\n",
|
||||
i, sn, symbol_pname[as]);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(graph_file, "}\n");
|
||||
|
||||
for (i = 0; i < nsyms; ++i)
|
||||
FREE(symbol_pname[i]);
|
||||
FREE(symbol_pname);
|
||||
}
|
||||
|
||||
static void
|
||||
graph_state(int stateno)
|
||||
{
|
||||
short *isp;
|
||||
int rule;
|
||||
short *sp;
|
||||
short *sp1;
|
||||
|
||||
larno = (unsigned)lookaheads[stateno];
|
||||
fprintf(graph_file, "\n\tq%d [label=\"%d:\\l", stateno, stateno);
|
||||
|
||||
for (isp = itemset; isp < itemsetend; isp++)
|
||||
{
|
||||
sp1 = sp = ritem + *isp;
|
||||
|
||||
while (*sp >= 0)
|
||||
++sp;
|
||||
rule = -(*sp);
|
||||
fprintf(graph_file, " %s -> ", symbol_pname[rlhs[rule]]);
|
||||
|
||||
for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
|
||||
fprintf(graph_file, "%s ", symbol_pname[*sp]);
|
||||
|
||||
putc('.', graph_file);
|
||||
|
||||
while (*sp >= 0)
|
||||
{
|
||||
fprintf(graph_file, " %s", symbol_pname[*sp]);
|
||||
sp++;
|
||||
}
|
||||
|
||||
if (*sp1 < 0)
|
||||
graph_LA(-*sp1);
|
||||
|
||||
fprintf(graph_file, "\\l");
|
||||
}
|
||||
fprintf(graph_file, "\"];");
|
||||
}
|
||||
|
||||
static void
|
||||
graph_LA(int ruleno)
|
||||
{
|
||||
int i;
|
||||
unsigned tokensetsize;
|
||||
unsigned *rowp;
|
||||
|
||||
tokensetsize = (unsigned)WORDSIZE(ntokens);
|
||||
|
||||
if (ruleno == LAruleno[larno])
|
||||
{
|
||||
rowp = LA + larno * tokensetsize;
|
||||
|
||||
fprintf(graph_file, " { ");
|
||||
for (i = ntokens - 1; i >= 0; i--)
|
||||
{
|
||||
if (BIT(rowp, i))
|
||||
fprintf(graph_file, "%s ", symbol_pname[i]);
|
||||
}
|
||||
fprintf(graph_file, "}");
|
||||
++larno;
|
||||
}
|
||||
}
|
||||
294
external/bsd/byacc/dist/install-sh
vendored
Executable file
294
external/bsd/byacc/dist/install-sh
vendored
Executable file
@@ -0,0 +1,294 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
#
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd=$cpprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd=$stripprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "$0: no input file specified" >&2
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d "$dst" ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f "$src" ] || [ -d "$src" ]
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "$0: $src does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "$0: no destination specified" >&2
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d "$dst" ]
|
||||
then
|
||||
dst=$dst/`basename "$src"`
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS=$oIFS
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp=$pathcomp$1
|
||||
shift
|
||||
|
||||
if [ ! -d "$pathcomp" ] ;
|
||||
then
|
||||
$mkdirprog "$pathcomp"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd "$dst" &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename "$dst"`
|
||||
else
|
||||
dstfile=`basename "$dst" $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename "$dst"`
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
rmtmp=$dstdir/#rm.$$#
|
||||
|
||||
# Trap to clean up temp files at exit.
|
||||
|
||||
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd "$src" "$dsttmp" &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
|
||||
|
||||
# Now remove or move aside any old file at destination location. We try this
|
||||
# two ways since rm can't unlink itself on some systems and the destination
|
||||
# file might be busy for other reasons. In this case, the final cleanup
|
||||
# might fail but the new file should still install successfully.
|
||||
|
||||
{
|
||||
if [ -f "$dstdir/$dstfile" ]
|
||||
then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
|
||||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
|
||||
{
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
|
||||
fi &&
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
|
||||
{
|
||||
(exit 0); exit
|
||||
}
|
||||
659
external/bsd/byacc/dist/lalr.c
vendored
Normal file
659
external/bsd/byacc/dist/lalr.c
vendored
Normal file
@@ -0,0 +1,659 @@
|
||||
/* $NetBSD: lalr.c,v 1.5 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: lalr.c,v 1.9 2009/10/27 09:49:27 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: lalr.c,v 1.5 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
typedef struct shorts
|
||||
{
|
||||
struct shorts *next;
|
||||
Value_t value;
|
||||
}
|
||||
shorts;
|
||||
|
||||
static Value_t map_goto(int state, int symbol);
|
||||
static Value_t **transpose(Value_t ** R, int n);
|
||||
static void add_lookback_edge(int stateno, int ruleno, int gotono);
|
||||
static void build_relations(void);
|
||||
static void compute_FOLLOWS(void);
|
||||
static void compute_lookaheads(void);
|
||||
static void digraph(Value_t ** relation);
|
||||
static void initialize_F(void);
|
||||
static void initialize_LA(void);
|
||||
static void set_accessing_symbol(void);
|
||||
static void set_goto_map(void);
|
||||
static void set_maxrhs(void);
|
||||
static void set_reduction_table(void);
|
||||
static void set_shift_table(void);
|
||||
static void set_state_table(void);
|
||||
static void traverse(int i);
|
||||
|
||||
static int tokensetsize;
|
||||
Value_t *lookaheads;
|
||||
Value_t *LAruleno;
|
||||
unsigned *LA;
|
||||
Value_t *accessing_symbol;
|
||||
core **state_table;
|
||||
shifts **shift_table;
|
||||
reductions **reduction_table;
|
||||
Value_t *goto_map;
|
||||
Value_t *from_state;
|
||||
Value_t *to_state;
|
||||
|
||||
static Value_t infinity;
|
||||
static int maxrhs;
|
||||
static int ngotos;
|
||||
static unsigned *F;
|
||||
static Value_t **includes;
|
||||
static shorts **lookback;
|
||||
static Value_t **R;
|
||||
static Value_t *INDEX;
|
||||
static Value_t *VERTICES;
|
||||
static Value_t top;
|
||||
|
||||
void
|
||||
lalr(void)
|
||||
{
|
||||
tokensetsize = WORDSIZE(ntokens);
|
||||
|
||||
set_state_table();
|
||||
set_accessing_symbol();
|
||||
set_shift_table();
|
||||
set_reduction_table();
|
||||
set_maxrhs();
|
||||
initialize_LA();
|
||||
set_goto_map();
|
||||
initialize_F();
|
||||
build_relations();
|
||||
compute_FOLLOWS();
|
||||
compute_lookaheads();
|
||||
}
|
||||
|
||||
static void
|
||||
set_state_table(void)
|
||||
{
|
||||
core *sp;
|
||||
|
||||
state_table = NEW2(nstates, core *);
|
||||
for (sp = first_state; sp; sp = sp->next)
|
||||
state_table[sp->number] = sp;
|
||||
}
|
||||
|
||||
static void
|
||||
set_accessing_symbol(void)
|
||||
{
|
||||
core *sp;
|
||||
|
||||
accessing_symbol = NEW2(nstates, Value_t);
|
||||
for (sp = first_state; sp; sp = sp->next)
|
||||
accessing_symbol[sp->number] = sp->accessing_symbol;
|
||||
}
|
||||
|
||||
static void
|
||||
set_shift_table(void)
|
||||
{
|
||||
shifts *sp;
|
||||
|
||||
shift_table = NEW2(nstates, shifts *);
|
||||
for (sp = first_shift; sp; sp = sp->next)
|
||||
shift_table[sp->number] = sp;
|
||||
}
|
||||
|
||||
static void
|
||||
set_reduction_table(void)
|
||||
{
|
||||
reductions *rp;
|
||||
|
||||
reduction_table = NEW2(nstates, reductions *);
|
||||
for (rp = first_reduction; rp; rp = rp->next)
|
||||
reduction_table[rp->number] = rp;
|
||||
}
|
||||
|
||||
static void
|
||||
set_maxrhs(void)
|
||||
{
|
||||
Value_t *itemp;
|
||||
Value_t *item_end;
|
||||
int length;
|
||||
int max;
|
||||
|
||||
length = 0;
|
||||
max = 0;
|
||||
item_end = ritem + nitems;
|
||||
for (itemp = ritem; itemp < item_end; itemp++)
|
||||
{
|
||||
if (*itemp >= 0)
|
||||
{
|
||||
length++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (length > max)
|
||||
max = length;
|
||||
length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
maxrhs = max;
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_LA(void)
|
||||
{
|
||||
int i, j, k;
|
||||
reductions *rp;
|
||||
|
||||
lookaheads = NEW2(nstates + 1, Value_t);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
lookaheads[i] = (Value_t) k;
|
||||
rp = reduction_table[i];
|
||||
if (rp)
|
||||
k += rp->nreds;
|
||||
}
|
||||
lookaheads[nstates] = (Value_t) k;
|
||||
|
||||
LA = NEW2(k * tokensetsize, unsigned);
|
||||
LAruleno = NEW2(k, Value_t);
|
||||
lookback = NEW2(k, shorts *);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
rp = reduction_table[i];
|
||||
if (rp)
|
||||
{
|
||||
for (j = 0; j < rp->nreds; j++)
|
||||
{
|
||||
LAruleno[k] = rp->rules[j];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_goto_map(void)
|
||||
{
|
||||
shifts *sp;
|
||||
int i;
|
||||
int symbol;
|
||||
int k;
|
||||
Value_t *temp_map;
|
||||
Value_t state2;
|
||||
Value_t state1;
|
||||
|
||||
goto_map = NEW2(nvars + 1, Value_t) - ntokens;
|
||||
temp_map = NEW2(nvars + 1, Value_t) - ntokens;
|
||||
|
||||
ngotos = 0;
|
||||
for (sp = first_shift; sp; sp = sp->next)
|
||||
{
|
||||
for (i = sp->nshifts - 1; i >= 0; i--)
|
||||
{
|
||||
symbol = accessing_symbol[sp->shift[i]];
|
||||
|
||||
if (ISTOKEN(symbol))
|
||||
break;
|
||||
|
||||
if (ngotos == MAXSHORT)
|
||||
fatal("too many gotos");
|
||||
|
||||
ngotos++;
|
||||
goto_map[symbol]++;
|
||||
}
|
||||
}
|
||||
|
||||
k = 0;
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
{
|
||||
temp_map[i] = (Value_t) k;
|
||||
k += goto_map[i];
|
||||
}
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
goto_map[i] = temp_map[i];
|
||||
|
||||
goto_map[nsyms] = (Value_t) ngotos;
|
||||
temp_map[nsyms] = (Value_t) ngotos;
|
||||
|
||||
from_state = NEW2(ngotos, Value_t);
|
||||
to_state = NEW2(ngotos, Value_t);
|
||||
|
||||
for (sp = first_shift; sp; sp = sp->next)
|
||||
{
|
||||
state1 = sp->number;
|
||||
for (i = sp->nshifts - 1; i >= 0; i--)
|
||||
{
|
||||
state2 = sp->shift[i];
|
||||
symbol = accessing_symbol[state2];
|
||||
|
||||
if (ISTOKEN(symbol))
|
||||
break;
|
||||
|
||||
k = temp_map[symbol]++;
|
||||
from_state[k] = state1;
|
||||
to_state[k] = state2;
|
||||
}
|
||||
}
|
||||
|
||||
FREE(temp_map + ntokens);
|
||||
}
|
||||
|
||||
/* Map_goto maps a state/symbol pair into its numeric representation. */
|
||||
|
||||
static Value_t
|
||||
map_goto(int state, int symbol)
|
||||
{
|
||||
int high;
|
||||
int low;
|
||||
int middle;
|
||||
int s;
|
||||
|
||||
low = goto_map[symbol];
|
||||
high = goto_map[symbol + 1];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
assert(low <= high);
|
||||
middle = (low + high) >> 1;
|
||||
s = from_state[middle];
|
||||
if (s == state)
|
||||
return (Value_t) (middle);
|
||||
else if (s < state)
|
||||
low = middle + 1;
|
||||
else
|
||||
high = middle - 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_F(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
shifts *sp;
|
||||
Value_t *edge;
|
||||
unsigned *rowp;
|
||||
Value_t *rp;
|
||||
Value_t **reads;
|
||||
int nedges;
|
||||
int stateno;
|
||||
int symbol;
|
||||
int nwords;
|
||||
|
||||
nwords = ngotos * tokensetsize;
|
||||
F = NEW2(nwords, unsigned);
|
||||
|
||||
reads = NEW2(ngotos, Value_t *);
|
||||
edge = NEW2(ngotos + 1, Value_t);
|
||||
nedges = 0;
|
||||
|
||||
rowp = F;
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
stateno = to_state[i];
|
||||
sp = shift_table[stateno];
|
||||
|
||||
if (sp)
|
||||
{
|
||||
k = sp->nshifts;
|
||||
|
||||
for (j = 0; j < k; j++)
|
||||
{
|
||||
symbol = accessing_symbol[sp->shift[j]];
|
||||
if (ISVAR(symbol))
|
||||
break;
|
||||
SETBIT(rowp, symbol);
|
||||
}
|
||||
|
||||
for (; j < k; j++)
|
||||
{
|
||||
symbol = accessing_symbol[sp->shift[j]];
|
||||
if (nullable[symbol])
|
||||
edge[nedges++] = map_goto(stateno, symbol);
|
||||
}
|
||||
|
||||
if (nedges)
|
||||
{
|
||||
reads[i] = rp = NEW2(nedges + 1, Value_t);
|
||||
|
||||
for (j = 0; j < nedges; j++)
|
||||
rp[j] = edge[j];
|
||||
|
||||
rp[nedges] = -1;
|
||||
nedges = 0;
|
||||
}
|
||||
}
|
||||
|
||||
rowp += tokensetsize;
|
||||
}
|
||||
|
||||
SETBIT(F, 0);
|
||||
digraph(reads);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
if (reads[i])
|
||||
FREE(reads[i]);
|
||||
}
|
||||
|
||||
FREE(reads);
|
||||
FREE(edge);
|
||||
}
|
||||
|
||||
static void
|
||||
build_relations(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
Value_t *rulep;
|
||||
Value_t *rp;
|
||||
shifts *sp;
|
||||
int length;
|
||||
int nedges;
|
||||
int done_flag;
|
||||
Value_t state1;
|
||||
Value_t stateno;
|
||||
int symbol1;
|
||||
int symbol2;
|
||||
Value_t *shortp;
|
||||
Value_t *edge;
|
||||
Value_t *states;
|
||||
Value_t **new_includes;
|
||||
|
||||
includes = NEW2(ngotos, Value_t *);
|
||||
edge = NEW2(ngotos + 1, Value_t);
|
||||
states = NEW2(maxrhs + 1, Value_t);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
nedges = 0;
|
||||
state1 = from_state[i];
|
||||
symbol1 = accessing_symbol[to_state[i]];
|
||||
|
||||
for (rulep = derives[symbol1]; *rulep >= 0; rulep++)
|
||||
{
|
||||
length = 1;
|
||||
states[0] = state1;
|
||||
stateno = state1;
|
||||
|
||||
for (rp = ritem + rrhs[*rulep]; *rp >= 0; rp++)
|
||||
{
|
||||
symbol2 = *rp;
|
||||
sp = shift_table[stateno];
|
||||
k = sp->nshifts;
|
||||
|
||||
for (j = 0; j < k; j++)
|
||||
{
|
||||
stateno = sp->shift[j];
|
||||
if (accessing_symbol[stateno] == symbol2)
|
||||
break;
|
||||
}
|
||||
|
||||
states[length++] = stateno;
|
||||
}
|
||||
|
||||
add_lookback_edge(stateno, *rulep, i);
|
||||
|
||||
length--;
|
||||
done_flag = 0;
|
||||
while (!done_flag)
|
||||
{
|
||||
done_flag = 1;
|
||||
rp--;
|
||||
if (ISVAR(*rp))
|
||||
{
|
||||
stateno = states[--length];
|
||||
edge[nedges++] = map_goto(stateno, *rp);
|
||||
if (nullable[*rp] && length > 0)
|
||||
done_flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nedges)
|
||||
{
|
||||
includes[i] = shortp = NEW2(nedges + 1, Value_t);
|
||||
for (j = 0; j < nedges; j++)
|
||||
shortp[j] = edge[j];
|
||||
shortp[nedges] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
new_includes = transpose(includes, ngotos);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
if (includes[i])
|
||||
FREE(includes[i]);
|
||||
|
||||
FREE(includes);
|
||||
|
||||
includes = new_includes;
|
||||
|
||||
FREE(edge);
|
||||
FREE(states);
|
||||
}
|
||||
|
||||
static void
|
||||
add_lookback_edge(int stateno, int ruleno, int gotono)
|
||||
{
|
||||
int i, k;
|
||||
int found;
|
||||
shorts *sp;
|
||||
|
||||
i = lookaheads[stateno];
|
||||
k = lookaheads[stateno + 1];
|
||||
found = 0;
|
||||
while (!found && i < k)
|
||||
{
|
||||
if (LAruleno[i] == ruleno)
|
||||
found = 1;
|
||||
else
|
||||
++i;
|
||||
}
|
||||
assert(found);
|
||||
|
||||
sp = NEW(shorts);
|
||||
sp->next = lookback[i];
|
||||
sp->value = (Value_t) gotono;
|
||||
lookback[i] = sp;
|
||||
}
|
||||
|
||||
static Value_t **
|
||||
transpose(Value_t ** R2, int n)
|
||||
{
|
||||
Value_t **new_R;
|
||||
Value_t **temp_R;
|
||||
Value_t *nedges;
|
||||
Value_t *sp;
|
||||
int i;
|
||||
int k;
|
||||
|
||||
nedges = NEW2(n, Value_t);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
sp = R2[i];
|
||||
if (sp)
|
||||
{
|
||||
while (*sp >= 0)
|
||||
nedges[*sp++]++;
|
||||
}
|
||||
}
|
||||
|
||||
new_R = NEW2(n, Value_t *);
|
||||
temp_R = NEW2(n, Value_t *);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
k = nedges[i];
|
||||
if (k > 0)
|
||||
{
|
||||
sp = NEW2(k + 1, Value_t);
|
||||
new_R[i] = sp;
|
||||
temp_R[i] = sp;
|
||||
sp[k] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
FREE(nedges);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
sp = R2[i];
|
||||
if (sp)
|
||||
{
|
||||
while (*sp >= 0)
|
||||
*temp_R[*sp++]++ = (Value_t) i;
|
||||
}
|
||||
}
|
||||
|
||||
FREE(temp_R);
|
||||
|
||||
return (new_R);
|
||||
}
|
||||
|
||||
static void
|
||||
compute_FOLLOWS(void)
|
||||
{
|
||||
digraph(includes);
|
||||
}
|
||||
|
||||
static void
|
||||
compute_lookaheads(void)
|
||||
{
|
||||
int i, n;
|
||||
unsigned *fp1, *fp2, *fp3;
|
||||
shorts *sp, *next;
|
||||
unsigned *rowp;
|
||||
|
||||
rowp = LA;
|
||||
n = lookaheads[nstates];
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
fp3 = rowp + tokensetsize;
|
||||
for (sp = lookback[i]; sp; sp = sp->next)
|
||||
{
|
||||
fp1 = rowp;
|
||||
fp2 = F + tokensetsize * sp->value;
|
||||
while (fp1 < fp3)
|
||||
*fp1++ |= *fp2++;
|
||||
}
|
||||
rowp = fp3;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (sp = lookback[i]; sp; sp = next)
|
||||
{
|
||||
next = sp->next;
|
||||
FREE(sp);
|
||||
}
|
||||
|
||||
FREE(lookback);
|
||||
FREE(F);
|
||||
}
|
||||
|
||||
static void
|
||||
digraph(Value_t ** relation)
|
||||
{
|
||||
int i;
|
||||
|
||||
infinity = (Value_t) (ngotos + 2);
|
||||
INDEX = NEW2(ngotos + 1, Value_t);
|
||||
VERTICES = NEW2(ngotos + 1, Value_t);
|
||||
top = 0;
|
||||
|
||||
R = relation;
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
INDEX[i] = 0;
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
if (INDEX[i] == 0 && R[i])
|
||||
traverse(i);
|
||||
}
|
||||
|
||||
FREE(INDEX);
|
||||
FREE(VERTICES);
|
||||
}
|
||||
|
||||
static void
|
||||
traverse(int i)
|
||||
{
|
||||
unsigned *fp1;
|
||||
unsigned *fp2;
|
||||
unsigned *fp3;
|
||||
int j;
|
||||
Value_t *rp;
|
||||
|
||||
Value_t height;
|
||||
unsigned *base;
|
||||
|
||||
VERTICES[++top] = (Value_t) i;
|
||||
INDEX[i] = height = top;
|
||||
|
||||
base = F + i * tokensetsize;
|
||||
fp3 = base + tokensetsize;
|
||||
|
||||
rp = R[i];
|
||||
if (rp)
|
||||
{
|
||||
while ((j = *rp++) >= 0)
|
||||
{
|
||||
if (INDEX[j] == 0)
|
||||
traverse(j);
|
||||
|
||||
if (INDEX[i] > INDEX[j])
|
||||
INDEX[i] = INDEX[j];
|
||||
|
||||
fp1 = base;
|
||||
fp2 = F + j * tokensetsize;
|
||||
|
||||
while (fp1 < fp3)
|
||||
*fp1++ |= *fp2++;
|
||||
}
|
||||
}
|
||||
|
||||
if (INDEX[i] == height)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
j = VERTICES[top--];
|
||||
INDEX[j] = infinity;
|
||||
|
||||
if (i == j)
|
||||
break;
|
||||
|
||||
fp1 = base;
|
||||
fp2 = F + j * tokensetsize;
|
||||
|
||||
while (fp1 < fp3)
|
||||
*fp2++ = *fp1++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NO_LEAKS
|
||||
void
|
||||
lalr_leaks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (includes != 0)
|
||||
{
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
free(includes[i]);
|
||||
}
|
||||
DO_FREE(includes);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
603
external/bsd/byacc/dist/lr0.c
vendored
Normal file
603
external/bsd/byacc/dist/lr0.c
vendored
Normal file
@@ -0,0 +1,603 @@
|
||||
/* $NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: lr0.c,v 1.12 2010/06/09 08:53:17 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
static core *new_state(int symbol);
|
||||
static Value_t get_state(int symbol);
|
||||
static void allocate_itemsets(void);
|
||||
static void allocate_storage(void);
|
||||
static void append_states(void);
|
||||
static void free_storage(void);
|
||||
static void generate_states(void);
|
||||
static void initialize_states(void);
|
||||
static void new_itemsets(void);
|
||||
static void save_reductions(void);
|
||||
static void save_shifts(void);
|
||||
static void set_derives(void);
|
||||
static void set_nullable(void);
|
||||
|
||||
int nstates;
|
||||
core *first_state;
|
||||
shifts *first_shift;
|
||||
reductions *first_reduction;
|
||||
|
||||
static core **state_set;
|
||||
static core *this_state;
|
||||
static core *last_state;
|
||||
static shifts *last_shift;
|
||||
static reductions *last_reduction;
|
||||
|
||||
static int nshifts;
|
||||
static short *shift_symbol;
|
||||
|
||||
static Value_t *redset;
|
||||
static Value_t *shiftset;
|
||||
|
||||
static Value_t **kernel_base;
|
||||
static Value_t **kernel_end;
|
||||
static Value_t *kernel_items;
|
||||
|
||||
static void
|
||||
allocate_itemsets(void)
|
||||
{
|
||||
short *itemp;
|
||||
short *item_end;
|
||||
int symbol;
|
||||
int i;
|
||||
int count;
|
||||
int max;
|
||||
short *symbol_count;
|
||||
|
||||
count = 0;
|
||||
symbol_count = NEW2(nsyms, short);
|
||||
|
||||
item_end = ritem + nitems;
|
||||
for (itemp = ritem; itemp < item_end; itemp++)
|
||||
{
|
||||
symbol = *itemp;
|
||||
if (symbol >= 0)
|
||||
{
|
||||
count++;
|
||||
symbol_count[symbol]++;
|
||||
}
|
||||
}
|
||||
|
||||
kernel_base = NEW2(nsyms, short *);
|
||||
kernel_items = NEW2(count, short);
|
||||
|
||||
count = 0;
|
||||
max = 0;
|
||||
for (i = 0; i < nsyms; i++)
|
||||
{
|
||||
kernel_base[i] = kernel_items + count;
|
||||
count += symbol_count[i];
|
||||
if (max < symbol_count[i])
|
||||
max = symbol_count[i];
|
||||
}
|
||||
|
||||
shift_symbol = symbol_count;
|
||||
kernel_end = NEW2(nsyms, short *);
|
||||
}
|
||||
|
||||
static void
|
||||
allocate_storage(void)
|
||||
{
|
||||
allocate_itemsets();
|
||||
shiftset = NEW2(nsyms, short);
|
||||
redset = NEW2(nrules + 1, short);
|
||||
state_set = NEW2(nitems, core *);
|
||||
}
|
||||
|
||||
static void
|
||||
append_states(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
Value_t symbol;
|
||||
|
||||
#ifdef TRACE
|
||||
fprintf(stderr, "Entering append_states()\n");
|
||||
#endif
|
||||
for (i = 1; i < nshifts; i++)
|
||||
{
|
||||
symbol = shift_symbol[i];
|
||||
j = i;
|
||||
while (j > 0 && shift_symbol[j - 1] > symbol)
|
||||
{
|
||||
shift_symbol[j] = shift_symbol[j - 1];
|
||||
j--;
|
||||
}
|
||||
shift_symbol[j] = symbol;
|
||||
}
|
||||
|
||||
for (i = 0; i < nshifts; i++)
|
||||
{
|
||||
symbol = shift_symbol[i];
|
||||
shiftset[i] = get_state(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
free_storage(void)
|
||||
{
|
||||
FREE(shift_symbol);
|
||||
FREE(redset);
|
||||
FREE(shiftset);
|
||||
FREE(kernel_base);
|
||||
FREE(kernel_end);
|
||||
FREE(kernel_items);
|
||||
FREE(state_set);
|
||||
}
|
||||
|
||||
static void
|
||||
generate_states(void)
|
||||
{
|
||||
allocate_storage();
|
||||
itemset = NEW2(nitems, short);
|
||||
ruleset = NEW2(WORDSIZE(nrules), unsigned);
|
||||
set_first_derives();
|
||||
initialize_states();
|
||||
|
||||
while (this_state)
|
||||
{
|
||||
closure(this_state->items, this_state->nitems);
|
||||
save_reductions();
|
||||
new_itemsets();
|
||||
append_states();
|
||||
|
||||
if (nshifts > 0)
|
||||
save_shifts();
|
||||
|
||||
this_state = this_state->next;
|
||||
}
|
||||
|
||||
free_storage();
|
||||
}
|
||||
|
||||
static Value_t
|
||||
get_state(int symbol)
|
||||
{
|
||||
int key;
|
||||
short *isp1;
|
||||
short *isp2;
|
||||
short *iend;
|
||||
core *sp;
|
||||
int found;
|
||||
int n;
|
||||
|
||||
#ifdef TRACE
|
||||
fprintf(stderr, "Entering get_state(%d)\n", symbol);
|
||||
#endif
|
||||
|
||||
isp1 = kernel_base[symbol];
|
||||
iend = kernel_end[symbol];
|
||||
n = (int)(iend - isp1);
|
||||
|
||||
key = *isp1;
|
||||
assert(0 <= key && key < nitems);
|
||||
sp = state_set[key];
|
||||
if (sp)
|
||||
{
|
||||
found = 0;
|
||||
while (!found)
|
||||
{
|
||||
if (sp->nitems == n)
|
||||
{
|
||||
found = 1;
|
||||
isp1 = kernel_base[symbol];
|
||||
isp2 = sp->items;
|
||||
|
||||
while (found && isp1 < iend)
|
||||
{
|
||||
if (*isp1++ != *isp2++)
|
||||
found = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
if (sp->link)
|
||||
{
|
||||
sp = sp->link;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp = sp->link = new_state(symbol);
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state_set[key] = sp = new_state(symbol);
|
||||
}
|
||||
|
||||
return (sp->number);
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_states(void)
|
||||
{
|
||||
unsigned i;
|
||||
short *start_derives;
|
||||
core *p;
|
||||
|
||||
start_derives = derives[start_symbol];
|
||||
for (i = 0; start_derives[i] >= 0; ++i)
|
||||
continue;
|
||||
|
||||
p = (core *)MALLOC(sizeof(core) + i * sizeof(short));
|
||||
NO_SPACE(p);
|
||||
|
||||
p->next = 0;
|
||||
p->link = 0;
|
||||
p->number = 0;
|
||||
p->accessing_symbol = 0;
|
||||
p->nitems = (Value_t) i;
|
||||
|
||||
for (i = 0; start_derives[i] >= 0; ++i)
|
||||
p->items[i] = rrhs[start_derives[i]];
|
||||
|
||||
first_state = last_state = this_state = p;
|
||||
nstates = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
new_itemsets(void)
|
||||
{
|
||||
Value_t i;
|
||||
int shiftcount;
|
||||
short *isp;
|
||||
short *ksp;
|
||||
Value_t symbol;
|
||||
|
||||
for (i = 0; i < nsyms; i++)
|
||||
kernel_end[i] = 0;
|
||||
|
||||
shiftcount = 0;
|
||||
isp = itemset;
|
||||
while (isp < itemsetend)
|
||||
{
|
||||
i = *isp++;
|
||||
symbol = ritem[i];
|
||||
if (symbol > 0)
|
||||
{
|
||||
ksp = kernel_end[symbol];
|
||||
if (!ksp)
|
||||
{
|
||||
shift_symbol[shiftcount++] = symbol;
|
||||
ksp = kernel_base[symbol];
|
||||
}
|
||||
|
||||
*ksp++ = (Value_t) (i + 1);
|
||||
kernel_end[symbol] = ksp;
|
||||
}
|
||||
}
|
||||
|
||||
nshifts = shiftcount;
|
||||
}
|
||||
|
||||
static core *
|
||||
new_state(int symbol)
|
||||
{
|
||||
unsigned n;
|
||||
core *p;
|
||||
short *isp1;
|
||||
short *isp2;
|
||||
short *iend;
|
||||
|
||||
#ifdef TRACE
|
||||
fprintf(stderr, "Entering new_state(%d)\n", symbol);
|
||||
#endif
|
||||
|
||||
if (nstates >= MAXSHORT)
|
||||
fatal("too many states");
|
||||
|
||||
isp1 = kernel_base[symbol];
|
||||
iend = kernel_end[symbol];
|
||||
n = (unsigned)(iend - isp1);
|
||||
|
||||
p = (core *)allocate((sizeof(core) + (n - 1) * sizeof(short)));
|
||||
p->accessing_symbol = (Value_t) symbol;
|
||||
p->number = (Value_t) nstates;
|
||||
p->nitems = (Value_t) n;
|
||||
|
||||
isp2 = p->items;
|
||||
while (isp1 < iend)
|
||||
*isp2++ = *isp1++;
|
||||
|
||||
last_state->next = p;
|
||||
last_state = p;
|
||||
|
||||
nstates++;
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
/* show_cores is used for debugging */
|
||||
|
||||
void
|
||||
show_cores(void)
|
||||
{
|
||||
core *p;
|
||||
int i, j, k, n;
|
||||
int itemno;
|
||||
|
||||
k = 0;
|
||||
for (p = first_state; p; ++k, p = p->next)
|
||||
{
|
||||
if (k)
|
||||
printf("\n");
|
||||
printf("state %d, number = %d, accessing symbol = %s\n",
|
||||
k, p->number, symbol_name[p->accessing_symbol]);
|
||||
n = p->nitems;
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
itemno = p->items[i];
|
||||
printf("%4d ", itemno);
|
||||
j = itemno;
|
||||
while (ritem[j] >= 0)
|
||||
++j;
|
||||
printf("%s :", symbol_name[rlhs[-ritem[j]]]);
|
||||
j = rrhs[-ritem[j]];
|
||||
while (j < itemno)
|
||||
printf(" %s", symbol_name[ritem[j++]]);
|
||||
printf(" .");
|
||||
while (ritem[j] >= 0)
|
||||
printf(" %s", symbol_name[ritem[j++]]);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* show_ritems is used for debugging */
|
||||
|
||||
void
|
||||
show_ritems(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nitems; ++i)
|
||||
printf("ritem[%d] = %d\n", i, ritem[i]);
|
||||
}
|
||||
|
||||
/* show_rrhs is used for debugging */
|
||||
void
|
||||
show_rrhs(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nrules; ++i)
|
||||
printf("rrhs[%d] = %d\n", i, rrhs[i]);
|
||||
}
|
||||
|
||||
/* show_shifts is used for debugging */
|
||||
|
||||
void
|
||||
show_shifts(void)
|
||||
{
|
||||
shifts *p;
|
||||
int i, j, k;
|
||||
|
||||
k = 0;
|
||||
for (p = first_shift; p; ++k, p = p->next)
|
||||
{
|
||||
if (k)
|
||||
printf("\n");
|
||||
printf("shift %d, number = %d, nshifts = %d\n", k, p->number,
|
||||
p->nshifts);
|
||||
j = p->nshifts;
|
||||
for (i = 0; i < j; ++i)
|
||||
printf("\t%d\n", p->shift[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_shifts(void)
|
||||
{
|
||||
shifts *p;
|
||||
short *sp1;
|
||||
short *sp2;
|
||||
short *send;
|
||||
|
||||
p = (shifts *)allocate((sizeof(shifts) +
|
||||
(unsigned)(nshifts - 1) * sizeof(short)));
|
||||
|
||||
p->number = this_state->number;
|
||||
p->nshifts = (Value_t) nshifts;
|
||||
|
||||
sp1 = shiftset;
|
||||
sp2 = p->shift;
|
||||
send = shiftset + nshifts;
|
||||
|
||||
while (sp1 < send)
|
||||
*sp2++ = *sp1++;
|
||||
|
||||
if (last_shift)
|
||||
{
|
||||
last_shift->next = p;
|
||||
last_shift = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
first_shift = p;
|
||||
last_shift = p;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_reductions(void)
|
||||
{
|
||||
short *isp;
|
||||
short *rp1;
|
||||
short *rp2;
|
||||
int item;
|
||||
Value_t count;
|
||||
reductions *p;
|
||||
short *rend;
|
||||
|
||||
count = 0;
|
||||
for (isp = itemset; isp < itemsetend; isp++)
|
||||
{
|
||||
item = ritem[*isp];
|
||||
if (item < 0)
|
||||
{
|
||||
redset[count++] = (Value_t) - item;
|
||||
}
|
||||
}
|
||||
|
||||
if (count)
|
||||
{
|
||||
p = (reductions *)allocate((sizeof(reductions) +
|
||||
(unsigned)(count - 1) *
|
||||
sizeof(short)));
|
||||
|
||||
p->number = this_state->number;
|
||||
p->nreds = count;
|
||||
|
||||
rp1 = redset;
|
||||
rp2 = p->rules;
|
||||
rend = rp1 + count;
|
||||
|
||||
while (rp1 < rend)
|
||||
*rp2++ = *rp1++;
|
||||
|
||||
if (last_reduction)
|
||||
{
|
||||
last_reduction->next = p;
|
||||
last_reduction = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
first_reduction = p;
|
||||
last_reduction = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_derives(void)
|
||||
{
|
||||
Value_t i, k;
|
||||
int lhs;
|
||||
short *rules;
|
||||
|
||||
derives = NEW2(nsyms, short *);
|
||||
rules = NEW2(nvars + nrules, short);
|
||||
|
||||
k = 0;
|
||||
for (lhs = start_symbol; lhs < nsyms; lhs++)
|
||||
{
|
||||
derives[lhs] = rules + k;
|
||||
for (i = 0; i < nrules; i++)
|
||||
{
|
||||
if (rlhs[i] == lhs)
|
||||
{
|
||||
rules[k] = i;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
rules[k] = -1;
|
||||
k++;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
print_derives();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
print_derives(void)
|
||||
{
|
||||
int i;
|
||||
short *sp;
|
||||
|
||||
printf("\nDERIVES\n\n");
|
||||
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
printf("%s derives ", symbol_name[i]);
|
||||
for (sp = derives[i]; *sp >= 0; sp++)
|
||||
{
|
||||
printf(" %d", *sp);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
set_nullable(void)
|
||||
{
|
||||
int i, j;
|
||||
int empty;
|
||||
int done_flag;
|
||||
|
||||
nullable = MALLOC(nsyms);
|
||||
NO_SPACE(nullable);
|
||||
|
||||
for (i = 0; i < nsyms; ++i)
|
||||
nullable[i] = 0;
|
||||
|
||||
done_flag = 0;
|
||||
while (!done_flag)
|
||||
{
|
||||
done_flag = 1;
|
||||
for (i = 1; i < nitems; i++)
|
||||
{
|
||||
empty = 1;
|
||||
while ((j = ritem[i]) >= 0)
|
||||
{
|
||||
if (!nullable[j])
|
||||
empty = 0;
|
||||
++i;
|
||||
}
|
||||
if (empty)
|
||||
{
|
||||
j = rlhs[-j];
|
||||
if (!nullable[j])
|
||||
{
|
||||
nullable[j] = 1;
|
||||
done_flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
for (i = 0; i < nsyms; i++)
|
||||
{
|
||||
if (nullable[i])
|
||||
printf("%s is nullable\n", symbol_name[i]);
|
||||
else
|
||||
printf("%s is not nullable\n", symbol_name[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
lr0(void)
|
||||
{
|
||||
set_derives();
|
||||
set_nullable();
|
||||
generate_states();
|
||||
}
|
||||
|
||||
#ifdef NO_LEAKS
|
||||
void
|
||||
lr0_leaks(void)
|
||||
{
|
||||
DO_FREE(derives[start_symbol]);
|
||||
DO_FREE(derives);
|
||||
DO_FREE(nullable);
|
||||
}
|
||||
#endif
|
||||
694
external/bsd/byacc/dist/main.c
vendored
Normal file
694
external/bsd/byacc/dist/main.c
vendored
Normal file
@@ -0,0 +1,694 @@
|
||||
/* $NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: main.c,v 1.36 2011/09/06 22:44:45 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h> /* for _exit() */
|
||||
|
||||
|
||||
#if defined(HAVE_ATEXIT)
|
||||
# ifdef HAVE_MKSTEMP
|
||||
# define USE_MKSTEMP 1
|
||||
# elif defined(HAVE_FCNTL_H)
|
||||
# define USE_MKSTEMP 1
|
||||
# include <fcntl.h> /* for open(), O_EXCL, etc. */
|
||||
# else
|
||||
# define USE_MKSTEMP 0
|
||||
# endif
|
||||
#else
|
||||
# define USE_MKSTEMP 0
|
||||
#endif
|
||||
|
||||
#if USE_MKSTEMP
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
typedef struct _my_tmpfiles
|
||||
{
|
||||
struct _my_tmpfiles *next;
|
||||
char *name;
|
||||
}
|
||||
MY_TMPFILES;
|
||||
|
||||
static MY_TMPFILES *my_tmpfiles;
|
||||
#endif /* USE_MKSTEMP */
|
||||
|
||||
char dflag;
|
||||
char gflag;
|
||||
char iflag;
|
||||
char lflag;
|
||||
static char oflag;
|
||||
char rflag;
|
||||
char tflag;
|
||||
char vflag;
|
||||
|
||||
const char *symbol_prefix;
|
||||
const char *myname = "yacc";
|
||||
|
||||
int lineno;
|
||||
int outline;
|
||||
|
||||
static char empty_string[] = "";
|
||||
static char default_file_prefix[] = "y";
|
||||
static int explicit_file_name;
|
||||
|
||||
static char *file_prefix = default_file_prefix;
|
||||
|
||||
char *code_file_name;
|
||||
char *input_file_name = empty_string;
|
||||
char *defines_file_name;
|
||||
char *externs_file_name;
|
||||
|
||||
static char *graph_file_name;
|
||||
static char *output_file_name;
|
||||
static char *verbose_file_name;
|
||||
|
||||
FILE *action_file; /* a temp file, used to save actions associated */
|
||||
/* with rules until the parser is written */
|
||||
FILE *code_file; /* y.code.c (used when the -r option is specified) */
|
||||
FILE *defines_file; /* y.tab.h */
|
||||
FILE *externs_file; /* y.tab.i */
|
||||
FILE *input_file; /* the input file */
|
||||
FILE *output_file; /* y.tab.c */
|
||||
FILE *text_file; /* a temp file, used to save text until all */
|
||||
/* symbols have been defined */
|
||||
FILE *union_file; /* a temp file, used to save the union */
|
||||
/* definition until all symbol have been */
|
||||
/* defined */
|
||||
FILE *verbose_file; /* y.output */
|
||||
FILE *graph_file; /* y.dot */
|
||||
|
||||
int nitems;
|
||||
int nrules;
|
||||
int nsyms;
|
||||
int ntokens;
|
||||
int nvars;
|
||||
|
||||
Value_t start_symbol;
|
||||
char **symbol_name;
|
||||
char **symbol_pname;
|
||||
Value_t *symbol_value;
|
||||
short *symbol_prec;
|
||||
char *symbol_assoc;
|
||||
|
||||
int pure_parser;
|
||||
int exit_code;
|
||||
|
||||
Value_t *ritem;
|
||||
Value_t *rlhs;
|
||||
Value_t *rrhs;
|
||||
Value_t *rprec;
|
||||
Assoc_t *rassoc;
|
||||
Value_t **derives;
|
||||
char *nullable;
|
||||
|
||||
/*
|
||||
* Since fclose() is called via the signal handler, it might die. Don't loop
|
||||
* if there is a problem closing a file.
|
||||
*/
|
||||
#define DO_CLOSE(fp) \
|
||||
if (fp != 0) { \
|
||||
FILE *use = fp; \
|
||||
fp = 0; \
|
||||
fclose(use); \
|
||||
}
|
||||
|
||||
static int got_intr = 0;
|
||||
|
||||
void
|
||||
done(int k)
|
||||
{
|
||||
DO_CLOSE(input_file);
|
||||
DO_CLOSE(output_file);
|
||||
|
||||
DO_CLOSE(action_file);
|
||||
DO_CLOSE(defines_file);
|
||||
DO_CLOSE(graph_file);
|
||||
DO_CLOSE(text_file);
|
||||
DO_CLOSE(union_file);
|
||||
DO_CLOSE(verbose_file);
|
||||
|
||||
if (got_intr)
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
#ifdef NO_LEAKS
|
||||
if (rflag)
|
||||
DO_FREE(code_file_name);
|
||||
|
||||
if (dflag)
|
||||
DO_FREE(defines_file_name);
|
||||
|
||||
if (iflag)
|
||||
DO_FREE(externs_file_name);
|
||||
|
||||
if (oflag)
|
||||
DO_FREE(output_file_name);
|
||||
|
||||
if (vflag)
|
||||
DO_FREE(verbose_file_name);
|
||||
|
||||
if (gflag)
|
||||
DO_FREE(graph_file_name);
|
||||
|
||||
lr0_leaks();
|
||||
lalr_leaks();
|
||||
mkpar_leaks();
|
||||
output_leaks();
|
||||
reader_leaks();
|
||||
#endif
|
||||
|
||||
if (rflag)
|
||||
DO_CLOSE(code_file);
|
||||
|
||||
exit(k);
|
||||
}
|
||||
|
||||
static void
|
||||
onintr(int sig GCC_UNUSED)
|
||||
{
|
||||
got_intr = 1;
|
||||
done(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void
|
||||
set_signals(void)
|
||||
{
|
||||
#ifdef SIGINT
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGINT, onintr);
|
||||
#endif
|
||||
#ifdef SIGTERM
|
||||
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGTERM, onintr);
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGHUP, onintr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
static const char *msg[] =
|
||||
{
|
||||
""
|
||||
,"Options:"
|
||||
," -b file_prefix set filename prefix (default \"y.\")"
|
||||
," -d write definitions (y.tab.h)"
|
||||
," -i write interface (y.tab.i)"
|
||||
," -g write a graphical description"
|
||||
," -l suppress #line directives"
|
||||
," -o output_file (default \"y.tab.c\")"
|
||||
," -p symbol_prefix set symbol prefix (default \"yy\")"
|
||||
," -P create a reentrant parser, e.g., \"%pure-parser\""
|
||||
," -r produce separate code and table files (y.code.c)"
|
||||
," -t add debugging support"
|
||||
," -v write description (y.output)"
|
||||
," -V show version information and exit"
|
||||
};
|
||||
unsigned n;
|
||||
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "Usage: %s [options] filename\n", myname);
|
||||
for (n = 0; n < sizeof(msg) / sizeof(msg[0]); ++n)
|
||||
fprintf(stderr, "%s\n", msg[n]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
setflag(int ch)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
gflag = 1;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
pure_parser = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
rflag = 1;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
tflag = 1;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
printf("%s - %s\n", myname, VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'y':
|
||||
/* noop for bison compatibility. byacc is already designed to be posix
|
||||
* yacc compatible. */
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
getargs(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
int ch;
|
||||
|
||||
if (argc > 0)
|
||||
myname = argv[0];
|
||||
|
||||
for (i = 1; i < argc; ++i)
|
||||
{
|
||||
s = argv[i];
|
||||
if (*s != '-')
|
||||
break;
|
||||
switch (ch = *++s)
|
||||
{
|
||||
case '\0':
|
||||
input_file = stdin;
|
||||
if (i + 1 < argc)
|
||||
usage();
|
||||
return;
|
||||
|
||||
case '-':
|
||||
++i;
|
||||
goto no_more_options;
|
||||
|
||||
case 'b':
|
||||
if (*++s)
|
||||
file_prefix = s;
|
||||
else if (++i < argc)
|
||||
file_prefix = argv[i];
|
||||
else
|
||||
usage();
|
||||
continue;
|
||||
|
||||
case 'o':
|
||||
if (*++s)
|
||||
output_file_name = s;
|
||||
else if (++i < argc)
|
||||
output_file_name = argv[i];
|
||||
else
|
||||
usage();
|
||||
explicit_file_name = 1;
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
if (*++s)
|
||||
symbol_prefix = s;
|
||||
else if (++i < argc)
|
||||
symbol_prefix = argv[i];
|
||||
else
|
||||
usage();
|
||||
continue;
|
||||
|
||||
default:
|
||||
setflag(ch);
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (ch = *++s)
|
||||
{
|
||||
case '\0':
|
||||
goto end_of_option;
|
||||
|
||||
default:
|
||||
setflag(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
end_of_option:;
|
||||
}
|
||||
|
||||
no_more_options:;
|
||||
if (i + 1 != argc)
|
||||
usage();
|
||||
input_file_name = argv[i];
|
||||
}
|
||||
|
||||
void *
|
||||
allocate(size_t n)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = NULL;
|
||||
if (n)
|
||||
{
|
||||
p = CALLOC(1, n);
|
||||
NO_SPACE(p);
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
#define CREATE_FILE_NAME(dest, suffix) \
|
||||
dest = MALLOC(len + strlen(suffix) + 1); \
|
||||
NO_SPACE(dest); \
|
||||
strcpy(dest, file_prefix); \
|
||||
strcpy(dest + len, suffix)
|
||||
|
||||
static void
|
||||
create_file_names(void)
|
||||
{
|
||||
size_t len;
|
||||
const char *defines_suffix;
|
||||
const char *externs_suffix;
|
||||
char *prefix;
|
||||
|
||||
prefix = NULL;
|
||||
defines_suffix = DEFINES_SUFFIX;
|
||||
externs_suffix = EXTERNS_SUFFIX;
|
||||
|
||||
/* compute the file_prefix from the user provided output_file_name */
|
||||
if (output_file_name != 0)
|
||||
{
|
||||
if (!(prefix = strstr(output_file_name, ".tab.c"))
|
||||
&& (prefix = strstr(output_file_name, ".c")))
|
||||
{
|
||||
defines_suffix = ".h";
|
||||
externs_suffix = ".i";
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix != NULL)
|
||||
{
|
||||
len = (size_t) (prefix - output_file_name);
|
||||
file_prefix = MALLOC(len + 1);
|
||||
NO_SPACE(file_prefix);
|
||||
strncpy(file_prefix, output_file_name, len)[len] = 0;
|
||||
}
|
||||
else
|
||||
len = strlen(file_prefix);
|
||||
|
||||
/* if "-o filename" was not given */
|
||||
if (output_file_name == 0)
|
||||
{
|
||||
oflag = 1;
|
||||
CREATE_FILE_NAME(output_file_name, OUTPUT_SUFFIX);
|
||||
}
|
||||
|
||||
if (rflag)
|
||||
{
|
||||
CREATE_FILE_NAME(code_file_name, CODE_SUFFIX);
|
||||
}
|
||||
else
|
||||
code_file_name = output_file_name;
|
||||
|
||||
if (dflag)
|
||||
{
|
||||
if (explicit_file_name)
|
||||
{
|
||||
char *suffix;
|
||||
defines_file_name = strdup(output_file_name);
|
||||
if (defines_file_name == 0)
|
||||
no_space();
|
||||
/* does the output_file_name have a known suffix */
|
||||
suffix = strrchr(output_file_name, '.');
|
||||
if (suffix != 0 &&
|
||||
(!strcmp(suffix, ".c") || /* good, old-fashioned C */
|
||||
!strcmp(suffix, ".C") || /* C++, or C on Windows */
|
||||
!strcmp(suffix, ".cc") || /* C++ */
|
||||
!strcmp(suffix, ".cxx") || /* C++ */
|
||||
!strcmp(suffix, ".cpp"))) /* C++ (Windows) */
|
||||
{
|
||||
strncpy(defines_file_name, output_file_name,
|
||||
suffix - output_file_name + 1);
|
||||
defines_file_name[suffix - output_file_name + 1] = 'h';
|
||||
defines_file_name[suffix - output_file_name + 2] = 0;
|
||||
} else {
|
||||
fprintf(stderr,"%s: suffix of output file name %s"
|
||||
" not recognized, no -d file generated.\n",
|
||||
myname, output_file_name);
|
||||
dflag = 0;
|
||||
free(defines_file_name);
|
||||
defines_file_name = 0;
|
||||
}
|
||||
} else {
|
||||
CREATE_FILE_NAME(defines_file_name, defines_suffix);
|
||||
}
|
||||
}
|
||||
|
||||
if (iflag)
|
||||
{
|
||||
CREATE_FILE_NAME(externs_file_name, externs_suffix);
|
||||
}
|
||||
|
||||
if (vflag)
|
||||
{
|
||||
CREATE_FILE_NAME(verbose_file_name, VERBOSE_SUFFIX);
|
||||
}
|
||||
|
||||
if (gflag)
|
||||
{
|
||||
CREATE_FILE_NAME(graph_file_name, GRAPH_SUFFIX);
|
||||
}
|
||||
|
||||
if (prefix != NULL)
|
||||
{
|
||||
FREE(file_prefix);
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_MKSTEMP
|
||||
static void
|
||||
close_tmpfiles(void)
|
||||
{
|
||||
while (my_tmpfiles != 0)
|
||||
{
|
||||
MY_TMPFILES *next = my_tmpfiles->next;
|
||||
|
||||
chmod(my_tmpfiles->name, 0644);
|
||||
unlink(my_tmpfiles->name);
|
||||
|
||||
free(my_tmpfiles->name);
|
||||
free(my_tmpfiles);
|
||||
|
||||
my_tmpfiles = next;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_MKSTEMP
|
||||
static int
|
||||
my_mkstemp(char *temp)
|
||||
{
|
||||
int fd;
|
||||
char *dname;
|
||||
char *fname;
|
||||
char *name;
|
||||
|
||||
/*
|
||||
* Split-up to use tempnam, rather than tmpnam; the latter (like
|
||||
* mkstemp) is unusable on Windows.
|
||||
*/
|
||||
if ((fname = strrchr(temp, '/')) != 0)
|
||||
{
|
||||
dname = strdup(temp);
|
||||
dname[++fname - temp] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
dname = 0;
|
||||
fname = temp;
|
||||
}
|
||||
if ((name = tempnam(dname, fname)) != 0)
|
||||
{
|
||||
fd = open(name, O_CREAT | O_EXCL | O_RDWR);
|
||||
strcpy(temp, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
if (dname != 0)
|
||||
free(dname);
|
||||
|
||||
return fd;
|
||||
}
|
||||
#define mkstemp(s) my_mkstemp(s)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* tmpfile() should be adequate, except that it may require special privileges
|
||||
* to use, e.g., MinGW and Windows 7 where it tries to use the root directory.
|
||||
*/
|
||||
static FILE *
|
||||
open_tmpfile(const char *label)
|
||||
{
|
||||
FILE *result;
|
||||
#if USE_MKSTEMP
|
||||
int fd;
|
||||
const char *tmpdir;
|
||||
char *name;
|
||||
const char *mark;
|
||||
|
||||
if ((tmpdir = getenv("TMPDIR")) == 0 || access(tmpdir, W_OK) != 0)
|
||||
{
|
||||
#ifdef P_tmpdir
|
||||
tmpdir = P_tmpdir;
|
||||
#else
|
||||
tmpdir = "/tmp";
|
||||
#endif
|
||||
if (access(tmpdir, W_OK) != 0)
|
||||
tmpdir = ".";
|
||||
}
|
||||
|
||||
name = malloc(strlen(tmpdir) + 10 + strlen(label));
|
||||
|
||||
result = 0;
|
||||
if (name != 0)
|
||||
{
|
||||
if ((mark = strrchr(label, '_')) == 0)
|
||||
mark = label + strlen(label);
|
||||
|
||||
sprintf(name, "%s/%.*sXXXXXX", tmpdir, (int)(mark - label), label);
|
||||
fd = mkstemp(name);
|
||||
if (fd >= 0)
|
||||
{
|
||||
result = fdopen(fd, "w+");
|
||||
if (result != 0)
|
||||
{
|
||||
MY_TMPFILES *item;
|
||||
|
||||
if (my_tmpfiles == 0)
|
||||
{
|
||||
atexit(close_tmpfiles);
|
||||
}
|
||||
|
||||
item = NEW(MY_TMPFILES);
|
||||
NO_SPACE(item);
|
||||
|
||||
item->name = name;
|
||||
NO_SPACE(item->name);
|
||||
|
||||
item->next = my_tmpfiles;
|
||||
my_tmpfiles = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
result = tmpfile();
|
||||
#endif
|
||||
|
||||
if (result == 0)
|
||||
open_error(label);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
open_files(void)
|
||||
{
|
||||
create_file_names();
|
||||
|
||||
if (input_file == 0)
|
||||
{
|
||||
input_file = fopen(input_file_name, "r");
|
||||
if (input_file == 0)
|
||||
open_error(input_file_name);
|
||||
}
|
||||
|
||||
action_file = open_tmpfile("action_file");
|
||||
text_file = open_tmpfile("text_file");
|
||||
|
||||
if (vflag)
|
||||
{
|
||||
verbose_file = fopen(verbose_file_name, "w");
|
||||
if (verbose_file == 0)
|
||||
open_error(verbose_file_name);
|
||||
}
|
||||
|
||||
if (gflag)
|
||||
{
|
||||
graph_file = fopen(graph_file_name, "w");
|
||||
if (graph_file == 0)
|
||||
open_error(graph_file_name);
|
||||
fprintf(graph_file, "digraph %s {\n", file_prefix);
|
||||
fprintf(graph_file, "\tedge [fontsize=10];\n");
|
||||
fprintf(graph_file, "\tnode [shape=box,fontsize=10];\n");
|
||||
fprintf(graph_file, "\torientation=landscape;\n");
|
||||
fprintf(graph_file, "\trankdir=LR;\n");
|
||||
fprintf(graph_file, "\t/*\n");
|
||||
fprintf(graph_file, "\tmargin=0.2;\n");
|
||||
fprintf(graph_file, "\tpage=\"8.27,11.69\"; // for A4 printing\n");
|
||||
fprintf(graph_file, "\tratio=auto;\n");
|
||||
fprintf(graph_file, "\t*/\n");
|
||||
}
|
||||
|
||||
if (dflag)
|
||||
{
|
||||
defines_file = fopen(defines_file_name, "w");
|
||||
if (defines_file == 0)
|
||||
open_error(defines_file_name);
|
||||
union_file = open_tmpfile("union_file");
|
||||
}
|
||||
|
||||
if (iflag)
|
||||
{
|
||||
externs_file = fopen(externs_file_name, "w");
|
||||
if (externs_file == 0)
|
||||
open_error(externs_file_name);
|
||||
}
|
||||
|
||||
output_file = fopen(output_file_name, "w");
|
||||
if (output_file == 0)
|
||||
open_error(output_file_name);
|
||||
|
||||
if (rflag)
|
||||
{
|
||||
code_file = fopen(code_file_name, "w");
|
||||
if (code_file == 0)
|
||||
open_error(code_file_name);
|
||||
}
|
||||
else
|
||||
code_file = output_file;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SRexpect = -1;
|
||||
RRexpect = -1;
|
||||
exit_code = EXIT_SUCCESS;
|
||||
|
||||
set_signals();
|
||||
getargs(argc, argv);
|
||||
open_files();
|
||||
reader();
|
||||
lr0();
|
||||
lalr();
|
||||
make_parser();
|
||||
graph();
|
||||
finalize_closure();
|
||||
verbose();
|
||||
output();
|
||||
done(exit_code);
|
||||
/*NOTREACHED */
|
||||
}
|
||||
182
external/bsd/byacc/dist/makefile.in
vendored
Normal file
182
external/bsd/byacc/dist/makefile.in
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
# Id: makefile.in,v 1.16 2010/06/09 09:46:37 tom Exp
|
||||
#
|
||||
# UNIX template-makefile for Berkeley Yacc
|
||||
|
||||
THIS = yacc
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
CC = @CC@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
transform = @program_transform_name@
|
||||
|
||||
DEFINES =
|
||||
EXTRA_CFLAGS = @EXTRA_CFLAGS@
|
||||
CPPFLAGS = -I. -I$(srcdir) $(DEFINES) -DHAVE_CONFIG_H -DYYPATCH=`cat $(srcdir)/VERSION` @CPPFLAGS@
|
||||
CFLAGS = @CFLAGS@ $(CPPFLAGS) $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
|
||||
CTAGS = @CTAGS@
|
||||
ETAGS = @ETAGS@
|
||||
LINT = @LINT@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = $(DESTDIR)@bindir@
|
||||
mandir = $(DESTDIR)@mandir@/man1
|
||||
manext = 1
|
||||
|
||||
testdir = $(srcdir)/test
|
||||
|
||||
x = @EXEEXT@
|
||||
o = .@OBJEXT@
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
SHELL = /bin/sh
|
||||
@SET_MAKE@
|
||||
|
||||
H_FILES = \
|
||||
defs.h
|
||||
|
||||
C_FILES = \
|
||||
closure.c \
|
||||
error.c \
|
||||
graph.c \
|
||||
lalr.c \
|
||||
lr0.c \
|
||||
main.c \
|
||||
mkpar.c \
|
||||
output.c \
|
||||
reader.c \
|
||||
skeleton.c \
|
||||
symtab.c \
|
||||
verbose.c \
|
||||
warshall.c
|
||||
|
||||
OBJS = \
|
||||
closure$o \
|
||||
error$o \
|
||||
graph$o \
|
||||
lalr$o \
|
||||
lr0$o \
|
||||
main$o \
|
||||
mkpar$o \
|
||||
output$o \
|
||||
reader$o \
|
||||
skeleton$o \
|
||||
symtab$o \
|
||||
verbose$o \
|
||||
warshall$o
|
||||
|
||||
TRANSFORM_BIN = sed 's/$x$$//' |sed '$(transform)'|sed 's/$$/$x/'
|
||||
TRANSFORM_MAN = sed 's/$(manext)$$//'|sed '$(transform)'|sed 's/$$/$(manext)/'
|
||||
|
||||
actual_bin = `echo $(THIS)$x | $(TRANSFORM_BIN)`
|
||||
actual_man = `echo $(THIS).$(manext)| $(TRANSFORM_MAN)`
|
||||
|
||||
all : $(THIS)$x
|
||||
|
||||
install: all installdirs
|
||||
$(INSTALL_PROGRAM) $(THIS)$x $(bindir)/$(actual_bin)
|
||||
- $(INSTALL_DATA) $(srcdir)/$(THIS).1 $(mandir)/$(actual_man)
|
||||
|
||||
installdirs:
|
||||
mkdir -p $(bindir)
|
||||
- mkdir -p $(mandir)
|
||||
|
||||
uninstall:
|
||||
- rm -f $(bindir)/$(actual_bin)
|
||||
- rm -f $(mandir)/$(actual_man)
|
||||
|
||||
################################################################################
|
||||
.SUFFIXES : $o .i .html .$(manext) .cat .ps .pdf .txt
|
||||
|
||||
.c$o:
|
||||
@RULE_CC@
|
||||
@ECHO_CC@$(CC) -c $(CFLAGS) $<
|
||||
|
||||
.c.i :
|
||||
@RULE_CC@
|
||||
@ECHO_CC@$(CPP) -C $(CPPFLAGS) $*.c >$@
|
||||
|
||||
.$(manext).cat :
|
||||
- nroff -man $(srcdir)/$(THIS).$(manext) >$@
|
||||
|
||||
.$(manext).html :
|
||||
GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | groff -Thtml -man" >$@
|
||||
|
||||
.$(manext).ps :
|
||||
$(SHELL) -c "tbl $*.$(manext) | groff -man" >$@
|
||||
|
||||
.$(manext).txt :
|
||||
GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | nroff -Tascii -man | col -bx" >$@
|
||||
|
||||
.ps.pdf :
|
||||
ps2pdf $*.ps
|
||||
|
||||
################################################################################
|
||||
|
||||
$(THIS)$x : $(OBJS)
|
||||
@ECHO_LD@$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||
|
||||
mostlyclean :
|
||||
- rm -f core .nfs* *$o *.bak *.BAK *.out
|
||||
|
||||
clean : mostlyclean
|
||||
- rm -f $(THIS)$x
|
||||
|
||||
distclean : clean
|
||||
- rm -f config.log config.cache config.status config.h makefile
|
||||
- rm -f *.html *.cat *.pdf *.ps *.txt
|
||||
- cd test && rm -f test-*
|
||||
|
||||
realclean: distclean
|
||||
- rm -f tags TAGS
|
||||
|
||||
################################################################################
|
||||
docs :: $(THIS).html \
|
||||
$(THIS).pdf \
|
||||
$(THIS).ps \
|
||||
$(THIS).txt
|
||||
$(THIS).html : $(THIS).$(manext)
|
||||
$(THIS).pdf : $(THIS).ps
|
||||
$(THIS).ps : $(THIS).$(manext)
|
||||
$(THIS).txt : $(THIS).$(manext)
|
||||
################################################################################
|
||||
check: $(THIS)$x
|
||||
$(SHELL) $(testdir)/run_test.sh $(testdir)
|
||||
|
||||
check_make:
|
||||
$(SHELL) $(testdir)/run_make.sh $(testdir)
|
||||
|
||||
check_lint:
|
||||
$(SHELL) $(testdir)/run_lint.sh $(testdir)
|
||||
################################################################################
|
||||
tags: $(H_FILES) $(C_FILES)
|
||||
$(CTAGS) $(C_FILES) $(H_FILES)
|
||||
|
||||
lint: $(C_FILES)
|
||||
$(LINT) $(CPPFLAGS) $(C_FILES)
|
||||
|
||||
@MAKE_UPPER_TAGS@TAGS: $(H_FILES) $(C_FILES)
|
||||
@MAKE_UPPER_TAGS@ $(ETAGS) $(C_FILES) $(H_FILES)
|
||||
|
||||
depend:
|
||||
makedepend -- $(CPPFLAGS) -- $(C_FILES)
|
||||
|
||||
$(OBJS) : defs.h
|
||||
|
||||
main$o \
|
||||
skeleton$o : makefile VERSION
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
396
external/bsd/byacc/dist/mkpar.c
vendored
Normal file
396
external/bsd/byacc/dist/mkpar.c
vendored
Normal file
@@ -0,0 +1,396 @@
|
||||
/* $NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: mkpar.c,v 1.11 2010/06/09 08:53:17 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
static action *add_reduce(action *actions, int ruleno, int symbol);
|
||||
static action *add_reductions(int stateno, action *actions);
|
||||
static action *get_shifts(int stateno);
|
||||
static action *parse_actions(int stateno);
|
||||
static int sole_reduction(int stateno);
|
||||
static void defreds(void);
|
||||
static void find_final_state(void);
|
||||
static void free_action_row(action *p);
|
||||
static void remove_conflicts(void);
|
||||
static void total_conflicts(void);
|
||||
static void unused_rules(void);
|
||||
|
||||
action **parser;
|
||||
|
||||
int SRexpect;
|
||||
int RRexpect;
|
||||
|
||||
int SRtotal;
|
||||
int RRtotal;
|
||||
|
||||
Value_t *SRconflicts;
|
||||
Value_t *RRconflicts;
|
||||
Value_t *defred;
|
||||
Value_t *rules_used;
|
||||
Value_t nunused;
|
||||
Value_t final_state;
|
||||
|
||||
static Value_t SRcount;
|
||||
static Value_t RRcount;
|
||||
|
||||
void
|
||||
make_parser(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
parser = NEW2(nstates, action *);
|
||||
for (i = 0; i < nstates; i++)
|
||||
parser[i] = parse_actions(i);
|
||||
|
||||
find_final_state();
|
||||
remove_conflicts();
|
||||
unused_rules();
|
||||
if (SRtotal + RRtotal > 0)
|
||||
total_conflicts();
|
||||
defreds();
|
||||
}
|
||||
|
||||
static action *
|
||||
parse_actions(int stateno)
|
||||
{
|
||||
action *actions;
|
||||
|
||||
actions = get_shifts(stateno);
|
||||
actions = add_reductions(stateno, actions);
|
||||
return (actions);
|
||||
}
|
||||
|
||||
static action *
|
||||
get_shifts(int stateno)
|
||||
{
|
||||
action *actions, *temp;
|
||||
shifts *sp;
|
||||
Value_t *to_state2;
|
||||
Value_t i, k;
|
||||
Value_t symbol;
|
||||
|
||||
actions = 0;
|
||||
sp = shift_table[stateno];
|
||||
if (sp)
|
||||
{
|
||||
to_state2 = sp->shift;
|
||||
for (i = (Value_t) (sp->nshifts - 1); i >= 0; i--)
|
||||
{
|
||||
k = to_state2[i];
|
||||
symbol = accessing_symbol[k];
|
||||
if (ISTOKEN(symbol))
|
||||
{
|
||||
temp = NEW(action);
|
||||
temp->next = actions;
|
||||
temp->symbol = symbol;
|
||||
temp->number = k;
|
||||
temp->prec = symbol_prec[symbol];
|
||||
temp->action_code = SHIFT;
|
||||
temp->assoc = symbol_assoc[symbol];
|
||||
actions = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (actions);
|
||||
}
|
||||
|
||||
static action *
|
||||
add_reductions(int stateno, action *actions)
|
||||
{
|
||||
int i, j, m, n;
|
||||
int ruleno, tokensetsize;
|
||||
unsigned *rowp;
|
||||
|
||||
tokensetsize = WORDSIZE(ntokens);
|
||||
m = lookaheads[stateno];
|
||||
n = lookaheads[stateno + 1];
|
||||
for (i = m; i < n; i++)
|
||||
{
|
||||
ruleno = LAruleno[i];
|
||||
rowp = LA + i * tokensetsize;
|
||||
for (j = ntokens - 1; j >= 0; j--)
|
||||
{
|
||||
if (BIT(rowp, j))
|
||||
actions = add_reduce(actions, ruleno, j);
|
||||
}
|
||||
}
|
||||
return (actions);
|
||||
}
|
||||
|
||||
static action *
|
||||
add_reduce(action *actions,
|
||||
int ruleno,
|
||||
int symbol)
|
||||
{
|
||||
action *temp, *prev, *next;
|
||||
|
||||
prev = 0;
|
||||
for (next = actions; next && next->symbol < symbol; next = next->next)
|
||||
prev = next;
|
||||
|
||||
while (next && next->symbol == symbol && next->action_code == SHIFT)
|
||||
{
|
||||
prev = next;
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
while (next && next->symbol == symbol &&
|
||||
next->action_code == REDUCE && next->number < ruleno)
|
||||
{
|
||||
prev = next;
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
temp = NEW(action);
|
||||
temp->next = next;
|
||||
temp->symbol = (Value_t) symbol;
|
||||
temp->number = (Value_t) ruleno;
|
||||
temp->prec = rprec[ruleno];
|
||||
temp->action_code = REDUCE;
|
||||
temp->assoc = rassoc[ruleno];
|
||||
|
||||
if (prev)
|
||||
prev->next = temp;
|
||||
else
|
||||
actions = temp;
|
||||
|
||||
return (actions);
|
||||
}
|
||||
|
||||
static void
|
||||
find_final_state(void)
|
||||
{
|
||||
int goal, i;
|
||||
Value_t *to_state2;
|
||||
shifts *p;
|
||||
|
||||
p = shift_table[0];
|
||||
to_state2 = p->shift;
|
||||
goal = ritem[1];
|
||||
for (i = p->nshifts - 1; i >= 0; --i)
|
||||
{
|
||||
final_state = to_state2[i];
|
||||
if (accessing_symbol[final_state] == goal)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unused_rules(void)
|
||||
{
|
||||
int i;
|
||||
action *p;
|
||||
|
||||
rules_used = (Value_t *) MALLOC((unsigned)nrules * sizeof(Value_t));
|
||||
NO_SPACE(rules_used);
|
||||
|
||||
for (i = 0; i < nrules; ++i)
|
||||
rules_used[i] = 0;
|
||||
|
||||
for (i = 0; i < nstates; ++i)
|
||||
{
|
||||
for (p = parser[i]; p; p = p->next)
|
||||
{
|
||||
if (p->action_code == REDUCE && p->suppressed == 0)
|
||||
rules_used[p->number] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
nunused = 0;
|
||||
for (i = 3; i < nrules; ++i)
|
||||
if (!rules_used[i])
|
||||
++nunused;
|
||||
|
||||
if (nunused)
|
||||
{
|
||||
if (nunused == 1)
|
||||
fprintf(stderr, "%s: 1 rule never reduced\n", myname);
|
||||
else
|
||||
fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remove_conflicts(void)
|
||||
{
|
||||
int i;
|
||||
int symbol;
|
||||
action *p, *pref = 0;
|
||||
|
||||
SRtotal = 0;
|
||||
RRtotal = 0;
|
||||
SRconflicts = NEW2(nstates, Value_t);
|
||||
RRconflicts = NEW2(nstates, Value_t);
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
SRcount = 0;
|
||||
RRcount = 0;
|
||||
symbol = -1;
|
||||
for (p = parser[i]; p; p = p->next)
|
||||
{
|
||||
if (p->symbol != symbol)
|
||||
{
|
||||
pref = p;
|
||||
symbol = p->symbol;
|
||||
}
|
||||
else if (i == final_state && symbol == 0)
|
||||
{
|
||||
SRcount++;
|
||||
p->suppressed = 1;
|
||||
}
|
||||
else if (pref != 0 && pref->action_code == SHIFT)
|
||||
{
|
||||
if (pref->prec > 0 && p->prec > 0)
|
||||
{
|
||||
if (pref->prec < p->prec)
|
||||
{
|
||||
pref->suppressed = 2;
|
||||
pref = p;
|
||||
}
|
||||
else if (pref->prec > p->prec)
|
||||
{
|
||||
p->suppressed = 2;
|
||||
}
|
||||
else if (pref->assoc == LEFT)
|
||||
{
|
||||
pref->suppressed = 2;
|
||||
pref = p;
|
||||
}
|
||||
else if (pref->assoc == RIGHT)
|
||||
{
|
||||
p->suppressed = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pref->suppressed = 2;
|
||||
p->suppressed = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SRcount++;
|
||||
p->suppressed = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RRcount++;
|
||||
p->suppressed = 1;
|
||||
}
|
||||
}
|
||||
SRtotal += SRcount;
|
||||
RRtotal += RRcount;
|
||||
SRconflicts[i] = SRcount;
|
||||
RRconflicts[i] = RRcount;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
total_conflicts(void)
|
||||
{
|
||||
fprintf(stderr, "%s: ", myname);
|
||||
if (SRtotal == 1)
|
||||
fprintf(stderr, "1 shift/reduce conflict");
|
||||
else if (SRtotal > 1)
|
||||
fprintf(stderr, "%d shift/reduce conflicts", SRtotal);
|
||||
|
||||
if (SRtotal && RRtotal)
|
||||
fprintf(stderr, ", ");
|
||||
|
||||
if (RRtotal == 1)
|
||||
fprintf(stderr, "1 reduce/reduce conflict");
|
||||
else if (RRtotal > 1)
|
||||
fprintf(stderr, "%d reduce/reduce conflicts", RRtotal);
|
||||
|
||||
fprintf(stderr, ".\n");
|
||||
|
||||
if (SRexpect >= 0 && SRtotal != SRexpect)
|
||||
{
|
||||
fprintf(stderr, "%s: ", myname);
|
||||
fprintf(stderr, "expected %d shift/reduce conflict%s.\n",
|
||||
SRexpect, PLURAL(SRexpect));
|
||||
exit_code = EXIT_FAILURE;
|
||||
}
|
||||
if (RRexpect >= 0 && RRtotal != RRexpect)
|
||||
{
|
||||
fprintf(stderr, "%s: ", myname);
|
||||
fprintf(stderr, "expected %d reduce/reduce conflict%s.\n",
|
||||
RRexpect, PLURAL(RRexpect));
|
||||
exit_code = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
sole_reduction(int stateno)
|
||||
{
|
||||
int count, ruleno;
|
||||
action *p;
|
||||
|
||||
count = 0;
|
||||
ruleno = 0;
|
||||
for (p = parser[stateno]; p; p = p->next)
|
||||
{
|
||||
if (p->action_code == SHIFT && p->suppressed == 0)
|
||||
return (0);
|
||||
else if (p->action_code == REDUCE && p->suppressed == 0)
|
||||
{
|
||||
if (ruleno > 0 && p->number != ruleno)
|
||||
return (0);
|
||||
if (p->symbol != 1)
|
||||
++count;
|
||||
ruleno = p->number;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
return (0);
|
||||
return (ruleno);
|
||||
}
|
||||
|
||||
static void
|
||||
defreds(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
defred = NEW2(nstates, Value_t);
|
||||
for (i = 0; i < nstates; i++)
|
||||
defred[i] = (Value_t) sole_reduction(i);
|
||||
}
|
||||
|
||||
static void
|
||||
free_action_row(action *p)
|
||||
{
|
||||
action *q;
|
||||
|
||||
while (p)
|
||||
{
|
||||
q = p->next;
|
||||
FREE(p);
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_parser(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nstates; i++)
|
||||
free_action_row(parser[i]);
|
||||
|
||||
FREE(parser);
|
||||
}
|
||||
|
||||
#ifdef NO_LEAKS
|
||||
void
|
||||
mkpar_leaks(void)
|
||||
{
|
||||
DO_FREE(defred);
|
||||
DO_FREE(rules_used);
|
||||
DO_FREE(SRconflicts);
|
||||
DO_FREE(RRconflicts);
|
||||
}
|
||||
#endif
|
||||
1498
external/bsd/byacc/dist/output.c
vendored
Normal file
1498
external/bsd/byacc/dist/output.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
60
external/bsd/byacc/dist/package/byacc.spec
vendored
Normal file
60
external/bsd/byacc/dist/package/byacc.spec
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
Summary: byacc - public domain Berkeley LALR Yacc parser generator
|
||||
%define AppProgram byacc
|
||||
%define AppVersion 20110908
|
||||
%define UseProgram yacc
|
||||
# $XTermId: byacc.spec,v 1.10 2011/09/08 09:45:02 tom Exp $
|
||||
Name: %{AppProgram}
|
||||
Version: %{AppVersion}
|
||||
Release: 1
|
||||
License: Public Domain, MIT
|
||||
Group: Applications/Development
|
||||
URL: ftp://invisible-island.net/%{AppProgram}
|
||||
Source0: %{AppProgram}-%{AppVersion}.tgz
|
||||
Packager: Thomas Dickey <dickey@invisible-island.net>
|
||||
|
||||
%description
|
||||
This package provides a parser generator utility that reads a grammar
|
||||
specification from a file and generates an LR(1) parser for it. The
|
||||
parsers consist of a set of LALR(1) parsing tables and a driver
|
||||
routine written in the C programming language. It has a public domain
|
||||
license which includes the generated C.
|
||||
|
||||
%prep
|
||||
|
||||
%setup -q -n %{AppProgram}-%{AppVersion}
|
||||
|
||||
%build
|
||||
|
||||
INSTALL_PROGRAM='${INSTALL}' \
|
||||
./configure \
|
||||
--program-prefix=b \
|
||||
--target %{_target_platform} \
|
||||
--prefix=%{_prefix} \
|
||||
--bindir=%{_bindir} \
|
||||
--libdir=%{_libdir} \
|
||||
--mandir=%{_mandir}
|
||||
|
||||
make
|
||||
|
||||
%install
|
||||
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
( cd $RPM_BUILD_ROOT%{_bindir} && ln -s %{AppProgram} %{UseProgram} )
|
||||
|
||||
strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram}
|
||||
|
||||
%clean
|
||||
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%{_prefix}/bin/%{AppProgram}
|
||||
%{_prefix}/bin/%{UseProgram}
|
||||
%{_mandir}/man1/%{AppProgram}.*
|
||||
|
||||
%changelog
|
||||
# each patch should add its ChangeLog entries here
|
||||
|
||||
* Sun Jun 06 2010 Thomas Dickey
|
||||
- initial version
|
||||
211
external/bsd/byacc/dist/package/debian/changelog
vendored
Normal file
211
external/bsd/byacc/dist/package/debian/changelog
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
byacc (20110908) unstable; urgency=low
|
||||
|
||||
* add "-i" option.
|
||||
* add error-check in reader.c
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Mon, 05 Sep 2011 20:05:51 -0400
|
||||
|
||||
byacc (20101229) unstable; urgency=low
|
||||
|
||||
* fixes from Christos Zoulos
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Wed, 29 Dec 2010 13:03:50 -0500
|
||||
|
||||
byacc (20101226) unstable; urgency=low
|
||||
|
||||
* portability fix for MinGW
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 25 Dec 2010 19:37:54 -0500
|
||||
|
||||
byacc (20101127) unstable; urgency=low
|
||||
|
||||
* corrected yyerror use of %parse-param data
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 27 Nov 2010 12:32:00 -0500
|
||||
|
||||
byacc (20101126) unstable; urgency=low
|
||||
|
||||
* additional fix to generated code to avoid symbol conflict
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Fri, 26 Nov 2010 04:23:08 -0500
|
||||
|
||||
byacc (20101124) unstable; urgency=low
|
||||
|
||||
* amend fix for Red Hat #112617 to restore warning message.
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Mon, 22 Nov 2010 08:21:23 -0500
|
||||
|
||||
byacc (20101122) unstable; urgency=low
|
||||
|
||||
* fix for generated header to avoid symbol conflict
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Mon, 22 Nov 2010 08:21:23 -0500
|
||||
|
||||
byacc (20100610) unstable; urgency=low
|
||||
|
||||
* Add package scripts to upstream source, for test-builds.
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Thu, 10 Jun 2010 08:59:11 -0400
|
||||
|
||||
byacc (20100216-1) unstable; urgency=low
|
||||
|
||||
* New upstream release
|
||||
* debian/source/format: Added using format "3.0 (quilt)"
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Tue, 20 Apr 2010 12:56:11 -0700
|
||||
|
||||
byacc (20091027-1) unstable; urgency=low
|
||||
|
||||
* New upstream release
|
||||
* debian/control:
|
||||
- Updated to policy 3.8.4
|
||||
- Add ${misc:Depends}
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Tue, 02 Feb 2010 21:36:34 -0800
|
||||
|
||||
byacc (20090221-1) unstable; urgency=low
|
||||
|
||||
* New upstream release
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Thu, 26 Feb 2009 21:06:20 -0800
|
||||
|
||||
byacc (20080826-1) unstable; urgency=high
|
||||
|
||||
* New upstream release
|
||||
* debian/patches/02-skeleton.patch: Removed - merged upstream
|
||||
* debian/control: Updated to policy 3.8.0
|
||||
* debian/preinst, debian/postrm: removed - empty (lintian)
|
||||
* debian/watch: version 3 and make FTP passive
|
||||
* Acknowledge NMU - thanks.
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Wed, 11 Sep 2008 23:58:00 -0700
|
||||
|
||||
byacc (20070509-1.1) unstable; urgency=high
|
||||
|
||||
* Non-maintainer upload.
|
||||
* Fix stack overflow in skeleton.c with upstream patch.
|
||||
Closes: #491182 aka CVE-2008-3196
|
||||
|
||||
-- Thomas Viehmann <tv@beamnet.de> Sun, 24 Aug 2008 23:13:07 +0200
|
||||
|
||||
byacc (20070509-1) unstable; urgency=low
|
||||
|
||||
* New upstream release
|
||||
* debian/watch: Fix to use passive FTP
|
||||
* debian/compat: added instead of use of DH_COMPAT in debian/rules
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Tue, 26 Jun 2007 22:39:45 -0700
|
||||
|
||||
byacc (20050813-1) unstable; urgency=low
|
||||
|
||||
* New upstream release:
|
||||
- Do not close union_file for -d option (Closes: #322858)
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Sun, 14 Aug 2005 10:14:12 +0100
|
||||
|
||||
byacc (20050505-1) unstable; urgency=low
|
||||
|
||||
* New maintainer (Closes: #321377)
|
||||
* Switch to new upstream and new source (Closes: #240662)
|
||||
* debian/copyright: Update to new upstream and add source information
|
||||
(Closes: #166300)
|
||||
* Acknowledge fix in NMUs (Closes: #283174)
|
||||
* New manual page does not have the formatting problem (Closes: #100947)
|
||||
* Added debian/watch file.
|
||||
|
||||
-- Dave Beckett <dajobe@debian.org> Fri, 5 Aug 2005 22:50:20 +0100
|
||||
|
||||
byacc (1.9.1-1.1) unstable; urgency=low
|
||||
|
||||
* Remove alternative in prerm. Closes: #283174
|
||||
|
||||
-- LaMont Jones <lamont@debian.org> Fri, 26 Nov 2004 18:49:09 -0700
|
||||
|
||||
byacc (1.9.1-1) unstable; urgency=low
|
||||
|
||||
* Maintainer upload.
|
||||
* Fixed alternatives entry, closes: Bug#146195;
|
||||
* Changed priority to "extra" at behest of Daniel Bungert,
|
||||
closes: Bug#142271.
|
||||
* Fixed awful packaging error which meant the test/ directory was excluded
|
||||
from the orig.tar.gz.
|
||||
|
||||
-- Jason Henry Parker <henry@debian.org> Fri, 27 Sep 2002 16:25:27 -0400
|
||||
|
||||
byacc (1.9-13.1) unstable; urgency=low
|
||||
|
||||
* Non-maintainer upload
|
||||
* Removed erraneous escapes in manpage - some data wasn't visable,
|
||||
closes: Bug#100947
|
||||
* Alternatives entry added, closes: Bug#113168
|
||||
* Standards-version: 3.5.6
|
||||
* Maintainer script cleaning
|
||||
|
||||
-- Daniel Bungert <drb@debian.org> Fri, 29 Mar 2002 16:58:30 -0500
|
||||
|
||||
byacc (1.9-13) unstable; urgency=low
|
||||
|
||||
* Applied patch from "Randolph Chung" <tausq@debian.org> to fix build problems
|
||||
on ia64, closes: Bug#91966
|
||||
|
||||
-- Jason Henry Parker <henry@debian.org> Thu, 29 Mar 2001 21:41:19 +1000
|
||||
|
||||
byacc (1.9-12) unstable; urgency=low
|
||||
|
||||
* Updated to latest version of debhelper, and Standards-Version: 3.2.1.0, closes: Bug#81444
|
||||
* Added Build-Depends: debhelper, closes: Bug#70207
|
||||
* Removed mktemp() calls in main.c
|
||||
|
||||
-- Jason Henry Parker <henry@debian.org> Mon, 18 Dec 2000 08:02:54 +1000
|
||||
|
||||
byacc (1.9-11.7) unstable; urgency=low
|
||||
|
||||
* New maintainer.
|
||||
* Updated to dh_make and standards version 2.4.0.0, no lintian errors
|
||||
or warnings.
|
||||
* Added several more files from the upstream distribution to
|
||||
/usr/doc/byacc.
|
||||
|
||||
-- Jason Henry Parker <henry@debian.org> Sat, 2 Jan 1999 03:04:17 +1000
|
||||
|
||||
byacc (1.9-11.6) unstable; urgency=low
|
||||
|
||||
* Patch by <mdorman@law.miami.edu> to remove some
|
||||
superfluous files that can interfere with the build process on other
|
||||
architectures. (Bug #21607).
|
||||
|
||||
-- Vincent Renardias <vincent@waw.com> Fri, 24 Apr 1998 19:56:58 +0200
|
||||
|
||||
byacc (1.9-11.5) unstable; urgency=low
|
||||
|
||||
* Added 'binary-arch' target in debian/rules (Bug #12742).
|
||||
|
||||
-- Vincent Renardias <vincent@waw.com> Sun, 9 Nov 1997 23:37:31 +0100
|
||||
|
||||
byacc (1.9-11.4) unstable; urgency=low
|
||||
|
||||
* Cosmetic change (Fix bug #9623).
|
||||
|
||||
-- Vincent Renardias <vincent@waw.com> Fri, 9 May 1997 16:30:24 +0200
|
||||
|
||||
byacc (1.9-11.3) unstable; urgency=low
|
||||
|
||||
* Rebuilt with libc6.
|
||||
|
||||
-- Debian QA Group <debian-qa@lists.debian.org> Thu, 1 May 1997 22:02:04 +0200
|
||||
|
||||
byacc (1.9-11.2) unstable; urgency=low
|
||||
|
||||
* Orphaned the package at his maintainer's request (dgregor@coil.com).
|
||||
|
||||
-- Debian QA Group <debian-qa@lists.debian.org> Sun, 20 Apr 1997 20:03:03 +0200
|
||||
|
||||
byacc (1.9-11.1) unstable; urgency=low
|
||||
|
||||
* Converted to new source format (Fixes #8085).
|
||||
* Compressed manpage.
|
||||
* Fixed to allow compilation on non-i386 (Fixes #3361).
|
||||
* Added extended description (Fixes #3567).
|
||||
* Added diversion to avoid conflict with bison (Fixes #8086).
|
||||
|
||||
-- Vincent Renardias <vincent@waw.com> Sun, 20 Apr 1997 15:59:28 +0200
|
||||
1
external/bsd/byacc/dist/package/debian/compat
vendored
Normal file
1
external/bsd/byacc/dist/package/debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
||||
5
|
||||
17
external/bsd/byacc/dist/package/debian/control
vendored
Normal file
17
external/bsd/byacc/dist/package/debian/control
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
Source: byacc
|
||||
Maintainer: Dave Beckett <dajobe@debian.org>
|
||||
Section: devel
|
||||
Priority: extra
|
||||
Standards-Version: 3.8.4
|
||||
Build-Depends: debhelper (>= 5)
|
||||
Homepage: http://invisible-island.net/byacc/
|
||||
|
||||
Package: byacc
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: public domain Berkeley LALR Yacc parser generator
|
||||
This package provides a parser generator utility that reads a grammar
|
||||
specification from a file and generates an LR(1) parser for it. The
|
||||
parsers consist of a set of LALR(1) parsing tables and a driver
|
||||
routine written in the C programming language. It has a public domain
|
||||
license which includes the generated C.
|
||||
120
external/bsd/byacc/dist/package/debian/copyright
vendored
Normal file
120
external/bsd/byacc/dist/package/debian/copyright
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
Upstream source http://dickey.his.com/byacc/byacc.html
|
||||
|
||||
Berkeley Yacc is in the public domain; changes made to it by the current
|
||||
maintainer are likewise unrestricted. That applies to most of the files.
|
||||
A few files (currently those related to autoconf scripting) have other
|
||||
licenses as noted here.
|
||||
|
||||
Current byacc upstream maintainer: Thomas Dickey <dickey@invisible-island.net>
|
||||
|
||||
Public domain notice and no warranty:
|
||||
-------------------------------------------------------------------------------
|
||||
Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made
|
||||
as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input
|
||||
specification that conforms to the AT&T Yacc documentation. Specifications
|
||||
that take advantage of undocumented features of AT&T Yacc will probably be
|
||||
rejected.
|
||||
|
||||
Berkeley Yacc is distributed with no warranty whatever. The code
|
||||
is certain to contain errors. Neither the author nor any contributor
|
||||
takes responsibility for any consequences of its use.
|
||||
|
||||
Berkeley Yacc is in the public domain. The data structures and algorithms
|
||||
used in Berkeley Yacc are all either taken from documents available to the
|
||||
general public or are inventions of the author. Anyone may freely distribute
|
||||
source or binary forms of Berkeley Yacc whether unchanged or modified.
|
||||
Distributers may charge whatever fees they can obtain for Berkeley Yacc.
|
||||
Programs generated by Berkeley Yacc may be distributed freely.
|
||||
|
||||
Please report bugs to
|
||||
|
||||
robert.corbett@eng.Sun.COM
|
||||
|
||||
Include a small example if possible. Please include the banner string from
|
||||
skeleton.c with the bug report. Do not expect rapid responses.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Files: aclocal.m4
|
||||
Licence: other-BSD
|
||||
Copyright: 2004-2009,2010 by Thomas E. Dickey
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, distribute with modifications, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name(s) of the above copyright
|
||||
holders shall not be used in advertising or otherwise to promote the
|
||||
sale, use or other dealings in this Software without prior written
|
||||
authorization.
|
||||
|
||||
Files: install-sh
|
||||
Copyright: 1994 X Consortium
|
||||
Licence: other-BSD
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of the X Consortium shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
ings in this Software without prior written authorization from the X Consor-
|
||||
tium.
|
||||
|
||||
FSF changes to this file are in the public domain.
|
||||
|
||||
Calling this script install-sh is preferred over install.sh, to prevent
|
||||
`make' implicit rules from creating a file called install from it
|
||||
when there is no Makefile.
|
||||
|
||||
This script is compatible with the BSD install script, but was written
|
||||
from scratch. It can only install one file at a time, a restriction
|
||||
shared with many OS's install programs.
|
||||
|
||||
Files: debian/*
|
||||
Copyright: 2010 Thomas E. Dickey
|
||||
Licence: other-BSD
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of the above listed
|
||||
copyright holder(s) not be used in advertising or publicity pertaining
|
||||
to distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
|
||||
TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
|
||||
LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License can be found in '/usr/share/common-licenses/GPL-2'
|
||||
4
external/bsd/byacc/dist/package/debian/docs
vendored
Normal file
4
external/bsd/byacc/dist/package/debian/docs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
README
|
||||
ACKNOWLEDGEMENTS
|
||||
NEW_FEATURES
|
||||
NOTES
|
||||
15
external/bsd/byacc/dist/package/debian/postinst
vendored
Normal file
15
external/bsd/byacc/dist/package/debian/postinst
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#! /bin/sh
|
||||
# postinst script for byacc
|
||||
|
||||
set -e
|
||||
|
||||
if [ $1 != "upgrade" ] ; then
|
||||
update-alternatives \
|
||||
--install /usr/bin/yacc yacc /usr/bin/byacc 80 \
|
||||
--slave /usr/share/man/man1/yacc.1.gz yaccman \
|
||||
/usr/share/man/man1/byacc.1.gz
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
12
external/bsd/byacc/dist/package/debian/prerm
vendored
Normal file
12
external/bsd/byacc/dist/package/debian/prerm
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /bin/sh
|
||||
# prerm script for byacc
|
||||
|
||||
set -e
|
||||
|
||||
if [ $1 != "upgrade" ]; then
|
||||
update-alternatives --remove yacc /usr/bin/byacc
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
93
external/bsd/byacc/dist/package/debian/rules
vendored
Executable file
93
external/bsd/byacc/dist/package/debian/rules
vendored
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/make -f
|
||||
# MAde with the aid of dh_make, by Craig Small
|
||||
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
|
||||
# Some lines taken from debmake, by Cristoph Lameter.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
# These are used for cross-compiling and for saving the configure script
|
||||
# from having to guess our platform (since we know it already)
|
||||
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
|
||||
CFLAGS =
|
||||
|
||||
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
||||
CFLAGS += -O0
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
|
||||
INSTALL_PROGRAM += -s
|
||||
endif
|
||||
|
||||
|
||||
configure: configure-stamp
|
||||
configure-stamp:
|
||||
dh_testdir
|
||||
|
||||
CFLAGS="$(CFLAGS)" ./configure \
|
||||
--host=$(DEB_HOST_GNU_TYPE) \
|
||||
--build=$(DEB_BUILD_GNU_TYPE) \
|
||||
--prefix=/usr \
|
||||
--mandir=\$${prefix}/share/man \
|
||||
--sysconfdir=/etc \
|
||||
--program-transform-name='s,^,b,'
|
||||
|
||||
touch configure-stamp
|
||||
|
||||
build: build-stamp
|
||||
build-stamp: configure-stamp
|
||||
dh_testdir
|
||||
|
||||
$(MAKE)
|
||||
|
||||
touch build-stamp
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
|
||||
[ ! -f Makefile ] || $(MAKE) clean
|
||||
|
||||
rm -f configure-stamp build-stamp install-stamp \
|
||||
config.cache config.h config.status config.log makefile
|
||||
|
||||
rm -f *.o yacc
|
||||
|
||||
dh_clean
|
||||
|
||||
install: install-stamp
|
||||
install-stamp: build-stamp
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
|
||||
$(MAKE) install DESTDIR=$(CURDIR)/debian/byacc
|
||||
|
||||
touch install-stamp
|
||||
|
||||
# Build architecture-independent files here.
|
||||
binary-indep: build install
|
||||
# No binary-indep target.
|
||||
|
||||
# Build architecture-dependent files here.
|
||||
binary-arch: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_installchangelogs CHANGES
|
||||
dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_installdeb
|
||||
dh_shlibdeps
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install install-stamp
|
||||
1
external/bsd/byacc/dist/package/debian/source/format
vendored
Normal file
1
external/bsd/byacc/dist/package/debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
||||
3.0 (quilt)
|
||||
4
external/bsd/byacc/dist/package/debian/watch
vendored
Normal file
4
external/bsd/byacc/dist/package/debian/watch
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
version=3
|
||||
|
||||
opts=passive ftp://invisible-island.net/byacc/byacc-(\d+)\.tgz \
|
||||
debian uupdate
|
||||
6
external/bsd/byacc/dist/package/pkgsrc/DESCR
vendored
Normal file
6
external/bsd/byacc/dist/package/pkgsrc/DESCR
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Berkeley Yacc (byacc) is a LALR(1) parser generator. Berkeley Yacc
|
||||
has been made as compatible as possible with AT&T Yacc. Berkeley
|
||||
Yacc can accept any input specification that conforms to the AT&T
|
||||
Yacc documentation.
|
||||
|
||||
Some programs depend on a byacc (instead of bison).
|
||||
19
external/bsd/byacc/dist/package/pkgsrc/Makefile
vendored
Normal file
19
external/bsd/byacc/dist/package/pkgsrc/Makefile
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# $NetBSD: Makefile,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
|
||||
#
|
||||
|
||||
DISTNAME= byacc-20050813
|
||||
PKGREVISION= 1
|
||||
CATEGORIES= devel
|
||||
MASTER_SITES= ftp://invisible-island.net/byacc/
|
||||
EXTRACT_SUFX= .tgz
|
||||
|
||||
MAINTAINER= pkgsrc-users@NetBSD.org
|
||||
HOMEPAGE= http://dickey.his.com/byacc/byacc.html
|
||||
COMMENT= Berkeley Yacc
|
||||
|
||||
PKG_DESTDIR_SUPPORT= user-destdir
|
||||
|
||||
GNU_CONFIGURE= YES
|
||||
MAKE_FILE= makefile
|
||||
|
||||
.include "../../mk/bsd.pkg.mk"
|
||||
3
external/bsd/byacc/dist/package/pkgsrc/PLIST
vendored
Normal file
3
external/bsd/byacc/dist/package/pkgsrc/PLIST
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
@comment $NetBSD: PLIST,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
|
||||
bin/yacc
|
||||
man/man1/yacc.1
|
||||
6
external/bsd/byacc/dist/package/pkgsrc/distinfo
vendored
Normal file
6
external/bsd/byacc/dist/package/pkgsrc/distinfo
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
$NetBSD: distinfo,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
|
||||
|
||||
SHA1 (byacc-20050813.tgz) = 3258494f3422eb3150944c1823af1c9c2c386062
|
||||
RMD160 (byacc-20050813.tgz) = 3ee159857a79025a83e2b0807577925fe460f816
|
||||
Size (byacc-20050813.tgz) = 138684 bytes
|
||||
SHA1 (patch-aa) = decae78775a5e0f1e1f7aaaa258da53903aa1f7a
|
||||
2256
external/bsd/byacc/dist/reader.c
vendored
Normal file
2256
external/bsd/byacc/dist/reader.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
453
external/bsd/byacc/dist/skeleton.c
vendored
Normal file
453
external/bsd/byacc/dist/skeleton.c
vendored
Normal file
@@ -0,0 +1,453 @@
|
||||
/* $NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: skeleton.c,v 1.31 2011/09/07 09:37:59 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
/* The definition of yysccsid in the banner should be replaced with */
|
||||
/* a #pragma ident directive if the target C compiler supports */
|
||||
/* #pragma ident directives. */
|
||||
/* */
|
||||
/* If the skeleton is changed, the banner should be changed so that */
|
||||
/* the altered version can be easily distinguished from the original. */
|
||||
/* */
|
||||
/* The #defines included with the banner are there because they are */
|
||||
/* useful in subsequent code. The macros #defined in the header or */
|
||||
/* the body either are not useful outside of semantic actions or */
|
||||
/* are conditional. */
|
||||
|
||||
const char *const banner[] =
|
||||
{
|
||||
"#ifndef lint",
|
||||
"static const char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";",
|
||||
"#endif",
|
||||
"",
|
||||
"#ifdef _LIBC",
|
||||
"#include \"namespace.h\"",
|
||||
"#endif",
|
||||
"#include <stdlib.h>",
|
||||
"#include <string.h>",
|
||||
"",
|
||||
"#define YYBYACC 1",
|
||||
CONCAT1("#define YYMAJOR ", YYMAJOR),
|
||||
CONCAT1("#define YYMINOR ", YYMINOR),
|
||||
#ifdef YYPATCH
|
||||
CONCAT1("#define YYPATCH ", YYPATCH),
|
||||
#endif
|
||||
"",
|
||||
"#define YYEMPTY (-1)",
|
||||
"#define yyclearin (yychar = YYEMPTY)",
|
||||
"#define yyerrok (yyerrflag = 0)",
|
||||
"#define YYRECOVERING() (yyerrflag != 0)",
|
||||
"",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const xdecls[] =
|
||||
{
|
||||
"",
|
||||
"extern int YYPARSE_DECL();",
|
||||
#ifdef notdef
|
||||
"extern int YYLEX_DECL();",
|
||||
#endif
|
||||
"",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const tables[] =
|
||||
{
|
||||
"extern short yylhs[];",
|
||||
"extern short yylen[];",
|
||||
"extern short yydefred[];",
|
||||
"extern short yydgoto[];",
|
||||
"extern short yysindex[];",
|
||||
"extern short yyrindex[];",
|
||||
"extern short yygindex[];",
|
||||
"extern short yytable[];",
|
||||
"extern short yycheck[];",
|
||||
"",
|
||||
"#if YYDEBUG",
|
||||
"extern char *yyname[];",
|
||||
"extern char *yyrule[];",
|
||||
"#endif",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const global_vars[] =
|
||||
{
|
||||
"",
|
||||
"int yydebug;",
|
||||
"int yynerrs;",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const impure_vars[] =
|
||||
{
|
||||
"",
|
||||
"int yyerrflag;",
|
||||
"int yychar;",
|
||||
"YYSTYPE yyval;",
|
||||
"YYSTYPE yylval;",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const hdr_defs[] =
|
||||
{
|
||||
"",
|
||||
"/* define the initial stack-sizes */",
|
||||
"#ifdef YYSTACKSIZE",
|
||||
"#undef YYMAXDEPTH",
|
||||
"#define YYMAXDEPTH YYSTACKSIZE",
|
||||
"#else",
|
||||
"#ifdef YYMAXDEPTH",
|
||||
"#define YYSTACKSIZE YYMAXDEPTH",
|
||||
"#else",
|
||||
"#define YYSTACKSIZE 500",
|
||||
"#define YYMAXDEPTH 500",
|
||||
"#endif",
|
||||
"#endif",
|
||||
"",
|
||||
"#define YYINITSTACKSIZE 500",
|
||||
"",
|
||||
"typedef struct {",
|
||||
" unsigned stacksize;",
|
||||
" short *s_base;",
|
||||
" short *s_mark;",
|
||||
" short *s_last;",
|
||||
" YYSTYPE *l_base;",
|
||||
" YYSTYPE *l_mark;",
|
||||
"} YYSTACKDATA;",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const hdr_vars[] =
|
||||
{
|
||||
"/* variables for the parser stack */",
|
||||
"static YYSTACKDATA yystack;",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const body_vars[] =
|
||||
{
|
||||
" int yyerrflag;",
|
||||
" int yychar;",
|
||||
" YYSTYPE yyval;",
|
||||
" YYSTYPE yylval;",
|
||||
"",
|
||||
" /* variables for the parser stack */",
|
||||
" YYSTACKDATA yystack;",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const body_1[] =
|
||||
{
|
||||
"",
|
||||
"#if YYDEBUG",
|
||||
"#include <stdio.h> /* needed for printf */",
|
||||
"#endif",
|
||||
"",
|
||||
"#include <stdlib.h> /* needed for malloc, etc */",
|
||||
"#include <string.h> /* needed for memset */",
|
||||
"",
|
||||
"/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
|
||||
"static int yygrowstack(YYSTACKDATA *data)",
|
||||
"{",
|
||||
" int i;",
|
||||
" unsigned newsize;",
|
||||
" short *newss;",
|
||||
" YYSTYPE *newvs;",
|
||||
"",
|
||||
" if ((newsize = data->stacksize) == 0)",
|
||||
" newsize = YYINITSTACKSIZE;",
|
||||
" else if (newsize >= YYMAXDEPTH)",
|
||||
" return -1;",
|
||||
" else if ((newsize *= 2) > YYMAXDEPTH)",
|
||||
" newsize = YYMAXDEPTH;",
|
||||
"",
|
||||
" i = data->s_mark - data->s_base;",
|
||||
" newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));",
|
||||
" if (newss == 0)",
|
||||
" return -1;",
|
||||
"",
|
||||
" data->s_base = newss;",
|
||||
" data->s_mark = newss + i;",
|
||||
"",
|
||||
" newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
|
||||
" if (newvs == 0)",
|
||||
" return -1;",
|
||||
"",
|
||||
" data->l_base = newvs;",
|
||||
" data->l_mark = newvs + i;",
|
||||
"",
|
||||
" data->stacksize = newsize;",
|
||||
" data->s_last = data->s_base + newsize - 1;",
|
||||
" return 0;",
|
||||
"}",
|
||||
"",
|
||||
"#if YYPURE || defined(YY_NO_LEAKS)",
|
||||
"static void yyfreestack(YYSTACKDATA *data)",
|
||||
"{",
|
||||
" free(data->s_base);",
|
||||
" free(data->l_base);",
|
||||
" memset(data, 0, sizeof(*data));",
|
||||
"}",
|
||||
"#else",
|
||||
"#define yyfreestack(data) /* nothing */",
|
||||
"#endif",
|
||||
"",
|
||||
"#define YYABORT goto yyabort",
|
||||
"#define YYREJECT goto yyabort",
|
||||
"#define YYACCEPT goto yyaccept",
|
||||
"#define YYERROR goto yyerrlab",
|
||||
"",
|
||||
"int",
|
||||
"YYPARSE_DECL()",
|
||||
"{",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const body_2[] =
|
||||
{
|
||||
" int yym, yyn, yystate;",
|
||||
"#if YYDEBUG",
|
||||
" const char *yys;",
|
||||
"",
|
||||
" if ((yys = getenv(\"YYDEBUG\")) != 0)",
|
||||
" {",
|
||||
" yyn = *yys;",
|
||||
" if (yyn >= '0' && yyn <= '9')",
|
||||
" yydebug = yyn - '0';",
|
||||
" }",
|
||||
"#endif",
|
||||
"",
|
||||
" yynerrs = 0;",
|
||||
" yyerrflag = 0;",
|
||||
" yychar = YYEMPTY;",
|
||||
" yystate = 0;",
|
||||
"",
|
||||
"#if YYPURE",
|
||||
" memset(&yystack, 0, sizeof(yystack));",
|
||||
"#endif",
|
||||
"",
|
||||
" if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;",
|
||||
" yystack.s_mark = yystack.s_base;",
|
||||
" yystack.l_mark = yystack.l_base;",
|
||||
" yystate = 0;",
|
||||
" *yystack.s_mark = 0;",
|
||||
"",
|
||||
"yyloop:",
|
||||
" if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
|
||||
" if (yychar < 0)",
|
||||
" {",
|
||||
" if ((yychar = YYLEX) < 0) yychar = 0;",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" {",
|
||||
" yys = 0;",
|
||||
" if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
|
||||
" if (!yys) yys = \"illegal-symbol\";",
|
||||
" printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
|
||||
" YYPREFIX, yystate, yychar, yys);",
|
||||
" }",
|
||||
"#endif",
|
||||
" }",
|
||||
" if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&",
|
||||
" yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
|
||||
" {",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" printf(\"%sdebug: state %d, shifting to state %d\\n\",",
|
||||
" YYPREFIX, yystate, yytable[yyn]);",
|
||||
"#endif",
|
||||
" if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))",
|
||||
" {",
|
||||
" goto yyoverflow;",
|
||||
" }",
|
||||
" yystate = yytable[yyn];",
|
||||
" *++yystack.s_mark = yytable[yyn];",
|
||||
" *++yystack.l_mark = yylval;",
|
||||
" yychar = YYEMPTY;",
|
||||
" if (yyerrflag > 0) --yyerrflag;",
|
||||
" goto yyloop;",
|
||||
" }",
|
||||
" if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&",
|
||||
" yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
|
||||
" {",
|
||||
" yyn = yytable[yyn];",
|
||||
" goto yyreduce;",
|
||||
" }",
|
||||
" if (yyerrflag) goto yyinrecovery;",
|
||||
"",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const body_3[] =
|
||||
{
|
||||
"",
|
||||
" goto yyerrlab;",
|
||||
"",
|
||||
"yyerrlab:",
|
||||
" ++yynerrs;",
|
||||
"",
|
||||
"yyinrecovery:",
|
||||
" if (yyerrflag < 3)",
|
||||
" {",
|
||||
" yyerrflag = 3;",
|
||||
" for (;;)",
|
||||
" {",
|
||||
" if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&",
|
||||
" yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)",
|
||||
" {",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" printf(\"%sdebug: state %d, error recovery shifting\\",
|
||||
" to state %d\\n\", YYPREFIX, *yystack.s_mark, yytable[yyn]);",
|
||||
"#endif",
|
||||
" if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))",
|
||||
" {",
|
||||
" goto yyoverflow;",
|
||||
" }",
|
||||
" yystate = yytable[yyn];",
|
||||
" *++yystack.s_mark = yytable[yyn];",
|
||||
" *++yystack.l_mark = yylval;",
|
||||
" goto yyloop;",
|
||||
" }",
|
||||
" else",
|
||||
" {",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" printf(\"%sdebug: error recovery discarding state %d\
|
||||
\\n\",",
|
||||
" YYPREFIX, *yystack.s_mark);",
|
||||
"#endif",
|
||||
" if (yystack.s_mark <= yystack.s_base) goto yyabort;",
|
||||
" --yystack.s_mark;",
|
||||
" --yystack.l_mark;",
|
||||
" }",
|
||||
" }",
|
||||
" }",
|
||||
" else",
|
||||
" {",
|
||||
" if (yychar == 0) goto yyabort;",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" {",
|
||||
" yys = 0;",
|
||||
" if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
|
||||
" if (!yys) yys = \"illegal-symbol\";",
|
||||
" printf(\"%sdebug: state %d, error recovery discards token %d\
|
||||
(%s)\\n\",",
|
||||
" YYPREFIX, yystate, yychar, yys);",
|
||||
" }",
|
||||
"#endif",
|
||||
" yychar = YYEMPTY;",
|
||||
" goto yyloop;",
|
||||
" }",
|
||||
"",
|
||||
"yyreduce:",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",",
|
||||
" YYPREFIX, yystate, yyn, yyrule[yyn]);",
|
||||
"#endif",
|
||||
" yym = yylen[yyn];",
|
||||
" if (yym)",
|
||||
" yyval = yystack.l_mark[1-yym];",
|
||||
" else",
|
||||
" memset(&yyval, 0, sizeof yyval);",
|
||||
" switch (yyn)",
|
||||
" {",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const trailer[] =
|
||||
{
|
||||
" }",
|
||||
" yystack.s_mark -= yym;",
|
||||
" yystate = *yystack.s_mark;",
|
||||
" yystack.l_mark -= yym;",
|
||||
" yym = yylhs[yyn];",
|
||||
" if (yystate == 0 && yym == 0)",
|
||||
" {",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" printf(\"%sdebug: after reduction, shifting from state 0 to\\",
|
||||
" state %d\\n\", YYPREFIX, YYFINAL);",
|
||||
"#endif",
|
||||
" yystate = YYFINAL;",
|
||||
" *++yystack.s_mark = YYFINAL;",
|
||||
" *++yystack.l_mark = yyval;",
|
||||
" if (yychar < 0)",
|
||||
" {",
|
||||
" if ((yychar = YYLEX) < 0) yychar = 0;",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" {",
|
||||
" yys = 0;",
|
||||
" if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
|
||||
" if (!yys) yys = \"illegal-symbol\";",
|
||||
" printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
|
||||
" YYPREFIX, YYFINAL, yychar, yys);",
|
||||
" }",
|
||||
"#endif",
|
||||
" }",
|
||||
" if (yychar == 0) goto yyaccept;",
|
||||
" goto yyloop;",
|
||||
" }",
|
||||
" if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&",
|
||||
" yyn <= YYTABLESIZE && yycheck[yyn] == yystate)",
|
||||
" yystate = yytable[yyn];",
|
||||
" else",
|
||||
" yystate = yydgoto[yym];",
|
||||
"#if YYDEBUG",
|
||||
" if (yydebug)",
|
||||
" printf(\"%sdebug: after reduction, shifting from state %d \\",
|
||||
"to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);",
|
||||
"#endif",
|
||||
" if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))",
|
||||
" {",
|
||||
" goto yyoverflow;",
|
||||
" }",
|
||||
" *++yystack.s_mark = (short) yystate;",
|
||||
" *++yystack.l_mark = yyval;",
|
||||
" goto yyloop;",
|
||||
"",
|
||||
"yyoverflow:",
|
||||
0
|
||||
};
|
||||
|
||||
const char *const trailer_2[] =
|
||||
{
|
||||
"",
|
||||
"yyabort:",
|
||||
" yyfreestack(&yystack);",
|
||||
" return (1);",
|
||||
"",
|
||||
"yyaccept:",
|
||||
" yyfreestack(&yystack);",
|
||||
" return (0);",
|
||||
"}",
|
||||
0
|
||||
};
|
||||
|
||||
void
|
||||
write_section(FILE * fp, const char *const section[])
|
||||
{
|
||||
int c;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 0; (s = section[i]) != 0; ++i)
|
||||
{
|
||||
while ((c = *s) != 0)
|
||||
{
|
||||
putc(c, fp);
|
||||
++s;
|
||||
}
|
||||
if (fp == code_file)
|
||||
++outline;
|
||||
putc('\n', fp);
|
||||
}
|
||||
}
|
||||
121
external/bsd/byacc/dist/symtab.c
vendored
Normal file
121
external/bsd/byacc/dist/symtab.c
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/* $NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
|
||||
/* Id: symtab.c,v 1.9 2010/11/24 15:12:29 tom Exp */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
|
||||
|
||||
/* TABLE_SIZE is the number of entries in the symbol table. */
|
||||
/* TABLE_SIZE must be a power of two. */
|
||||
|
||||
#define TABLE_SIZE 1024
|
||||
|
||||
static bucket **symbol_table = 0;
|
||||
bucket *first_symbol;
|
||||
bucket *last_symbol;
|
||||
|
||||
static int
|
||||
hash(const char *name)
|
||||
{
|
||||
const char *s;
|
||||
int c, k;
|
||||
|
||||
assert(name && *name);
|
||||
s = name;
|
||||
k = *s;
|
||||
while ((c = *++s) != 0)
|
||||
k = (31 * k + c) & (TABLE_SIZE - 1);
|
||||
|
||||
return (k);
|
||||
}
|
||||
|
||||
bucket *
|
||||
make_bucket(const char *name)
|
||||
{
|
||||
bucket *bp;
|
||||
|
||||
assert(name != 0);
|
||||
|
||||
bp = (bucket *)MALLOC(sizeof(bucket));
|
||||
NO_SPACE(bp);
|
||||
|
||||
bp->link = 0;
|
||||
bp->next = 0;
|
||||
|
||||
bp->name = MALLOC(strlen(name) + 1);
|
||||
NO_SPACE(bp->name);
|
||||
|
||||
bp->tag = 0;
|
||||
bp->value = UNDEFINED;
|
||||
bp->index = 0;
|
||||
bp->prec = 0;
|
||||
bp->class = UNKNOWN;
|
||||
bp->assoc = TOKEN;
|
||||
strcpy(bp->name, name);
|
||||
|
||||
return (bp);
|
||||
}
|
||||
|
||||
bucket *
|
||||
lookup(const char *name)
|
||||
{
|
||||
bucket *bp, **bpp;
|
||||
|
||||
bpp = symbol_table + hash(name);
|
||||
bp = *bpp;
|
||||
|
||||
while (bp)
|
||||
{
|
||||
if (strcmp(name, bp->name) == 0)
|
||||
return (bp);
|
||||
bpp = &bp->link;
|
||||
bp = *bpp;
|
||||
}
|
||||
|
||||
*bpp = bp = make_bucket(name);
|
||||
last_symbol->next = bp;
|
||||
last_symbol = bp;
|
||||
|
||||
return (bp);
|
||||
}
|
||||
|
||||
void
|
||||
create_symbol_table(void)
|
||||
{
|
||||
int i;
|
||||
bucket *bp;
|
||||
|
||||
symbol_table = (bucket **)MALLOC(TABLE_SIZE * sizeof(bucket *));
|
||||
NO_SPACE(symbol_table);
|
||||
|
||||
for (i = 0; i < TABLE_SIZE; i++)
|
||||
symbol_table[i] = 0;
|
||||
|
||||
bp = make_bucket("error");
|
||||
bp->index = 1;
|
||||
bp->class = TERM;
|
||||
|
||||
first_symbol = bp;
|
||||
last_symbol = bp;
|
||||
symbol_table[hash("error")] = bp;
|
||||
}
|
||||
|
||||
void
|
||||
free_symbol_table(void)
|
||||
{
|
||||
FREE(symbol_table);
|
||||
symbol_table = 0;
|
||||
}
|
||||
|
||||
void
|
||||
free_symbols(void)
|
||||
{
|
||||
bucket *p, *q;
|
||||
|
||||
for (p = first_symbol; p; p = q)
|
||||
{
|
||||
q = p->next;
|
||||
FREE(p);
|
||||
}
|
||||
}
|
||||
4
external/bsd/byacc/dist/test/README
vendored
Normal file
4
external/bsd/byacc/dist/test/README
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
-- $Id: README,v 1.2 2009/10/29 00:56:20 christos Exp $
|
||||
|
||||
The files in this directory are input (.y) and output (.output, .tab.c, .tab.h)
|
||||
examples.
|
||||
461
external/bsd/byacc/dist/test/calc.output
vendored
Normal file
461
external/bsd/byacc/dist/test/calc.output
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
0 $accept : list $end
|
||||
|
||||
1 list :
|
||||
2 | list stat '\n'
|
||||
3 | list error '\n'
|
||||
|
||||
4 stat : expr
|
||||
5 | LETTER '=' expr
|
||||
|
||||
6 expr : '(' expr ')'
|
||||
7 | expr '+' expr
|
||||
8 | expr '-' expr
|
||||
9 | expr '*' expr
|
||||
10 | expr '/' expr
|
||||
11 | expr '%' expr
|
||||
12 | expr '&' expr
|
||||
13 | expr '|' expr
|
||||
14 | '-' expr
|
||||
15 | LETTER
|
||||
16 | number
|
||||
|
||||
17 number : DIGIT
|
||||
18 | number DIGIT
|
||||
|
||||
state 0
|
||||
$accept : . list $end (0)
|
||||
list : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
list goto 1
|
||||
|
||||
|
||||
state 1
|
||||
$accept : list . $end (0)
|
||||
list : list . stat '\n' (2)
|
||||
list : list . error '\n' (3)
|
||||
|
||||
$end accept
|
||||
error shift 2
|
||||
DIGIT shift 3
|
||||
LETTER shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
stat goto 7
|
||||
expr goto 8
|
||||
number goto 9
|
||||
|
||||
|
||||
state 2
|
||||
list : list error . '\n' (3)
|
||||
|
||||
'\n' shift 10
|
||||
. error
|
||||
|
||||
|
||||
state 3
|
||||
number : DIGIT . (17)
|
||||
|
||||
. reduce 17
|
||||
|
||||
|
||||
state 4
|
||||
stat : LETTER . '=' expr (5)
|
||||
expr : LETTER . (15)
|
||||
|
||||
'=' shift 11
|
||||
'|' reduce 15
|
||||
'&' reduce 15
|
||||
'+' reduce 15
|
||||
'-' reduce 15
|
||||
'*' reduce 15
|
||||
'/' reduce 15
|
||||
'%' reduce 15
|
||||
'\n' reduce 15
|
||||
|
||||
|
||||
state 5
|
||||
expr : '-' . expr (14)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 13
|
||||
number goto 9
|
||||
|
||||
|
||||
state 6
|
||||
expr : '(' . expr ')' (6)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
number goto 9
|
||||
|
||||
|
||||
state 7
|
||||
list : list stat . '\n' (2)
|
||||
|
||||
'\n' shift 15
|
||||
. error
|
||||
|
||||
|
||||
state 8
|
||||
stat : expr . (4)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 4
|
||||
|
||||
|
||||
state 9
|
||||
expr : number . (16)
|
||||
number : number . DIGIT (18)
|
||||
|
||||
DIGIT shift 23
|
||||
'|' reduce 16
|
||||
'&' reduce 16
|
||||
'+' reduce 16
|
||||
'-' reduce 16
|
||||
'*' reduce 16
|
||||
'/' reduce 16
|
||||
'%' reduce 16
|
||||
'\n' reduce 16
|
||||
')' reduce 16
|
||||
|
||||
|
||||
state 10
|
||||
list : list error '\n' . (3)
|
||||
|
||||
. reduce 3
|
||||
|
||||
|
||||
state 11
|
||||
stat : LETTER '=' . expr (5)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 24
|
||||
number goto 9
|
||||
|
||||
|
||||
state 12
|
||||
expr : LETTER . (15)
|
||||
|
||||
. reduce 15
|
||||
|
||||
|
||||
state 13
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : '-' expr . (14)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 14
|
||||
expr : '(' expr . ')' (6)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
')' shift 25
|
||||
. error
|
||||
|
||||
|
||||
state 15
|
||||
list : list stat '\n' . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr '|' . expr (13)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 26
|
||||
number goto 9
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr '&' . expr (12)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 27
|
||||
number goto 9
|
||||
|
||||
|
||||
state 18
|
||||
expr : expr '+' . expr (7)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 28
|
||||
number goto 9
|
||||
|
||||
|
||||
state 19
|
||||
expr : expr '-' . expr (8)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 29
|
||||
number goto 9
|
||||
|
||||
|
||||
state 20
|
||||
expr : expr '*' . expr (9)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 30
|
||||
number goto 9
|
||||
|
||||
|
||||
state 21
|
||||
expr : expr '/' . expr (10)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 31
|
||||
number goto 9
|
||||
|
||||
|
||||
state 22
|
||||
expr : expr '%' . expr (11)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 32
|
||||
number goto 9
|
||||
|
||||
|
||||
state 23
|
||||
number : number DIGIT . (18)
|
||||
|
||||
. reduce 18
|
||||
|
||||
|
||||
state 24
|
||||
stat : LETTER '=' expr . (5)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 5
|
||||
|
||||
|
||||
state 25
|
||||
expr : '(' expr ')' . (6)
|
||||
|
||||
. reduce 6
|
||||
|
||||
|
||||
state 26
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : expr '|' expr . (13)
|
||||
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 13
|
||||
'\n' reduce 13
|
||||
')' reduce 13
|
||||
|
||||
|
||||
state 27
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr '&' expr . (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 12
|
||||
'&' reduce 12
|
||||
'\n' reduce 12
|
||||
')' reduce 12
|
||||
|
||||
|
||||
state 28
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr '+' expr . (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 7
|
||||
'&' reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
'\n' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 29
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr '-' expr . (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 8
|
||||
'&' reduce 8
|
||||
'+' reduce 8
|
||||
'-' reduce 8
|
||||
'\n' reduce 8
|
||||
')' reduce 8
|
||||
|
||||
|
||||
state 30
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr '*' expr . (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 31
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr '/' expr . (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 32
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr '%' expr . (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 11
|
||||
|
||||
|
||||
16 terminals, 5 nonterminals
|
||||
19 grammar rules, 33 states
|
||||
673
external/bsd/byacc/dist/test/calc.tab.c
vendored
Normal file
673
external/bsd/byacc/dist/test/calc.tab.c
vendored
Normal file
@@ -0,0 +1,673 @@
|
||||
/* $NetBSD: calc.tab.c,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc_"
|
||||
|
||||
#define YYPURE 0
|
||||
|
||||
#line 2 "calc.y"
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
int regs[26];
|
||||
int base;
|
||||
|
||||
#line 106 "calc.tab.c"
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(void)
|
||||
# define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
#define YYERRCODE 256
|
||||
static const short calc_lhs[] = { -1,
|
||||
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 3,
|
||||
};
|
||||
static const short calc_len[] = { 2,
|
||||
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 1, 1, 1, 2,
|
||||
};
|
||||
static const short calc_defred[] = { 1,
|
||||
0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
|
||||
0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
|
||||
0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
|
||||
10, 11,
|
||||
};
|
||||
static const short calc_dgoto[] = { 1,
|
||||
7, 8, 9,
|
||||
};
|
||||
static const short calc_sindex[] = { 0,
|
||||
-40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
|
||||
-38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
|
||||
-38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc_rindex[] = { 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc_gindex[] = { 0,
|
||||
0, 65, 0,
|
||||
};
|
||||
#define YYTABLESIZE 220
|
||||
static const short calc_table[] = { 6,
|
||||
16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
|
||||
15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
|
||||
0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
|
||||
0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
|
||||
0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
|
||||
8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
|
||||
0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
|
||||
14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
|
||||
26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
|
||||
0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
|
||||
0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
|
||||
0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
|
||||
0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
|
||||
0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
|
||||
};
|
||||
static const short calc_check[] = { 40,
|
||||
10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
|
||||
10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
|
||||
-1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
|
||||
-1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
|
||||
-1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
|
||||
38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
|
||||
-1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
|
||||
6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
|
||||
16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
|
||||
-1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
|
||||
-1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
|
||||
-1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
|
||||
-1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
|
||||
};
|
||||
#define YYFINAL 1
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 259
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : list",
|
||||
"list :",
|
||||
"list : list stat '\\n'",
|
||||
"list : list error '\\n'",
|
||||
"stat : expr",
|
||||
"stat : LETTER '=' expr",
|
||||
"expr : '(' expr ')'",
|
||||
"expr : expr '+' expr",
|
||||
"expr : expr '-' expr",
|
||||
"expr : expr '*' expr",
|
||||
"expr : expr '/' expr",
|
||||
"expr : expr '%' expr",
|
||||
"expr : expr '&' expr",
|
||||
"expr : expr '|' expr",
|
||||
"expr : '-' expr",
|
||||
"expr : LETTER",
|
||||
"expr : number",
|
||||
"number : DIGIT",
|
||||
"number : number DIGIT",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
/* variables for the parser stack */
|
||||
static YYSTACKDATA yystack;
|
||||
#line 63 "calc.y"
|
||||
/* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
while(!feof(stdin)) {
|
||||
yyparse();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
yylval = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
yylval = c - '0';
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
#line 345 "calc.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
case 3:
|
||||
#line 25 "calc.y"
|
||||
{ yyerrok ; }
|
||||
break;
|
||||
case 4:
|
||||
#line 29 "calc.y"
|
||||
{ printf("%d\n",yystack.l_mark[0]);}
|
||||
break;
|
||||
case 5:
|
||||
#line 31 "calc.y"
|
||||
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
|
||||
break;
|
||||
case 6:
|
||||
#line 35 "calc.y"
|
||||
{ yyval = yystack.l_mark[-1]; }
|
||||
break;
|
||||
case 7:
|
||||
#line 37 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
|
||||
break;
|
||||
case 8:
|
||||
#line 39 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 9:
|
||||
#line 41 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
|
||||
break;
|
||||
case 10:
|
||||
#line 43 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
|
||||
break;
|
||||
case 11:
|
||||
#line 45 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
|
||||
break;
|
||||
case 12:
|
||||
#line 47 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
|
||||
break;
|
||||
case 13:
|
||||
#line 49 "calc.y"
|
||||
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
|
||||
break;
|
||||
case 14:
|
||||
#line 51 "calc.y"
|
||||
{ yyval = - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 15:
|
||||
#line 53 "calc.y"
|
||||
{ yyval = regs[yystack.l_mark[0]]; }
|
||||
break;
|
||||
case 17:
|
||||
#line 58 "calc.y"
|
||||
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
|
||||
break;
|
||||
case 18:
|
||||
#line 60 "calc.y"
|
||||
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
|
||||
break;
|
||||
#line 611 "calc.tab.c"
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
5
external/bsd/byacc/dist/test/calc.tab.h
vendored
Normal file
5
external/bsd/byacc/dist/test/calc.tab.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: calc.tab.h,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
110
external/bsd/byacc/dist/test/calc.y
vendored
Normal file
110
external/bsd/byacc/dist/test/calc.y
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/* $NetBSD: calc.y,v 1.1.1.4 2011/09/10 21:22:08 christos Exp $ */
|
||||
|
||||
%{
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
int regs[26];
|
||||
int base;
|
||||
|
||||
%}
|
||||
|
||||
%start list
|
||||
|
||||
%token DIGIT LETTER
|
||||
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%left UMINUS /* supplies precedence for unary minus */
|
||||
|
||||
%% /* beginning of rules section */
|
||||
|
||||
list : /* empty */
|
||||
| list stat '\n'
|
||||
| list error '\n'
|
||||
{ yyerrok ; }
|
||||
;
|
||||
|
||||
stat : expr
|
||||
{ printf("%d\n",$1);}
|
||||
| LETTER '=' expr
|
||||
{ regs[$1] = $3; }
|
||||
;
|
||||
|
||||
expr : '(' expr ')'
|
||||
{ $$ = $2; }
|
||||
| expr '+' expr
|
||||
{ $$ = $1 + $3; }
|
||||
| expr '-' expr
|
||||
{ $$ = $1 - $3; }
|
||||
| expr '*' expr
|
||||
{ $$ = $1 * $3; }
|
||||
| expr '/' expr
|
||||
{ $$ = $1 / $3; }
|
||||
| expr '%' expr
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| '-' expr %prec UMINUS
|
||||
{ $$ = - $2; }
|
||||
| LETTER
|
||||
{ $$ = regs[$1]; }
|
||||
| number
|
||||
;
|
||||
|
||||
number: DIGIT
|
||||
{ $$ = $1; base = ($1==0) ? 8 : 10; }
|
||||
| number DIGIT
|
||||
{ $$ = base * $1 + $2; }
|
||||
;
|
||||
|
||||
%% /* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
while(!feof(stdin)) {
|
||||
yyparse();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
yylval = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
yylval = c - '0';
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
877
external/bsd/byacc/dist/test/calc1.output
vendored
Normal file
877
external/bsd/byacc/dist/test/calc1.output
vendored
Normal file
@@ -0,0 +1,877 @@
|
||||
0 $accept : line $end
|
||||
|
||||
1 lines :
|
||||
2 | lines line
|
||||
|
||||
3 line : dexp '\n'
|
||||
4 | vexp '\n'
|
||||
5 | DREG '=' dexp '\n'
|
||||
6 | VREG '=' vexp '\n'
|
||||
7 | error '\n'
|
||||
|
||||
8 dexp : CONST
|
||||
9 | DREG
|
||||
10 | dexp '+' dexp
|
||||
11 | dexp '-' dexp
|
||||
12 | dexp '*' dexp
|
||||
13 | dexp '/' dexp
|
||||
14 | '-' dexp
|
||||
15 | '(' dexp ')'
|
||||
|
||||
16 vexp : dexp
|
||||
17 | '(' dexp ',' dexp ')'
|
||||
18 | VREG
|
||||
19 | vexp '+' vexp
|
||||
20 | dexp '+' vexp
|
||||
21 | vexp '-' vexp
|
||||
22 | dexp '-' vexp
|
||||
23 | vexp '*' vexp
|
||||
24 | dexp '*' vexp
|
||||
25 | vexp '/' vexp
|
||||
26 | dexp '/' vexp
|
||||
27 | '-' vexp
|
||||
28 | '(' vexp ')'
|
||||
|
||||
state 0
|
||||
$accept : . line $end (0)
|
||||
|
||||
error shift 1
|
||||
DREG shift 2
|
||||
VREG shift 3
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
line goto 7
|
||||
dexp goto 8
|
||||
vexp goto 9
|
||||
|
||||
|
||||
state 1
|
||||
line : error . '\n' (7)
|
||||
|
||||
'\n' shift 10
|
||||
. error
|
||||
|
||||
|
||||
state 2
|
||||
line : DREG . '=' dexp '\n' (5)
|
||||
dexp : DREG . (9)
|
||||
|
||||
'=' shift 11
|
||||
'+' reduce 9
|
||||
'-' reduce 9
|
||||
'*' reduce 9
|
||||
'/' reduce 9
|
||||
'\n' reduce 9
|
||||
|
||||
|
||||
state 3
|
||||
line : VREG . '=' vexp '\n' (6)
|
||||
vexp : VREG . (18)
|
||||
|
||||
'=' shift 12
|
||||
'+' reduce 18
|
||||
'-' reduce 18
|
||||
'*' reduce 18
|
||||
'/' reduce 18
|
||||
'\n' reduce 18
|
||||
|
||||
|
||||
state 4
|
||||
dexp : CONST . (8)
|
||||
|
||||
. reduce 8
|
||||
|
||||
|
||||
state 5
|
||||
dexp : '-' . dexp (14)
|
||||
vexp : '-' . vexp (27)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 15
|
||||
vexp goto 16
|
||||
|
||||
|
||||
state 6
|
||||
dexp : '(' . dexp ')' (15)
|
||||
vexp : '(' . dexp ',' dexp ')' (17)
|
||||
vexp : '(' . vexp ')' (28)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 17
|
||||
vexp goto 18
|
||||
|
||||
|
||||
state 7
|
||||
$accept : line . $end (0)
|
||||
|
||||
$end accept
|
||||
|
||||
|
||||
8: shift/reduce conflict (shift 19, reduce 16) on '+'
|
||||
8: shift/reduce conflict (shift 20, reduce 16) on '-'
|
||||
8: shift/reduce conflict (shift 21, reduce 16) on '*'
|
||||
8: shift/reduce conflict (shift 22, reduce 16) on '/'
|
||||
8: shift/reduce conflict (shift 23, reduce 16) on '\n'
|
||||
state 8
|
||||
line : dexp . '\n' (3)
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
'+' shift 19
|
||||
'-' shift 20
|
||||
'*' shift 21
|
||||
'/' shift 22
|
||||
'\n' shift 23
|
||||
|
||||
|
||||
state 9
|
||||
line : vexp . '\n' (4)
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
'+' shift 24
|
||||
'-' shift 25
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
'\n' shift 28
|
||||
. error
|
||||
|
||||
|
||||
state 10
|
||||
line : error '\n' . (7)
|
||||
|
||||
. reduce 7
|
||||
|
||||
|
||||
state 11
|
||||
line : DREG '=' . dexp '\n' (5)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 31
|
||||
|
||||
|
||||
state 12
|
||||
line : VREG '=' . vexp '\n' (6)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 32
|
||||
vexp goto 33
|
||||
|
||||
|
||||
state 13
|
||||
dexp : DREG . (9)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 14
|
||||
vexp : VREG . (18)
|
||||
|
||||
. reduce 18
|
||||
|
||||
|
||||
15: reduce/reduce conflict (reduce 14, reduce 16) on '+'
|
||||
15: reduce/reduce conflict (reduce 14, reduce 16) on '-'
|
||||
15: reduce/reduce conflict (reduce 14, reduce 16) on '*'
|
||||
15: reduce/reduce conflict (reduce 14, reduce 16) on '/'
|
||||
15: reduce/reduce conflict (reduce 14, reduce 16) on '\n'
|
||||
15: reduce/reduce conflict (reduce 14, reduce 16) on ')'
|
||||
state 15
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
dexp : '-' dexp . (14)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 16
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
vexp : '-' vexp . (27)
|
||||
|
||||
. reduce 27
|
||||
|
||||
|
||||
17: shift/reduce conflict (shift 19, reduce 16) on '+'
|
||||
17: shift/reduce conflict (shift 20, reduce 16) on '-'
|
||||
17: shift/reduce conflict (shift 21, reduce 16) on '*'
|
||||
17: shift/reduce conflict (shift 22, reduce 16) on '/'
|
||||
17: shift/reduce conflict (shift 34, reduce 16) on ')'
|
||||
state 17
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
dexp : '(' dexp . ')' (15)
|
||||
vexp : dexp . (16)
|
||||
vexp : '(' dexp . ',' dexp ')' (17)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
'+' shift 19
|
||||
'-' shift 20
|
||||
'*' shift 21
|
||||
'/' shift 22
|
||||
')' shift 34
|
||||
',' shift 35
|
||||
|
||||
|
||||
state 18
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
vexp : '(' vexp . ')' (28)
|
||||
|
||||
'+' shift 24
|
||||
'-' shift 25
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
')' shift 36
|
||||
. error
|
||||
|
||||
|
||||
state 19
|
||||
dexp : dexp '+' . dexp (10)
|
||||
vexp : dexp '+' . vexp (20)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 37
|
||||
vexp goto 38
|
||||
|
||||
|
||||
state 20
|
||||
dexp : dexp '-' . dexp (11)
|
||||
vexp : dexp '-' . vexp (22)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 39
|
||||
vexp goto 40
|
||||
|
||||
|
||||
state 21
|
||||
dexp : dexp '*' . dexp (12)
|
||||
vexp : dexp '*' . vexp (24)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 41
|
||||
vexp goto 42
|
||||
|
||||
|
||||
state 22
|
||||
dexp : dexp '/' . dexp (13)
|
||||
vexp : dexp '/' . vexp (26)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 43
|
||||
vexp goto 44
|
||||
|
||||
|
||||
state 23
|
||||
line : dexp '\n' . (3)
|
||||
|
||||
. reduce 3
|
||||
|
||||
|
||||
state 24
|
||||
vexp : vexp '+' . vexp (19)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 32
|
||||
vexp goto 45
|
||||
|
||||
|
||||
state 25
|
||||
vexp : vexp '-' . vexp (21)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 32
|
||||
vexp goto 46
|
||||
|
||||
|
||||
state 26
|
||||
vexp : vexp '*' . vexp (23)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 32
|
||||
vexp goto 47
|
||||
|
||||
|
||||
state 27
|
||||
vexp : vexp '/' . vexp (25)
|
||||
|
||||
DREG shift 13
|
||||
VREG shift 14
|
||||
CONST shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
dexp goto 32
|
||||
vexp goto 48
|
||||
|
||||
|
||||
state 28
|
||||
line : vexp '\n' . (4)
|
||||
|
||||
. reduce 4
|
||||
|
||||
|
||||
state 29
|
||||
dexp : '-' . dexp (14)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 49
|
||||
|
||||
|
||||
state 30
|
||||
dexp : '(' . dexp ')' (15)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 50
|
||||
|
||||
|
||||
state 31
|
||||
line : DREG '=' dexp . '\n' (5)
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
|
||||
'+' shift 51
|
||||
'-' shift 52
|
||||
'*' shift 53
|
||||
'/' shift 54
|
||||
'\n' shift 55
|
||||
. error
|
||||
|
||||
|
||||
32: shift/reduce conflict (shift 19, reduce 16) on '+'
|
||||
32: shift/reduce conflict (shift 20, reduce 16) on '-'
|
||||
32: shift/reduce conflict (shift 21, reduce 16) on '*'
|
||||
32: shift/reduce conflict (shift 22, reduce 16) on '/'
|
||||
state 32
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
'+' shift 19
|
||||
'-' shift 20
|
||||
'*' shift 21
|
||||
'/' shift 22
|
||||
'\n' reduce 16
|
||||
')' reduce 16
|
||||
|
||||
|
||||
state 33
|
||||
line : VREG '=' vexp . '\n' (6)
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
'+' shift 24
|
||||
'-' shift 25
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
'\n' shift 56
|
||||
. error
|
||||
|
||||
|
||||
state 34
|
||||
dexp : '(' dexp ')' . (15)
|
||||
|
||||
. reduce 15
|
||||
|
||||
|
||||
state 35
|
||||
vexp : '(' dexp ',' . dexp ')' (17)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 57
|
||||
|
||||
|
||||
state 36
|
||||
vexp : '(' vexp ')' . (28)
|
||||
|
||||
. reduce 28
|
||||
|
||||
|
||||
37: reduce/reduce conflict (reduce 10, reduce 16) on '+'
|
||||
37: reduce/reduce conflict (reduce 10, reduce 16) on '-'
|
||||
37: shift/reduce conflict (shift 21, reduce 16) on '*'
|
||||
37: shift/reduce conflict (shift 22, reduce 16) on '/'
|
||||
37: reduce/reduce conflict (reduce 10, reduce 16) on '\n'
|
||||
37: reduce/reduce conflict (reduce 10, reduce 16) on ')'
|
||||
state 37
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp '+' dexp . (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
'*' shift 21
|
||||
'/' shift 22
|
||||
'+' reduce 10
|
||||
'-' reduce 10
|
||||
'\n' reduce 10
|
||||
')' reduce 10
|
||||
',' reduce 10
|
||||
|
||||
|
||||
state 38
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : dexp '+' vexp . (20)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
'+' reduce 20
|
||||
'-' reduce 20
|
||||
'\n' reduce 20
|
||||
')' reduce 20
|
||||
|
||||
|
||||
39: reduce/reduce conflict (reduce 11, reduce 16) on '+'
|
||||
39: reduce/reduce conflict (reduce 11, reduce 16) on '-'
|
||||
39: shift/reduce conflict (shift 21, reduce 16) on '*'
|
||||
39: shift/reduce conflict (shift 22, reduce 16) on '/'
|
||||
39: reduce/reduce conflict (reduce 11, reduce 16) on '\n'
|
||||
39: reduce/reduce conflict (reduce 11, reduce 16) on ')'
|
||||
state 39
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp '-' dexp . (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
'*' shift 21
|
||||
'/' shift 22
|
||||
'+' reduce 11
|
||||
'-' reduce 11
|
||||
'\n' reduce 11
|
||||
')' reduce 11
|
||||
',' reduce 11
|
||||
|
||||
|
||||
state 40
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : dexp '-' vexp . (22)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
'+' reduce 22
|
||||
'-' reduce 22
|
||||
'\n' reduce 22
|
||||
')' reduce 22
|
||||
|
||||
|
||||
41: reduce/reduce conflict (reduce 12, reduce 16) on '+'
|
||||
41: reduce/reduce conflict (reduce 12, reduce 16) on '-'
|
||||
41: reduce/reduce conflict (reduce 12, reduce 16) on '*'
|
||||
41: reduce/reduce conflict (reduce 12, reduce 16) on '/'
|
||||
41: reduce/reduce conflict (reduce 12, reduce 16) on '\n'
|
||||
41: reduce/reduce conflict (reduce 12, reduce 16) on ')'
|
||||
state 41
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp '*' dexp . (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
. reduce 12
|
||||
|
||||
|
||||
state 42
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : dexp '*' vexp . (24)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
. reduce 24
|
||||
|
||||
|
||||
43: reduce/reduce conflict (reduce 13, reduce 16) on '+'
|
||||
43: reduce/reduce conflict (reduce 13, reduce 16) on '-'
|
||||
43: reduce/reduce conflict (reduce 13, reduce 16) on '*'
|
||||
43: reduce/reduce conflict (reduce 13, reduce 16) on '/'
|
||||
43: reduce/reduce conflict (reduce 13, reduce 16) on '\n'
|
||||
43: reduce/reduce conflict (reduce 13, reduce 16) on ')'
|
||||
state 43
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
dexp : dexp '/' dexp . (13)
|
||||
vexp : dexp . (16)
|
||||
vexp : dexp . '+' vexp (20)
|
||||
vexp : dexp . '-' vexp (22)
|
||||
vexp : dexp . '*' vexp (24)
|
||||
vexp : dexp . '/' vexp (26)
|
||||
|
||||
. reduce 13
|
||||
|
||||
|
||||
state 44
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
vexp : dexp '/' vexp . (26)
|
||||
|
||||
. reduce 26
|
||||
|
||||
|
||||
state 45
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp '+' vexp . (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
'+' reduce 19
|
||||
'-' reduce 19
|
||||
'\n' reduce 19
|
||||
')' reduce 19
|
||||
|
||||
|
||||
state 46
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp '-' vexp . (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
'*' shift 26
|
||||
'/' shift 27
|
||||
'+' reduce 21
|
||||
'-' reduce 21
|
||||
'\n' reduce 21
|
||||
')' reduce 21
|
||||
|
||||
|
||||
state 47
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp '*' vexp . (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
|
||||
. reduce 23
|
||||
|
||||
|
||||
state 48
|
||||
vexp : vexp . '+' vexp (19)
|
||||
vexp : vexp . '-' vexp (21)
|
||||
vexp : vexp . '*' vexp (23)
|
||||
vexp : vexp . '/' vexp (25)
|
||||
vexp : vexp '/' vexp . (25)
|
||||
|
||||
. reduce 25
|
||||
|
||||
|
||||
state 49
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
dexp : '-' dexp . (14)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 50
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
dexp : '(' dexp . ')' (15)
|
||||
|
||||
'+' shift 51
|
||||
'-' shift 52
|
||||
'*' shift 53
|
||||
'/' shift 54
|
||||
')' shift 34
|
||||
. error
|
||||
|
||||
|
||||
state 51
|
||||
dexp : dexp '+' . dexp (10)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 58
|
||||
|
||||
|
||||
state 52
|
||||
dexp : dexp '-' . dexp (11)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 59
|
||||
|
||||
|
||||
state 53
|
||||
dexp : dexp '*' . dexp (12)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 60
|
||||
|
||||
|
||||
state 54
|
||||
dexp : dexp '/' . dexp (13)
|
||||
|
||||
DREG shift 13
|
||||
CONST shift 4
|
||||
'-' shift 29
|
||||
'(' shift 30
|
||||
. error
|
||||
|
||||
dexp goto 61
|
||||
|
||||
|
||||
state 55
|
||||
line : DREG '=' dexp '\n' . (5)
|
||||
|
||||
. reduce 5
|
||||
|
||||
|
||||
state 56
|
||||
line : VREG '=' vexp '\n' . (6)
|
||||
|
||||
. reduce 6
|
||||
|
||||
|
||||
state 57
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
vexp : '(' dexp ',' dexp . ')' (17)
|
||||
|
||||
'+' shift 51
|
||||
'-' shift 52
|
||||
'*' shift 53
|
||||
'/' shift 54
|
||||
')' shift 62
|
||||
. error
|
||||
|
||||
|
||||
state 58
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp '+' dexp . (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
|
||||
'*' shift 53
|
||||
'/' shift 54
|
||||
'+' reduce 10
|
||||
'-' reduce 10
|
||||
'\n' reduce 10
|
||||
')' reduce 10
|
||||
|
||||
|
||||
state 59
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp '-' dexp . (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
|
||||
'*' shift 53
|
||||
'/' shift 54
|
||||
'+' reduce 11
|
||||
'-' reduce 11
|
||||
'\n' reduce 11
|
||||
')' reduce 11
|
||||
|
||||
|
||||
state 60
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp '*' dexp . (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
|
||||
. reduce 12
|
||||
|
||||
|
||||
state 61
|
||||
dexp : dexp . '+' dexp (10)
|
||||
dexp : dexp . '-' dexp (11)
|
||||
dexp : dexp . '*' dexp (12)
|
||||
dexp : dexp . '/' dexp (13)
|
||||
dexp : dexp '/' dexp . (13)
|
||||
|
||||
. reduce 13
|
||||
|
||||
|
||||
state 62
|
||||
vexp : '(' dexp ',' dexp ')' . (17)
|
||||
|
||||
. reduce 17
|
||||
|
||||
|
||||
Rules never reduced:
|
||||
lines : (1)
|
||||
lines : lines line (2)
|
||||
|
||||
|
||||
State 8 contains 5 shift/reduce conflicts.
|
||||
State 15 contains 6 reduce/reduce conflicts.
|
||||
State 17 contains 5 shift/reduce conflicts.
|
||||
State 32 contains 4 shift/reduce conflicts.
|
||||
State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts.
|
||||
State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts.
|
||||
State 41 contains 6 reduce/reduce conflicts.
|
||||
State 43 contains 6 reduce/reduce conflicts.
|
||||
|
||||
|
||||
15 terminals, 5 nonterminals
|
||||
29 grammar rules, 63 states
|
||||
915
external/bsd/byacc/dist/test/calc1.tab.c
vendored
Normal file
915
external/bsd/byacc/dist/test/calc1.tab.c
vendored
Normal file
@@ -0,0 +1,915 @@
|
||||
/* $NetBSD: calc1.tab.c,v 1.1.1.3 2011/09/10 21:22:08 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc1_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc1_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc1_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc1_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc1_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc1_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc1_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc1_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc1_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc1_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc1_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc1_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc1_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc1_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc1_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc1_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc1_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc1_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc1_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc1_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc1_"
|
||||
|
||||
#define YYPURE 0
|
||||
|
||||
#line 2 "calc1.y"
|
||||
|
||||
/* http://dinosaur.compilertools.net/yacc/index.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef struct interval
|
||||
{
|
||||
double lo, hi;
|
||||
}
|
||||
INTERVAL;
|
||||
|
||||
INTERVAL vmul(double, double, INTERVAL);
|
||||
INTERVAL vdiv(double, double, INTERVAL);
|
||||
|
||||
int dcheck(INTERVAL);
|
||||
|
||||
double dreg[26];
|
||||
INTERVAL vreg[26];
|
||||
|
||||
#line 28 "calc1.y"
|
||||
#ifdef YYSTYPE
|
||||
#undef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
#ifndef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
typedef union
|
||||
{
|
||||
int ival;
|
||||
double dval;
|
||||
INTERVAL vval;
|
||||
} YYSTYPE;
|
||||
#endif /* !YYSTYPE_IS_DECLARED */
|
||||
#line 136 "calc1.tab.c"
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(void)
|
||||
# define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define DREG 257
|
||||
#define VREG 258
|
||||
#define CONST 259
|
||||
#define UMINUS 260
|
||||
#define YYERRCODE 256
|
||||
static const short calc1_lhs[] = { -1,
|
||||
3, 3, 0, 0, 0, 0, 0, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2,
|
||||
};
|
||||
static const short calc1_len[] = { 2,
|
||||
0, 2, 2, 2, 4, 4, 2, 1, 1, 3,
|
||||
3, 3, 3, 2, 3, 1, 5, 1, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 2, 3,
|
||||
};
|
||||
static const short calc1_defred[] = { 0,
|
||||
0, 0, 0, 8, 0, 0, 0, 0, 0, 7,
|
||||
0, 0, 9, 18, 14, 27, 0, 0, 0, 0,
|
||||
0, 0, 3, 0, 0, 0, 0, 4, 0, 0,
|
||||
0, 0, 0, 15, 0, 28, 0, 0, 0, 0,
|
||||
12, 24, 13, 26, 0, 0, 23, 25, 14, 0,
|
||||
0, 0, 0, 0, 5, 6, 0, 0, 0, 12,
|
||||
13, 17,
|
||||
};
|
||||
static const short calc1_dgoto[] = { 7,
|
||||
32, 9, 0,
|
||||
};
|
||||
static const short calc1_sindex[] = { -40,
|
||||
-8, -48, -47, 0, -37, -37, 0, 2, 17, 0,
|
||||
-34, -37, 0, 0, 0, 0, -25, 90, -37, -37,
|
||||
-37, -37, 0, -37, -37, -37, -37, 0, -34, -34,
|
||||
25, 125, 31, 0, -34, 0, -11, 37, -11, 37,
|
||||
0, 0, 0, 0, 37, 37, 0, 0, 0, 111,
|
||||
-34, -34, -34, -34, 0, 0, 118, 69, 69, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc1_rindex[] = { 0,
|
||||
0, 38, 44, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, -9, 0, 0, 0, 0, 51, -3, 56, 61,
|
||||
0, 0, 0, 0, 67, 72, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 78, 83, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc1_gindex[] = { 0,
|
||||
4, 124, 0,
|
||||
};
|
||||
#define YYTABLESIZE 225
|
||||
static const short calc1_table[] = { 6,
|
||||
16, 10, 6, 8, 5, 30, 20, 5, 15, 17,
|
||||
29, 23, 11, 12, 31, 34, 21, 19, 35, 20,
|
||||
0, 22, 37, 39, 41, 43, 28, 0, 0, 0,
|
||||
21, 16, 49, 50, 55, 22, 0, 20, 57, 20,
|
||||
56, 20, 0, 21, 19, 0, 20, 9, 22, 0,
|
||||
0, 0, 0, 18, 58, 59, 60, 61, 26, 24,
|
||||
10, 25, 0, 27, 0, 11, 53, 51, 0, 52,
|
||||
22, 54, 26, 24, 0, 25, 19, 27, 26, 9,
|
||||
9, 21, 9, 27, 9, 18, 18, 10, 18, 0,
|
||||
18, 10, 11, 10, 10, 10, 11, 0, 11, 11,
|
||||
11, 22, 0, 22, 0, 22, 0, 19, 0, 19,
|
||||
53, 19, 21, 0, 21, 54, 21, 0, 10, 0,
|
||||
10, 0, 10, 11, 0, 11, 0, 11, 16, 18,
|
||||
36, 26, 24, 0, 25, 33, 27, 0, 0, 0,
|
||||
0, 0, 38, 40, 42, 44, 0, 45, 46, 47,
|
||||
48, 34, 53, 51, 0, 52, 0, 54, 62, 53,
|
||||
51, 0, 52, 0, 54, 0, 21, 19, 0, 20,
|
||||
0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 2, 3, 4, 13,
|
||||
14, 4, 13, 0, 4,
|
||||
};
|
||||
static const short calc1_check[] = { 40,
|
||||
10, 10, 40, 0, 45, 40, 10, 45, 5, 6,
|
||||
45, 10, 61, 61, 11, 41, 42, 43, 44, 45,
|
||||
-1, 47, 19, 20, 21, 22, 10, -1, -1, -1,
|
||||
42, 41, 29, 30, 10, 47, -1, 41, 35, 43,
|
||||
10, 45, -1, 42, 43, -1, 45, 10, 47, -1,
|
||||
-1, -1, -1, 10, 51, 52, 53, 54, 42, 43,
|
||||
10, 45, -1, 47, -1, 10, 42, 43, -1, 45,
|
||||
10, 47, 42, 43, -1, 45, 10, 47, 42, 42,
|
||||
43, 10, 45, 47, 47, 42, 43, 10, 45, -1,
|
||||
47, 41, 10, 43, 44, 45, 41, -1, 43, 44,
|
||||
45, 41, -1, 43, -1, 45, -1, 41, -1, 43,
|
||||
42, 45, 41, -1, 43, 47, 45, -1, 41, -1,
|
||||
43, -1, 45, 41, -1, 43, -1, 45, 5, 6,
|
||||
41, 42, 43, -1, 45, 12, 47, -1, -1, -1,
|
||||
-1, -1, 19, 20, 21, 22, -1, 24, 25, 26,
|
||||
27, 41, 42, 43, -1, 45, -1, 47, 41, 42,
|
||||
43, -1, 45, -1, 47, -1, 42, 43, -1, 45,
|
||||
-1, 47, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, 256, 257, 258, 259, 257,
|
||||
258, 259, 257, -1, 259,
|
||||
};
|
||||
#define YYFINAL 7
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 260
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,"DREG","VREG","CONST","UMINUS",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : line",
|
||||
"lines :",
|
||||
"lines : lines line",
|
||||
"line : dexp '\\n'",
|
||||
"line : vexp '\\n'",
|
||||
"line : DREG '=' dexp '\\n'",
|
||||
"line : VREG '=' vexp '\\n'",
|
||||
"line : error '\\n'",
|
||||
"dexp : CONST",
|
||||
"dexp : DREG",
|
||||
"dexp : dexp '+' dexp",
|
||||
"dexp : dexp '-' dexp",
|
||||
"dexp : dexp '*' dexp",
|
||||
"dexp : dexp '/' dexp",
|
||||
"dexp : '-' dexp",
|
||||
"dexp : '(' dexp ')'",
|
||||
"vexp : dexp",
|
||||
"vexp : '(' dexp ',' dexp ')'",
|
||||
"vexp : VREG",
|
||||
"vexp : vexp '+' vexp",
|
||||
"vexp : dexp '+' vexp",
|
||||
"vexp : vexp '-' vexp",
|
||||
"vexp : dexp '-' vexp",
|
||||
"vexp : vexp '*' vexp",
|
||||
"vexp : dexp '*' vexp",
|
||||
"vexp : vexp '/' vexp",
|
||||
"vexp : dexp '/' vexp",
|
||||
"vexp : '-' vexp",
|
||||
"vexp : '(' vexp ')'",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
/* variables for the parser stack */
|
||||
static YYSTACKDATA yystack;
|
||||
#line 173 "calc1.y"
|
||||
/* beginning of subroutines section */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
#define BSZ 50 /* buffer size for floating point numbers */
|
||||
|
||||
/* lexical analysis */
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getchar()) == ' ')
|
||||
{ /* skip over blanks */
|
||||
}
|
||||
|
||||
if (isupper(c))
|
||||
{
|
||||
yylval.ival = c - 'A';
|
||||
return (VREG);
|
||||
}
|
||||
if (islower(c))
|
||||
{
|
||||
yylval.ival = c - 'a';
|
||||
return (DREG);
|
||||
}
|
||||
|
||||
if (isdigit(c) || c == '.')
|
||||
{
|
||||
/* gobble up digits, points, exponents */
|
||||
char buf[BSZ + 1], *cp = buf;
|
||||
int dot = 0, expr = 0;
|
||||
|
||||
for (; (cp - buf) < BSZ; ++cp, c = getchar())
|
||||
{
|
||||
|
||||
*cp = c;
|
||||
if (isdigit(c))
|
||||
continue;
|
||||
if (c == '.')
|
||||
{
|
||||
if (dot++ || expr)
|
||||
return ('.'); /* will cause syntax error */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == 'e')
|
||||
{
|
||||
if (expr++)
|
||||
return ('e'); /* will cause syntax error */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* end of number */
|
||||
break;
|
||||
}
|
||||
*cp = '\0';
|
||||
|
||||
if ((cp - buf) >= BSZ)
|
||||
printf("constant too long: truncated\n");
|
||||
else
|
||||
ungetc(c, stdin); /* push back last char read */
|
||||
yylval.dval = atof(buf);
|
||||
return (CONST);
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
static INTERVAL
|
||||
hilo(double a, double b, double c, double d)
|
||||
{
|
||||
/* returns the smallest interval containing a, b, c, and d */
|
||||
/* used by *, / routines */
|
||||
INTERVAL v;
|
||||
|
||||
if (a > b)
|
||||
{
|
||||
v.hi = a;
|
||||
v.lo = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
v.hi = b;
|
||||
v.lo = a;
|
||||
}
|
||||
|
||||
if (c > d)
|
||||
{
|
||||
if (c > v.hi)
|
||||
v.hi = c;
|
||||
if (d < v.lo)
|
||||
v.lo = d;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d > v.hi)
|
||||
v.hi = d;
|
||||
if (c < v.lo)
|
||||
v.lo = c;
|
||||
}
|
||||
return (v);
|
||||
}
|
||||
|
||||
INTERVAL
|
||||
vmul(double a, double b, INTERVAL v)
|
||||
{
|
||||
return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
|
||||
}
|
||||
|
||||
int
|
||||
dcheck(INTERVAL v)
|
||||
{
|
||||
if (v.hi >= 0. && v.lo <= 0.)
|
||||
{
|
||||
printf("divisor interval contains 0.\n");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
INTERVAL
|
||||
vdiv(double a, double b, INTERVAL v)
|
||||
{
|
||||
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
|
||||
}
|
||||
#line 484 "calc1.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
case 3:
|
||||
#line 54 "calc1.y"
|
||||
{
|
||||
(void) printf("%15.8f\n", yystack.l_mark[-1].dval);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
#line 58 "calc1.y"
|
||||
{
|
||||
(void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
#line 62 "calc1.y"
|
||||
{
|
||||
dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
#line 66 "calc1.y"
|
||||
{
|
||||
vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
#line 70 "calc1.y"
|
||||
{
|
||||
yyerrok;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
#line 77 "calc1.y"
|
||||
{
|
||||
yyval.dval = dreg[yystack.l_mark[0].ival];
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
#line 81 "calc1.y"
|
||||
{
|
||||
yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
#line 85 "calc1.y"
|
||||
{
|
||||
yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
#line 89 "calc1.y"
|
||||
{
|
||||
yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
#line 93 "calc1.y"
|
||||
{
|
||||
yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
#line 97 "calc1.y"
|
||||
{
|
||||
yyval.dval = -yystack.l_mark[0].dval;
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
#line 101 "calc1.y"
|
||||
{
|
||||
yyval.dval = yystack.l_mark[-1].dval;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
#line 107 "calc1.y"
|
||||
{
|
||||
yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
#line 111 "calc1.y"
|
||||
{
|
||||
yyval.vval.lo = yystack.l_mark[-3].dval;
|
||||
yyval.vval.hi = yystack.l_mark[-1].dval;
|
||||
if ( yyval.vval.lo > yyval.vval.hi )
|
||||
{
|
||||
(void) printf("interval out of order\n");
|
||||
YYERROR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
#line 121 "calc1.y"
|
||||
{
|
||||
yyval.vval = vreg[yystack.l_mark[0].ival];
|
||||
}
|
||||
break;
|
||||
case 19:
|
||||
#line 125 "calc1.y"
|
||||
{
|
||||
yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
|
||||
yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
#line 130 "calc1.y"
|
||||
{
|
||||
yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
|
||||
yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
#line 135 "calc1.y"
|
||||
{
|
||||
yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
|
||||
yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
|
||||
}
|
||||
break;
|
||||
case 22:
|
||||
#line 140 "calc1.y"
|
||||
{
|
||||
yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
|
||||
yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
|
||||
}
|
||||
break;
|
||||
case 23:
|
||||
#line 145 "calc1.y"
|
||||
{
|
||||
yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
#line 149 "calc1.y"
|
||||
{
|
||||
yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
#line 153 "calc1.y"
|
||||
{
|
||||
if (dcheck(yystack.l_mark[0].vval)) YYERROR;
|
||||
yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
|
||||
}
|
||||
break;
|
||||
case 26:
|
||||
#line 158 "calc1.y"
|
||||
{
|
||||
if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
|
||||
yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
#line 163 "calc1.y"
|
||||
{
|
||||
yyval.vval.hi = -yystack.l_mark[0].vval.lo;
|
||||
yyval.vval.lo = -yystack.l_mark[0].vval.hi;
|
||||
}
|
||||
break;
|
||||
case 28:
|
||||
#line 168 "calc1.y"
|
||||
{
|
||||
yyval.vval = yystack.l_mark[-1].vval;
|
||||
}
|
||||
break;
|
||||
#line 853 "calc1.tab.c"
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
20
external/bsd/byacc/dist/test/calc1.tab.h
vendored
Normal file
20
external/bsd/byacc/dist/test/calc1.tab.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/* $NetBSD: calc1.tab.h,v 1.1.1.3 2011/09/10 21:22:10 christos Exp $ */
|
||||
|
||||
#define DREG 257
|
||||
#define VREG 258
|
||||
#define CONST 259
|
||||
#define UMINUS 260
|
||||
#ifdef YYSTYPE
|
||||
#undef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
#ifndef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
typedef union
|
||||
{
|
||||
int ival;
|
||||
double dval;
|
||||
INTERVAL vval;
|
||||
} YYSTYPE;
|
||||
#endif /* !YYSTYPE_IS_DECLARED */
|
||||
extern YYSTYPE calc1_lval;
|
||||
309
external/bsd/byacc/dist/test/calc1.y
vendored
Normal file
309
external/bsd/byacc/dist/test/calc1.y
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
/* $NetBSD: calc1.y,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
|
||||
|
||||
%{
|
||||
|
||||
/* http://dinosaur.compilertools.net/yacc/index.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef struct interval
|
||||
{
|
||||
double lo, hi;
|
||||
}
|
||||
INTERVAL;
|
||||
|
||||
INTERVAL vmul(double, double, INTERVAL);
|
||||
INTERVAL vdiv(double, double, INTERVAL);
|
||||
|
||||
int dcheck(INTERVAL);
|
||||
|
||||
double dreg[26];
|
||||
INTERVAL vreg[26];
|
||||
|
||||
%}
|
||||
%expect 18
|
||||
|
||||
%start line
|
||||
%union
|
||||
{
|
||||
int ival;
|
||||
double dval;
|
||||
INTERVAL vval;
|
||||
}
|
||||
|
||||
%token <ival> DREG VREG /* indices into dreg, vreg arrays */
|
||||
%token <dval> CONST /* floating point constant */
|
||||
|
||||
%type <dval> dexp /* expression */
|
||||
%type <vval> vexp /* interval expression */
|
||||
|
||||
/* precedence information about the operators */
|
||||
|
||||
%left '+' '-'
|
||||
%left '*' '/'
|
||||
%left UMINUS /* precedence for unary minus */
|
||||
|
||||
%% /* beginning of rules section */
|
||||
|
||||
lines : /* empty */
|
||||
| lines line
|
||||
;
|
||||
|
||||
line : dexp '\n'
|
||||
{
|
||||
(void) printf("%15.8f\n", $1);
|
||||
}
|
||||
| vexp '\n'
|
||||
{
|
||||
(void) printf("(%15.8f, %15.8f)\n", $1.lo, $1.hi);
|
||||
}
|
||||
| DREG '=' dexp '\n'
|
||||
{
|
||||
dreg[$1] = $3;
|
||||
}
|
||||
| VREG '=' vexp '\n'
|
||||
{
|
||||
vreg[$1] = $3;
|
||||
}
|
||||
| error '\n'
|
||||
{
|
||||
yyerrok;
|
||||
}
|
||||
;
|
||||
|
||||
dexp : CONST
|
||||
| DREG
|
||||
{
|
||||
$$ = dreg[$1];
|
||||
}
|
||||
| dexp '+' dexp
|
||||
{
|
||||
$$ = $1 + $3;
|
||||
}
|
||||
| dexp '-' dexp
|
||||
{
|
||||
$$ = $1 - $3;
|
||||
}
|
||||
| dexp '*' dexp
|
||||
{
|
||||
$$ = $1 * $3;
|
||||
}
|
||||
| dexp '/' dexp
|
||||
{
|
||||
$$ = $1 / $3;
|
||||
}
|
||||
| '-' dexp %prec UMINUS
|
||||
{
|
||||
$$ = -$2;
|
||||
}
|
||||
| '(' dexp ')'
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
vexp : dexp
|
||||
{
|
||||
$$.hi = $$.lo = $1;
|
||||
}
|
||||
| '(' dexp ',' dexp ')'
|
||||
{
|
||||
$$.lo = $2;
|
||||
$$.hi = $4;
|
||||
if ( $$.lo > $$.hi )
|
||||
{
|
||||
(void) printf("interval out of order\n");
|
||||
YYERROR;
|
||||
}
|
||||
}
|
||||
| VREG
|
||||
{
|
||||
$$ = vreg[$1];
|
||||
}
|
||||
| vexp '+' vexp
|
||||
{
|
||||
$$.hi = $1.hi + $3.hi;
|
||||
$$.lo = $1.lo + $3.lo;
|
||||
}
|
||||
| dexp '+' vexp
|
||||
{
|
||||
$$.hi = $1 + $3.hi;
|
||||
$$.lo = $1 + $3.lo;
|
||||
}
|
||||
| vexp '-' vexp
|
||||
{
|
||||
$$.hi = $1.hi - $3.lo;
|
||||
$$.lo = $1.lo - $3.hi;
|
||||
}
|
||||
| dexp '-' vexp
|
||||
{
|
||||
$$.hi = $1 - $3.lo;
|
||||
$$.lo = $1 - $3.hi;
|
||||
}
|
||||
| vexp '*' vexp
|
||||
{
|
||||
$$ = vmul( $1.lo, $1.hi, $3 );
|
||||
}
|
||||
| dexp '*' vexp
|
||||
{
|
||||
$$ = vmul ($1, $1, $3 );
|
||||
}
|
||||
| vexp '/' vexp
|
||||
{
|
||||
if (dcheck($3)) YYERROR;
|
||||
$$ = vdiv ( $1.lo, $1.hi, $3 );
|
||||
}
|
||||
| dexp '/' vexp
|
||||
{
|
||||
if (dcheck ( $3 )) YYERROR;
|
||||
$$ = vdiv ($1, $1, $3 );
|
||||
}
|
||||
| '-' vexp %prec UMINUS
|
||||
{
|
||||
$$.hi = -$2.lo;
|
||||
$$.lo = -$2.hi;
|
||||
}
|
||||
| '(' vexp ')'
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
%% /* beginning of subroutines section */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
#define BSZ 50 /* buffer size for floating point numbers */
|
||||
|
||||
/* lexical analysis */
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getchar()) == ' ')
|
||||
{ /* skip over blanks */
|
||||
}
|
||||
|
||||
if (isupper(c))
|
||||
{
|
||||
yylval.ival = c - 'A';
|
||||
return (VREG);
|
||||
}
|
||||
if (islower(c))
|
||||
{
|
||||
yylval.ival = c - 'a';
|
||||
return (DREG);
|
||||
}
|
||||
|
||||
if (isdigit(c) || c == '.')
|
||||
{
|
||||
/* gobble up digits, points, exponents */
|
||||
char buf[BSZ + 1], *cp = buf;
|
||||
int dot = 0, expr = 0;
|
||||
|
||||
for (; (cp - buf) < BSZ; ++cp, c = getchar())
|
||||
{
|
||||
|
||||
*cp = c;
|
||||
if (isdigit(c))
|
||||
continue;
|
||||
if (c == '.')
|
||||
{
|
||||
if (dot++ || expr)
|
||||
return ('.'); /* will cause syntax error */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == 'e')
|
||||
{
|
||||
if (expr++)
|
||||
return ('e'); /* will cause syntax error */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* end of number */
|
||||
break;
|
||||
}
|
||||
*cp = '\0';
|
||||
|
||||
if ((cp - buf) >= BSZ)
|
||||
printf("constant too long: truncated\n");
|
||||
else
|
||||
ungetc(c, stdin); /* push back last char read */
|
||||
yylval.dval = atof(buf);
|
||||
return (CONST);
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
static INTERVAL
|
||||
hilo(double a, double b, double c, double d)
|
||||
{
|
||||
/* returns the smallest interval containing a, b, c, and d */
|
||||
/* used by *, / routines */
|
||||
INTERVAL v;
|
||||
|
||||
if (a > b)
|
||||
{
|
||||
v.hi = a;
|
||||
v.lo = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
v.hi = b;
|
||||
v.lo = a;
|
||||
}
|
||||
|
||||
if (c > d)
|
||||
{
|
||||
if (c > v.hi)
|
||||
v.hi = c;
|
||||
if (d < v.lo)
|
||||
v.lo = d;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d > v.hi)
|
||||
v.hi = d;
|
||||
if (c < v.lo)
|
||||
v.lo = c;
|
||||
}
|
||||
return (v);
|
||||
}
|
||||
|
||||
INTERVAL
|
||||
vmul(double a, double b, INTERVAL v)
|
||||
{
|
||||
return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
|
||||
}
|
||||
|
||||
int
|
||||
dcheck(INTERVAL v)
|
||||
{
|
||||
if (v.hi >= 0. && v.lo <= 0.)
|
||||
{
|
||||
printf("divisor interval contains 0.\n");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
INTERVAL
|
||||
vdiv(double a, double b, INTERVAL v)
|
||||
{
|
||||
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
|
||||
}
|
||||
461
external/bsd/byacc/dist/test/calc2.output
vendored
Normal file
461
external/bsd/byacc/dist/test/calc2.output
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
0 $accept : list $end
|
||||
|
||||
1 list :
|
||||
2 | list stat '\n'
|
||||
3 | list error '\n'
|
||||
|
||||
4 stat : expr
|
||||
5 | LETTER '=' expr
|
||||
|
||||
6 expr : '(' expr ')'
|
||||
7 | expr '+' expr
|
||||
8 | expr '-' expr
|
||||
9 | expr '*' expr
|
||||
10 | expr '/' expr
|
||||
11 | expr '%' expr
|
||||
12 | expr '&' expr
|
||||
13 | expr '|' expr
|
||||
14 | '-' expr
|
||||
15 | LETTER
|
||||
16 | number
|
||||
|
||||
17 number : DIGIT
|
||||
18 | number DIGIT
|
||||
|
||||
state 0
|
||||
$accept : . list $end (0)
|
||||
list : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
list goto 1
|
||||
|
||||
|
||||
state 1
|
||||
$accept : list . $end (0)
|
||||
list : list . stat '\n' (2)
|
||||
list : list . error '\n' (3)
|
||||
|
||||
$end accept
|
||||
error shift 2
|
||||
DIGIT shift 3
|
||||
LETTER shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
stat goto 7
|
||||
expr goto 8
|
||||
number goto 9
|
||||
|
||||
|
||||
state 2
|
||||
list : list error . '\n' (3)
|
||||
|
||||
'\n' shift 10
|
||||
. error
|
||||
|
||||
|
||||
state 3
|
||||
number : DIGIT . (17)
|
||||
|
||||
. reduce 17
|
||||
|
||||
|
||||
state 4
|
||||
stat : LETTER . '=' expr (5)
|
||||
expr : LETTER . (15)
|
||||
|
||||
'=' shift 11
|
||||
'|' reduce 15
|
||||
'&' reduce 15
|
||||
'+' reduce 15
|
||||
'-' reduce 15
|
||||
'*' reduce 15
|
||||
'/' reduce 15
|
||||
'%' reduce 15
|
||||
'\n' reduce 15
|
||||
|
||||
|
||||
state 5
|
||||
expr : '-' . expr (14)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 13
|
||||
number goto 9
|
||||
|
||||
|
||||
state 6
|
||||
expr : '(' . expr ')' (6)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
number goto 9
|
||||
|
||||
|
||||
state 7
|
||||
list : list stat . '\n' (2)
|
||||
|
||||
'\n' shift 15
|
||||
. error
|
||||
|
||||
|
||||
state 8
|
||||
stat : expr . (4)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 4
|
||||
|
||||
|
||||
state 9
|
||||
expr : number . (16)
|
||||
number : number . DIGIT (18)
|
||||
|
||||
DIGIT shift 23
|
||||
'|' reduce 16
|
||||
'&' reduce 16
|
||||
'+' reduce 16
|
||||
'-' reduce 16
|
||||
'*' reduce 16
|
||||
'/' reduce 16
|
||||
'%' reduce 16
|
||||
'\n' reduce 16
|
||||
')' reduce 16
|
||||
|
||||
|
||||
state 10
|
||||
list : list error '\n' . (3)
|
||||
|
||||
. reduce 3
|
||||
|
||||
|
||||
state 11
|
||||
stat : LETTER '=' . expr (5)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 24
|
||||
number goto 9
|
||||
|
||||
|
||||
state 12
|
||||
expr : LETTER . (15)
|
||||
|
||||
. reduce 15
|
||||
|
||||
|
||||
state 13
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : '-' expr . (14)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 14
|
||||
expr : '(' expr . ')' (6)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
')' shift 25
|
||||
. error
|
||||
|
||||
|
||||
state 15
|
||||
list : list stat '\n' . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr '|' . expr (13)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 26
|
||||
number goto 9
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr '&' . expr (12)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 27
|
||||
number goto 9
|
||||
|
||||
|
||||
state 18
|
||||
expr : expr '+' . expr (7)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 28
|
||||
number goto 9
|
||||
|
||||
|
||||
state 19
|
||||
expr : expr '-' . expr (8)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 29
|
||||
number goto 9
|
||||
|
||||
|
||||
state 20
|
||||
expr : expr '*' . expr (9)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 30
|
||||
number goto 9
|
||||
|
||||
|
||||
state 21
|
||||
expr : expr '/' . expr (10)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 31
|
||||
number goto 9
|
||||
|
||||
|
||||
state 22
|
||||
expr : expr '%' . expr (11)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 32
|
||||
number goto 9
|
||||
|
||||
|
||||
state 23
|
||||
number : number DIGIT . (18)
|
||||
|
||||
. reduce 18
|
||||
|
||||
|
||||
state 24
|
||||
stat : LETTER '=' expr . (5)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 5
|
||||
|
||||
|
||||
state 25
|
||||
expr : '(' expr ')' . (6)
|
||||
|
||||
. reduce 6
|
||||
|
||||
|
||||
state 26
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : expr '|' expr . (13)
|
||||
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 13
|
||||
'\n' reduce 13
|
||||
')' reduce 13
|
||||
|
||||
|
||||
state 27
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr '&' expr . (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 12
|
||||
'&' reduce 12
|
||||
'\n' reduce 12
|
||||
')' reduce 12
|
||||
|
||||
|
||||
state 28
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr '+' expr . (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 7
|
||||
'&' reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
'\n' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 29
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr '-' expr . (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 8
|
||||
'&' reduce 8
|
||||
'+' reduce 8
|
||||
'-' reduce 8
|
||||
'\n' reduce 8
|
||||
')' reduce 8
|
||||
|
||||
|
||||
state 30
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr '*' expr . (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 31
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr '/' expr . (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 32
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr '%' expr . (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 11
|
||||
|
||||
|
||||
16 terminals, 5 nonterminals
|
||||
19 grammar rules, 33 states
|
||||
673
external/bsd/byacc/dist/test/calc2.tab.c
vendored
Normal file
673
external/bsd/byacc/dist/test/calc2.tab.c
vendored
Normal file
@@ -0,0 +1,673 @@
|
||||
/* $NetBSD: calc2.tab.c,v 1.1.1.3 2011/09/10 21:22:08 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc2_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc2_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc2_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc2_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc2_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc2_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc2_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc2_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc2_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc2_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc2_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc2_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc2_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc2_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc2_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc2_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc2_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc2_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc2_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc2_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc2_"
|
||||
|
||||
#define YYPURE 0
|
||||
|
||||
#line 7 "calc2.y"
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
#line 103 "calc2.tab.c"
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(int regs[26], int * base)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(int * base)
|
||||
# define YYLEX yylex(base)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(regs, base, msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
#define YYERRCODE 256
|
||||
static const short calc2_lhs[] = { -1,
|
||||
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 3,
|
||||
};
|
||||
static const short calc2_len[] = { 2,
|
||||
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 1, 1, 1, 2,
|
||||
};
|
||||
static const short calc2_defred[] = { 1,
|
||||
0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
|
||||
0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
|
||||
0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
|
||||
10, 11,
|
||||
};
|
||||
static const short calc2_dgoto[] = { 1,
|
||||
7, 8, 9,
|
||||
};
|
||||
static const short calc2_sindex[] = { 0,
|
||||
-40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
|
||||
-38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
|
||||
-38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc2_rindex[] = { 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc2_gindex[] = { 0,
|
||||
0, 65, 0,
|
||||
};
|
||||
#define YYTABLESIZE 220
|
||||
static const short calc2_table[] = { 6,
|
||||
16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
|
||||
15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
|
||||
0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
|
||||
0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
|
||||
0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
|
||||
8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
|
||||
0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
|
||||
14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
|
||||
26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
|
||||
0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
|
||||
0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
|
||||
0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
|
||||
0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
|
||||
0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
|
||||
};
|
||||
static const short calc2_check[] = { 40,
|
||||
10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
|
||||
10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
|
||||
-1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
|
||||
-1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
|
||||
-1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
|
||||
38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
|
||||
-1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
|
||||
6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
|
||||
16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
|
||||
-1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
|
||||
-1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
|
||||
-1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
|
||||
-1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
|
||||
};
|
||||
#define YYFINAL 1
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 259
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : list",
|
||||
"list :",
|
||||
"list : list stat '\\n'",
|
||||
"list : list error '\\n'",
|
||||
"stat : expr",
|
||||
"stat : LETTER '=' expr",
|
||||
"expr : '(' expr ')'",
|
||||
"expr : expr '+' expr",
|
||||
"expr : expr '-' expr",
|
||||
"expr : expr '*' expr",
|
||||
"expr : expr '/' expr",
|
||||
"expr : expr '%' expr",
|
||||
"expr : expr '&' expr",
|
||||
"expr : expr '|' expr",
|
||||
"expr : '-' expr",
|
||||
"expr : LETTER",
|
||||
"expr : number",
|
||||
"number : DIGIT",
|
||||
"number : number DIGIT",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
/* variables for the parser stack */
|
||||
static YYSTACKDATA yystack;
|
||||
#line 65 "calc2.y"
|
||||
/* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int regs[26];
|
||||
int base = 10;
|
||||
|
||||
while(!feof(stdin)) {
|
||||
yyparse(regs, &base);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
YYERROR_DECL()
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(int *base)
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
yylval = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
yylval = (c - '0') % (*base);
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
#line 345 "calc2.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror(regs, base, "syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
case 3:
|
||||
#line 27 "calc2.y"
|
||||
{ yyerrok ; }
|
||||
break;
|
||||
case 4:
|
||||
#line 31 "calc2.y"
|
||||
{ printf("%d\n",yystack.l_mark[0]);}
|
||||
break;
|
||||
case 5:
|
||||
#line 33 "calc2.y"
|
||||
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
|
||||
break;
|
||||
case 6:
|
||||
#line 37 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-1]; }
|
||||
break;
|
||||
case 7:
|
||||
#line 39 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
|
||||
break;
|
||||
case 8:
|
||||
#line 41 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 9:
|
||||
#line 43 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
|
||||
break;
|
||||
case 10:
|
||||
#line 45 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
|
||||
break;
|
||||
case 11:
|
||||
#line 47 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
|
||||
break;
|
||||
case 12:
|
||||
#line 49 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
|
||||
break;
|
||||
case 13:
|
||||
#line 51 "calc2.y"
|
||||
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
|
||||
break;
|
||||
case 14:
|
||||
#line 53 "calc2.y"
|
||||
{ yyval = - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 15:
|
||||
#line 55 "calc2.y"
|
||||
{ yyval = regs[yystack.l_mark[0]]; }
|
||||
break;
|
||||
case 17:
|
||||
#line 60 "calc2.y"
|
||||
{ yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
|
||||
break;
|
||||
case 18:
|
||||
#line 62 "calc2.y"
|
||||
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
|
||||
break;
|
||||
#line 611 "calc2.tab.c"
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror(regs, base, "yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
5
external/bsd/byacc/dist/test/calc2.tab.h
vendored
Normal file
5
external/bsd/byacc/dist/test/calc2.tab.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: calc2.tab.h,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
115
external/bsd/byacc/dist/test/calc2.y
vendored
Normal file
115
external/bsd/byacc/dist/test/calc2.y
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $NetBSD: calc2.y,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
|
||||
|
||||
%parse-param { int regs[26] }
|
||||
%parse-param { int *base }
|
||||
|
||||
%lex-param { int *base }
|
||||
|
||||
%{
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
%}
|
||||
|
||||
%start list
|
||||
|
||||
%token DIGIT LETTER
|
||||
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%left UMINUS /* supplies precedence for unary minus */
|
||||
|
||||
%% /* beginning of rules section */
|
||||
|
||||
list : /* empty */
|
||||
| list stat '\n'
|
||||
| list error '\n'
|
||||
{ yyerrok ; }
|
||||
;
|
||||
|
||||
stat : expr
|
||||
{ printf("%d\n",$1);}
|
||||
| LETTER '=' expr
|
||||
{ regs[$1] = $3; }
|
||||
;
|
||||
|
||||
expr : '(' expr ')'
|
||||
{ $$ = $2; }
|
||||
| expr '+' expr
|
||||
{ $$ = $1 + $3; }
|
||||
| expr '-' expr
|
||||
{ $$ = $1 - $3; }
|
||||
| expr '*' expr
|
||||
{ $$ = $1 * $3; }
|
||||
| expr '/' expr
|
||||
{ $$ = $1 / $3; }
|
||||
| expr '%' expr
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| '-' expr %prec UMINUS
|
||||
{ $$ = - $2; }
|
||||
| LETTER
|
||||
{ $$ = regs[$1]; }
|
||||
| number
|
||||
;
|
||||
|
||||
number: DIGIT
|
||||
{ $$ = $1; (*base) = ($1==0) ? 8 : 10; }
|
||||
| number DIGIT
|
||||
{ $$ = (*base) * $1 + $2; }
|
||||
;
|
||||
|
||||
%% /* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int regs[26];
|
||||
int base = 10;
|
||||
|
||||
while(!feof(stdin)) {
|
||||
yyparse(regs, &base);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
YYERROR_DECL()
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(int *base)
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
yylval = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
yylval = (c - '0') % (*base);
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
461
external/bsd/byacc/dist/test/calc3.output
vendored
Normal file
461
external/bsd/byacc/dist/test/calc3.output
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
0 $accept : list $end
|
||||
|
||||
1 list :
|
||||
2 | list stat '\n'
|
||||
3 | list error '\n'
|
||||
|
||||
4 stat : expr
|
||||
5 | LETTER '=' expr
|
||||
|
||||
6 expr : '(' expr ')'
|
||||
7 | expr '+' expr
|
||||
8 | expr '-' expr
|
||||
9 | expr '*' expr
|
||||
10 | expr '/' expr
|
||||
11 | expr '%' expr
|
||||
12 | expr '&' expr
|
||||
13 | expr '|' expr
|
||||
14 | '-' expr
|
||||
15 | LETTER
|
||||
16 | number
|
||||
|
||||
17 number : DIGIT
|
||||
18 | number DIGIT
|
||||
|
||||
state 0
|
||||
$accept : . list $end (0)
|
||||
list : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
list goto 1
|
||||
|
||||
|
||||
state 1
|
||||
$accept : list . $end (0)
|
||||
list : list . stat '\n' (2)
|
||||
list : list . error '\n' (3)
|
||||
|
||||
$end accept
|
||||
error shift 2
|
||||
DIGIT shift 3
|
||||
LETTER shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
stat goto 7
|
||||
expr goto 8
|
||||
number goto 9
|
||||
|
||||
|
||||
state 2
|
||||
list : list error . '\n' (3)
|
||||
|
||||
'\n' shift 10
|
||||
. error
|
||||
|
||||
|
||||
state 3
|
||||
number : DIGIT . (17)
|
||||
|
||||
. reduce 17
|
||||
|
||||
|
||||
state 4
|
||||
stat : LETTER . '=' expr (5)
|
||||
expr : LETTER . (15)
|
||||
|
||||
'=' shift 11
|
||||
'|' reduce 15
|
||||
'&' reduce 15
|
||||
'+' reduce 15
|
||||
'-' reduce 15
|
||||
'*' reduce 15
|
||||
'/' reduce 15
|
||||
'%' reduce 15
|
||||
'\n' reduce 15
|
||||
|
||||
|
||||
state 5
|
||||
expr : '-' . expr (14)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 13
|
||||
number goto 9
|
||||
|
||||
|
||||
state 6
|
||||
expr : '(' . expr ')' (6)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
number goto 9
|
||||
|
||||
|
||||
state 7
|
||||
list : list stat . '\n' (2)
|
||||
|
||||
'\n' shift 15
|
||||
. error
|
||||
|
||||
|
||||
state 8
|
||||
stat : expr . (4)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 4
|
||||
|
||||
|
||||
state 9
|
||||
expr : number . (16)
|
||||
number : number . DIGIT (18)
|
||||
|
||||
DIGIT shift 23
|
||||
'|' reduce 16
|
||||
'&' reduce 16
|
||||
'+' reduce 16
|
||||
'-' reduce 16
|
||||
'*' reduce 16
|
||||
'/' reduce 16
|
||||
'%' reduce 16
|
||||
'\n' reduce 16
|
||||
')' reduce 16
|
||||
|
||||
|
||||
state 10
|
||||
list : list error '\n' . (3)
|
||||
|
||||
. reduce 3
|
||||
|
||||
|
||||
state 11
|
||||
stat : LETTER '=' . expr (5)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 24
|
||||
number goto 9
|
||||
|
||||
|
||||
state 12
|
||||
expr : LETTER . (15)
|
||||
|
||||
. reduce 15
|
||||
|
||||
|
||||
state 13
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : '-' expr . (14)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 14
|
||||
expr : '(' expr . ')' (6)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
')' shift 25
|
||||
. error
|
||||
|
||||
|
||||
state 15
|
||||
list : list stat '\n' . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr '|' . expr (13)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 26
|
||||
number goto 9
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr '&' . expr (12)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 27
|
||||
number goto 9
|
||||
|
||||
|
||||
state 18
|
||||
expr : expr '+' . expr (7)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 28
|
||||
number goto 9
|
||||
|
||||
|
||||
state 19
|
||||
expr : expr '-' . expr (8)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 29
|
||||
number goto 9
|
||||
|
||||
|
||||
state 20
|
||||
expr : expr '*' . expr (9)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 30
|
||||
number goto 9
|
||||
|
||||
|
||||
state 21
|
||||
expr : expr '/' . expr (10)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 31
|
||||
number goto 9
|
||||
|
||||
|
||||
state 22
|
||||
expr : expr '%' . expr (11)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 32
|
||||
number goto 9
|
||||
|
||||
|
||||
state 23
|
||||
number : number DIGIT . (18)
|
||||
|
||||
. reduce 18
|
||||
|
||||
|
||||
state 24
|
||||
stat : LETTER '=' expr . (5)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 5
|
||||
|
||||
|
||||
state 25
|
||||
expr : '(' expr ')' . (6)
|
||||
|
||||
. reduce 6
|
||||
|
||||
|
||||
state 26
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : expr '|' expr . (13)
|
||||
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 13
|
||||
'\n' reduce 13
|
||||
')' reduce 13
|
||||
|
||||
|
||||
state 27
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr '&' expr . (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 12
|
||||
'&' reduce 12
|
||||
'\n' reduce 12
|
||||
')' reduce 12
|
||||
|
||||
|
||||
state 28
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr '+' expr . (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 7
|
||||
'&' reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
'\n' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 29
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr '-' expr . (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 8
|
||||
'&' reduce 8
|
||||
'+' reduce 8
|
||||
'-' reduce 8
|
||||
'\n' reduce 8
|
||||
')' reduce 8
|
||||
|
||||
|
||||
state 30
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr '*' expr . (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 31
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr '/' expr . (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 32
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr '%' expr . (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 11
|
||||
|
||||
|
||||
16 terminals, 5 nonterminals
|
||||
19 grammar rules, 33 states
|
||||
673
external/bsd/byacc/dist/test/calc3.tab.c
vendored
Normal file
673
external/bsd/byacc/dist/test/calc3.tab.c
vendored
Normal file
@@ -0,0 +1,673 @@
|
||||
/* $NetBSD: calc3.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc3_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc3_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc3_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc3_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc3_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc3_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc3_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc3_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc3_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc3_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc3_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc3_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc3_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc3_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc3_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc3_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc3_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc3_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc3_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc3_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc3_"
|
||||
|
||||
#define YYPURE 1
|
||||
|
||||
#line 9 "calc3.y"
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
#line 103 "calc3.tab.c"
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(int regs[26], int * base)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(&yylval, YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base)
|
||||
# define YYLEX yylex(&yylval, base)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(regs, base, msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
#define YYERRCODE 256
|
||||
static const short calc3_lhs[] = { -1,
|
||||
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 3,
|
||||
};
|
||||
static const short calc3_len[] = { 2,
|
||||
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 1, 1, 1, 2,
|
||||
};
|
||||
static const short calc3_defred[] = { 1,
|
||||
0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
|
||||
0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
|
||||
0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
|
||||
10, 11,
|
||||
};
|
||||
static const short calc3_dgoto[] = { 1,
|
||||
7, 8, 9,
|
||||
};
|
||||
static const short calc3_sindex[] = { 0,
|
||||
-40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
|
||||
-38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
|
||||
-38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc3_rindex[] = { 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc3_gindex[] = { 0,
|
||||
0, 65, 0,
|
||||
};
|
||||
#define YYTABLESIZE 220
|
||||
static const short calc3_table[] = { 6,
|
||||
16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
|
||||
15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
|
||||
0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
|
||||
0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
|
||||
0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
|
||||
8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
|
||||
0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
|
||||
14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
|
||||
26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
|
||||
0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
|
||||
0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
|
||||
0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
|
||||
0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
|
||||
0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
|
||||
};
|
||||
static const short calc3_check[] = { 40,
|
||||
10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
|
||||
10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
|
||||
-1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
|
||||
-1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
|
||||
-1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
|
||||
38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
|
||||
-1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
|
||||
6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
|
||||
16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
|
||||
-1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
|
||||
-1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
|
||||
-1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
|
||||
-1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
|
||||
};
|
||||
#define YYFINAL 1
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 259
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : list",
|
||||
"list :",
|
||||
"list : list stat '\\n'",
|
||||
"list : list error '\\n'",
|
||||
"stat : expr",
|
||||
"stat : LETTER '=' expr",
|
||||
"expr : '(' expr ')'",
|
||||
"expr : expr '+' expr",
|
||||
"expr : expr '-' expr",
|
||||
"expr : expr '*' expr",
|
||||
"expr : expr '/' expr",
|
||||
"expr : expr '%' expr",
|
||||
"expr : expr '&' expr",
|
||||
"expr : expr '|' expr",
|
||||
"expr : '-' expr",
|
||||
"expr : LETTER",
|
||||
"expr : number",
|
||||
"number : DIGIT",
|
||||
"number : number DIGIT",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
#line 67 "calc3.y"
|
||||
/* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int regs[26];
|
||||
int base = 10;
|
||||
|
||||
while(!feof(stdin)) {
|
||||
yyparse(regs, &base);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
YYERROR_DECL()
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
YYLEX_DECL()
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
*yylval = (c - 'a');
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
*yylval = (c - '0') % (*base);
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
#line 338 "calc3.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* variables for the parser stack */
|
||||
YYSTACKDATA yystack;
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror(regs, base, "syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
case 3:
|
||||
#line 29 "calc3.y"
|
||||
{ yyerrok ; }
|
||||
break;
|
||||
case 4:
|
||||
#line 33 "calc3.y"
|
||||
{ printf("%d\n",yystack.l_mark[0]);}
|
||||
break;
|
||||
case 5:
|
||||
#line 35 "calc3.y"
|
||||
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
|
||||
break;
|
||||
case 6:
|
||||
#line 39 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-1]; }
|
||||
break;
|
||||
case 7:
|
||||
#line 41 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
|
||||
break;
|
||||
case 8:
|
||||
#line 43 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 9:
|
||||
#line 45 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
|
||||
break;
|
||||
case 10:
|
||||
#line 47 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
|
||||
break;
|
||||
case 11:
|
||||
#line 49 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
|
||||
break;
|
||||
case 12:
|
||||
#line 51 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
|
||||
break;
|
||||
case 13:
|
||||
#line 53 "calc3.y"
|
||||
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
|
||||
break;
|
||||
case 14:
|
||||
#line 55 "calc3.y"
|
||||
{ yyval = - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 15:
|
||||
#line 57 "calc3.y"
|
||||
{ yyval = regs[yystack.l_mark[0]]; }
|
||||
break;
|
||||
case 17:
|
||||
#line 62 "calc3.y"
|
||||
{ yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
|
||||
break;
|
||||
case 18:
|
||||
#line 64 "calc3.y"
|
||||
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
|
||||
break;
|
||||
#line 611 "calc3.tab.c"
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror(regs, base, "yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
5
external/bsd/byacc/dist/test/calc3.tab.h
vendored
Normal file
5
external/bsd/byacc/dist/test/calc3.tab.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: calc3.tab.h,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
117
external/bsd/byacc/dist/test/calc3.y
vendored
Normal file
117
external/bsd/byacc/dist/test/calc3.y
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/* $NetBSD: calc3.y,v 1.1.1.3 2011/09/10 21:22:07 christos Exp $ */
|
||||
|
||||
%pure-parser
|
||||
|
||||
%parse-param { int regs[26] }
|
||||
%parse-param { int *base }
|
||||
|
||||
%lex-param { int *base }
|
||||
|
||||
%{
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
%}
|
||||
|
||||
%start list
|
||||
|
||||
%token DIGIT LETTER
|
||||
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%left UMINUS /* supplies precedence for unary minus */
|
||||
|
||||
%% /* beginning of rules section */
|
||||
|
||||
list : /* empty */
|
||||
| list stat '\n'
|
||||
| list error '\n'
|
||||
{ yyerrok ; }
|
||||
;
|
||||
|
||||
stat : expr
|
||||
{ printf("%d\n",$1);}
|
||||
| LETTER '=' expr
|
||||
{ regs[$1] = $3; }
|
||||
;
|
||||
|
||||
expr : '(' expr ')'
|
||||
{ $$ = $2; }
|
||||
| expr '+' expr
|
||||
{ $$ = $1 + $3; }
|
||||
| expr '-' expr
|
||||
{ $$ = $1 - $3; }
|
||||
| expr '*' expr
|
||||
{ $$ = $1 * $3; }
|
||||
| expr '/' expr
|
||||
{ $$ = $1 / $3; }
|
||||
| expr '%' expr
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| '-' expr %prec UMINUS
|
||||
{ $$ = - $2; }
|
||||
| LETTER
|
||||
{ $$ = regs[$1]; }
|
||||
| number
|
||||
;
|
||||
|
||||
number: DIGIT
|
||||
{ $$ = $1; (*base) = ($1==0) ? 8 : 10; }
|
||||
| number DIGIT
|
||||
{ $$ = (*base) * $1 + $2; }
|
||||
;
|
||||
|
||||
%% /* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int regs[26];
|
||||
int base = 10;
|
||||
|
||||
while(!feof(stdin)) {
|
||||
yyparse(regs, &base);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
YYERROR_DECL()
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
YYLEX_DECL()
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
*yylval = (c - 'a');
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
*yylval = (c - '0') % (*base);
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
573
external/bsd/byacc/dist/test/code_calc.code.c
vendored
Normal file
573
external/bsd/byacc/dist/test/code_calc.code.c
vendored
Normal file
@@ -0,0 +1,573 @@
|
||||
/* $NetBSD: code_calc.code.c,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#define YYPURE 0
|
||||
|
||||
#line 2 "code_calc.y"
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
int regs[26];
|
||||
int base;
|
||||
|
||||
#line 25 "code_calc.code.c"
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(void)
|
||||
# define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
#define YYERRCODE 256
|
||||
#define YYTABLESIZE 220
|
||||
#define YYFINAL 1
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 259
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc_"
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
extern short yylhs[];
|
||||
extern short yylen[];
|
||||
extern short yydefred[];
|
||||
extern short yydgoto[];
|
||||
extern short yysindex[];
|
||||
extern short yyrindex[];
|
||||
extern short yygindex[];
|
||||
extern short yytable[];
|
||||
extern short yycheck[];
|
||||
|
||||
#if YYDEBUG
|
||||
extern char *yyname[];
|
||||
extern char *yyrule[];
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
/* variables for the parser stack */
|
||||
static YYSTACKDATA yystack;
|
||||
#line 63 "code_calc.y"
|
||||
/* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
while(!feof(stdin)) {
|
||||
yyparse();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void) {
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
yylval = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
yylval = c - '0';
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
#line 245 "code_calc.code.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
case 3:
|
||||
#line 25 "code_calc.y"
|
||||
{ yyerrok ; }
|
||||
break;
|
||||
case 4:
|
||||
#line 29 "code_calc.y"
|
||||
{ printf("%d\n",yystack.l_mark[0]);}
|
||||
break;
|
||||
case 5:
|
||||
#line 31 "code_calc.y"
|
||||
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
|
||||
break;
|
||||
case 6:
|
||||
#line 35 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-1]; }
|
||||
break;
|
||||
case 7:
|
||||
#line 37 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
|
||||
break;
|
||||
case 8:
|
||||
#line 39 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 9:
|
||||
#line 41 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
|
||||
break;
|
||||
case 10:
|
||||
#line 43 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
|
||||
break;
|
||||
case 11:
|
||||
#line 45 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
|
||||
break;
|
||||
case 12:
|
||||
#line 47 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
|
||||
break;
|
||||
case 13:
|
||||
#line 49 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
|
||||
break;
|
||||
case 14:
|
||||
#line 51 "code_calc.y"
|
||||
{ yyval = - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 15:
|
||||
#line 53 "code_calc.y"
|
||||
{ yyval = regs[yystack.l_mark[0]]; }
|
||||
break;
|
||||
case 17:
|
||||
#line 58 "code_calc.y"
|
||||
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
|
||||
break;
|
||||
case 18:
|
||||
#line 60 "code_calc.y"
|
||||
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
|
||||
break;
|
||||
#line 511 "code_calc.code.c"
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
461
external/bsd/byacc/dist/test/code_calc.output
vendored
Normal file
461
external/bsd/byacc/dist/test/code_calc.output
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
0 $accept : list $end
|
||||
|
||||
1 list :
|
||||
2 | list stat '\n'
|
||||
3 | list error '\n'
|
||||
|
||||
4 stat : expr
|
||||
5 | LETTER '=' expr
|
||||
|
||||
6 expr : '(' expr ')'
|
||||
7 | expr '+' expr
|
||||
8 | expr '-' expr
|
||||
9 | expr '*' expr
|
||||
10 | expr '/' expr
|
||||
11 | expr '%' expr
|
||||
12 | expr '&' expr
|
||||
13 | expr '|' expr
|
||||
14 | '-' expr
|
||||
15 | LETTER
|
||||
16 | number
|
||||
|
||||
17 number : DIGIT
|
||||
18 | number DIGIT
|
||||
|
||||
state 0
|
||||
$accept : . list $end (0)
|
||||
list : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
list goto 1
|
||||
|
||||
|
||||
state 1
|
||||
$accept : list . $end (0)
|
||||
list : list . stat '\n' (2)
|
||||
list : list . error '\n' (3)
|
||||
|
||||
$end accept
|
||||
error shift 2
|
||||
DIGIT shift 3
|
||||
LETTER shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
stat goto 7
|
||||
expr goto 8
|
||||
number goto 9
|
||||
|
||||
|
||||
state 2
|
||||
list : list error . '\n' (3)
|
||||
|
||||
'\n' shift 10
|
||||
. error
|
||||
|
||||
|
||||
state 3
|
||||
number : DIGIT . (17)
|
||||
|
||||
. reduce 17
|
||||
|
||||
|
||||
state 4
|
||||
stat : LETTER . '=' expr (5)
|
||||
expr : LETTER . (15)
|
||||
|
||||
'=' shift 11
|
||||
'|' reduce 15
|
||||
'&' reduce 15
|
||||
'+' reduce 15
|
||||
'-' reduce 15
|
||||
'*' reduce 15
|
||||
'/' reduce 15
|
||||
'%' reduce 15
|
||||
'\n' reduce 15
|
||||
|
||||
|
||||
state 5
|
||||
expr : '-' . expr (14)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 13
|
||||
number goto 9
|
||||
|
||||
|
||||
state 6
|
||||
expr : '(' . expr ')' (6)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
number goto 9
|
||||
|
||||
|
||||
state 7
|
||||
list : list stat . '\n' (2)
|
||||
|
||||
'\n' shift 15
|
||||
. error
|
||||
|
||||
|
||||
state 8
|
||||
stat : expr . (4)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 4
|
||||
|
||||
|
||||
state 9
|
||||
expr : number . (16)
|
||||
number : number . DIGIT (18)
|
||||
|
||||
DIGIT shift 23
|
||||
'|' reduce 16
|
||||
'&' reduce 16
|
||||
'+' reduce 16
|
||||
'-' reduce 16
|
||||
'*' reduce 16
|
||||
'/' reduce 16
|
||||
'%' reduce 16
|
||||
'\n' reduce 16
|
||||
')' reduce 16
|
||||
|
||||
|
||||
state 10
|
||||
list : list error '\n' . (3)
|
||||
|
||||
. reduce 3
|
||||
|
||||
|
||||
state 11
|
||||
stat : LETTER '=' . expr (5)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 24
|
||||
number goto 9
|
||||
|
||||
|
||||
state 12
|
||||
expr : LETTER . (15)
|
||||
|
||||
. reduce 15
|
||||
|
||||
|
||||
state 13
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : '-' expr . (14)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 14
|
||||
expr : '(' expr . ')' (6)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
')' shift 25
|
||||
. error
|
||||
|
||||
|
||||
state 15
|
||||
list : list stat '\n' . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr '|' . expr (13)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 26
|
||||
number goto 9
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr '&' . expr (12)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 27
|
||||
number goto 9
|
||||
|
||||
|
||||
state 18
|
||||
expr : expr '+' . expr (7)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 28
|
||||
number goto 9
|
||||
|
||||
|
||||
state 19
|
||||
expr : expr '-' . expr (8)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 29
|
||||
number goto 9
|
||||
|
||||
|
||||
state 20
|
||||
expr : expr '*' . expr (9)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 30
|
||||
number goto 9
|
||||
|
||||
|
||||
state 21
|
||||
expr : expr '/' . expr (10)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 31
|
||||
number goto 9
|
||||
|
||||
|
||||
state 22
|
||||
expr : expr '%' . expr (11)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 32
|
||||
number goto 9
|
||||
|
||||
|
||||
state 23
|
||||
number : number DIGIT . (18)
|
||||
|
||||
. reduce 18
|
||||
|
||||
|
||||
state 24
|
||||
stat : LETTER '=' expr . (5)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 5
|
||||
|
||||
|
||||
state 25
|
||||
expr : '(' expr ')' . (6)
|
||||
|
||||
. reduce 6
|
||||
|
||||
|
||||
state 26
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : expr '|' expr . (13)
|
||||
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 13
|
||||
'\n' reduce 13
|
||||
')' reduce 13
|
||||
|
||||
|
||||
state 27
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr '&' expr . (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 12
|
||||
'&' reduce 12
|
||||
'\n' reduce 12
|
||||
')' reduce 12
|
||||
|
||||
|
||||
state 28
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr '+' expr . (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 7
|
||||
'&' reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
'\n' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 29
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr '-' expr . (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 8
|
||||
'&' reduce 8
|
||||
'+' reduce 8
|
||||
'-' reduce 8
|
||||
'\n' reduce 8
|
||||
')' reduce 8
|
||||
|
||||
|
||||
state 30
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr '*' expr . (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 31
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr '/' expr . (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 32
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr '%' expr . (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 11
|
||||
|
||||
|
||||
16 terminals, 5 nonterminals
|
||||
19 grammar rules, 33 states
|
||||
201
external/bsd/byacc/dist/test/code_calc.tab.c
vendored
Normal file
201
external/bsd/byacc/dist/test/code_calc.tab.c
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
/* $NetBSD: code_calc.tab.c,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc_"
|
||||
const short calc_lhs[] = { -1,
|
||||
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 3,
|
||||
};
|
||||
const short calc_len[] = { 2,
|
||||
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 1, 1, 1, 2,
|
||||
};
|
||||
const short calc_defred[] = { 1,
|
||||
0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
|
||||
0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
|
||||
0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
|
||||
10, 11,
|
||||
};
|
||||
const short calc_dgoto[] = { 1,
|
||||
7, 8, 9,
|
||||
};
|
||||
const short calc_sindex[] = { 0,
|
||||
-40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
|
||||
-38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
|
||||
-38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
|
||||
0, 0,
|
||||
};
|
||||
const short calc_rindex[] = { 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
|
||||
0, 0,
|
||||
};
|
||||
const short calc_gindex[] = { 0,
|
||||
0, 65, 0,
|
||||
};
|
||||
const short calc_table[] = { 6,
|
||||
16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
|
||||
15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
|
||||
0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
|
||||
0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
|
||||
0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
|
||||
8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
|
||||
0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
|
||||
14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
|
||||
26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
|
||||
0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
|
||||
0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
|
||||
0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
|
||||
0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
|
||||
0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
|
||||
};
|
||||
const short calc_check[] = { 40,
|
||||
10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
|
||||
10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
|
||||
-1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
|
||||
-1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
|
||||
-1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
|
||||
38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
|
||||
-1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
|
||||
6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
|
||||
16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
|
||||
-1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
|
||||
-1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
|
||||
-1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
|
||||
-1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
|
||||
};
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
const char *yyname[] = {
|
||||
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
|
||||
};
|
||||
const char *yyrule[] = {
|
||||
"$accept : list",
|
||||
"list :",
|
||||
"list : list stat '\\n'",
|
||||
"list : list error '\\n'",
|
||||
"stat : expr",
|
||||
"stat : LETTER '=' expr",
|
||||
"expr : '(' expr ')'",
|
||||
"expr : expr '+' expr",
|
||||
"expr : expr '-' expr",
|
||||
"expr : expr '*' expr",
|
||||
"expr : expr '/' expr",
|
||||
"expr : expr '%' expr",
|
||||
"expr : expr '&' expr",
|
||||
"expr : expr '|' expr",
|
||||
"expr : '-' expr",
|
||||
"expr : LETTER",
|
||||
"expr : number",
|
||||
"number : DIGIT",
|
||||
"number : number DIGIT",
|
||||
|
||||
};
|
||||
#endif
|
||||
5
external/bsd/byacc/dist/test/code_calc.tab.h
vendored
Normal file
5
external/bsd/byacc/dist/test/code_calc.tab.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: code_calc.tab.h,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
109
external/bsd/byacc/dist/test/code_calc.y
vendored
Normal file
109
external/bsd/byacc/dist/test/code_calc.y
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/* $NetBSD: code_calc.y,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
|
||||
|
||||
%{
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
int regs[26];
|
||||
int base;
|
||||
|
||||
%}
|
||||
|
||||
%start list
|
||||
|
||||
%token DIGIT LETTER
|
||||
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%left UMINUS /* supplies precedence for unary minus */
|
||||
|
||||
%% /* beginning of rules section */
|
||||
|
||||
list : /* empty */
|
||||
| list stat '\n'
|
||||
| list error '\n'
|
||||
{ yyerrok ; }
|
||||
;
|
||||
|
||||
stat : expr
|
||||
{ printf("%d\n",$1);}
|
||||
| LETTER '=' expr
|
||||
{ regs[$1] = $3; }
|
||||
;
|
||||
|
||||
expr : '(' expr ')'
|
||||
{ $$ = $2; }
|
||||
| expr '+' expr
|
||||
{ $$ = $1 + $3; }
|
||||
| expr '-' expr
|
||||
{ $$ = $1 - $3; }
|
||||
| expr '*' expr
|
||||
{ $$ = $1 * $3; }
|
||||
| expr '/' expr
|
||||
{ $$ = $1 / $3; }
|
||||
| expr '%' expr
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| '-' expr %prec UMINUS
|
||||
{ $$ = - $2; }
|
||||
| LETTER
|
||||
{ $$ = regs[$1]; }
|
||||
| number
|
||||
;
|
||||
|
||||
number: DIGIT
|
||||
{ $$ = $1; base = ($1==0) ? 8 : 10; }
|
||||
| number DIGIT
|
||||
{ $$ = base * $1 + $2; }
|
||||
;
|
||||
|
||||
%% /* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
while(!feof(stdin)) {
|
||||
yyparse();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void) {
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
yylval = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
yylval = c - '0';
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
482
external/bsd/byacc/dist/test/code_error.code.c
vendored
Normal file
482
external/bsd/byacc/dist/test/code_error.code.c
vendored
Normal file
@@ -0,0 +1,482 @@
|
||||
/* $NetBSD: code_error.code.c,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#define YYPURE 0
|
||||
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(void)
|
||||
# define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define YYERRCODE 256
|
||||
#define YYTABLESIZE 0
|
||||
#define YYFINAL 2
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 0
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse error_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex error_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror error_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar error_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval error_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval error_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug error_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs error_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag error_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs error_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen error_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred error_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto error_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex error_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex error_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex error_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable error_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck error_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname error_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule error_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "error_"
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
extern short yylhs[];
|
||||
extern short yylen[];
|
||||
extern short yydefred[];
|
||||
extern short yydgoto[];
|
||||
extern short yysindex[];
|
||||
extern short yyrindex[];
|
||||
extern short yygindex[];
|
||||
extern short yytable[];
|
||||
extern short yycheck[];
|
||||
|
||||
#if YYDEBUG
|
||||
extern char *yyname[];
|
||||
extern char *yyrule[];
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
/* variables for the parser stack */
|
||||
static YYSTACKDATA yystack;
|
||||
#line 4 "code_error.y"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("yyparse() = %d\n", yyparse());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char* s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
#line 215 "code_error.code.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
27
external/bsd/byacc/dist/test/code_error.output
vendored
Normal file
27
external/bsd/byacc/dist/test/code_error.output
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
0 $accept : S $end
|
||||
|
||||
1 S : error
|
||||
|
||||
state 0
|
||||
$accept : . S $end (0)
|
||||
|
||||
error shift 1
|
||||
. error
|
||||
|
||||
S goto 2
|
||||
|
||||
|
||||
state 1
|
||||
S : error . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
|
||||
state 2
|
||||
$accept : S . $end (0)
|
||||
|
||||
$end accept
|
||||
|
||||
|
||||
2 terminals, 2 nonterminals
|
||||
2 grammar rules, 3 states
|
||||
120
external/bsd/byacc/dist/test/code_error.tab.c
vendored
Normal file
120
external/bsd/byacc/dist/test/code_error.tab.c
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
/* $NetBSD: code_error.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse error_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex error_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror error_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar error_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval error_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval error_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug error_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs error_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag error_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs error_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen error_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred error_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto error_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex error_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex error_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex error_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable error_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck error_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname error_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule error_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "error_"
|
||||
const short error_lhs[] = { -1,
|
||||
0,
|
||||
};
|
||||
const short error_len[] = { 2,
|
||||
1,
|
||||
};
|
||||
const short error_defred[] = { 0,
|
||||
1, 0,
|
||||
};
|
||||
const short error_dgoto[] = { 2,
|
||||
};
|
||||
const short error_sindex[] = { -256,
|
||||
0, 0,
|
||||
};
|
||||
const short error_rindex[] = { 0,
|
||||
0, 0,
|
||||
};
|
||||
const short error_gindex[] = { 0,
|
||||
};
|
||||
const short error_table[] = { 1,
|
||||
};
|
||||
const short error_check[] = { 256,
|
||||
};
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
const char *yyname[] = {
|
||||
|
||||
"end-of-file",
|
||||
};
|
||||
const char *yyrule[] = {
|
||||
"$accept : S",
|
||||
"S : error",
|
||||
|
||||
};
|
||||
#endif
|
||||
2
external/bsd/byacc/dist/test/code_error.tab.h
vendored
Normal file
2
external/bsd/byacc/dist/test/code_error.tab.h
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* $NetBSD: code_error.tab.h,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
|
||||
|
||||
31
external/bsd/byacc/dist/test/code_error.y
vendored
Normal file
31
external/bsd/byacc/dist/test/code_error.y
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $NetBSD: code_error.y,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
|
||||
|
||||
%%
|
||||
S: error
|
||||
%%
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("yyparse() = %d\n", yyparse());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char* s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
27
external/bsd/byacc/dist/test/error.output
vendored
Normal file
27
external/bsd/byacc/dist/test/error.output
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
0 $accept : S $end
|
||||
|
||||
1 S : error
|
||||
|
||||
state 0
|
||||
$accept : . S $end (0)
|
||||
|
||||
error shift 1
|
||||
. error
|
||||
|
||||
S goto 2
|
||||
|
||||
|
||||
state 1
|
||||
S : error . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
|
||||
state 2
|
||||
$accept : S . $end (0)
|
||||
|
||||
$end accept
|
||||
|
||||
|
||||
2 terminals, 2 nonterminals
|
||||
2 grammar rules, 3 states
|
||||
501
external/bsd/byacc/dist/test/error.tab.c
vendored
Normal file
501
external/bsd/byacc/dist/test/error.tab.c
vendored
Normal file
@@ -0,0 +1,501 @@
|
||||
/* $NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
/* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
|
||||
static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse error_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex error_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror error_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar error_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval error_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval error_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug error_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs error_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag error_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs error_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen error_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred error_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto error_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex error_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex error_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex error_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable error_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck error_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname error_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule error_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "error_"
|
||||
|
||||
#define YYPURE 0
|
||||
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(void)
|
||||
# define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define YYERRCODE 256
|
||||
static const short error_lhs[] = { -1,
|
||||
0,
|
||||
};
|
||||
static const short error_len[] = { 2,
|
||||
1,
|
||||
};
|
||||
static const short error_defred[] = { 0,
|
||||
1, 0,
|
||||
};
|
||||
static const short error_dgoto[] = { 2,
|
||||
};
|
||||
static const short error_sindex[] = { -256,
|
||||
0, 0,
|
||||
};
|
||||
static const short error_rindex[] = { 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short error_gindex[] = { 0,
|
||||
};
|
||||
#define YYTABLESIZE 0
|
||||
static const short error_table[] = { 1,
|
||||
};
|
||||
static const short error_check[] = { 256,
|
||||
};
|
||||
#define YYFINAL 2
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 0
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : S",
|
||||
"S : error",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
/* variables for the parser stack */
|
||||
static YYSTACKDATA yystack;
|
||||
#line 4 "error.y"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("yyparse() = %d\n", yyparse());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char* s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
#line 233 "error.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
1
external/bsd/byacc/dist/test/error.tab.h
vendored
Normal file
1
external/bsd/byacc/dist/test/error.tab.h
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/* $NetBSD: error.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
|
||||
31
external/bsd/byacc/dist/test/error.y
vendored
Normal file
31
external/bsd/byacc/dist/test/error.y
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $NetBSD: error.y,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $ */
|
||||
|
||||
%%
|
||||
S: error
|
||||
%%
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("yyparse() = %d\n", yyparse());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
yylex(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char* s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
1625
external/bsd/byacc/dist/test/ftp.output
vendored
Normal file
1625
external/bsd/byacc/dist/test/ftp.output
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1985
external/bsd/byacc/dist/test/ftp.tab.c
vendored
Normal file
1985
external/bsd/byacc/dist/test/ftp.tab.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
65
external/bsd/byacc/dist/test/ftp.tab.h
vendored
Normal file
65
external/bsd/byacc/dist/test/ftp.tab.h
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/* $NetBSD: ftp.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
|
||||
|
||||
#define A 257
|
||||
#define B 258
|
||||
#define C 259
|
||||
#define E 260
|
||||
#define F 261
|
||||
#define I 262
|
||||
#define L 263
|
||||
#define N 264
|
||||
#define P 265
|
||||
#define R 266
|
||||
#define S 267
|
||||
#define T 268
|
||||
#define SP 269
|
||||
#define CRLF 270
|
||||
#define COMMA 271
|
||||
#define STRING 272
|
||||
#define NUMBER 273
|
||||
#define USER 274
|
||||
#define PASS 275
|
||||
#define ACCT 276
|
||||
#define REIN 277
|
||||
#define QUIT 278
|
||||
#define PORT 279
|
||||
#define PASV 280
|
||||
#define TYPE 281
|
||||
#define STRU 282
|
||||
#define MODE 283
|
||||
#define RETR 284
|
||||
#define STOR 285
|
||||
#define APPE 286
|
||||
#define MLFL 287
|
||||
#define MAIL 288
|
||||
#define MSND 289
|
||||
#define MSOM 290
|
||||
#define MSAM 291
|
||||
#define MRSQ 292
|
||||
#define MRCP 293
|
||||
#define ALLO 294
|
||||
#define REST 295
|
||||
#define RNFR 296
|
||||
#define RNTO 297
|
||||
#define ABOR 298
|
||||
#define DELE 299
|
||||
#define CWD 300
|
||||
#define LIST 301
|
||||
#define NLST 302
|
||||
#define SITE 303
|
||||
#define STAT 304
|
||||
#define HELP 305
|
||||
#define NOOP 306
|
||||
#define MKD 307
|
||||
#define RMD 308
|
||||
#define PWD 309
|
||||
#define CDUP 310
|
||||
#define STOU 311
|
||||
#define SMNT 312
|
||||
#define SYST 313
|
||||
#define SIZE 314
|
||||
#define MDTM 315
|
||||
#define UMASK 316
|
||||
#define IDLE 317
|
||||
#define CHMOD 318
|
||||
#define LEXERR 319
|
||||
1225
external/bsd/byacc/dist/test/ftp.y
vendored
Normal file
1225
external/bsd/byacc/dist/test/ftp.y
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2214
external/bsd/byacc/dist/test/grammar.output
vendored
Normal file
2214
external/bsd/byacc/dist/test/grammar.output
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2015
external/bsd/byacc/dist/test/grammar.tab.c
vendored
Normal file
2015
external/bsd/byacc/dist/test/grammar.tab.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
external/bsd/byacc/dist/test/grammar.tab.h
vendored
Normal file
37
external/bsd/byacc/dist/test/grammar.tab.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/* $NetBSD: grammar.tab.h,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
|
||||
|
||||
#define T_IDENTIFIER 257
|
||||
#define T_TYPEDEF_NAME 258
|
||||
#define T_DEFINE_NAME 259
|
||||
#define T_AUTO 260
|
||||
#define T_EXTERN 261
|
||||
#define T_REGISTER 262
|
||||
#define T_STATIC 263
|
||||
#define T_TYPEDEF 264
|
||||
#define T_INLINE 265
|
||||
#define T_EXTENSION 266
|
||||
#define T_CHAR 267
|
||||
#define T_DOUBLE 268
|
||||
#define T_FLOAT 269
|
||||
#define T_INT 270
|
||||
#define T_VOID 271
|
||||
#define T_LONG 272
|
||||
#define T_SHORT 273
|
||||
#define T_SIGNED 274
|
||||
#define T_UNSIGNED 275
|
||||
#define T_ENUM 276
|
||||
#define T_STRUCT 277
|
||||
#define T_UNION 278
|
||||
#define T_Bool 279
|
||||
#define T_Complex 280
|
||||
#define T_Imaginary 281
|
||||
#define T_TYPE_QUALIFIER 282
|
||||
#define T_BRACKETS 283
|
||||
#define T_LBRACE 284
|
||||
#define T_MATCHRBRACE 285
|
||||
#define T_ELLIPSIS 286
|
||||
#define T_INITIALIZER 287
|
||||
#define T_STRING_LITERAL 288
|
||||
#define T_ASM 289
|
||||
#define T_ASMARG 290
|
||||
#define T_VA_DCL 291
|
||||
1175
external/bsd/byacc/dist/test/grammar.y
vendored
Normal file
1175
external/bsd/byacc/dist/test/grammar.y
vendored
Normal file
File diff suppressed because it is too large
Load Diff
461
external/bsd/byacc/dist/test/pure_calc.output
vendored
Normal file
461
external/bsd/byacc/dist/test/pure_calc.output
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
0 $accept : list $end
|
||||
|
||||
1 list :
|
||||
2 | list stat '\n'
|
||||
3 | list error '\n'
|
||||
|
||||
4 stat : expr
|
||||
5 | LETTER '=' expr
|
||||
|
||||
6 expr : '(' expr ')'
|
||||
7 | expr '+' expr
|
||||
8 | expr '-' expr
|
||||
9 | expr '*' expr
|
||||
10 | expr '/' expr
|
||||
11 | expr '%' expr
|
||||
12 | expr '&' expr
|
||||
13 | expr '|' expr
|
||||
14 | '-' expr
|
||||
15 | LETTER
|
||||
16 | number
|
||||
|
||||
17 number : DIGIT
|
||||
18 | number DIGIT
|
||||
|
||||
state 0
|
||||
$accept : . list $end (0)
|
||||
list : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
list goto 1
|
||||
|
||||
|
||||
state 1
|
||||
$accept : list . $end (0)
|
||||
list : list . stat '\n' (2)
|
||||
list : list . error '\n' (3)
|
||||
|
||||
$end accept
|
||||
error shift 2
|
||||
DIGIT shift 3
|
||||
LETTER shift 4
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
stat goto 7
|
||||
expr goto 8
|
||||
number goto 9
|
||||
|
||||
|
||||
state 2
|
||||
list : list error . '\n' (3)
|
||||
|
||||
'\n' shift 10
|
||||
. error
|
||||
|
||||
|
||||
state 3
|
||||
number : DIGIT . (17)
|
||||
|
||||
. reduce 17
|
||||
|
||||
|
||||
state 4
|
||||
stat : LETTER . '=' expr (5)
|
||||
expr : LETTER . (15)
|
||||
|
||||
'=' shift 11
|
||||
'|' reduce 15
|
||||
'&' reduce 15
|
||||
'+' reduce 15
|
||||
'-' reduce 15
|
||||
'*' reduce 15
|
||||
'/' reduce 15
|
||||
'%' reduce 15
|
||||
'\n' reduce 15
|
||||
|
||||
|
||||
state 5
|
||||
expr : '-' . expr (14)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 13
|
||||
number goto 9
|
||||
|
||||
|
||||
state 6
|
||||
expr : '(' . expr ')' (6)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
number goto 9
|
||||
|
||||
|
||||
state 7
|
||||
list : list stat . '\n' (2)
|
||||
|
||||
'\n' shift 15
|
||||
. error
|
||||
|
||||
|
||||
state 8
|
||||
stat : expr . (4)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 4
|
||||
|
||||
|
||||
state 9
|
||||
expr : number . (16)
|
||||
number : number . DIGIT (18)
|
||||
|
||||
DIGIT shift 23
|
||||
'|' reduce 16
|
||||
'&' reduce 16
|
||||
'+' reduce 16
|
||||
'-' reduce 16
|
||||
'*' reduce 16
|
||||
'/' reduce 16
|
||||
'%' reduce 16
|
||||
'\n' reduce 16
|
||||
')' reduce 16
|
||||
|
||||
|
||||
state 10
|
||||
list : list error '\n' . (3)
|
||||
|
||||
. reduce 3
|
||||
|
||||
|
||||
state 11
|
||||
stat : LETTER '=' . expr (5)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 24
|
||||
number goto 9
|
||||
|
||||
|
||||
state 12
|
||||
expr : LETTER . (15)
|
||||
|
||||
. reduce 15
|
||||
|
||||
|
||||
state 13
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : '-' expr . (14)
|
||||
|
||||
. reduce 14
|
||||
|
||||
|
||||
state 14
|
||||
expr : '(' expr . ')' (6)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
')' shift 25
|
||||
. error
|
||||
|
||||
|
||||
state 15
|
||||
list : list stat '\n' . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr '|' . expr (13)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 26
|
||||
number goto 9
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr '&' . expr (12)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 27
|
||||
number goto 9
|
||||
|
||||
|
||||
state 18
|
||||
expr : expr '+' . expr (7)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 28
|
||||
number goto 9
|
||||
|
||||
|
||||
state 19
|
||||
expr : expr '-' . expr (8)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 29
|
||||
number goto 9
|
||||
|
||||
|
||||
state 20
|
||||
expr : expr '*' . expr (9)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 30
|
||||
number goto 9
|
||||
|
||||
|
||||
state 21
|
||||
expr : expr '/' . expr (10)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 31
|
||||
number goto 9
|
||||
|
||||
|
||||
state 22
|
||||
expr : expr '%' . expr (11)
|
||||
|
||||
DIGIT shift 3
|
||||
LETTER shift 12
|
||||
'-' shift 5
|
||||
'(' shift 6
|
||||
. error
|
||||
|
||||
expr goto 32
|
||||
number goto 9
|
||||
|
||||
|
||||
state 23
|
||||
number : number DIGIT . (18)
|
||||
|
||||
. reduce 18
|
||||
|
||||
|
||||
state 24
|
||||
stat : LETTER '=' expr . (5)
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'|' shift 16
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'\n' reduce 5
|
||||
|
||||
|
||||
state 25
|
||||
expr : '(' expr ')' . (6)
|
||||
|
||||
. reduce 6
|
||||
|
||||
|
||||
state 26
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
expr : expr '|' expr . (13)
|
||||
|
||||
'&' shift 17
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 13
|
||||
'\n' reduce 13
|
||||
')' reduce 13
|
||||
|
||||
|
||||
state 27
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr '&' expr . (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'+' shift 18
|
||||
'-' shift 19
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 12
|
||||
'&' reduce 12
|
||||
'\n' reduce 12
|
||||
')' reduce 12
|
||||
|
||||
|
||||
state 28
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr '+' expr . (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 7
|
||||
'&' reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
'\n' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 29
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr '-' expr . (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
'*' shift 20
|
||||
'/' shift 21
|
||||
'%' shift 22
|
||||
'|' reduce 8
|
||||
'&' reduce 8
|
||||
'+' reduce 8
|
||||
'-' reduce 8
|
||||
'\n' reduce 8
|
||||
')' reduce 8
|
||||
|
||||
|
||||
state 30
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr '*' expr . (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 31
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr '/' expr . (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 32
|
||||
expr : expr . '+' expr (7)
|
||||
expr : expr . '-' expr (8)
|
||||
expr : expr . '*' expr (9)
|
||||
expr : expr . '/' expr (10)
|
||||
expr : expr . '%' expr (11)
|
||||
expr : expr '%' expr . (11)
|
||||
expr : expr . '&' expr (12)
|
||||
expr : expr . '|' expr (13)
|
||||
|
||||
. reduce 11
|
||||
|
||||
|
||||
16 terminals, 5 nonterminals
|
||||
19 grammar rules, 33 states
|
||||
673
external/bsd/byacc/dist/test/pure_calc.tab.c
vendored
Normal file
673
external/bsd/byacc/dist/test/pure_calc.tab.c
vendored
Normal file
@@ -0,0 +1,673 @@
|
||||
/* $NetBSD: pure_calc.tab.c,v 1.1.1.3 2011/09/10 21:22:03 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse calc_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex calc_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror calc_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar calc_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval calc_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval calc_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug calc_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs calc_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag calc_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs calc_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen calc_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred calc_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto calc_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex calc_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex calc_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex calc_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable calc_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck calc_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname calc_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule calc_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "calc_"
|
||||
|
||||
#define YYPURE 1
|
||||
|
||||
#line 2 "pure_calc.y"
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
int regs[26];
|
||||
int base;
|
||||
|
||||
#line 106 "pure_calc.tab.c"
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(&yylval, YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(YYSTYPE *yylval)
|
||||
# define YYLEX yylex(&yylval)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
#define YYERRCODE 256
|
||||
static const short calc_lhs[] = { -1,
|
||||
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 3,
|
||||
};
|
||||
static const short calc_len[] = { 2,
|
||||
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 1, 1, 1, 2,
|
||||
};
|
||||
static const short calc_defred[] = { 1,
|
||||
0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
|
||||
0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
|
||||
0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
|
||||
10, 11,
|
||||
};
|
||||
static const short calc_dgoto[] = { 1,
|
||||
7, 8, 9,
|
||||
};
|
||||
static const short calc_sindex[] = { 0,
|
||||
-40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
|
||||
-38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
|
||||
-38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc_rindex[] = { 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short calc_gindex[] = { 0,
|
||||
0, 65, 0,
|
||||
};
|
||||
#define YYTABLESIZE 220
|
||||
static const short calc_table[] = { 6,
|
||||
16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
|
||||
15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
|
||||
0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
|
||||
0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
|
||||
0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
|
||||
8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
|
||||
0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
|
||||
14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
|
||||
26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
|
||||
0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
|
||||
0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
|
||||
0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
|
||||
0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
|
||||
0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
|
||||
};
|
||||
static const short calc_check[] = { 40,
|
||||
10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
|
||||
10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
|
||||
-1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
|
||||
-1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
|
||||
-1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
|
||||
38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
|
||||
-1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
|
||||
6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
|
||||
16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
|
||||
-1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
|
||||
-1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
|
||||
-1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
|
||||
-1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
|
||||
-1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
|
||||
};
|
||||
#define YYFINAL 1
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 259
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : list",
|
||||
"list :",
|
||||
"list : list stat '\\n'",
|
||||
"list : list error '\\n'",
|
||||
"stat : expr",
|
||||
"stat : LETTER '=' expr",
|
||||
"expr : '(' expr ')'",
|
||||
"expr : expr '+' expr",
|
||||
"expr : expr '-' expr",
|
||||
"expr : expr '*' expr",
|
||||
"expr : expr '/' expr",
|
||||
"expr : expr '%' expr",
|
||||
"expr : expr '&' expr",
|
||||
"expr : expr '|' expr",
|
||||
"expr : '-' expr",
|
||||
"expr : LETTER",
|
||||
"expr : number",
|
||||
"number : DIGIT",
|
||||
"number : number DIGIT",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
#line 63 "pure_calc.y"
|
||||
/* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
while(!feof(stdin)) {
|
||||
yyparse();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(YYSTYPE *value)
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
*value = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
*value = c - '0';
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
#line 338 "pure_calc.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* variables for the parser stack */
|
||||
YYSTACKDATA yystack;
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
case 3:
|
||||
#line 25 "pure_calc.y"
|
||||
{ yyerrok ; }
|
||||
break;
|
||||
case 4:
|
||||
#line 29 "pure_calc.y"
|
||||
{ printf("%d\n",yystack.l_mark[0]);}
|
||||
break;
|
||||
case 5:
|
||||
#line 31 "pure_calc.y"
|
||||
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
|
||||
break;
|
||||
case 6:
|
||||
#line 35 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-1]; }
|
||||
break;
|
||||
case 7:
|
||||
#line 37 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
|
||||
break;
|
||||
case 8:
|
||||
#line 39 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 9:
|
||||
#line 41 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
|
||||
break;
|
||||
case 10:
|
||||
#line 43 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
|
||||
break;
|
||||
case 11:
|
||||
#line 45 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
|
||||
break;
|
||||
case 12:
|
||||
#line 47 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
|
||||
break;
|
||||
case 13:
|
||||
#line 49 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
|
||||
break;
|
||||
case 14:
|
||||
#line 51 "pure_calc.y"
|
||||
{ yyval = - yystack.l_mark[0]; }
|
||||
break;
|
||||
case 15:
|
||||
#line 53 "pure_calc.y"
|
||||
{ yyval = regs[yystack.l_mark[0]]; }
|
||||
break;
|
||||
case 17:
|
||||
#line 58 "pure_calc.y"
|
||||
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
|
||||
break;
|
||||
case 18:
|
||||
#line 60 "pure_calc.y"
|
||||
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
|
||||
break;
|
||||
#line 611 "pure_calc.tab.c"
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
5
external/bsd/byacc/dist/test/pure_calc.tab.h
vendored
Normal file
5
external/bsd/byacc/dist/test/pure_calc.tab.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: pure_calc.tab.h,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
|
||||
|
||||
#define DIGIT 257
|
||||
#define LETTER 258
|
||||
#define UMINUS 259
|
||||
110
external/bsd/byacc/dist/test/pure_calc.y
vendored
Normal file
110
external/bsd/byacc/dist/test/pure_calc.y
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/* $NetBSD: pure_calc.y,v 1.1.1.3 2011/09/10 21:22:10 christos Exp $ */
|
||||
|
||||
%{
|
||||
# include <stdio.h>
|
||||
# include <ctype.h>
|
||||
|
||||
int regs[26];
|
||||
int base;
|
||||
|
||||
%}
|
||||
|
||||
%start list
|
||||
|
||||
%token DIGIT LETTER
|
||||
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%left UMINUS /* supplies precedence for unary minus */
|
||||
|
||||
%% /* beginning of rules section */
|
||||
|
||||
list : /* empty */
|
||||
| list stat '\n'
|
||||
| list error '\n'
|
||||
{ yyerrok ; }
|
||||
;
|
||||
|
||||
stat : expr
|
||||
{ printf("%d\n",$1);}
|
||||
| LETTER '=' expr
|
||||
{ regs[$1] = $3; }
|
||||
;
|
||||
|
||||
expr : '(' expr ')'
|
||||
{ $$ = $2; }
|
||||
| expr '+' expr
|
||||
{ $$ = $1 + $3; }
|
||||
| expr '-' expr
|
||||
{ $$ = $1 - $3; }
|
||||
| expr '*' expr
|
||||
{ $$ = $1 * $3; }
|
||||
| expr '/' expr
|
||||
{ $$ = $1 / $3; }
|
||||
| expr '%' expr
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| '-' expr %prec UMINUS
|
||||
{ $$ = - $2; }
|
||||
| LETTER
|
||||
{ $$ = regs[$1]; }
|
||||
| number
|
||||
;
|
||||
|
||||
number: DIGIT
|
||||
{ $$ = $1; base = ($1==0) ? 8 : 10; }
|
||||
| number DIGIT
|
||||
{ $$ = base * $1 + $2; }
|
||||
;
|
||||
|
||||
%% /* start of programs */
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
while(!feof(stdin)) {
|
||||
yyparse();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex(YYSTYPE *value)
|
||||
{
|
||||
/* lexical analysis routine */
|
||||
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
|
||||
/* return DIGIT for a digit, yylval = 0 through 9 */
|
||||
/* all other characters are returned immediately */
|
||||
|
||||
int c;
|
||||
|
||||
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
|
||||
|
||||
/* c is now nonblank */
|
||||
|
||||
if( islower( c )) {
|
||||
*value = c - 'a';
|
||||
return ( LETTER );
|
||||
}
|
||||
if( isdigit( c )) {
|
||||
*value = c - '0';
|
||||
return ( DIGIT );
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
27
external/bsd/byacc/dist/test/pure_error.output
vendored
Normal file
27
external/bsd/byacc/dist/test/pure_error.output
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
0 $accept : S $end
|
||||
|
||||
1 S : error
|
||||
|
||||
state 0
|
||||
$accept : . S $end (0)
|
||||
|
||||
error shift 1
|
||||
. error
|
||||
|
||||
S goto 2
|
||||
|
||||
|
||||
state 1
|
||||
S : error . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
|
||||
state 2
|
||||
$accept : S . $end (0)
|
||||
|
||||
$end accept
|
||||
|
||||
|
||||
2 terminals, 2 nonterminals
|
||||
2 grammar rules, 3 states
|
||||
500
external/bsd/byacc/dist/test/pure_error.tab.c
vendored
Normal file
500
external/bsd/byacc/dist/test/pure_error.tab.c
vendored
Normal file
@@ -0,0 +1,500 @@
|
||||
/* $NetBSD: pure_error.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
||||
#endif
|
||||
|
||||
#define YYBYACC 1
|
||||
#define YYMAJOR 1
|
||||
#define YYMINOR 9
|
||||
|
||||
#define YYEMPTY (-1)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define yyerrok (yyerrflag = 0)
|
||||
#define YYRECOVERING() (yyerrflag != 0)
|
||||
|
||||
|
||||
#ifndef yyparse
|
||||
#define yyparse error_parse
|
||||
#endif /* yyparse */
|
||||
|
||||
#ifndef yylex
|
||||
#define yylex error_lex
|
||||
#endif /* yylex */
|
||||
|
||||
#ifndef yyerror
|
||||
#define yyerror error_error
|
||||
#endif /* yyerror */
|
||||
|
||||
#ifndef yychar
|
||||
#define yychar error_char
|
||||
#endif /* yychar */
|
||||
|
||||
#ifndef yyval
|
||||
#define yyval error_val
|
||||
#endif /* yyval */
|
||||
|
||||
#ifndef yylval
|
||||
#define yylval error_lval
|
||||
#endif /* yylval */
|
||||
|
||||
#ifndef yydebug
|
||||
#define yydebug error_debug
|
||||
#endif /* yydebug */
|
||||
|
||||
#ifndef yynerrs
|
||||
#define yynerrs error_nerrs
|
||||
#endif /* yynerrs */
|
||||
|
||||
#ifndef yyerrflag
|
||||
#define yyerrflag error_errflag
|
||||
#endif /* yyerrflag */
|
||||
|
||||
#ifndef yylhs
|
||||
#define yylhs error_lhs
|
||||
#endif /* yylhs */
|
||||
|
||||
#ifndef yylen
|
||||
#define yylen error_len
|
||||
#endif /* yylen */
|
||||
|
||||
#ifndef yydefred
|
||||
#define yydefred error_defred
|
||||
#endif /* yydefred */
|
||||
|
||||
#ifndef yydgoto
|
||||
#define yydgoto error_dgoto
|
||||
#endif /* yydgoto */
|
||||
|
||||
#ifndef yysindex
|
||||
#define yysindex error_sindex
|
||||
#endif /* yysindex */
|
||||
|
||||
#ifndef yyrindex
|
||||
#define yyrindex error_rindex
|
||||
#endif /* yyrindex */
|
||||
|
||||
#ifndef yygindex
|
||||
#define yygindex error_gindex
|
||||
#endif /* yygindex */
|
||||
|
||||
#ifndef yytable
|
||||
#define yytable error_table
|
||||
#endif /* yytable */
|
||||
|
||||
#ifndef yycheck
|
||||
#define yycheck error_check
|
||||
#endif /* yycheck */
|
||||
|
||||
#ifndef yyname
|
||||
#define yyname error_name
|
||||
#endif /* yyname */
|
||||
|
||||
#ifndef yyrule
|
||||
#define yyrule error_rule
|
||||
#endif /* yyrule */
|
||||
#define YYPREFIX "error_"
|
||||
|
||||
#define YYPURE 1
|
||||
|
||||
|
||||
#ifndef YYSTYPE
|
||||
typedef int YYSTYPE;
|
||||
#endif
|
||||
|
||||
/* compatibility with bison */
|
||||
#ifdef YYPARSE_PARAM
|
||||
/* compatibility with FreeBSD */
|
||||
# ifdef YYPARSE_PARAM_TYPE
|
||||
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
|
||||
# else
|
||||
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
|
||||
# endif
|
||||
#else
|
||||
# define YYPARSE_DECL() yyparse(void)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to lex. */
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
|
||||
# define YYLEX yylex(&yylval, YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX_DECL() yylex(YYSTYPE *yylval)
|
||||
# define YYLEX yylex(&yylval)
|
||||
#endif
|
||||
|
||||
/* Parameters sent to yyerror. */
|
||||
#define YYERROR_DECL() yyerror(const char *s)
|
||||
#define YYERROR_CALL(msg) yyerror(msg)
|
||||
|
||||
extern int YYPARSE_DECL();
|
||||
|
||||
#define YYERRCODE 256
|
||||
static const short error_lhs[] = { -1,
|
||||
0,
|
||||
};
|
||||
static const short error_len[] = { 2,
|
||||
1,
|
||||
};
|
||||
static const short error_defred[] = { 0,
|
||||
1, 0,
|
||||
};
|
||||
static const short error_dgoto[] = { 2,
|
||||
};
|
||||
static const short error_sindex[] = { -256,
|
||||
0, 0,
|
||||
};
|
||||
static const short error_rindex[] = { 0,
|
||||
0, 0,
|
||||
};
|
||||
static const short error_gindex[] = { 0,
|
||||
};
|
||||
#define YYTABLESIZE 0
|
||||
static const short error_table[] = { 1,
|
||||
};
|
||||
static const short error_check[] = { 256,
|
||||
};
|
||||
#define YYFINAL 2
|
||||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 0
|
||||
#if YYDEBUG
|
||||
static const char *yyname[] = {
|
||||
|
||||
"end-of-file",
|
||||
};
|
||||
static const char *yyrule[] = {
|
||||
"$accept : S",
|
||||
"S : error",
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int yydebug;
|
||||
int yynerrs;
|
||||
|
||||
/* define the initial stack-sizes */
|
||||
#ifdef YYSTACKSIZE
|
||||
#undef YYMAXDEPTH
|
||||
#define YYMAXDEPTH YYSTACKSIZE
|
||||
#else
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 500
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define YYINITSTACKSIZE 500
|
||||
|
||||
typedef struct {
|
||||
unsigned stacksize;
|
||||
short *s_base;
|
||||
short *s_mark;
|
||||
short *s_last;
|
||||
YYSTYPE *l_base;
|
||||
YYSTYPE *l_mark;
|
||||
} YYSTACKDATA;
|
||||
#line 4 "pure_error.y"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("yyparse() = %d\n", yyparse());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
yylex(YYSTYPE *value)
|
||||
{
|
||||
return value ? 0 : -1;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char* s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
#line 226 "pure_error.tab.c"
|
||||
|
||||
#if YYDEBUG
|
||||
#include <stdio.h> /* needed for printf */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* needed for malloc, etc */
|
||||
#include <string.h> /* needed for memset */
|
||||
|
||||
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
|
||||
static int yygrowstack(YYSTACKDATA *data)
|
||||
{
|
||||
int i;
|
||||
unsigned newsize;
|
||||
short *newss;
|
||||
YYSTYPE *newvs;
|
||||
|
||||
if ((newsize = data->stacksize) == 0)
|
||||
newsize = YYINITSTACKSIZE;
|
||||
else if (newsize >= YYMAXDEPTH)
|
||||
return -1;
|
||||
else if ((newsize *= 2) > YYMAXDEPTH)
|
||||
newsize = YYMAXDEPTH;
|
||||
|
||||
i = data->s_mark - data->s_base;
|
||||
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
|
||||
if (newss == 0)
|
||||
return -1;
|
||||
|
||||
data->s_base = newss;
|
||||
data->s_mark = newss + i;
|
||||
|
||||
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
|
||||
if (newvs == 0)
|
||||
return -1;
|
||||
|
||||
data->l_base = newvs;
|
||||
data->l_mark = newvs + i;
|
||||
|
||||
data->stacksize = newsize;
|
||||
data->s_last = data->s_base + newsize - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if YYPURE || defined(YY_NO_LEAKS)
|
||||
static void yyfreestack(YYSTACKDATA *data)
|
||||
{
|
||||
free(data->s_base);
|
||||
free(data->l_base);
|
||||
memset(data, 0, sizeof(*data));
|
||||
}
|
||||
#else
|
||||
#define yyfreestack(data) /* nothing */
|
||||
#endif
|
||||
|
||||
#define YYABORT goto yyabort
|
||||
#define YYREJECT goto yyabort
|
||||
#define YYACCEPT goto yyaccept
|
||||
#define YYERROR goto yyerrlab
|
||||
|
||||
int
|
||||
YYPARSE_DECL()
|
||||
{
|
||||
int yyerrflag;
|
||||
int yychar;
|
||||
YYSTYPE yyval;
|
||||
YYSTYPE yylval;
|
||||
|
||||
/* variables for the parser stack */
|
||||
YYSTACKDATA yystack;
|
||||
int yym, yyn, yystate;
|
||||
#if YYDEBUG
|
||||
const char *yys;
|
||||
|
||||
if ((yys = getenv("YYDEBUG")) != 0)
|
||||
{
|
||||
yyn = *yys;
|
||||
if (yyn >= '0' && yyn <= '9')
|
||||
yydebug = yyn - '0';
|
||||
}
|
||||
#endif
|
||||
|
||||
yynerrs = 0;
|
||||
yyerrflag = 0;
|
||||
yychar = YYEMPTY;
|
||||
yystate = 0;
|
||||
|
||||
#if YYPURE
|
||||
memset(&yystack, 0, sizeof(yystack));
|
||||
#endif
|
||||
|
||||
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
|
||||
yystack.s_mark = yystack.s_base;
|
||||
yystack.l_mark = yystack.l_base;
|
||||
yystate = 0;
|
||||
*yystack.s_mark = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, shifting to state %d\n",
|
||||
YYPREFIX, yystate, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
yychar = YYEMPTY;
|
||||
if (yyerrflag > 0) --yyerrflag;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
goto yyreduce;
|
||||
}
|
||||
if (yyerrflag) goto yyinrecovery;
|
||||
|
||||
yyerror("syntax error");
|
||||
|
||||
goto yyerrlab;
|
||||
|
||||
yyerrlab:
|
||||
++yynerrs;
|
||||
|
||||
yyinrecovery:
|
||||
if (yyerrflag < 3)
|
||||
{
|
||||
yyerrflag = 3;
|
||||
for (;;)
|
||||
{
|
||||
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, error recovery shifting\
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
yystate = yytable[yyn];
|
||||
*++yystack.s_mark = yytable[yyn];
|
||||
*++yystack.l_mark = yylval;
|
||||
goto yyloop;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: error recovery discarding state %d\n",
|
||||
YYPREFIX, *yystack.s_mark);
|
||||
#endif
|
||||
if (yystack.s_mark <= yystack.s_base) goto yyabort;
|
||||
--yystack.s_mark;
|
||||
--yystack.l_mark;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yychar == 0) goto yyabort;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
||||
YYPREFIX, yystate, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
yychar = YYEMPTY;
|
||||
goto yyloop;
|
||||
}
|
||||
|
||||
yyreduce:
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
||||
YYPREFIX, yystate, yyn, yyrule[yyn]);
|
||||
#endif
|
||||
yym = yylen[yyn];
|
||||
if (yym)
|
||||
yyval = yystack.l_mark[1-yym];
|
||||
else
|
||||
memset(&yyval, 0, sizeof yyval);
|
||||
switch (yyn)
|
||||
{
|
||||
}
|
||||
yystack.s_mark -= yym;
|
||||
yystate = *yystack.s_mark;
|
||||
yystack.l_mark -= yym;
|
||||
yym = yylhs[yyn];
|
||||
if (yystate == 0 && yym == 0)
|
||||
{
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state 0 to\
|
||||
state %d\n", YYPREFIX, YYFINAL);
|
||||
#endif
|
||||
yystate = YYFINAL;
|
||||
*++yystack.s_mark = YYFINAL;
|
||||
*++yystack.l_mark = yyval;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = YYLEX) < 0) yychar = 0;
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("%sdebug: state %d, reading %d (%s)\n",
|
||||
YYPREFIX, YYFINAL, yychar, yys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (yychar == 0) goto yyaccept;
|
||||
goto yyloop;
|
||||
}
|
||||
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
||||
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
||||
yystate = yytable[yyn];
|
||||
else
|
||||
yystate = yydgoto[yym];
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
printf("%sdebug: after reduction, shifting from state %d \
|
||||
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
|
||||
#endif
|
||||
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
|
||||
{
|
||||
goto yyoverflow;
|
||||
}
|
||||
*++yystack.s_mark = (short) yystate;
|
||||
*++yystack.l_mark = yyval;
|
||||
goto yyloop;
|
||||
|
||||
yyoverflow:
|
||||
yyerror("yacc stack overflow");
|
||||
|
||||
yyabort:
|
||||
yyfreestack(&yystack);
|
||||
return (1);
|
||||
|
||||
yyaccept:
|
||||
yyfreestack(&yystack);
|
||||
return (0);
|
||||
}
|
||||
2
external/bsd/byacc/dist/test/pure_error.tab.h
vendored
Normal file
2
external/bsd/byacc/dist/test/pure_error.tab.h
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* $NetBSD: pure_error.tab.h,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
|
||||
|
||||
31
external/bsd/byacc/dist/test/pure_error.y
vendored
Normal file
31
external/bsd/byacc/dist/test/pure_error.y
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $NetBSD: pure_error.y,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
|
||||
|
||||
%%
|
||||
S: error
|
||||
%%
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef YYBYACC
|
||||
extern int YYLEX_DECL();
|
||||
static void YYERROR_DECL();
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("yyparse() = %d\n", yyparse());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
yylex(YYSTYPE *value)
|
||||
{
|
||||
return value ? 0 : -1;
|
||||
}
|
||||
|
||||
static void
|
||||
yyerror(const char* s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
20
external/bsd/byacc/dist/test/run_lint.sh
vendored
Normal file
20
external/bsd/byacc/dist/test/run_lint.sh
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Id: run_lint.sh,v 1.1 2010/06/08 09:00:58 tom Exp
|
||||
# vi:ts=4 sw=4:
|
||||
|
||||
# run lint on each of the ".c" files in the test directory
|
||||
|
||||
if test $# = 1
|
||||
then
|
||||
PROG_DIR=`pwd`
|
||||
TEST_DIR=$1
|
||||
else
|
||||
PROG_DIR=..
|
||||
TEST_DIR=.
|
||||
fi
|
||||
|
||||
echo '** '`date`
|
||||
for i in ${TEST_DIR}/*.c
|
||||
do
|
||||
make -f $PROG_DIR/makefile lint C_FILES=$i srcdir=$PROG_DIR
|
||||
done
|
||||
22
external/bsd/byacc/dist/test/run_make.sh
vendored
Normal file
22
external/bsd/byacc/dist/test/run_make.sh
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# Id: run_make.sh,v 1.1 2010/06/08 09:00:39 tom Exp
|
||||
# vi:ts=4 sw=4:
|
||||
|
||||
# do a test-compile on each of the ".c" files in the test-directory
|
||||
|
||||
if test $# = 1
|
||||
then
|
||||
PROG_DIR=`pwd`
|
||||
TEST_DIR=$1
|
||||
else
|
||||
PROG_DIR=..
|
||||
TEST_DIR=.
|
||||
fi
|
||||
|
||||
echo '** '`date`
|
||||
for i in ${TEST_DIR}/*.c
|
||||
do
|
||||
obj=`echo "$i" |sed -e 's/\.c$/.o/'`
|
||||
make -f $PROG_DIR/makefile $obj C_FILES=$i srcdir=$PROG_DIR
|
||||
test -f $obj && rm $obj
|
||||
done
|
||||
73
external/bsd/byacc/dist/test/run_test.sh
vendored
Normal file
73
external/bsd/byacc/dist/test/run_test.sh
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
# Id: run_test.sh,v 1.6 2010/06/08 08:53:38 tom Exp
|
||||
# vi:ts=4 sw=4:
|
||||
|
||||
if test $# = 1
|
||||
then
|
||||
PROG_DIR=`pwd`
|
||||
TEST_DIR=$1
|
||||
else
|
||||
PROG_DIR=..
|
||||
TEST_DIR=.
|
||||
fi
|
||||
|
||||
YACC=$PROG_DIR/yacc
|
||||
|
||||
tmpfile=temp$$
|
||||
|
||||
echo '** '`date`
|
||||
for i in ${TEST_DIR}/*.y
|
||||
do
|
||||
case $i in
|
||||
test*)
|
||||
echo "?? ignored $i"
|
||||
;;
|
||||
*)
|
||||
root=`basename $i .y`
|
||||
ROOT="test-$root"
|
||||
prefix=${root}_
|
||||
|
||||
OPTS=
|
||||
TYPE=".output .tab.c .tab.h"
|
||||
case $i in
|
||||
${TEST_DIR}/code_*)
|
||||
OPTS="$OPTS -r"
|
||||
TYPE="$TYPE .code.c"
|
||||
prefix=`echo "$prefix" | sed -e 's/^code_//'`
|
||||
;;
|
||||
${TEST_DIR}/pure_*)
|
||||
OPTS="$OPTS -P"
|
||||
prefix=`echo "$prefix" | sed -e 's/^pure_//'`
|
||||
;;
|
||||
esac
|
||||
|
||||
$YACC $OPTS -v -d -p $prefix -b $ROOT $i
|
||||
for type in $TYPE
|
||||
do
|
||||
REF=${TEST_DIR}/${root}${type}
|
||||
CMP=${ROOT}${type}
|
||||
if test ! -f $CMP ; then
|
||||
echo "...not found $CMP"
|
||||
continue
|
||||
fi
|
||||
sed -e s,$CMP,$REF, \
|
||||
-e /YYPATCH/d \
|
||||
-e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
|
||||
< $CMP >$tmpfile \
|
||||
&& mv $tmpfile $CMP
|
||||
if test ! -f $REF
|
||||
then
|
||||
mv $CMP $REF
|
||||
echo "...saved $REF"
|
||||
elif ( cmp -s $REF $CMP )
|
||||
then
|
||||
echo "...ok $REF"
|
||||
rm -f $CMP
|
||||
else
|
||||
echo "...diff $REF"
|
||||
diff -u $REF $CMP
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user