From 19dd8d033e44d9b11e5fff46b3789ffae7ae6e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 6 Dec 2006 22:57:59 +0000 Subject: [PATCH] upgraded to bison 2.3 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19439 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/bison/ChangeLog | 1805 +++++++++++- src/bin/bison/Makefile.am | 9 +- src/bin/bison/Makefile.cfg | 27 +- src/bin/bison/Makefile.in | 35 +- src/bin/bison/Makefile.maint | 148 +- src/bin/bison/NEWS | 98 +- src/bin/bison/PACKAGING | 56 + src/bin/bison/README-alpha | 38 - src/bin/bison/REFERENCES | 30 - src/bin/bison/THANKS | 8 +- src/bin/bison/TODO | 59 +- src/bin/bison/aclocal.m4 | 8 +- src/bin/bison/config.h | 36 +- src/bin/bison/config.hin | 106 +- src/bin/bison/configure | 2611 +++++++++++++---- src/bin/bison/configure.ac | 10 +- src/bin/bison/data/Makefile.am | 2 +- src/bin/bison/data/Makefile.in | 20 +- src/bin/bison/data/c++.m4 | 17 +- src/bin/bison/data/c.m4 | 228 +- src/bin/bison/data/glr.c | 1497 ++++++---- src/bin/bison/data/glr.cc | 389 +++ src/bin/bison/data/lalr1.cc | 1510 ++++------ src/bin/bison/data/location.cc | 253 ++ src/bin/bison/data/m4sugar/m4sugar.m4 | 15 +- src/bin/bison/data/yacc.c | 786 ++--- src/bin/bison/doc/FAQ | 109 - src/bin/bison/doc/Makefile.am | 4 +- src/bin/bison/doc/Makefile.in | 20 +- src/bin/bison/doc/bison.info | 1378 ++++++--- src/bin/bison/doc/bison.texinfo | 1105 ++++--- src/bin/bison/doc/stamp-vti | 8 +- src/bin/bison/doc/version.texi | 8 +- src/bin/bison/lib/Jamfile | 3 +- src/bin/bison/lib/Makefile.in | 67 +- src/bin/bison/lib/abitset.c | 20 +- src/bin/bison/lib/alloca.c | 491 ---- src/bin/bison/lib/alloca_.h | 52 - src/bin/bison/lib/argmatch.c | 2 +- src/bin/bison/lib/argmatch.h | 21 +- src/bin/bison/lib/basename.c | 2 +- src/bin/bison/lib/bbitset.h | 18 +- src/bin/bison/lib/bitset.c | 26 +- src/bin/bison/lib/bitset.h | 4 + src/bin/bison/lib/bitset_stats.c | 18 +- src/bin/bison/lib/bitsetv-print.c | 29 +- src/bin/bison/lib/bitsetv.c | 29 +- src/bin/bison/lib/dirname.c | 2 +- src/bin/bison/lib/dup-safer.c | 2 +- src/bin/bison/lib/ebitset.c | 23 +- src/bin/bison/lib/exitfail.c | 2 +- src/bin/bison/lib/fd-safer.c | 2 +- src/bin/bison/lib/fopen-safer.c | 2 +- src/bin/bison/lib/get-errno.c | 6 +- src/bin/bison/lib/getopt.c | 82 +- src/bin/bison/lib/getopt.h | 6 +- src/bin/bison/lib/getopt1.c | 2 +- src/bin/bison/lib/gnulib.mk | 35 +- src/bin/bison/lib/hard-locale.c | 2 +- src/bin/bison/lib/hash.c | 2 +- src/bin/bison/lib/lbitset.c | 23 +- src/bin/bison/lib/malloc.c | 2 +- src/bin/bison/lib/obstack.c | 13 +- src/bin/bison/lib/obstack.h | 12 +- src/bin/bison/lib/pipe-safer.c | 2 +- src/bin/bison/lib/quote.c | 2 +- src/bin/bison/lib/quotearg.c | 19 +- src/bin/bison/lib/realloc.c | 39 - src/bin/bison/lib/stdbool_.h | 38 +- src/bin/bison/lib/strerror.c | 49 + src/bin/bison/lib/stripslash.c | 2 +- src/bin/bison/lib/strndup.c | 29 +- src/bin/bison/lib/strnlen.c | 29 +- src/bin/bison/lib/strtol.c | 447 +++ src/bin/bison/lib/strtoul.c | 20 + src/bin/bison/lib/strverscmp.c | 131 + src/bin/bison/lib/{xstrdup.c => strverscmp.h} | 25 +- src/bin/bison/lib/subpipe.c | 22 +- src/bin/bison/lib/subpipe.h | 26 +- src/bin/bison/lib/timevar.c | 34 +- src/bin/bison/lib/timevar.h | 23 +- src/bin/bison/lib/unlocked-io.h | 193 +- src/bin/bison/lib/vbitset.c | 9 +- src/bin/bison/lib/verify.h | 141 + src/bin/bison/lib/xalloc-die.c | 5 +- src/bin/bison/lib/xmalloc.c | 2 +- src/bin/bison/lib/xstrndup.c | 2 +- src/bin/bison/src/LR0.c | 44 +- src/bin/bison/src/Makefile.am | 6 +- src/bin/bison/src/Makefile.in | 31 +- src/bin/bison/src/assoc.c | 7 +- src/bin/bison/src/assoc.h | 4 +- src/bin/bison/src/closure.c | 5 +- src/bin/bison/src/complain.c | 4 +- src/bin/bison/src/conflicts.c | 52 +- src/bin/bison/src/derives.c | 6 +- src/bin/bison/src/files.c | 109 +- src/bin/bison/src/files.h | 19 +- src/bin/bison/src/getargs.c | 24 +- src/bin/bison/src/getargs.h | 8 +- src/bin/bison/src/gram.c | 16 +- src/bin/bison/src/gram.h | 13 +- src/bin/bison/src/lalr.c | 21 +- src/bin/bison/src/location.c | 4 +- src/bin/bison/src/location.h | 10 +- src/bin/bison/src/main.c | 10 +- src/bin/bison/src/muscle_tab.c | 9 +- src/bin/bison/src/nullable.c | 9 +- src/bin/bison/src/output.c | 44 +- src/bin/bison/src/output.h | 4 +- src/bin/bison/src/parse-gram.c | 1827 +++++++----- src/bin/bison/src/parse-gram.h | 104 +- src/bin/bison/src/parse-gram.y | 118 +- src/bin/bison/src/print.c | 4 +- src/bin/bison/src/print_graph.c | 1 + src/bin/bison/src/reader.c | 183 +- src/bin/bison/src/reader.h | 16 +- src/bin/bison/src/reduce.c | 7 +- src/bin/bison/src/relation.c | 1 + src/bin/bison/src/scan-gram.c | 1289 ++++---- src/bin/bison/src/scan-gram.l | 160 +- src/bin/bison/src/scan-skel.c | 242 +- src/bin/bison/src/scan-skel.h | 15 +- src/bin/bison/src/scan-skel.l | 37 +- src/bin/bison/src/state.c | 31 +- src/bin/bison/src/symlist.c | 85 +- src/bin/bison/src/symlist.h | 30 +- src/bin/bison/src/symtab.c | 50 +- src/bin/bison/src/symtab.h | 6 +- src/bin/bison/src/system.h | 37 +- src/bin/bison/src/tables.c | 22 +- src/bin/bison/src/uniqstr.c | 1 + src/bin/bison/src/vcg.c | 26 +- 133 files changed, 12689 insertions(+), 6784 deletions(-) create mode 100644 src/bin/bison/PACKAGING delete mode 100644 src/bin/bison/README-alpha delete mode 100644 src/bin/bison/REFERENCES create mode 100644 src/bin/bison/data/glr.cc create mode 100644 src/bin/bison/data/location.cc delete mode 100644 src/bin/bison/doc/FAQ delete mode 100644 src/bin/bison/lib/alloca.c delete mode 100644 src/bin/bison/lib/alloca_.h delete mode 100644 src/bin/bison/lib/realloc.c create mode 100644 src/bin/bison/lib/strerror.c create mode 100644 src/bin/bison/lib/strtol.c create mode 100644 src/bin/bison/lib/strtoul.c create mode 100644 src/bin/bison/lib/strverscmp.c rename src/bin/bison/lib/{xstrdup.c => strverscmp.h} (58%) create mode 100644 src/bin/bison/lib/verify.h diff --git a/src/bin/bison/ChangeLog b/src/bin/bison/ChangeLog index 64f4b1ad7c..c44f0e4c72 100644 --- a/src/bin/bison/ChangeLog +++ b/src/bin/bison/ChangeLog @@ -1,3 +1,1788 @@ +2006-06-05 Paul Eggert + + * NEWS: Version 2.3. + * configure.ac (AC_INIT): Likewise. + +2006-05-30 Paul Eggert + + * data/glr.c (YYRECOVERING): Define to be a function-like macro + with no arguments, not as an object-like macro. This is for + compatibility with data/yacc.c. Problem reported by John P. Hartmann in + . + * doc/bison.texinfo (Action Features, Error Recovery, Table of Symbols): + Document this. + +2006-05-30 Joel E. Denny + + * src/getargs.c (usage): Back out yesterday's modification of the + --help output so that we don't have to wait for translation before + releasing 2.3. + +2006-05-29 Paul Eggert + + * doc/bison.texinfo (Introduction): Don't say "GLR grammar". + Problem reported by Akim Demaille. + +2006-05-29 Joel E. Denny + + * src/getargs.c (usage): Mention GLR not just LALR(1) in --help output. + +2006-05-26 Paul Eggert + + * data/yacc.c (yy_reduce_print): Omit trailing white space in + generated source code. Problem reported by Frans Englich in + . + +2006-05-22 Paul Eggert + + * Makefile.maint (gzip_rsyncable, GZIP_ENV): Compute within the + shell, not within 'make', so that 'make' by an ordinary builder + (using GNU make) does not worry about configuring gzip. This also + works around a bug reported independently by Keith Thompson and by + Georg Schwarz, whereby gzip 1.2.4 --help would output usage on + stderr rather than stdout, messing up the build logs. + +2006-05-21 Joel E. Denny + + * data/yacc.c (yyparse): Wrap the final return from yyparse inside YYID + to make sure that YYID will never be unused. This fixes a 'make + maintainer-check' failure caused by the recent changes to the 'Trivial + grammars' test case, which caused g++ 4.1.0 to complain that YYID was + not used. + * data/glr.c (yyparse): Wrap yyparse's return inside YYID just in case. + +2006-05-21 Joel E. Denny + + * data/glr.c (yyresolveLocations): Remove bogus YYASSERT that the + state before an empty RHS is always resolved here. Only the location + of that state is guaranteed to be resolved, and that's enough. This + fixes the remaining bug reported by Derek M. Jones in + . + * tests/glr-regression.at (Uninitialized location when reporting + ambiguity): Test the above case. + Also, the embedded comments in this test case claim it checks the case + of an empty RHS that has inherited the initial location. However, the + corresponding LHS was already resolved, so yyresolveLocations didn't + actually have reason to modify it. Fix this by forcing + nondeterministic operation at the beginning of the parse. + +2006-05-20 Paul Eggert + + * data/c.m4 (b4_yy_symbol_print_generate): + (b4_yy_symbol_print_generate): Use 'YYSTYPE const' rather than + 'const YYSTYPE', and similarly for YYLTYPE. This fixes one + of the bugs reported today by Derek M Jones in + . + * doc/bison.texinfo (Value Type): Document that YYSTYPE must be + defined to be a type name without parens or brackets. + (Location Type): Similarly for YYLTYPE. + * tests/regression.at (Trivial grammars): Put in a test for this + bug that will be caught by 'make maintainer-check' (though not, + alas, by 'make check' unless your compiler is picky). + +2006-05-19 Paul Eggert + + * NEWS: Version 2.2. + * configure.ac (AC_INIT): Likewise. + +2006-05-17 Joel E. Denny + + * data/glr.c (yyreportTree): Make room in yystates for the state + preceding the RHS. This fixes the segmentation fault reported by Derek + M. Jones in + . + (yyreportTree, yypdumpstack): Subtract 1 from yyrule before printing + to the user. Reported for yyreportTree by Derek M. Jones later in the + same thread. + * THANKS: Add Derek M. Jones. + Update my email address. + Fix typo in Steve Murphy's name. + +2006-05-14 Paul Eggert + + * data/glr.c (yyreportSyntaxError): Fix off-by-one error in + checking against YYLAST that caused the parser to miss a potential + alternative in its diagnostic. + Problem reported by Maria Jose Moron Fernandez in + . + * data/lalr1.cc (yysyntax_error_): Likewise. + * data/yacc.c (yysyntax_error): Likewise. + * tests/regression.at (_AT_DATA_DANCER_Y): Use static array for + tokens, in case we run into an older C compiler. + (_AT_DATA_EXPECT2_Y, AT_CHECK_EXPECT2): New macros. + Use them to check for the off-by-one error fixed above. + + * data/yacc.c (yytnamerr): Fix typo: local var should be of type + YYSIZE_T, not size_t. + * tests/regression.at (Trivial grammars): New test, to catch + the error fixed by the above patch. + +2006-05-14 Akim Demaille + + * doc/bison.texinfo (C++ Bison Interface): Clarify the naming + scheme. + Reported by Steve Murphy. + +2006-05-14 Akim Demaille + + * data/glr.cc, data/lalr1.cc: Using %defines is mandatory. + * data/glr.cc: b4_location_flag is now b4_locations_flag. + +2006-05-14 Akim Demaille + + Implement --trace=m4. + * src/getargs.c (trace_types, trace_args): Accept trace_m4. + * src/output.c (output_skeleton): When set, pass -dV to m4. + + Factor the handling of flags in m4. + * src/output.c (prepare): Rename the muscle names debug, defines, + error_verbose to debug_flag, defines_flag, error_verbose_flag. + * data/c.m4: Adjust. + (_b4_define_flag_if, b4_define_flag_if, b4_defines_if): New. + Use b4_define_flag_if to define other b4_FLAG_if macros. + (b4_location_if): As a consequence, rename as... + (b4_locations_if): this, for consistency. + Adjust all the skeletons. + +2006-05-14 Akim Demaille + + * etc/bench.pm: Shorten bench names. + +2006-05-14 Akim Demaille + + * src/output.h, src/output.c (error_verbose): Move to... + * src/getargs.h, src/getargs.c: here. + Sort the flags. + Adjust dependencies. + +2006-05-13 Paul Eggert + + * data/c.m4 (b4_copyright): Put the special exception for Bison + skeletons here, so we don't have to put it in each skeleton. All + uses changed. Suggested by Akim Demaille. Also, wrap the + copyright notice, in case it is longer than 80 columns. Replace + comma by newline after title. + +2006-05-11 Paul Eggert + + * doc/bison.texinfo (Calc++ Scanner): The flex behavior is an + incompatibility, not a bug. Mention that it wasn't fixed as of + flex 2.5.33. + +2006-05-11 Akim Demaille + + * examples/extexi: Enforce the precedence of concatenation over + >>. + Reported by Tommy Nordgren. + +2006-05-11 Akim Demaille + + * data/lalr1.cc (yytranslate_): Rename token as t to avoid clashes + with the member "token". + Reported by Martin Nylin. + +2006-05-08 Paul Eggert + + * data/glr.c: Switch to Bison 2.2 special-exception language in + the copyright notice. Use more-regular format for titles and + copyright notices. + * data/glr.cc: Likewise. + * data/location.cc: Likewise. + * data/yacc.cc: Likewise. + * doc/bison.texinfo (Conditions): Document this. + * NEWS: likewise. Upgrade version to 2.2. + +2006-04-27 Akim Demaille + + * data/glr.cc: Remove dead code. + +2006-04-25 Paul Eggert + + * bootstrap: Comment out the AM_CPPFLAGS line, since we don't use + that variable and the line breaks the bootstrap. Problem reported + by Juan M. Guerrero. + +2006-04-24 Akim Demaille + + * doc/bison.texinfo (Multiple start-symbols): New. + +2006-04-24 Akim Demaille + + * etc/README, etc/bench.pl: New. + +2006-04-03 Akim Demaille + + * src/scan-gram.l: Be robust to BRACED_CODE appearing before any + rule. + Reported by Mickael Labau. + * tests/input.at (Torturing the Scanner): Test it. + +2006-03-16 Paul Eggert + + * doc/bison.texinfo (Decl Summary): Don't mention yylloc twice. + Problem reported by Bob Rossi. + +2006-03-13 Paul Eggert + + * doc/bison.texinfo: Remove @shorttitlepage stuff; it wasn't used + and didn't really work. + For the index, use @ifnotinfo, not @iftex. + Minor cleanups of spacing and terminology. + +2006-03-12 Akim Demaille + + * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Fix the definition + of AT_NAME_PREFIX when %name-prefix is not used. + +2006-03-12 Akim Demaille + + Apply --prefix to C++ skeletons too: they change the namespace. + The test suite already exercize these cases. + * data/c++.m4 (b4_namespace): New. + * data/lalr1.cc, data/glr.cc, data/location.cc: Use it instead of `yy'. + * data/lalr1.cc (yytnameerr_): Move its definition into the namespace. + * data/yacc.c, data/glr.c: Remove a useless `[]'. + * doc/bison.texinfo: Document it. + (Option Cross Key): Use @multitable in all formats. It looks + nicer, even in TeX outputs. + (Rules): Use the same code whatever the output type is. + * tests/local.at (_AT_BISON_OPTION_PUSHDEFS) + (_AT_BISON_OPTION_POPDEFS): Support AT_NAME_PREFIX. + * tests/calc.at: Use it, instead of hard coding `yy'. + +2006-03-10 Akim Demaille + + * TODO: Remove dead items. + +2006-03-10 Akim Demaille + + * doc/FAQ: Remove, merged into... + * doc/bison.texinfo (FAQ): this. + * doc/Makefile.am (EXTRA_DIST): Adjust. + +2006-03-10 Akim Demaille + + * data/c.m4 (b4_token_enum): Always define the enum of tokens, + even if empty. + * data/lalrl1.cc, data/glr.cc (parser::token_type): New. + * doc/bison.texinfo (Calc++ Scanner): Use it. + +2006-03-09 Paul Eggert + + Fix two nits reported by twlevo, plus one more that I discovered. + + * src/assoc.h (assoc_to_string): Give a name to the arg, as + this is the usual Bison style. + * src/location.h (location_print): Likewise. + + * src/reader.h (token_name): Likewise. + +2006-03-08 Paul Eggert + + Fix some nits reported by twlevo. + * doc/FAQ: Remove ancient Y2K FAQ, replacing it with "secure" + and "POSIX". Use more-modern syntax for URLs. Mention C++ + and ask for Java. Don't hardwire OS version numbers. Add + copyright notice. + * m4/.cvsignore: Add unistd_h.m4, for latest gnulib. + * src/conflicts.c (solved_conflicts_obstack): Now static. + +2006-03-08 Joel E. Denny + + * doc/bison.texinfo (Introduction): Mention GLR and C++ as on the web + page. Say "you can use it" not "you may use it" as on the web page; + we're describing capabilities not granting permission. + +2006-03-06 Paul Eggert + + * data/glr.c (yyresolveLocations): Rename local variables to avoid + shadowing warnings. Use usual patter for iterating through RHS. + * tests/glr-regression.at + (Uninitialized location when reporting ambiguity): + Modify yylex so that it uses its argument, rather than trying + to rely on ARGSUSED (which doesn't work for gcc with warnings). + const char -> char const. + + * tests/Makefile.am ($(srcdir)/package.m4, maintainer-check-valgrind): + Don't use tabs inside commands; it messes up 'ps'. + Problem reported by twlevo. + +2006-03-06 Joel E. Denny + + * tests/glr-regression.at (Uninitialized location when reporting + ambiguity): New test case. + * data/glr.c (yyresolveLocations): New function, which uses + YYLLOC_DEFAULT. + (yyresolveValue): Invoke yyresolveLocations before reporting an + ambiguity. + * doc/bison.texinfo (Default Action for Locations): Note + YYLLOC_DEFAULT's usage for ambiguity locations. + (GLR Semantic Actions): Cross-reference those notes. + +2006-03-04 Joel E. Denny + + * tests/glr-regression.at (Leaked semantic values when reporting + ambiguity): Remove unnecessary union and type declarations. + (Leaked lookahead after nondeterministic parse syntax error): New test + case. + * data/glr.c (yyparse): Check for zero stacks remaining before + attempting to shift the lookahead so that you don't lose it. + +2006-03-02 Joel E. Denny + + Avoid memory leaks by not invoking longjmp in yyreportAmbiguity. + * tests/glr-regression.at (Leaked semantic values when reporting + ambiguity): New test case. + * data/glr.c (yyreportAmbiguity): Invoke yyyerror directly and return + yyabort rather than invoking yyFail, which invokes longjmp. Remove the + now unnecessary yystackp parameter. + (yyresolveValue): Return yyreportAmbiguity's result. Now the necessary + destructors can be called. + + * tests/glr-regression.at: Don't invoke bison with `-t' unnecessarily + in existing testcases. + +2006-03-02 Joel E. Denny + + Don't leak semantic values for parent RHS when a user action cuts the + parser, and clean up related code a bit. + * tests/glr-regression.at (Leaked merged semantic value if user action + cuts parse): Rename to... + (Leaked semantic values if user action cuts parse): ... this. Add check + for leaked parent RHS values. + * data/glr.c (yydestroyGLRState): In debugging output, distinguish + between an unresolved state (non-empty chain of semantic options) and + an incomplete one (signaled by an empty chain). + (yyresolveStates): Document the interface. Move all manipulation of a + successfully or unsuccessfully resolved yyGLRState to... + (yyresolveValue): ... here so that yyresolveValue always leaves a + yyGLRState with consistent data and thus is easier to understand. + Remove the yyvalp and yylocp parameters since they are always just + taken from the yys parameter. When reporting a discarded merged value + in debugging output, note that it is incompletely merged. Document the + interface. + (yyresolveAction): If resolving any of the RHS states fails, destroy + them all rather than leaking them. Thus, as long as user actions are + written to clean up the RHS correctly, yyresolveAction always cleans up + the RHS of a semantic option. Document the interface. + +2006-02-27 Paul Eggert + + * data/glr.c (yyexpandGLRStack): Catch an off-by-one error that + led to a segmentation fault in GNU Pascal. Problem reported + by Waldek Hebisch. + +2006-02-21 Joel E. Denny + + * doc/bison.texinfo (Mid-Rule Actions): Explain how to bury a + mid-rule action inside a nonterminal symbol in order to declare a + destructor for its semantic value. + +2006-02-16 Paul Eggert + + * data/yacc.c [(! defined yyoverflow || YYERROR_VERBOSE) && ! + YYSTACK_USE_ALLOCA && ! defined YYSTACK_ALLOC && defined + __cplusplus && ! defined _STDLIB_H && ! + ((defined YYMALLOC || defined malloc) && (defined YYFREE || + defined free))]: Include rather than rolling our own + declarations of malloc and free, to avoid problems with + incompatible declarations (using 'throw') C++'s stdlib.h. This + should fix Debian bug 340012 + , + reported by Guillaume Melquiond. + +2006-02-13 Paul Eggert + + * NEWS: Clarify symbols versus types in unused-value warnings. + + * configure.ac (AC_INIT): Bump version number. + +2006-02-13 Paul Eggert + + * NEWS: Version 2.1a. + * tests/headers.at (AT_TEST_CPP_GUARD_H): Declare yyerror and yylex, + since C99 requires this. + +2006-02-11 Paul Eggert + + * m4/c-working.m4: New file. + * configure.ac (BISON_TEST_FOR_WORKING_C_COMPILER): Use it. + +2006-02-10 Paul Eggert + + * Makefile.maint: Merge from coreutils. + +2006-02-09 Paul Eggert + + More portability fixes for problems summarized by Nelson H. F. Beebe. + + * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Catch a + configuration screwup "./configure CC=/opt/SUNWspro/bin/c89 + CFLAGS="-xarch=generic64" CXX=/opt/SUNWspro/bin/CC + LDFLAGS="-xarch=generic64" with Sun C 5.7 on Solaris 10; this + messes up because C++ code is compiled in 32-bit mode but linked + in 64-bit mode. + +2006-02-08 Paul Eggert + + More portability fixes for problems summarized by Nelson H. F. Beebe. + + * doc/bison.texinfo (Calc++ Scanner): Work around a bug in flex + 2.5.31. This resembles the 2005-10-10 patch to src/scan-skel.l. + + * examples/calc++/Makefile.am (check_PROGRAMS): Renamed from + nodist_PROGRAMS, since we don't need to actually compile the + example if we're just doing a plain 'make'. This avoids bothering + the installer unnecessarily about problems due to weird C++ + compilers. + +2006-02-06 Paul Eggert + + More portability fixes for problems summarized by Nelson H. F. Beebe. + + * tests/headers.at (AT_TEST_CPP_GUARD_H): Use #include <...> rather + than #include "...", and compile with -I'.'. The old method was + not portable, according to Posix and the C standard, and it does + not work with Sun C 5.7, where previous #line directives affect + the working directory used in later #include "..." directives. + +2006-02-06 Juan Manuel Guerrero + + Various DJGGP specific issues in /djgpp + +2006-02-02 Paul Eggert + + More portability fixes for problems summarized by Nelson H. F. Beebe. + + * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Check that + '#include ' works and that you can apply ++ to iterators. + +2006-02-01 Paul Eggert + + Work around portability problems summarized by Nelson H. F. Beebe in + . + + * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Check + that '#include ' works. + + * data/lalr1.cc (yytranslate_): No longer inline, to work around a + porting problem to g++ 3.4.3 on Darwin 7.9.0, where g++ complained + "warning: sorry: semantics of inline function static data `const + unsigned char translate_table[262]' are wrong (you'll wind up with + multiple copies)". + + * lib/bbitset.h (struct bitset_vtable): Rename members not, and, + or, xor to not_, and_, or_, and xor_, respectively. This works + around a bug in GCC 3.4.3 on Irix 6.5, which apparently has a + random system header somewhere that includes the equivalent of + . + + * tests/headers.at (AT_TEST_CPP_GUARD_H): Don't assume that "$CC + -E" works; it apparently doesn't work with PathScale EKO Compiler + Suite Version 2.0. + +2006-01-30 Joel E. Denny + + During deterministic GLR operation, user actions should be able to + influence the parse by changing yychar. To make this easier to fix and + to make glr.c easier to evolve in general, don't maintain yytoken in + parallel with yychar; just compute yytoken when needed. + * tests/glr-regression.at (Incorrect lookahead during deterministic + GLR): Check that setting yychar in a user action has the intended + effect. + * data/glr.c (yyGLRStack): Remove yytokenp member. + (yyclearin): Don't set *yytokenp. + (yyprocessOneStack, yyreportSyntaxError, yyrecoverSyntaxError): Examine + yychar rather than *yytokenp to determine the current lookahead. + Compute yytoken locally when needed. + (yyparse): Likewise. Remove the local yytoken that yytokenp used to + point to. + + * doc/bison.texinfo (Bison Options): Remove stray sentence fragment + after `--report' documentation. + +2006-01-30 Paul Eggert + + * src/parse-gram.y (grammar_declaration): Location of printer + symbol is @1, not list->location. Bug reported by twlevo. + * tests/input.at (Incompatible Aliases): Adjust to above change. + +2006-01-29 Paul Eggert + + * tests/input.at (AT_CHECK_UNUSED_VALUES): Remove. Instead, do + all the test at once. This makes the output easier to read in the + normal case. + + Fix a longstanding bug uncovered by bro-0.9a9/src/parse.y, which I + got from . The bug is that + when two actions appeared in succession, the second one was + scanned before the first one was added to the grammar rule + as a midrule action. Bison then output the incorrect warning + "parse.y:905.17-906.36: warning: unused value: $3". + * src/parse-gram.y (BRACED_CODE, action): These are no longer + associated with a value. + (rhs): Don't invoke grammar_current_rule_action_append. + (action): Invoke it here instead. + * src/reader.c (grammar_midrule_action): Now extern. + (grammar_current_rule_action_append): Don't invoke + grammar_midrule_action; that is now the scanner's job. + * src/reader.h (last_string, last_braced_code_loc): + (grammar_midrule_action): New decls. + * src/scan-gram.l (last_string): Now extern, sigh. + (last_braced_code_loc): New extern variable. + ("{"): Invoke grammar_midrule_action if the current + rule already has an action. + ("}"): Set last_braced_code_loc before returning. + * tests/input.at (AT_CHECK_UNUSED_VALUES): + Add some tests to check that the above changes fixed the bug. + +2006-01-27 Paul Eggert + + * src/reader.c (symbol_should_be_used): Renamed from symbol_typed_p. + All used changed. Check whether the symbol has a destructor, + not whether it is typed. + * tests/input.at (AT_CHECK_UNUSED_VALUES): Add a destructor, so + that the values are still reported as unused. All line numbers + adjusted. + +2006-01-23 Paul Eggert + + Work around a bug in bro 0.8, which underparenthesizes its + definition of YYLLOC_DEFAULT. + * data/glr.c: Change all uses of YYLLOC_DEFAULT to parenthesize + their arguments. + * data/lalr1.cc: Likewise. + * data/yacc.cc: Likewise. + +2006-01-22 Paul Eggert + + Work around a bug in Pike 7.0, and give the Pike folks a + better way to override the usual int widths. + * data/yacc.c (b4_int_type): Use yytype_uint8, etc., so that the + user can override the types. + (short): #undef, to work around a bug in Pike 7.0. + (yytype_uint8, yytype_int8, yytype_uint16, yytype_int16): New types. + (union yyalloc.yyss): Use yytype_int16 rather than short. + All uses changed. + (yysigned_char): Remove. + * src/parse-gram.y (YYTYPE_UINT8, YYTYPE_INT8, YYTYPE_UINT16): + (YYTYPE_INT16): New macros, to test the new facility in yacc.c. + * tests/regression.at (Web2c Actions): Adjust to above changes. + + * src/reader.c (check_and_convert_grammar): New function. + (reader): Close the input file even if something went wrong during + parsing. Minor file descriptor leak reported by twlevo. + + * src/assoc.c (assoc_to_string): Use a default: abort (); case + to pacify gcc -Wswitch-default. + * src/scan-gram.l (adjust_location): Use a default: break; case + to pacify gcc -Wswitch-default. + * src/scan-skel.h (skel_get_lineno, skel_get_in, skel_get_out): + (skel_get_leng, skel_get_text, skel_set_lineno, skel_set_in): + (skel_set_out, skel_get_debug, skel_set_debug, skel_lex_destroy): + Move these decls to scan-skel.l, since they don't need to be + visible elsewhere. + * src/scan-skel.l: Accept the above decls. + (skel_lex): New decl, to pacify GCC when unpatched flex 2.5.31 + is used. + +2006-01-21 Paul Eggert + + * Makefile.cfg (local-checks-to-skip): Add changelog-check, + since we don't want to insist on a version number at the start + of the changelog every time. + * Makefile.maint: Sync from coreutils a bit better. + (sc_trailing_blank): Renamed from sc_trailing_space. + All uses changed. + (sc_no_if_have_config_h, sc_require_config_h): + (sc_prohibit_assert_without_use): New rules. + (sc_obsolete_symbols): Don't catch Makefile.maint itself. + (sc_dd_max_sym_length): Fix leading spaces in rule. + (sc_system_h_headers): Prefix with @. + (sc_useless_cpp_parens, m4-check): Output line numbers. + (changelog-check): Allow version only in head. + * data/c.m4: Use "defined FOO" instead of "defined (FOO)", to + satisfy new Makefile.maint rule. + * data/glr.c: Likewise. + * data/glr.cc: Likewise. + * data/lalr1.cc: Likewise. + * data/yacc.c: Likewise. + * lib/ebitsetv.c: Likewise. + * lib/lbitset.c: Likewise. + * lib/subpipe.c: Likewise. + * lib/timevar.c: Likewise. + * src/system.h: Likewise. + * data/yacc.c (YYSTYPE): Don't generate trailing spaces in output. + * djgpp/Makefile.maint: Add copyright notice. + * djgpp/README.in: Likewise. + * djgpp/config.bat: Likewise. + * djgpp/config.site: Likewise. + * djgpp/config_h.sed: Likewise. + * djgpp/djunpack.bat: Likewise. + * djgpp/config.sed: Fix copyright notice to match standard format. + * djgpp/subpipe.h: Likewise. + * lib/bitsetv-print.c: Likewise. + * lib/bitsetv.c: Likewise. + * lib/subpipe.h: Likewise. + * lib/timevar.c: Likewise. + * lib/timevar.h: Likewise. + * djgpp/subpipe.c: Use standard recipe for config.h. + * lib/abitset.c: Likewise. + * lib/bitset.c: Likewise. + * lib/bitset_stats.c: Likewise. + * lib/bitsetv-print.c: Likewise. + * lib/bitsetv.c: Likewise. + * lib/ebitsetv.c: Likewise. + * lib/get-errno.c: Likewise. + * lib/lbitset.c: Likewise. + * lib/subpipe.c: Likewise. + * lib/timevar.c: Likewise. + * lib/vbitset.c: Likewise. + * tests/local.at: Likewise. + * src/scan-gram.l: Don't include verify.h, since system.h does + that for us. + * .x-sc_require_config_h: New file. + * .x-sc_unmarked_diagnostics: New file. + +2006-01-20 Paul Eggert + + Be a bit more systematic about using 'abort'. + * lib/abitset.c (abitset_test): Remove ATTRIBUTE_UNUSED; not needed. + * lib/bitset.c (bitset_bytes, bitset_init, bitset_op4_cmp): + Put 'default: abort ();' before some other case, to satisfy older + pedantic compilers. + * lib/bitset_stats.c (bitset_stats_init): Likewise. + * lib/ebitset.c (ebitset_elt_find, ebitset_op3_cmp): Likewise. + * lib/lbitset.c (lbitset_elt_find, lbitset_op3_cmp): Likewise. + * src/conflicts.c (resolve_sr_conflict): Likewise. + * src/vcg.c (get_color_str, get_textmode_str, get_shape_str): + (get_decision_str, get_orientation_str, get_node_alignment_str): + (get_arrow_mode_str, get_crossing_type_str, get_view_str): + (get_linestyle_str, get_arrowstyle_str): Likewise. + * src/conflicts.c (resolve_sr_conflict): + Use a default case rather than one for the one remaining enum + value, to catch invalid enum values as well. + * src/lalr.c (set_goto_map, map_goto): + Prefer "assert (FOO);" to "if (!FOO) abort ();". + * src/nullable.c (nullable_compute, token_definitions_output): + Likewise. + * src/reader.c (packgram, reader): Likewise. + * src/state.c (transitions_to, state_new, state_reduction_find): + Likewise. + * src/symtab.c (symbol_user_token_number_set, symbol_make_alias): + (symbol_pack): Likewise. + * src/tables.c (conflict_row, pack_vector): Likewise. + * src/scan-skel.l (QPUTS): Remove unnecessary parens. + (BASE_QPUTS, "@output ".*\n): Remove unnecessary asserts. + * src/system.h: Don't include . + (assert): New macro. + + * doc/bison.texinfo (Prologue, Rules, Actions, Union Decl, Action Decl): + (Destructor Decl, Parser Function, Pure Calling): + Describe rules for braces inside C code more carefully. + +2006-01-19 Paul Eggert + + Fix some porting glitches found by Nelson H. F. Beebe. + * lib/abitset.c (abitset_resize): Rewrite to avoid warnings from + compilers that don't understand that abort () does not return. + * src/state.c (transitions_to): Likewise. + * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Check + that '#include ' works. + * src/system.h (INT8_MIN, INT16_MIN, INT32_MIN, INT8_MAX): + (INT16_MAX, UINT8_MAX, INT32_MAX, UINT16_MAX, UINT32_MAX): + #undef if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901, + for the benefit of some pre-C99 compilers. + + * bootstrap: Undo changes to gnulib files that autoreconf made. + + Minor fixups to get 'make maintainer-check' to work. + * configure.ac: Don't use -Wnested-externs, as it's incompatible + with the new verify.h implementation. + * data/c.m4 (b4_yy_symbol_print_generate): YYUSE (yyoutput). + * data/glr.c (YYUSE): Depend on __GNUC__ as well. + * data/yacc.c (YYUSE): Likewise. + * data/lalr1.cc (yysyntax_error_): YYUSE (yystate). + * lib/subpipe.c (end_of_output_subpipe): The args are unused. + * src/parse-gram.y (declaration): Don't pass a string constant + to a function that expects char *, since GCC might complain + about the constant value. + * src/reader.c (symbol_typed_p): Add parens to pacify GCC. + * tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): #undef yylloc and yylval + before #defining them. + * tests/glr-regression.at + (Incorrectly initialized location for empty right-hand side in GLR): + In yyerror, use the msg arg. + (Corrupted semantic options if user action cuts parse): + (Incorrect lookahead during deterministic GLR): + (Incorrect lookahead during nondeterministic GLR): + Don't name a local var 'index'; it shadows string.h's 'index'. + +2006-01-19 Akim Demaille + + * tests/calc.at (_AT_DATA_CALC_Y): Initialize the whole initial + location, not just parts of it. + +2006-01-18 Paul Eggert + + * NEWS: Document the fact that multiple %unions are now allowed. + * doc/bison.texinfo (Union Decl): Likewise. + * TODO: This feature is now implemented, so remove it from + the wishlist. + + * Makefile.maint: Merge with coreutils Makefile.maint. + (CVS_LIST): Use build-aux version if available. + (VERSION_REGEXP): New macro. + (syntax-check-rules): Add sc_no_if_have_config_h, + sc_prohibit_assert_without_use, sc_require_config_h, + sc_useless_cpp_parens. + (sc_obsolete_symbols): Check for O_NDELAY. + (sc_dd_max_sym_length): Track coreutils. + (sc_unmarked_diagnostics): Look in all files, not just *.c. + (sc_useless_cpp_parens): New rule. + (news-date-check): Look for version or today's date. + (changelog-check): Don't require version number near head. + (copyright-check): Use current year instead of hardwiring 2005. + (my-distcheck): Depend on $(release_archive_dir)/$(prev-tgz). + (announcement): Add --gpg-key-ID. + + * djgpp/config.sed: Add copyright notice, and replace "filesystem" + with "file system". + + Avoid undefined behavior that addressed just before the start of an + array. Problem reported by twlevo. + * src/reader.c (packgram): Prepend a new sentinel before ritem. + * src/lalr.c (build_relations): Rely on new sentinel. + * src/gram.c (gram_free): Adjust to new sentinel. + +2006-01-12 Joel E. Denny + + * data/glr.c (yyGLRStateSet): Rename yylookaheadStatuses to + yylookaheadNeeds. All uses updated. + (yysplitStack): Rename local yynewLookaheadStatuses to + yynewLookaheadNeeds. + * data/glr-regression.at (Incorrect lookahead during nondeterministic + GLR): In comments, change `lookahead status' to `lookahead need'. + +2006-01-11 Paul Hilfinger + + * data/glr.c (yysplitStack): A little stylistic rewrite. + +2006-01-11 Paul Hilfinger + + * data/glr.c (yyaddDeferredAction): Flesh out the comment. + +2006-01-11 Joel E. Denny + + * doc/bison.texinfo: Fix some typos. + (GLR Semantic Actions): New subsection discussing special + considerations because GLR semantic actions might be deferred. + (Actions): Mention look-ahead usage of yylval. + (Actions and Locations): Mention look-ahead usage of yylloc. + (Special Features for Use in Actions): Add YYEOF entry and mention it + in the yychar entry. + In the yychar entry, remove mention of the local yychar case (pure + parser) since this is irrelevant information when writing semantic + actions and since it's already discussed in `Bison Symbols' where + yychar is otherwise described as an external variable. + In the yychar entry, don't call it the `current' look-ahead since it + isn't when semantic actions are deferred. + In the yychar and yyclearin entries, add note about deferred semantic + actions. + Add yylloc and yylval entries discussing look-ahead usage. + (Look-Ahead Tokens): When discussing yychar, don't call it the + `current' look-ahead, and do mention yylval and yylloc. + (Error Recovery): Cross-reference `Action Features' when mentioning + yyclearin. + (Bison Symbols): In the yychar entry, don't call it the `current' + look-ahead. + In the yylloc and yylval entries, mention look-ahead usage. + +2006-01-08 Joel E. Denny + + * tests/glr-regression.at: Update copyright year to 2006. + +2006-01-06 Joel E. Denny + + * data/glr.c (yyGLRStateSet): Add yybool* yylookaheadStatuses member to + use during nondeterministic operation to track which stacks have + actually needed the current lookahead. + (yyinitStateSet, yyfreeStateSet, yyremoveDeletes, yysplitStack): + Allocate, deallocate, resize, and otherwise shuffle space for + yylookaheadStatuses in parallel with yystates member of yyGLRStateSet. + (yysplitStack, yyprocessOneStack, yyparse): Set lookahead status + appropriately during nondeterministic operation. + (yySemanticOption): Add int yyrawchar, YYSTYPE yyval, and YYLTYPE yyloc + members to store the current lookahead to be used by the deferred + user action. + (yyaddDeferredAction): Add size_t yyk parameter specifying the stack + from which the RHS is taken. Set the lookahead members of the new + yySemanticOption according to the lookahead status for stack yyk. + (yyglrShiftDefer, yyglrReduce): Pass yyk parameter on to + yyaddDeferredAction. + (yyresolveAction): Set yychar, yylval, and yylloc to the lookahead + members of yySemanticOption before invoking yyuserAction, and then set + them back to their current values afterward. + (yyparse): Set yychar = YYEMPTY where yytoken = YYEMPTY. + (yyreportAmbiguity): Add /*ARGSUSED*/ to pacify lint. + * tests/glr-regression.at: Remove `.' from the ends of recent test case + titles for consistency. + (Leaked merged semantic value if user action cuts parse): In order to + suppress lint warnings, use arguments in merge function, and assign + char value < 128 in main. + (Incorrect lookahead during deterministic GLR): New test case. + (Incorrect lookahead during nondeterministic GLR): New test case. + +2006-01-06 Joel E. Denny + + * data/c.m4 (b4_yy_symbol_print_generate): In yy_symbol_print, accept + !yyvaluep as signal that no semantic value is available to print. + * data/glr.c (yydestroyGLRState): If state is not resolved, don't try + to print a semantic value. + +2006-01-06 Joel E. Denny + + * tests/glr-regression.at: For consistency with my newer test cases, + don't thank myself. + +2006-01-05 Joel E. Denny + + * data/glr.c (yyresolveValue): When merging semantic options, if at + least one user action succeeds but a later one cuts the parse, then + destroy the semantic value before returning rather than leaking it. + (yyresolveStates): If a user action cuts the parse and thus + yyresolveValue fails, ignore the (unset) semantic value rather than + corrupting the yyGLRState, and empty the semantic options list since + the user actions should have called all necessary destructors. + Simplify code with YYCHK. + * tests/glr-regression.at (Corrupted semantic options if user action + cuts parse): New test case. + (Undesirable destructors if user action cuts parse): New test case. + Before applying any of this patch, this test case never actually failed + for me... but only because the corrupted semantic options usually + masked this bug. + (Leaked merged semantic value if user action cuts parse): New test + case. + +2006-01-05 Akim Demaille + + * src/reader.c, src/symlist.h, src/symlist.c: s/mid_rule/midrule/. + +2006-01-04 Paul Eggert + + * data/c.m4 (b4_c_modern): New macro, with a new provision for + _MSC_VER. Problem reported by Cenzato Marco. + (b4_c_function_def): Use it. + * data/yacc.c (YYMODERN_C): Remove. All uses replaced by + b4_c_modern. + (yystrlen, yystpcpy, yyparse): Use b4_c_function... macros rather + than rolling our own. + +2006-01-04 Akim Demaille + + Also warn about non-used mid-rule values. + * src/symlist.h, src/symlist.c (symbol_list): Add a mid_rule + member. + (symbol_list_new): Adjust. + * src/reader.c (symbol_typed_p): New. + (grammar_rule_check): Use it. + (grammar_midrule_action): Bind a mid-rule LHS to its rule. + Check its rule. + * tests/input.at (AT_CHECK_UNUSED_VALUES): New. + Use it. + * tests/actions.at (Exotic Dollars): Adjust. + +2006-01-04 Akim Demaille + + * src/reader.c (grammar_midrule_action): If $$ is set in a + mid-rule, move the `used' bit to its lhs. + * tests/input.at (Unused values): New. + * tests/actions.at (Exotic Dollars): Adjust: exp is not typed. + +2006-01-03 Paul Eggert + + * doc/bison.texinfo (Bison Options): Say more accurately what + --yacc does. + * src/parse-gram.y (rules_or_grammar_declaration): Don't complain + about declarations in the grammar when in Yacc mode, as POSIX does + not require a diagnostic when the grammar uses extensions. + + * src/reduce.c (reduce_grammar): Remove unnecessary cast to bool. + + Warn about dubious constructions like "%token T T". + Reported by twlevo. + * src/symtab.h (struct symbol.declared): New member. + * src/symtab.c (symbol_new): Initialize it to false. + (symbol_class_set): New arg DECLARING, specifying whether + this is a declaration that we want to warn about, if there + is more than one of them. All uses changed. + + * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: + Allow multiple %union directives, whose contents concatenate. + * src/parse-gram.y (grammar_declaration): Likewise. + Use muscle_code_grow, so that we don't need stype_line any more. + All uses changed. + + * src/muscle_tab.c (muscle_grow): Fix comment. + + * ChangeLog, data/c.m4, data/glr.c, data/glr.cc, data/location.cc: + * data/yacc.c, src/getargs.c, src/output.c, tests/cxx-type.at: + Update copyright year to 2006. + +2006-01-03 Akim Demaille + + Have glr.cc pass (some of) the calc.at tests. + * data/glr.cc (b4_parse_param_orig): New. + (b4_parse_param): Improve its definition, and bound it more + clearly in the skeleton. + (b4_epilogue): Append, instead of prepending, in order to keep + #line consistency. + Simplify the generation of auxiliary functions: locations and + purity are mandated. + (b4_global_tokens_and_yystype): Honor it. + * data/location.cc (c++.m4): Don't include it. + * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Define AT_GLR_CC_IF + and AT_SKEL_CC_IF. + * tests/calc.at (AT_CHECK_CALC): Rely on AT_SKEL_CC_IF instead of + AT_LALR1_CC_IF. + Be sure to initialize the first position's filename. + (AT_CHECK_CALC_LALR1_CC): Add %location and %defines, they are + mandated anyway. + (AT_CHECK_CALC_GLR_CC): New. + Use it to exercise glr.cc as a lalr1.cc drop-in replacement. + +2006-01-02 Akim Demaille + + * src/output.c (output_skeleton): Don't hard wire the inclusion of + c.m4. + * data/c++.m4, data/glr.c, data/yacc.c: Include c.m4. + * data/glr.cc: Do not include stack.hh. + +2006-01-02 Joel E. Denny + + * data/glr.c: Reformat whitespace with tabs. + (b4_lpure_formals): Remove this unused m4 macro. + * tests/cxx-type.at: Reformat whitespace with tabs. + (_AT_TEST_GLR_CXXTYPES): In union Node, rename node_info to nodeInfo + since it's a member. Rename type to isNterm for clarity. + +2005-12-29 Akim + + Let glr.cc catch up with symbol_value_print. + * data/glr.cc (b4_yysymprint_generate): Replace by... + (b4_yy_symbol_print_generate): this. + (yy_symbol_print, yy_symbol_value_print): Declare them. + +2005-12-28 Paul Eggert + + * src/location.h (boundary): Note that a line or column equal + to INT_MAX indicates an overflow. + * src/scan-gram.l: Include verify.h. Don't include get-errno.h. + (rule_length_overflow, increment_rule_length, add_column_width): + New functions. + ({id}, "\"", "'"): + ("}"): + Use increment_rule_length rather than incrementing it by hand. + (adjust_location, handle_syncline): Diagnose overflow. + (handle_action_dollar, handle_action_at): + Fix bug with monstrosities like $-2147483648. + Remove now-unnecessary checks. + (scan_integer): Verify assumptions and remove now-unnecessary checks. + (convert_ucn_to_byte): Verify assumptions. + (handle_syncline): New arg LOC. All callers changed. + Don't store through a value derived from char const * pointer. + + * src/reader.c (grammar_rule_check): Rewrite slightly to avoid + GCC warnings. + +2005-12-27 Paul Eggert + + * src/reader.c (grammar_midrule_action, grammar_symbol_append): + Remove unnecessary forward static decls. + +2005-12-27 Akim Demaille + + * src/reader.c (grammar_current_rule_check): Also check that $$ + is used. + Take the rule to check as argument, hence rename as... + (grammar_rule_check): this. + * src/reader.h, src/reader.c (grammar_rule_begin, grammar_rule_end): + Rename as... + (grammar_rule_begin, grammar_rule_end): these, for consistency. + (grammar_midrule_action, grammar_symbol_append): Now static. + * tests/torture.at (input): Don't rely on the default action + being always performed. + * tests/calc.at: "Set" $$ even when the action is "cut" with + YYERROR or other. + * tests/actions.at (Exotic Dollars): Instead of using unused + values, check that the warning is issued. + +2005-12-22 Paul Eggert + + * NEWS: Improve wording for unused-value warnings. + +2005-12-22 Akim Demaille + + * data/lalr1.cc, data/yacc.c, data/glr.c, data/c.m4 + (b4_yysymprint_generate): Rename as... + (b4_yy_symbol_print_generate): this. + Generate yy_symbol_print instead of yysymprint. + Generate also yy_symbol_value_print, and use it. + +2005-12-22 Akim Demaille + + * NEWS: Warn about unused values. + * src/symlist.h, src/symlist.c (symbol_list, symbol_list_new): Add + a `used' member. + (symbol_list_n_get, symbol_list_n_used_set): New. + (symbol_list_n_type_name_get): Use symbol_list_n_get. + * src/scan-gram.l (handle_action_dollar): Flag used symbols. + * src/reader.c (grammar_current_rule_check): Check that values are + used. + * src/symtab.c (symbol_print): Accept 0. + * tests/existing.at: Remove the type information. + Empty the actions. + Remove useless actions (beware of mid-rule actions: perl -000 + -pi -e 's/\s*\{\}(?=[\n\s]*[|;])//g'). + * tests/actions.at (Exotic Dollars): Use unused values. + * tests/calc.at: Likewise. + * tests/glr-regression.at (No users destructors if stack 0 deleted): + Likewise. + + * src/gram.c (rule_useful_p, rule_never_reduced_p): Use + rule_useful_p. + +2005-12-21 Paul Eggert + + Undo 2005-12-01 tentative license wording change. The wording is + still being reviewed by the lawyers, and we don't want to wait for + them before publishing a test release. For now, revert to the + previous wording. + * NEWS: Undo 2005-12-01 change. + * data/glr.c: Revert to previous license wording. + * data/glr.cc: Likewise. + * data/lalr1.cc: Likewise. + * data/location.cc: Likewise. + * data/yacc.c: Likewise. + + * NEWS: Reword %destructor vs YYABORT etc. + * data/glr.c: Use American spacing, for consistency. + * data/glr.cc: Likewise. + * data/lalr1.cc: Likewise. + * data/yacc.c: Likewise. + * data/yacc.c: Reformat comments slightly. + * doc/bison.texinfo: Replace "non-" with "non" when that makes sense, + for consistency. Fix some spelling errors and reword recently-included + text slightly. + * tests/cxx-type.at: Cast results of malloc, for C++. + +2005-12-21 Joel E. Denny + + * tests/cxx-type.at: Construct a tree, count the parents of shared + nodes, and free each node once and only once. Previously, the memory + for semantic values was leaked instead. + +2005-12-21 Joel E. Denny + + * data/glr.c (struct yyGLRStack): If pure, add yyval and yyloc members. + (yylval, yylloc): If pure, #define to yystackp->yyval and + yystackp->yyloc similar to yychar and yynerrs. + (yyparse): If pure, remove local yylval and yylloc. Add local + yystackp to accommodate pure definitions of yylval and yylloc. + (b4_lex_param, b4_lyyerror_args, b4_lpure_args): If pure, change + yylvalp and yyllocp to &yylval and &yylloc. + (nerrs, char, lval, lloc): If pure, add #define's for b4_prefix[] + namespace. Previously, nerrs and char were missing, but lval and lloc + weren't necessary. + (yyprocessOneStack, yyreportSyntaxError, yyrecoverSyntaxError): Remove + yylvalp and yyllocp parameters since, if pure, these are now always + accessible through yystackp. If not pure, they are still accessible + globally. + * data/glr.c, data/yacc.c (YYLLOC_DEFAULT): Change `if (N)' to + `if (YYID (N))' to pacify lint. + +2005-12-21 Akim Demaille + + YYACCEPT, YYERROR, and YYABORT, as user actions, should not + destroy the RHS symbols of a rule. + * data/yacc.c (yylen): Initialize to 0. + Keep its value to the number of items to possibly shift. + In particular, a regular successful parse that ends on YYFINAL by + a (internal) YYACCEPT must not have yylen != 0. + (yyerrorlab, yyreturn): Pop the RHS. + Reorder a bit to emphasize the `shifting' bits of code. + (YYPOPSTACK): Now accept a number of items to pop. + * data/lalr1.cc: Likewise. + * data/glr.c: Formatting changes. + Use goto instead of fall through. + * doc/bison.texinfo (Destructor Decl): Complete. + +2005-12-20 Juan Manuel Guerrero + + * Makefile.am: DJGPP specific files added to EXTRA_DIST. + * djgpp/Makefile.maint: Fix PACKAGE variable computation. + * djgpp/config.bat: Replace every occurence of the file name + scan-gram-c.c with c-scan-gram.c. The same for scan-skel-c.c with + c-scan-skel.c to conform with the 8.3 file name restriction on MSDOS. + * djgpp/config.sed: Replace every occurence of the file name + scan-gram-c.c with c-scan-gram.c. The same for scan-skel-c.c with + c-scan-skel.c to conform with the 8.3 file name restriction on MSDOS. + * djgpp/djunpack.bat: DJGPP specific file. + * djgpp/fnchange.lst: DJGPP specific file. + * djgpp/README.in: Add new information about how to unpack the bison + source on MSDOS and other systems which have 8.3 file name restrictions + using djunpack.bat and fnchange.lst. + +2005-12-12 Paul Eggert + + * bootstrap (build_cvs_prefix): Remove; unused. + (CVS_PREFIX): Adjust to yesterday's Savannah reorganization + when getting gnulib. + +2005-12-12 "Joel E. Denny" + + * data/glr.c: Reorder typedef declarations for structs to match order + of struct declarations. + Rename yystack everywhere to yystackp except in yyparse where it's not + a pointer. + (yyglrShift): Change parameter YYSTYPE yysval to YYSTYPE* yyvalp for + consistency. + (yyis_table_ninf): Change 0 to YYID (0) to pacify lint. + (yyreportSyntaxError): Add /*ARGSUSED*/ to pacify lint. + (yyparse): Change while (yytrue) to while ( YYID (yytrue)) to pacify + lint. + +2005-12-09 Paul Eggert + + * tests/sets.at (Accept): Fix typos in regular expression used to + sed out the final state number. + + Work around portability problem on Solaris 10: flex-generated + files include before , which messes up + because the latter defines __EXTENSIONS__. Address the problem + by creating two new little files that include first, + then include the flex-generated files. Rewrite everyone else + to include first, as well. + * lib/timevar.c: Always include "config.h". + * src/Makefile.am (bison_SOURCES): Replace scan-gram.l with + scan-gram-c.c, and scan-skel.l with scan-skel-c.c. + (EXTRA_bison_SOURCES): New macro. + * src/scan-gram-c.c, src/scan-skel-c.c: New files. + * src/system.h: Don't include config.h. + * src/LR0.c: Include first. + * src/assoc.c: Likewise. + * src/closure.c: Likewise. + * src/complain.c: Likewise. + * src/conflicts.c: Likewise. + * src/derives.c: Likewise. + * src/files.c: Likewise. + * src/getargs.c: Likewise. + * src/gram.c: Likewise. + * src/lalr.c: Likewise. + * src/location.c: Likewise. + * src/main.c: Likewise. + * src/muscle_tab.c: Likewise. + * src/nullable.c: Likewise. + * src/output.c: Likewise. + * src/parse-gram.y: Likewise. + * src/print.c: Likewise. + * src/print_graph.c: Likewise. + * src/reader.c: Likewise. + * src/reduce.c: Likewise. + * src/relation.c: Likewise. + * src/state.c: Likewise. + * src/symlist.c: Likewise. + * src/symtab.c: Likewise. + * src/tables.c: Likewise. + * src/uniqstr.c: Likewise. + * src/vcg.c: Likewise. + + * src/parse-gram.y: Fix minor problems uncovered by lint. + (current_lhs, current_lhs_location): Now static. + (current_assoc): Remove unused variable. + + Cleanups so that Bison-generated parsers have less lint. + * data/c.m4 (b4_yydestruct_generate, b4_yysymprint_generate): + Prepend /*ARGSUSED*/, for lint's sake. + * data/glr.c (YYUSE): Properly parenthesize, and use an alternate + definition if 'lint' is defined. + (YYID): New macro (or function, if lint). + All uses of /*CONSTCOND*/0 replaced by YYID(0). + * data/yacc.c: Likewise. + * data/glr.c (yyuserAction, yyuserMerge, yy_reduce_print): + (yyrecoverSyntaxError): Prepend /*ARGSUSED*/. + * data/glr.cc (YYLLOC_DEFAULT): Omit /*CONSTCOND*/ since this code + is C++ only. + * data/lalr1.cc (YYUSE): Just use a cast, since this code is C++ only. + * data/yacc.c (YYSTACK_FREE) [defined YYSTACK_ALLOC]: + Use YYID(0) rather than 0, for lint. + (yystrlen): Rewrite to avoid lint warning about ptrdiff_t overflow. + (yysyntax_error): Rewrite to avoid lint warnings about parenthesization. + +2005-12-07 Paul Eggert + + * tests/glr-regression.at + (Improper handling of embedded actions and dollar(-N) in GLR parsers): + Close memory leak reported by twlevo. + +2005-12-06 "Joel E. Denny" + + * data/glr.c (yyprocessOneStack, yyparse): Synchronize the shift for + all stacks. + (yyparse): Iterate another stack in order to call user destructors. + * tests/glr-regression.at (No users destructors if stack 0 deleted): + New test case. + (Duplicated user destructor for lookahead): This test now is expected + to succeed. + +2005-12-01 Paul Eggert + + * NEWS: Document the following change. + * data/yacc.c: Say "parser skeleton" rather than "file", since + it's no longer just a file. + * data/glr.c: Grant a special exception for C GLR parsers, that + reads like the already-existing exception for C LALR(1) parsers. + * data/glr.cc: Likewise. + * data/lalr1.cc: Likewise. + * data/location.cc: Likewise. + * data/yacc.c: Reword the "written by" statement to clarify that + it was the parser skeleton, not the entire output file. + * data/glr.c: Written by Paul Hilfinger. + * data/glr.cc: Written by Akim Demaille. + * data/lalr1.cc: Likewise. + +2005-11-18 Paul Eggert + + * data/yacc.c (yy_reduce_print, YY_REDUCE_PRINT): + Fix typos in previous change that broke 'make check'. + YY_REDUCE_PRINT cannot be a pseudo-varargs macro; that isn't + supported in C. + * tests/calc.at (_AT_CHECK_CALC,_AT_CHECK_CALC_ERROR): + Don't check NUM-STDERR-LINES, since the output format is fluctuating. + We can revert this once things settle down. + + * src/conflicts.c (conflicts_print): Don't print file name twice + when %expect fails because there were no conflicts. + * doc/bison.texinfo (Expect Decl): Tighten up wording in previous + change. + * tests/conflicts.at (%expect not enough, %expect too much): + (%expect with reduce conflicts): Adjust to new behavior. + +2005-11-18 Akim Demaille + + * src/conflicts.c (conflicts_print): Unsatisfied %expectation are + errors. + * NEWS: Document this. + * doc/bison.texinfo (Expect Decl): Likewise. + +2005-11-16 Akim Demaille + + Generalize the display of semantic values and locations in traces. + * data/glr.c (yy_reduce_print): Fix indices (again). + * data/c++.m4 (b4_rhs_value, b4_rhs_location): Don't expect + literal integers. + * data/lalr1.cc (yyreduce_print): Rename as... + (yy_reduce_print): this. + Display values and locations. + * data/yacc.c (yy_reduce_print): Likewise. + (YY_REDUCE_PRINT): Adjust to pass the required arguments. + (yysymprint): Move higher to be visible from yy_reduce_print). + (yyparse): Adjust. + * tests/calc.at: Adjust the expected length of the traces. + +2005-11-14 Akim Demaille + + * data/glr.c (yy_reduce_print): The loop was quite wrong: type are + from 1 to N, while values and location start at 0. + (b4_rhs_location, b4_rhs_value): Add parens around $1 and $2. + +2005-11-14 Akim Demaille + + * data/glr.c (yy_reduce_print): Fix the $ number. + +2005-11-14 Akim Demaille + + "Use" parse parameters. + * data/c.m4 (b4_parse_param_for, b4_parse_param_use): New. + * data/glr.c, data/glr.cc: Use them. + * data/glr.c (YYUSE): Have a C++ definition that supports + non-pointer types. + +2005-11-14 Akim Demaille + + * data/glr.c (yyexpandGLRStack): Declare only if defined. + +2005-11-14 Akim Demaille + + * data/glr.cc: New. + * data/m4sugar/m4sugar.m4 (m4_prepend): New. + +2005-11-12 Akim Demaille + + Let position and location be PODs. + * data/location.cc (position::initialize, location::initialize): New. + (position::position, location::location): Define only if + b4_location_constructors is defined. + * data/lalr1.cc (b4_location_constructors): Define it for backward + compatibility. + * doc/bison.texinfo (Initial Action Decl): Use initialize. + +2005-11-12 Akim Demaille + + * data/lalr1.cc: Move the body of the ctor and dtor into the + parser file (instead of the header). + Wrap the implementations in a "namespace yy". + +2005-11-12 Akim Demaille + + Have glr.c include its header file when created. + * data/glr.c (b4_shared_declarations): New. + Output them verbatim in the parser if !%defines, otherwise + output then in the header file, and include it instead. + +2005-11-11 Akim Demaille + + * data/glr.c: Comment changes. + +2005-11-11 Akim Demaille + + When yydebug, report semantic and location values for reductions. + * data/glr.c (yy_reduce_print): Report the semantic values and the + locations. + (YY_REDUCE_PRINT): Adjust. + (yyglrReduce): Use them. + (b4_rhs_value, b4_rhs_location): Remove m4_eval invocations. + * data/c.m4 (b4_yysymprint_generate): Specify the const arguments. + * tests/calc.at (_AT_CHECK_CALC_ERROR): Remove the reduction + traces. + +2005-11-10 Akim Demaille + + * data/glr.c (yynewGLRStackItem, YY_RESERVE_GLRSTACK): New. + (yyaddDeferredAction, yyglrShift, yyglrShiftDefer): Use them. + (yyexpandGLRStack, YYRELOC): Define only when YYSTACKEXPANDABLE. + +2005-11-09 Albert Chin-A-Young + + * m4/cxx.m4, examples/Makefile.am: Don't build + examples/calc++ if no C++ compiler is available. (trivial change) + +2005-11-09 Akim Demaille + + * src/scan-skel.l: Use a couple of asserts. + +2005-11-03 Akim Demaille + + In some (weird) cases, the final state number is incorrect. + Reported by Alexandre Duret-Lutz. + * src/LR0.c (state_list_append): Remove the computation of + final_state. + (save_reductions): Do it here. + (get_state): Alpha conversion. + (generate_states): Use a for loop. + * src/gram.h (item_number_is_rule_number) + (item_number_is_symbol_number): New. + * src/state.c: Use assert. + * src/system.h: Include assert.h. + * tests/sets.at (Accept): New. + +2005-10-30 Paul Hilfinger + + * data/glr.c (yyfill): Adjust comment. + (yyresolveAction): Initialize default location properly + for empty right-hand sides. + (yydoAction): Ditto. + Add comment explaining apparently dead code. + * tests/glr-regression.at + (Incorrectly initialized location for empty right-hand side in GLR): + New test. + +2005-10-30 Paul Eggert + + * bootstrap (cleanup_gnulib): New function. Use it to clean up + gnulib when interrupted. This fixes some race conditions and + works around some portability problems (one noted by Paul + Hilfinger). + +2005-10-22 Akim + + * Makefile.cfg: Adjust to config -> build-aux. + Reported by twledo. + +2005-10-21 Akim Demaille + + * data/c.m4 (b4_yydestruct_generate, b4_yysymprint_generate): Pass + the %parse-params. + * data/glr.c (YY_SYMBOL_PRINT, yydestroyGLRState): Adjust. + * data/yacc.c (b4_Pure_if): Rename as... + (b4_yacc_pure_if): this. + (YY_SYMBOL_PRINT, yyparse): Adjust. + * doc/bison.texinfo: Formatting changes. + +2005-10-21 Akim Demaille + + Finish the transition config -> build-aux. + * configure.ac, Makefile.am: Use build-aux. + * config/prev-version, config/announce-gen, config/Makefile.am: + Move to... + * build-aux/prev-version, build-aux/announce-gen, + * build-aux/Makefile.am: here. + +2005-10-14 Akim Demaille + + * examples/calc++/test: Use set -x only when VERBOSE. + +2005-10-13 Paul Eggert + + * NEWS: Bison now warns if it finds a stray `$' or `@' in an action. + * src/scan-gram.l ([$@]): Implement this. + +2005-10-13 Akim Demaille + + * src/scan-skel.l: Output the base name parts of the parser and + header file names. + * tests/output.at (AT_CHECK_OUTPUT): Support subdirectories, and + additional checks. + Use this to exercise C++ outputs in subdirs. + Reported by Oleg Smolsky. + +2005-10-12 Paul Eggert + + * data/c.m4 (b4_c_function_def): Look at __C99_FUNC__, not at + __STDC_VERSION__, as IBM cc 7.0 doesn't define the latter either. + Problem reported by John P. Hartmann. + * data/yacc.c (YYMODERN_C): Likewise. Don't define if the user has + already defined it. + +2005-10-12 Akim Demaille + + * src/parse-gram.y (version_check): Exit 63 to please missing + (stands for "version mismatch). + * tests/input.at, doc/bison.texinfo: Adjust. + +2005-10-10 Paul Eggert + + Work around portability problems with Visual Age C compiler + (xlc and xlC_r) reported by John P. Hartmann. + * data/location.cc (initial_column, initial_line): Remove. + All uses replaced by 0 and 1. + * src/scan-gram.l (gram_wrap): Redefine to avoid bug in flex 2.5.31 + that xlc complains about. + * src/scan-skel.l (skel_wrap): Likewise. + * data/c.m4 (b4_c_function_def): Look at __STDC_VERSION__ as well + as __STDC__. + * data/yacc.c (YYMODERN_C): New macro, which also looks at + __STDC_VERSION__. Use it everywhere instead of looking at + __STDC__ and __cplusplus. + +2005-10-10 Akim Demaille + + * examples/calc++/test: Be quiet unless VERBOSE. + +2005-10-05 Paul Eggert + + * data/c.m4 (yydestruct, yysymprint): + Use YYUSE instead of casting to void. + * data/glr.c (YYUSE): New macro. + (yyuserMerge, yyreportAmbiguity, yyreportSyntaxError): + Use it instead of rolling our own. + (YYLLOC_DEFAULT, YYCHK, YYDPRINTF, YY_SYMBOL_PRINT, YY_REDUCE_PRINT): + (YYCHK1): + Use /*CONSTCOND*/ to suppress lint warnings. + * data/lalr1.cc (YYLLOC_DEFAULT, YY_SYMBOL_PRINT, YY_REDUCE_PRINT): + (YY_STACK_PRINT): Use 'false' not '0'. + (YYUSE): New macro. + (yysymprint_, yydestruct_): Use it instead of rolling our own. + * data/yacc.c (YYUSE): New macro. + (YYCOPY, YYSTACK_RELOCATE, YYBACKUP, YYLLOC_DEFAULT): + (YYDPRINTF, YY_SYMBOL_PRINT, YY_STACK_PRINT, YY_REDUCE_PRINT): + (yyerrorlab): Use /*CONSTCOND*/ to suppress lint warnings. + + + * data/m4sugar/m4sugar.m4 (_m4_map): New macro. + (m4_map, m4_map_sep): Use it. Handle the empty list correctly. + +2005-10-04 Paul Eggert + + Undo the parts of the unlocked-I/O change that substituted + putc or puts for printf. This might hurt performance a bit, + but some people prefer the printf style. + * data/c.m4 (yysymprint): Prefer printf to puts and putc. + * data/glr.c (YYFPUTC, YYFPUTS, YYDPUTS): Remove. + All uses replaced by YYFPRINTF and YYDPRINTF. + * data/yacc.c: Likewise. + * lib/bitset.c (bitset_print): Likewise. + * lib/bitsetv.c (bitsetv_dump, debug-bitsetv): Prefer printf to + putc and puts. + * lib/lbitset.c (debug_lbitset): Likewise. + * src/closure.c (print_firsts, print_fderives): Likewise. + * src/gram.c (grammar_dump): Likewise. + * src/lalr.c (look_ahead_tokens_print): Likewise. + * src/output.c (escaped_output): Likewise. + (user_actions_output): Break apart two printfs. + * src/parse-gram.y (%printer): Prefer printf to putc and puts. + * src/reduce.c (reduce_print): Likewise. + * src/state.c (state_rule_look_ahead_tokens_print): Likewise. + * src/system.h: Include unlocked-io.h rathe than stdio.h. + + * data/glr.c (yyuserMerge, yyreportAmbiguity, yyreportSyntaxError): + Use assignments rather than casts-to-void to suppress + unused-variable warnings. This pacifies 'lint'. + * data/lalr1.cc (yysymprint_, yydestruct_): Use a call to suppress + unused-variable warnings. + +2005-10-03 Juan Manuel Guerrero + + * Makefile.am: DJGPP specific files added to EXTRA_DIST. + +2005-10-02 Paul Eggert + + Use unlocked I/O for a minor performance improvement on hosts like + GNU/Linux and Solaris that support unlocked I/O. The basic idea + is to use the gnlib unlocked-io module, and to prefer putc and + puts to printf when either will work (since the latter doesn't + come in an unlocked flavor). + * bootstrap (gnulib_modules): Add unlocked-io. + * data/c.m4 (yysymprint): Prefer puts and putc to printf. + * data/glr.c (YYFPUTC, YYFPUTS, YYDPUTS): New macros. + Prefer them to YYFPRINTF and YYDPRINTF if either will do, + and similarly for puts and putc and printf. + * data/yacc.c: Likewise. + * lib/bitset.c (bitset_print): Likewise. + * lib/bitset.h [USE_UNLOCKED_IO]: Include unlocked-io.h. + * lib/bitsetv.c (bitsetv_dump, debug-bitsetv): Prefer putc and puts + to printf. + * lib/lbitset.c (debug_lbitset): Likewise. + * src/closure.c (print_firsts, print_fderives): Likewise. + * src/gram.c (grammar_dump): Likewise. + * src/lalr.c (look_ahead_tokens_print): Likewise. + * src/output.c (escaped_output): Likewise. + (user_actions_output): Coalesce two printfs. + * src/parse-gram.y (%printer): Prefer putc and puts to printf. + * src/reduce.c (reduce_print): Likewise. + * src/state.c (state_rule_look_ahead_tokens_print): Likewise. + * src/system.h: Include unlocked-io.h rather than stdio.h. + + * data/lalr1.cc: Don't put an unmatched ' in a dnl comment, as + this confuses xgettext. + +2005-10-02 Akim Demaille + + * bootstrap (gnulib_modules): Add strverscmp. + * lib/.cvsignore: Add strverscmp.c, strverscmp.h. + * m4/.cvsignore: Add strverscmp.m4. + * src/parse-gram.y (%require): New token, new rule. + (version_check): New. + * src/scan-gram.l (%require): Adjust. + * tests/input.at (AT_REQUIRE): New. + Use it. + * doc/bison.texinfo (Require Decl): New. + (Calc++ Parser): Use %require. + +2005-10-02 Akim Demaille + + * data/location.cc: New. + +2005-10-02 Paul Eggert , + Akim Demaille + + Make sure -odir/foo.cc creates dir/location.hh etc. + * src/files.h (spec_outfile, parser_file_name, spec_name_prefix) + (spec_file_prefix, spec_verbose_file, spec_graph_file) + (spec_defines_file): Now const. + (dir_prefix): New. + (short_base_name): Remove. + * src/files.c: Adjust. + (dirname.h): Include. + (base_name): Don't prototype it. + (finput): Remove, duplicates gram_in. + (full_base_name, short_base_name): Replace by... + (all_but_ext, all_but_tab_ext): these. + (compute_base_names): Rename as... + (compute_file_name_parts): this. + Update to compute the new variables, including dir_prefix. + Adjust dependencies. + * src/output.c (prepare): Output them. + * src/reader.c: Adjust to use gram_in, not finput. + * src/scan-skel.l (@dir_prefix@): New. + +2005-10-02 Juan Manuel Guerrero + + * lib/subpipe.c: New function end_of_output_subpipe() added + to allow support for non-posix systems. This is a no-op function + for posix systems. + + * lib/subpipe.h: New function end_of_output_subpipe() added + to allow support for non-posix systems. This is a no-op function + for posix systems. + + * src/output.c (output_skeleton): Use end_of_output_subpipe() to + handle the lack of pipe/fork functionality on non-posix systems. + + * djgpp/Makefile.maint: DJGPP specific file. + + * djgpp/README.in: DJGPP specific file. + + * djgpp/config.bat: DJGPP specific configuration file. + + * djgpp/config.sed: DJGPP specific configuration file. + + * djgpp/config.site: DJGPP specific configuration file. + + * djgpp/config_h.sed: DJGPP specific configuration file. + + * djgpp/subpipe.c: DJGPP specific replacement file for lib/subpipe.c. + + * djgpp/subpipe.h: DJGPP specific replacement file for lib/subpipe.h. + +2005-10-02 Akim Demaille + + * data/location.cc: New, extract from... + * data/lalr1.cc: here. + (location.hh): Include it after the user prologue, in case the + filename type is defined by the user. + Forward declation location and position before the pre-prologue. + (yyresult_): Rename as... + (yyresult): this, it's a local variable, not an attribute. + * data/Makefile.am (dist_pkgdata_DATA): Adjust. + +2005-10-01 Akim Demaille + + * examples/extexi: Restore the #line generation. + +2005-09-30 Akim Demaille , + Alexandre Duret-Lutz + + Move the token type and YYSTYPE in the parser class. + * data/lalr1.cc (stack.hh, location.hh): Include earlier. + (parser::token): New, from the moved free definition of tokens. + (parser::semantic_value): Now a full definition instead of an + indirection to YYSTYPE. + (b4_post_prologue): No longer included in the header file, but + in the implementation file. + * doc/bison.texi (C+ Language Interface): Update. + * src/parse-gram.y: Support unary %define. + * tests/actions.at: Define global_tokens_and_yystype for backward + compatibility until we update the tests. + * tests/calc.at: Idem. + (first_line, first_column, last_line, last_column): Define for lalr1.cc + to simplify the code. + +2005-09-29 Paul Eggert + + Port to SunOS 4.1.4, which lacks strtoul and strerror. + Ah, the good old days! Problem reported by Peter Klein. + * bootstrap (gnulib_modules): Add strerror, strtoul. + * lib/.cvsignore: Add strerror.c, strtol.c, strtoul.c + * m4/.cvsignore: Add strerror.m4, strtol.m4, strtoul.m4. + +2005-09-29 Akim Demaille + + * data/c.m4 (b4_error_verbose_if): New. + * data/lalr1.cc: Use it. + (YYERROR_VERBOSE_IF): Remove. + (yyn_, yylen_, yystate_, yynerrs_, yyerrstatus_): Remove as + parser members, replaced by... + (yyn, yylen, yystate, yynerss, yyerrstatus): these parser::parse + local variables. + (yysyntax_error_): Takes the state number as argument. + (yyreduce_print_): Use the argument yyrule, not the former + attribute yyn_. + +2005-09-26 Paul Eggert + + * bootstrap (gnulib_modules): Add verify. + * lib/.cvsignore: Add verify.h. + * src/getargs.c: Use ARGMATCH_VERIFY rather than verify. + * src/system.h (verify): Remove. + Include verify.h instead. + * src/tables.c (tables_generate): Use new API for 'verify'. + +2005-09-21 Paul Eggert + + * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Do not use + local variables whose names begin with 'yy'. + * tests/calc.at (_AT_DATA_CALC_Y): Likewise. + Trivial changes from Joel E. Denny. + + * bootstrap (gnulib_modules): Remove alloca. Bison doesn't need + it itself. + * src/main.c (main) [C_ALLOCA]: Don't flush alloca'ed memory; we + don't use alloca any more. + + * data/yacc.c [YYSTACK_USE_ALLOCA && !defined __GNUC__ && ! defined + __BUILTIN_VA_ARG_INCR && ! defined _AIX && ! defined _MSC_VER && + defined _ALLOCA_H]: Don't include ; not needed in this case. + * tests/torture.at (Exploding the Stack Size with Alloca): Adjust + to match yacc.c, to test more hosts. + +2005-09-20 Paul Eggert + + * data/yacc.c (YYSIZE_T): Reindent to make it clearer. This + doesn't affect behavior. + (YYSTACK_ALLOC) [YYSTACK_USE_ALLOCA]: Improve support for + Solaris, AIX, MSC. + (_STDLIB_H): Renamed from YYINCLUDED_STDLIB_H. All uses changed. + This works a bit better with glibc, if user code has already included + stdlib.h. + * doc/bison.texinfo (Bison Parser): Document that users can't + arbitrarily use malloc and free for other purposes. Document + that and might be included. + (Table of Symbols): Under YYSTACK_USE_ALLOCA, Don't claim that the + user must declare alloca. + + * HACKING (release): Forwarn the Translation Project about + stable releses. + +2005-09-20 Akim Demaille + + * data/glr.c: Use b4_token_enums, not b4_token_enums_defines. + +2005-09-19 Paul Eggert + + * data/yacc.c (YYSIZE_MAXIMUM): New macro. + (YYSTACK_ALLOC_MAXIMUM): Use it. + (yysyntax_error): New function. + (yyparse) [YYERROR_VERBOSE]: Don't leak memory indefinitely if + multiple syntax errors are reported, and alloca is being used. + Instead, reallocate buffers twice as big each time, so that + we waste at most half the allocated memory. Start with a small + (128-byte) buffer that will suffice in most cases anyway. + Use yysyntax_error to do most of the work. + + * doc/bison.texinfo (Error Reporting, Table of Symbols): + yynerrs is the number of errors reported, not the number of + errors encountered. + + * tests/glr-regression.at (Duplicated user destructor for lookahead): + Mark it as expected to fail. + Cast result of malloc; problem reported by twlevo@xs4all.nl. + * tests/actions.at, tests/calc.at, tests/glr-regression.at: + Don't start user-code symbols with "yy", to avoid name space problems. + +2005-09-19 Akim Demaille + + Remove the traits, failed experiment. + It never proved useful, and anyway because of the current + definition, it was not possible to have several specialization of + this traits, making it useless. + * data/lalr1.cc (yy:traits): Remove. + Inline its definitions in the parser class. + +2005-09-19 Akim Demaille + + * tests/atlocal.in (LIBS): Pass INTLLIBS to address failures on at + least Mac OSX with a /usr/local install of gettext. + +2005-09-19 Akim Demaille + + * data/lalr1.cc (yyparse): Rename yylooka and yyilooka as yychar + and yytoken for similarity with the other skeletons. + +2005-09-19 Akim Demaille + + * NEWS, configure.ac: update version number to 2.1a. + 2005-09-16 Paul Eggert * NEWS: Version 2.1. @@ -5590,7 +7375,7 @@ Reported by Charles-Henry de Boysson. * tests/calc.at (_AT_CHECK_CALC, _AT_CHECK_CALC_ERROR): Don't - check the length of the traces when %glr. + check the length of the traces when %glr. (_AT_CHECK_CALC_ERROR): Also skip `^Stack' lines, coming from GLR's traces. (AT_CHECK_CALC_LALR, AT_CHECK_CALC_GLR): New. @@ -5735,7 +7520,7 @@ struct lbitset_struct, struct bitset_stats_struct): New types. All uses of struct bitset_struct changed to union bitset_union, etc. - * lib/abitset.c (struct abitset_struct, abitset, + * lib/abitset.c (struct abitset_struct, abitset, struct bitset_struct): Remove. * lib/bitset_stats.c (struct bitset_stats_struct, bitset_stats, struct bitset_struct): Remove. @@ -6821,7 +8606,7 @@ 2002-06-28 Akim Demaille - * src/reader.h: s/grammer_current_rule_merge_set/grammar_.../. + * src/reader.h: s/grammer_current_rule_merge_set/grammar_.../. * src/conflicts.c (conflicts_total_count): `i' is unsigned, to pacify GCC. * src/output.c (save_row): Initialize all the variables to pacify GCC. @@ -6851,7 +8636,7 @@ * src/getargs.c: * src/symlist.h: Add dprec and merger fields to symbol_list_s. - * src/symlist.c (symbol_list_new): Initialize dprec and merger fields. + * src/symlist.c (symbol_list_new): Initialize dprec and merger fields. Originally 2002-06-16 Paul Hilfinger @@ -8858,8 +10643,8 @@ 2002-01-20 Marc Autret - * src/system.h: Need to define __attribute__ away for non-GCC - compilers as well (i.e. the vendor C compiler). + * src/system.h: Need to define __attribute__ away for non-GCC + compilers as well (i.e., the vendor C compiler). Suggested by Albert Chin-A-Young. 2002-01-11 Tim Van Holder @@ -10029,7 +11814,7 @@ * src/warshall.c (bitmatrix_print): New. (TC): Use it. - When performing a transitive closure R(i, j) && R(j, k) => R(i, k), + When performing a transitive closure R(i, j) && R(j, k) => R(i, k), j must be the outer loop. * tests/regression.at (Broken Closure): New. @@ -11614,7 +13399,7 @@ * src/output.c (output): Delete call to reader_output_yylsp. * src/reader.c (reader): Likewise. - * src/reader.h: Delete declaration of reader_output_yylsp. + * src/reader.h: Delete declaration of reader_output_yylsp. 2001-09-02 Marc Autret @@ -14241,8 +16026,8 @@ ----- Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software - Foundation, Inc. + 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free + Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this diff --git a/src/bin/bison/Makefile.am b/src/bin/bison/Makefile.am index 33c3f05626..f247e24a2e 100644 --- a/src/bin/bison/Makefile.am +++ b/src/bin/bison/Makefile.am @@ -18,14 +18,19 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = config po runtime-po lib data src doc examples tests +SUBDIRS = build-aux po runtime-po lib data src doc examples tests # Files installed for use by Automake. aclocaldir = @aclocaldir@ aclocal_DATA = m4/bison-i18n.m4 EXTRA_DIST = GNUmakefile Makefile.cfg Makefile.maint \ - OChangeLog PACKAGING + OChangeLog PACKAGING \ + djgpp/Makefile.maint djgpp/README.in djgpp/config.bat \ + djgpp/config.sed djgpp/config.site djgpp/config_h.sed \ + djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \ + djgpp/fnchange.lst + .PHONY: maintainer-check maintainer-check: diff --git a/src/bin/bison/Makefile.cfg b/src/bin/bison/Makefile.cfg index 0d72c3eb79..fb15523168 100644 --- a/src/bin/bison/Makefile.cfg +++ b/src/bin/bison/Makefile.cfg @@ -1,5 +1,5 @@ # Customize Makefile.maint for Bison. -*- makefile -*- -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,8 +16,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. -prev_version_file = $(srcdir)/config/prev-version.txt -announce_gen = $(srcdir)/config/announce-gen +build_aux_dir = $(srcdir)/build-aux +prev_version_file = $(build_aux_dir)/prev-version.txt +announce_gen = $(build_aux_dir)/announce-gen release_archive_dir = releases # Use alpha.gnu.org for alpha and beta releases. @@ -32,18 +33,16 @@ url_dir_list = \ # Files to update automatically. wget_files = \ - $(srcdir)/config/config.guess \ - $(srcdir)/config/config.sub \ - $(srcdir)/config/texinfo.tex \ + $(build_aux_dir)/config.guess \ + $(build_aux_dir)/config.sub \ + $(build_aux_dir)/texinfo.tex \ cvs_files = \ - $(srcdir)/config/install-sh \ - $(srcdir)/config/mdate-sh \ - $(srcdir)/config/missing \ - $(srcdir)/config/mkinstalldirs + $(build_aux_dir)/install-sh \ + $(build_aux_dir)/mdate-sh \ + $(build_aux_dir)/missing \ + $(build_aux_dir)/mkinstalldirs # Tests not to run. -# local-checks-to-skip ?= \ -# author_mark_check \ -# strftime-check syntax-check makefile_path_separator_check \ -# makefile-check +local-checks-to-skip = \ + changelog-check diff --git a/src/bin/bison/Makefile.in b/src/bin/bison/Makefile.in index cd42aeab96..9c62f024be 100644 --- a/src/bin/bison/Makefile.in +++ b/src/bin/bison/Makefile.in @@ -36,17 +36,14 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.hin \ $(top_srcdir)/configure ABOUT-NLS AUTHORS COPYING ChangeLog \ - INSTALL NEWS THANKS TODO build-aux/config.guess \ - build-aux/config.rpath build-aux/config.sub build-aux/depcomp \ - build-aux/install-sh build-aux/mdate-sh build-aux/missing \ - build-aux/mkinstalldirs build-aux/texinfo.tex build-aux/ylwrap -subdir = . + INSTALL NEWS THANKS TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ - $(top_srcdir)/m4/bison-i18n.m4 $(top_srcdir)/m4/cxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \ + $(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \ $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \ $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \ @@ -63,11 +60,14 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \ $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strndup.m4 \ - $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/subpipe.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ + $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \ + $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \ $(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \ $(top_srcdir)/m4/ulonglong_gl.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/warning.m4 \ + $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ + $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \ $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -109,8 +109,6 @@ GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALLOCA_H = @ALLOCA_H@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ @@ -120,6 +118,8 @@ AUTOM4TE = @AUTOM4TE@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON_CXX_WORKS = @BISON_CXX_WORKS@ +BISON_CXX_WORKS_FALSE = @BISON_CXX_WORKS_FALSE@ +BISON_CXX_WORKS_TRUE = @BISON_CXX_WORKS_TRUE@ BISON_LOCALEDIR = @BISON_LOCALEDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -179,6 +179,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STDBOOL_H = @STDBOOL_H@ STRIP = @STRIP@ +UNISTD_H = @UNISTD_H@ USE_NLS = @USE_NLS@ VALGRIND = @VALGRIND@ VERSION = @VERSION@ @@ -234,10 +235,14 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = config po runtime-po lib data src doc examples tests +SUBDIRS = build-aux po runtime-po lib data src doc examples tests aclocal_DATA = m4/bison-i18n.m4 EXTRA_DIST = GNUmakefile Makefile.cfg Makefile.maint \ - OChangeLog PACKAGING + OChangeLog PACKAGING \ + djgpp/Makefile.maint djgpp/README.in djgpp/config.bat \ + djgpp/config.sed djgpp/config.site djgpp/config_h.sed \ + djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \ + djgpp/fnchange.lst all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -453,7 +458,7 @@ distdir: $(DISTFILES) esac $(am__remove_distdir) mkdir $(distdir) - $(mkdir_p) $(distdir)/build-aux $(distdir)/m4 $(distdir)/po $(distdir)/runtime-po $(distdir)/tests + $(mkdir_p) $(distdir)/djgpp $(distdir)/m4 $(distdir)/po $(distdir)/runtime-po $(distdir)/tests @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ diff --git a/src/bin/bison/Makefile.maint b/src/bin/bison/Makefile.maint index 8656fbbad6..9bae6be665 100644 --- a/src/bin/bison/Makefile.maint +++ b/src/bin/bison/Makefile.maint @@ -2,7 +2,7 @@ # This Makefile fragment is shared between the coreutils, # CPPI, Bison, and Autoconf. -## Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +## Copyright (C) 2001-2006 Free Software Foundation, Inc. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -25,24 +25,25 @@ ME := Makefile.maint # Do not save the original name or timestamp in the .tar.gz file. # Use --rsyncable if available. -GZIP_ENV = \ - "--no-name --best$$( \ - case $$(gzip --help) in \ - (*--rsyncable*) echo ' --rsyncable';; \ - esac \ - )" +gzip_rsyncable = \ + (gzip --help|grep rsyncable) >/dev/null 2>&1 && echo --rsyncable +GZIP_ENV = "--no-name --best `$(gzip_rsyncable)`" CVS = cvs +# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/ CVS_LIST = sh -c ' \ - (cvsu --find --types=AFGM $$*) 2>/dev/null || \ - awk -F/ '\''{ \ - if (!$$1 && $$3 !~ /^-/) { \ - f=FILENAME; \ - sub(/CVS\/Entries/, "", f); \ - print f $$2; \ - }}'\'' \ - $$(find $${*-*} -name Entries -print) /dev/null \ + if test -x $(srcdir)/build-aux/cvsu; then \ + $(srcdir)/build-aux/cvsu --find --types=AFGM $$*; \ + else \ + awk -F/ '\''{ \ + if (!$$1 && $$3 !~ /^-/) { \ + f=FILENAME; \ + sub(/CVS\/Entries/, "", f); \ + print f $$2; \ + }}'\'' \ + $$(find $${*-*} -name Entries -print) /dev/null; \ + fi \ ' dummy CVS_LIST_EXCEPT = \ @@ -53,6 +54,7 @@ ifeq ($(origin prev_version_file), undefined) endif PREV_VERSION := $(shell cat $(prev_version_file)) +VERSION_REGEXP = $(subst .,\.,$(VERSION)) tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]') tag-this-version = $(subst .,_,$(VERSION)) @@ -73,12 +75,17 @@ export LC_ALL = C ## Sanity checks. ## ## --------------- ## +# FIXME: add a check to prohibit definition in src/*.c of symbols defined +# in system.h. E.g. today I removed from tail.c a useless definition of +# ENOSYS. It was useless because system.h ensures it's defined. + # Checks that don't require cvs. # Run `changelog-check' last, as previous test may reveal problems requiring # new ChangeLog entries. local-checks-available = \ po-check copyright-check writable-files m4-check author_mark_check \ - changelog-check strftime-check syntax-check makefile_path_separator_check \ + changelog-check strftime-check $(syntax-check-rules) \ + makefile_path_separator_check \ makefile-check .PHONY: $(local-checks-available) @@ -93,16 +100,21 @@ syntax-check-rules = \ sc_dd_max_sym_length \ sc_error_exit_success \ sc_file_system \ + sc_no_if_have_config_h \ sc_obsolete_symbols \ sc_prohibit_atoi_atof \ sc_prohibit_jm_in_m4 \ + sc_prohibit_assert_without_use \ + sc_require_config_h \ sc_root_tests \ sc_space_tab \ sc_sun_os_names \ sc_system_h_headers \ sc_tight_scope \ - sc_trailing_space \ - sc_unmarked_diagnostics + sc_trailing_blank \ + sc_two_space_separator_in_usage \ + sc_unmarked_diagnostics \ + sc_useless_cpp_parens syntax-check: $(syntax-check-rules) # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \ @@ -135,8 +147,7 @@ sc_cast_of_alloca_return_value: exit 1; } || : sc_space_tab: - @grep -n '[ ] ' \ - $$($(CVS_LIST_EXCEPT)) && \ + @grep -n '[ ] ' $$($(CVS_LIST_EXCEPT)) && \ { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \ 1>&2; exit 1; } || : @@ -144,8 +155,7 @@ sc_space_tab: # They provide no error checking mechanism. # Instead, use strto* functions. sc_prohibit_atoi_atof: - @grep -nE '\<(ato[filq]|ato''ll)\>' \ - $$($(CVS_LIST_EXCEPT)) && \ + @grep -nE '\' $$($(CVS_LIST_EXCEPT)) && \ { echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \ 1>&2; exit 1; } || : @@ -158,16 +168,37 @@ sc_error_exit_success: exit 1; } || : sc_file_system: - @grep -ni 'file''system' \ - $$($(CVS_LIST_EXCEPT)) && \ + @grep -ni 'file''system' $$($(CVS_LIST_EXCEPT)) && \ { echo '$(ME): found use of "file''system";' \ 'rewrite to use "file system"' 1>&2; \ exit 1; } || : +sc_no_if_have_config_h: + @grep -n '^# *if HAVE_CONFIG_H' $$($(CVS_LIST_EXCEPT)) && \ + { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \ + 1>&2; exit 1; } || : + +# Nearly all .c files must include . +sc_require_config_h: + @grep -L '^# *include ' \ + $$($(CVS_LIST_EXCEPT) | grep '\.c$$') \ + | grep . && \ + { echo '$(ME): the above files do not include ' \ + 1>&2; exit 1; } || : + +# Prohibit the inclusion of assert.h without an actual use of assert. +sc_prohibit_assert_without_use: + @files=$$(grep -l '# *include ' \ + $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \ + grep -L '\ but don't use it" \ + 1>&2; exit 1; } || : + sc_obsolete_symbols: - @grep -nE '\<(HAVE_''FCNTL_H)\>' \ + @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ $$($(CVS_LIST_EXCEPT)) && \ - { echo '$(ME): do not use HAVE_''FCNTL_H' \ + { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \ 1>&2; exit 1; } || : # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ @@ -186,7 +217,7 @@ ifneq ($(wildcard $(dd_c)),) @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\ sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \ |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \ - | wc --max-line-length); \ + | wc --max-line-length); \ max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \ |tr -d '"' | wc --max-line-length); \ if test "$$len" = "$$max"; then :; else \ @@ -228,7 +259,7 @@ sc_root_tests: # Files in src/ should not include directly any of # the headers already included via system.h. sc_system_h_headers: .re-list - if test -f $(srcdir)/src/system.h; then \ + @if test -f $(srcdir)/src/system.h; then \ trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \ grep -nE -f .re-list \ $$($(CVS_LIST) src | \ @@ -240,28 +271,41 @@ sc_system_h_headers: .re-list sc_sun_os_names: @grep -nEi \ 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \ - $$($(CVS_LIST_EXCEPT)) && \ + $$($(CVS_LIST_EXCEPT)) && \ { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \ exit 1; } || : sc_tight_scope: $(MAKE) -C src $@ -sc_trailing_space: - @grep -n '[ ]$$' \ - $$($(CVS_LIST_EXCEPT)) && \ - { echo '$(ME): found trailing space(s)' \ +sc_trailing_blank: + @grep -n '[ ]$$' $$($(CVS_LIST_EXCEPT)) && \ + { echo '$(ME): found trailing blank(s)' \ + 1>&2; exit 1; } || : + +sc_two_space_separator_in_usage: + @grep -n '^ *--[a-z][0-9A-Za-z-]* [^ ].*\\$$' \ + $$($(CVS_LIST_EXCEPT)) && \ + { echo "$(ME): help2man requires at least two spaces between"; \ + echo "$(ME): an option and its description"; \ 1>&2; exit 1; } || : # Look for diagnostics that aren't marked for translation. # This won't find any for which error's format string is on a separate line. sc_unmarked_diagnostics: @grep -nE \ - '\&2; \ exit 1; } || : +# Avoid useless parentheses like those in this example: +# #if defined (SYMBOL) || defined (SYM2) +sc_useless_cpp_parens: + @grep -n '^# *if .*defined *(' $$($(CVS_LIST_EXCEPT)) && \ + { echo '$(ME): found useless parentheses in cpp directive' \ + 1>&2; exit 1; } || : + # Ensure that date's --help output stays in sync with the info # documentation for GNU strftime. The only exception is %N, # which date accepts but GNU strftime does not. @@ -286,15 +330,17 @@ makefile-check: news-date-check: NEWS today=`date +%Y-%m-%d`; \ - if head NEWS | grep '^\*.*'$$today >/dev/null; then \ + if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \ + >/dev/null; then \ :; \ else \ - echo "today's date is not in NEWS" 1>&2; \ + echo "version or today's date is not in NEWS" 1>&2; \ exit 1; \ fi changelog-check: - if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \ + if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \ + >/dev/null; then \ :; \ else \ echo "$(VERSION) not in ChangeLog" 1>&2; \ @@ -302,18 +348,21 @@ changelog-check: fi m4-check: - @grep 'AC_DEFUN([^[]' m4/*.m4 \ + @grep -n 'AC_DEFUN([^[]' m4/*.m4 \ && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \ exit 1; } || : # Verify that all source files using _() are listed in po/POTFILES.in. -# FIXME: don't hard-code src/false.c below; use a more general mechanism. +# FIXME: don't hard-code file names below; use a more general mechanism. po-check: if test -f po/POTFILES.in; then \ grep -E -v '^(#|$$)' po/POTFILES.in \ | grep -v '^src/false\.c$$' | sort > $@-1; \ files=; \ - for file in lib/*.[chly] src/*.[chly]; do \ + for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do \ + case $$file in \ + djgpp/* | man/*) continue;; \ + esac; \ case $$file in \ *.[ch]) \ base=`expr " $$file" : ' \(.*\)\..'`; \ @@ -321,7 +370,7 @@ po-check: esac; \ files="$$files $$file"; \ done; \ - grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \ + grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort -u > $@-2; \ diff -u $@-1 $@-2 || exit 1; \ rm -f $@-1 $@-2; \ fi @@ -363,7 +412,7 @@ v_etc_file = lib/version-etc.c # Make sure that the copyright date in $(v_etc_file) is up to date. copyright-check: @if test -f $(v_etc_file); then \ - grep 'enum { COPYRIGHT_YEAR = 2005 };' $(v_etc_file) \ + grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \ >/dev/null \ || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \ exit 1; }; \ @@ -419,7 +468,7 @@ null_AM_MAKEFLAGS = \ # have to have a recent version of gcc and glibc headers. TMPDIR ?= /tmp t=$(TMPDIR)/$(PACKAGE)/test -my-distcheck: $(local-check) +my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz) -rm -rf $(t) mkdir -p $(t) GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz @@ -441,16 +490,6 @@ my-distcheck: $(local-check) WGET = wget WGETFLAGS = -C off -tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//') -tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//') -bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//') -bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//') -xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//') -xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//') -tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/') -bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/') -xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/') - rel-check: tarz=/tmp/rel-check-tarz-$$$$; \ md5_tmp=/tmp/rel-check-md5-$$$$; \ @@ -471,6 +510,7 @@ announcement: NEWS ChangeLog $(rel-files) --prev=$(PREV_VERSION) \ --curr=$(VERSION) \ --release-archive-directory=$(release_archive_dir) \ + --gpg-key-id=$(gpg_key_ID) \ --news=NEWS \ $(addprefix --url-dir=, $(url_dir_list)) \ diff --git a/src/bin/bison/NEWS b/src/bin/bison/NEWS index 5ce9863945..3dca4fe091 100644 --- a/src/bin/bison/NEWS +++ b/src/bin/bison/NEWS @@ -1,8 +1,100 @@ Bison News ---------- +Changes in version 2.3, 2006-06-05: + +* GLR grammars should now use `YYRECOVERING ()' instead of `YYRECOVERING', + for compatibility with LALR(1) grammars. + +* It is now documented that any definition of YYSTYPE or YYLTYPE should + be to a type name that does not contain parentheses or brackets. + +Changes in version 2.2, 2006-05-19: + +* The distribution terms for all Bison-generated parsers now permit + using the parsers in nonfree programs. Previously, this permission + was granted only for Bison-generated LALR(1) parsers in C. + +* %name-prefix changes the namespace name in C++ outputs. + +* The C++ parsers export their token_type. + +* Bison now allows multiple %union declarations, and concatenates + their contents together. + +* New warning: unused values + Right-hand side symbols whose values are not used are reported, + if the symbols have destructors. For instance: + + exp: exp "?" exp ":" exp { $1 ? $1 : $3; } + | exp "+" exp + ; + + will trigger a warning about $$ and $5 in the first rule, and $3 in + the second ($1 is copied to $$ by the default rule). This example + most likely contains three errors, and could be rewritten as: + + exp: exp "?" exp ":" exp + { $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); } + | exp "+" exp + { $$ = $1 ? $1 : $3; if ($1) free ($3); } + ; + + However, if the original actions were really intended, memory leaks + and all, the warnings can be suppressed by letting Bison believe the + values are used, e.g.: + + exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); } + | exp "+" exp { $$ = $1; (void) $3; } + ; + + If there are mid-rule actions, the warning is issued if no action + uses it. The following triggers no warning: $1 and $3 are used. + + exp: exp { push ($1); } '+' exp { push ($3); sum (); }; + + The warning is intended to help catching lost values and memory leaks. + If a value is ignored, its associated memory typically is not reclaimed. + +* %destructor vs. YYABORT, YYACCEPT, and YYERROR. + Destructors are now called when user code invokes YYABORT, YYACCEPT, + and YYERROR, for all objects on the stack, other than objects + corresponding to the right-hand side of the current rule. + +* %expect, %expect-rr + Incorrect numbers of expected conflicts are now actual errors, + instead of warnings. + +* GLR, YACC parsers. + The %parse-params are available in the destructors (and the + experimental printers) as per the documentation. + +* Bison now warns if it finds a stray `$' or `@' in an action. + +* %require "VERSION" + This specifies that the grammar file depends on features implemented + in Bison version VERSION or higher. + +* lalr1.cc: The token and value types are now class members. + The tokens were defined as free form enums and cpp macros. YYSTYPE + was defined as a free form union. They are now class members: + tokens are enumerations of the `yy::parser::token' struct, and the + semantic values have the `yy::parser::semantic_type' type. + + If you do not want or can update to this scheme, the directive + `%define "global_tokens_and_yystype" "1"' triggers the global + definition of tokens and YYSTYPE. This change is suitable both + for previous releases of Bison, and this one. + + If you wish to update, then make sure older version of Bison will + fail using `%require "2.2"'. + +* DJGPP support added. + Changes in version 2.1, 2005-09-16: +* The C++ lalr1.cc skeleton supports %lex-param. + * Bison-generated parsers now support the translation of diagnostics like "syntax error" into languages other than English. The default language is still English. For details, please see the new @@ -24,7 +116,7 @@ Changes in version 2.1, 2005-09-16: a syntax error associated with '%token NUM "number"' they might print 'syntax error, unexpected number' instead of 'syntax error, unexpected "number"'. - + Changes in version 2.0, 2004-12-25: * Possibly-incompatible changes @@ -619,8 +711,8 @@ End: ----- -Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. +Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, +2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/src/bin/bison/PACKAGING b/src/bin/bison/PACKAGING new file mode 100644 index 0000000000..dd285c990c --- /dev/null +++ b/src/bin/bison/PACKAGING @@ -0,0 +1,56 @@ +Packaging hints for binary package distributors +=============================================== + +Although the source of the bison package comes as a single package, +in distributions of binary packages the installed files should +be split into two packages: + + bison-runtime + Contents: Runtime libraries and programs. + Audience: Anyone who wants to run internationalized programs + that contain Bison-generated parsers. + + bison + Contents: Tools and documentation for developers that use Bison. + Audience: Anyone who wants to develop programs that use parsers. + Dependencies: requires bison-runtime. + +The 'bison-runtime' binary package is much smaller than the 'bison' +binary package. It should be included in any distribution that +contains localized programs that use the diagnostics contained in +Bison-generated parsers. + +If you want to install both packages at the same time, you simply do +at the toplevel directory: + + ./configure + make + make install + +After installation, the file + + $prefix/share/locale/*/LC_MESSAGES/bison-runtime.mo + +belongs to the bison-runtime package; all other installed files belong +to the bison package. + +----- + +Copyright (C) 2002, 2005 Free Software Foundation, Inc. + +This file is part of Bison, the GNU Compiler Compiler. + +Bison is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +Bison is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with autoconf; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. diff --git a/src/bin/bison/README-alpha b/src/bin/bison/README-alpha deleted file mode 100644 index e076d73b84..0000000000 --- a/src/bin/bison/README-alpha +++ /dev/null @@ -1,38 +0,0 @@ --*- text -*- - -This is a test release of this package. Using it more or less -implicitly signs you up to help us find whatever problems you report. - -The documentation still needs more work. Suggestions welcome. -Patches even more welcome. - -Please send comments and problem reports about this test release to -bug-bison@gnu.org. This program will get better only if you report -the problems you encounter. - -Please, *do not package this*, *do not distribute it* widely, it is -not ready for full scale use. Because it is not fully functional, if -you distribute this package, we will be buried under bug reports from -panicked users. We don't have time to spend on this, and nor do the -users. - ------ - -Copyright (C) 2002 Free Software Foundation, Inc. - -This file is part of GNU Bison. - -GNU Bison is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Bison is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Bison; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. diff --git a/src/bin/bison/REFERENCES b/src/bin/bison/REFERENCES deleted file mode 100644 index b02eb18c52..0000000000 --- a/src/bin/bison/REFERENCES +++ /dev/null @@ -1,30 +0,0 @@ -From phr Tue Jul 8 10:36:19 1986 -Date: Tue, 8 Jul 86 00:52:24 EDT -From: phr (Paul Rubin) -To: riferguson%watmath.waterloo.edu@CSNET-RELAY.ARPA, tower -Subject: Re: Bison documentation? - -The main difference between Bison and Yacc that I know of is that -Bison supports the @N construction, which gives you access to -the starting and ending line number and character number associated -with any of the symbols in the current rule. - -Also, Bison supports the command `%expect N' which says not to mention -the conflicts if there are N shift/reduce conflicts and no reduce/reduce -conflicts. - -The differences in the algorithms stem mainly from the horrible -kludges that Johnson had to perpetrate to make Yacc fit in a PDP-11. - -Also, Bison uses a faster but less space-efficient encoding for the -parse tables (see Corbett's PhD thesis from Berkeley, "Static -Semantics in Compiler Error Recovery", June 1985, Report No. UCB/CSD -85/251), and more modern technique for generating the lookahead sets. -(See "Efficient Construction of LALR(1) Lookahead Sets" by F. DeRemer -and A. Pennello, in ACM TOPLS Vol 4 No 4, October 1982. Their -technique is the standard one now.) - - paul rubin - free software foundation - - diff --git a/src/bin/bison/THANKS b/src/bin/bison/THANKS index 983bf687b3..c00580e0b8 100644 --- a/src/bin/bison/THANKS +++ b/src/bin/bison/THANKS @@ -21,6 +21,7 @@ Cris Bailiff c.bailiff+bison@awayweb.com Cris van Pelt cris@amf03054.office.wxs.nl Daniel Hagerty hag@gnu.org David J. MacKenzie djm@gnu.org +Derek M. Jones derek@knosof.co.uk Dick Streefland dick.streefland@altium.nl Enrico Scholz enrico.scholz@informatik.tu-chemnitz.de Evgeny Stambulchik fnevgeny@plasma-gate.weizmann.ac.il @@ -34,7 +35,7 @@ Jan Nieuwenhuizen janneke@gnu.org Jesse Thilo jthilo@gnu.org Jim Kent jkent@arch.sel.sony.com Jim Meyering jim@meyering.net -Joel E. Denny jdenny@hubcap.clemson.edu +Joel E. Denny jdenny@ces.clemson.edu Juan Manuel Guerrero ST001906@HRZ1.HRZ.TU-Darmstadt.De Kees Zeelenberg kzlg@users.sourceforge.net Keith Browne kbrowne@legato.com @@ -42,15 +43,18 @@ Laurent Mascherpa laurent.mascherpa@epita.fr Magnus Fromreide magfr@lysator.liu.se Marc Autret autret_m@epita.fr Martin Mokrejs mmokrejs@natur.cuni.cz +Martin Nylin martin.nylin@linuxmail.org Matt Kraai kraai@alumni.cmu.edu Matt Rosing rosing@peakfive.com Michael Hayes m.hayes@elec.canterbury.ac.nz +Mickael Labau labau_m@epita.fr Mike Castle dalgoda@ix.netcom.com Neil Booth NeilB@earthling.net Nelson H. F. Beebe beebe@math.utah.edu Nicolas Burrus nicolas.burrus@epita.fr Nicolas Tisserand nicolas.tisserand@epita.fr Noah Friedman friedman@gnu.org +Oleg Smolsky oleg.smolsky@pacific-simulators.co.nz Pascal Bart pascal.bart@epita.fr Paul Eggert eggert@cs.ucla.edu Paul Hilfinger Hilfinger@CS.Berkeley.EDU @@ -64,10 +68,12 @@ Raja R Harinath harinath@cs.umn.edu Richard Stallman rms@gnu.org Robert Anisko anisko_r@epita.fr Shura debil_urod@ngs.ru +Steve Murphy murf@parsetree.com Tim Josling tej@melbpc.org.au Tim Van Holder tim.van.holder@pandora.be Tom Lane tgl@sss.pgh.pa.us Tom Tromey tromey@cygnus.com +Tommy Nordgren tommy.nordgren@chello.se Troy A. Johnson troyj@ecn.purdue.edu Vin Shelton acs@alumni.princeton.edu Wayne Green wayne@infosavvy.com diff --git a/src/bin/bison/TODO b/src/bin/bison/TODO index a44f64ece4..76ca736275 100644 --- a/src/bin/bison/TODO +++ b/src/bin/bison/TODO @@ -87,32 +87,6 @@ we should be able to have: Or something like this. -** yysymprint interface -It should be improved, in particular when using Bison features such as -locations, and YYPARSE_PARAMS. For the time being, it is almost -recommended to yyprint to steal internal variables... - -** Several %unions -I think this is a pleasant (but useless currently) feature, but in the -future, I want a means to %include other bits of grammars, and _then_ -it will be important for the various bits to define their needs in -%union. - -When implementing multiple-%union support, bare the following in mind: - -- when --yacc, this must be flagged as an error. Don't make it fatal - though. - -- The #line must now appear *inside* the definition of yystype. - Something like - - { - #line 12 "foo.y" - int ival; - #line 23 "foo.y" - char *sval; - } - ** %if and the like It should be possible to have %if/%else/%endif. The implementation is not clear: should it be lexical or syntactic. Vadim Maslow thinks it @@ -203,28 +177,16 @@ Paul notes: the source code. This should get fixed. * --graph -Show reductions. [] +Show reductions. * Broken options ? -** %no-parser [] -** %token-table [] -** Skeleton strategy. [] -Must we keep %no-parser? - %token-table? +** %no-parser +** %token-table +** Skeleton strategy +Must we keep %no-parser? %token-table? * src/print_graph.c -Find the best graph parameters. [] - -* doc/bison.texinfo -** Update -informations about ERROR_VERBOSE. [] -** Add explanations about -skeleton muscles. [] -%skeleton. [] - -* testsuite -** tests/pure-parser.at [] -New tests. +Find the best graph parameters. * BTYacc See if we can integrate backtracking in Bison. Charles-Henri de @@ -345,16 +307,17 @@ the parser with a means to create the (visual) parse tree. ----- -Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, +Inc. -This file is part of GNU Bison. +This file is part of Bison, the GNU Compiler Compiler. -GNU Bison is free software; you can redistribute it and/or modify +Bison is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. -GNU Bison is distributed in the hope that it will be useful, +Bison is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. diff --git a/src/bin/bison/aclocal.m4 b/src/bin/bison/aclocal.m4 index 15dc1cc1e9..3c5426ae3d 100644 --- a/src/bin/bison/aclocal.m4 +++ b/src/bin/bison/aclocal.m4 @@ -871,8 +871,8 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR -m4_include([m4/alloca.m4]) m4_include([m4/bison-i18n.m4]) +m4_include([m4/c-working.m4]) m4_include([m4/cxx.m4]) m4_include([m4/dirname.m4]) m4_include([m4/dmalloc.m4]) @@ -906,13 +906,19 @@ m4_include([m4/stdint_h_gl.m4]) m4_include([m4/stdio-safer.m4]) m4_include([m4/stpcpy.m4]) m4_include([m4/strdup.m4]) +m4_include([m4/strerror.m4]) m4_include([m4/strndup.m4]) m4_include([m4/strnlen.m4]) +m4_include([m4/strtol.m4]) +m4_include([m4/strtoul.m4]) +m4_include([m4/strverscmp.m4]) m4_include([m4/subpipe.m4]) m4_include([m4/timevar.m4]) m4_include([m4/uintmax_t_gl.m4]) m4_include([m4/ulonglong_gl.m4]) m4_include([m4/unistd-safer.m4]) +m4_include([m4/unistd_h.m4]) +m4_include([m4/unlocked-io.m4]) m4_include([m4/warning.m4]) m4_include([m4/xalloc.m4]) m4_include([m4/xstrndup.m4]) diff --git a/src/bin/bison/config.h b/src/bin/bison/config.h index 9795c31f6c..285409a445 100644 --- a/src/bin/bison/config.h +++ b/src/bin/bison/config.h @@ -1,14 +1,6 @@ /* config.h. Generated by configure. */ /* config.hin. Generated from configure.ac by autoheader. */ -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - /* Define to 1 if translation of program messages to the user's native language is requested. */ /* #undef ENABLE_NLS */ @@ -16,27 +8,19 @@ /* Define on systems for which file names may have a so-called `drive letter' prefix, define this to compute the length of that prefix, including the colon. */ -#define FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX 0 +#define FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX 0 /* Define if the backslash character may also serve as a file name component separator. */ -#define FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR 0 +#define FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR 0 -#if FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX -# define FILESYSTEM_PREFIX_LEN(Filename) \ +#if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX +# define FILE_SYSTEM_PREFIX_LEN(Filename) \ ((Filename)[0] && (Filename)[1] == ':' ? 2 : 0) #else -# define FILESYSTEM_PREFIX_LEN(Filename) 0 +# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 #endif -/* Define to 1 if you have `alloca' after including , a header that - may be supplied by this distribution. */ -#define HAVE_ALLOCA 1 - -/* Define HAVE_ALLOCA_H for backward compatibility with older code that - includes only if HAVE_ALLOCA_H is defined. */ -#define HAVE_ALLOCA_H 1 - /* Define to 1 if the system has the type `clock_t'. */ #define HAVE_CLOCK_T 1 @@ -178,10 +162,6 @@ /* Define to 1 if libc includes obstacks. */ #define HAVE_OBSTACK 1 -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#define HAVE_REALLOC 1 - /* Define to 1 if you have the `setlocale' function. */ #define HAVE_SETLOCALE 1 @@ -266,7 +246,7 @@ /* Define to 1 if the system has the type `_Bool'. */ /* #undef HAVE__BOOL */ -#if FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR +#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR # define ISSLASH(C) ((C) == '/' || (C) == '\\') #else # define ISSLASH(C) ((C) == '/') @@ -285,13 +265,13 @@ #define PACKAGE_NAME "GNU Bison" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Bison 1.875d" +#define PACKAGE_STRING "GNU Bison 2.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "bison" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.875d" +#define PACKAGE_VERSION "2.3" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be diff --git a/src/bin/bison/config.hin b/src/bin/bison/config.hin index 68e91d3729..ff0c48b96d 100644 --- a/src/bin/bison/config.hin +++ b/src/bin/bison/config.hin @@ -1,13 +1,5 @@ /* config.hin. Generated from configure.ac by autoheader. */ -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS @@ -28,14 +20,6 @@ # define FILE_SYSTEM_PREFIX_LEN(Filename) 0 #endif -/* Define to 1 if you have `alloca' after including , a header that - may be supplied by this distribution. */ -#undef HAVE_ALLOCA - -/* Define HAVE_ALLOCA_H for backward compatibility with older code that - includes only if HAVE_ALLOCA_H is defined. */ -#undef HAVE_ALLOCA_H - /* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework. */ #undef HAVE_CFLOCALECOPYCURRENT @@ -51,10 +35,58 @@ */ #undef HAVE_DCGETTEXT +/* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_CLEARERR_UNLOCKED + /* Define to 1 if you have the declaration of `clock', and to 0 if you don't. */ #undef HAVE_DECL_CLOCK +/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you + don't. */ +#undef HAVE_DECL_FEOF_UNLOCKED + +/* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FERROR_UNLOCKED + +/* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FFLUSH_UNLOCKED + +/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FGETS_UNLOCKED + +/* Define to 1 if you have the declaration of `fputc_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FPUTC_UNLOCKED + +/* Define to 1 if you have the declaration of `fputs_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FPUTS_UNLOCKED + +/* Define to 1 if you have the declaration of `fread_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FREAD_UNLOCKED + +/* Define to 1 if you have the declaration of `fwrite_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_FWRITE_UNLOCKED + +/* Define to 1 if you have the declaration of `getchar_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_GETCHAR_UNLOCKED + +/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you + don't. */ +#undef HAVE_DECL_GETC_UNLOCKED + +/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. + */ +#undef HAVE_DECL_GETENV + /* Define to 1 if you have the declaration of `getrusage', and to 0 if you don't. */ #undef HAVE_DECL_GETRUSAGE @@ -63,6 +95,14 @@ otherwise. */ #undef HAVE_DECL_MBSWIDTH_IN_WCHAR_H +/* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if + you don't. */ +#undef HAVE_DECL_PUTCHAR_UNLOCKED + +/* Define to 1 if you have the declaration of `putc_unlocked', and to 0 if you + don't. */ +#undef HAVE_DECL_PUTC_UNLOCKED + /* Define to 1 if you have the declaration of `strdup', and to 0 if you don't. */ #undef HAVE_DECL_STRDUP @@ -71,6 +111,10 @@ don't. */ #undef HAVE_DECL_STRERROR_R +/* Define to 1 if you have the declaration of `strndup', and to 0 if you + don't. */ +#undef HAVE_DECL_STRNDUP + /* Define to 1 if you have the declaration of `strnlen', and to 0 if you don't. */ #undef HAVE_DECL_STRNLEN @@ -165,6 +209,9 @@ /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R @@ -174,12 +221,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H -/* Define to 1 if you have the `strndup' function. */ +/* Define if you have the strndup() function and it works. */ #undef HAVE_STRNDUP +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the `strtoul' function. */ +#undef HAVE_STRTOUL + /* Define to 1 if the system has the type `struct tms'. */ #undef HAVE_STRUCT_TMS +/* Define to 1 if you have the `strverscmp' function. */ +#undef HAVE_STRVERSCMP + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RESOURCE_H @@ -267,20 +323,17 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#undef STACK_DIRECTION - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if strerror_r returns char *. */ #undef STRERROR_R_CHAR_P +/* Define to 1 if you want getc etc. to use unlocked I/O if available. + Unlocked I/O can improve performance in unithreaded apps, but it is not + safe for multithreaded apps. */ +#undef USE_UNLOCKED_IO + /* Version number of package */ #undef VERSION @@ -346,6 +399,9 @@ /* Define to `int' if does not define. */ #undef pid_t +/* Define to rpl_strndup if the replacement function should be used, */ +#undef strndup + /* Define to rpl_strnlen if the replacement function should be used. */ #undef strnlen diff --git a/src/bin/bison/configure b/src/bin/bison/configure index fc5dba981a..40270df340 100644 --- a/src/bin/bison/configure +++ b/src/bin/bison/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for GNU Bison 2.1. +# Generated by GNU Autoconf 2.59 for GNU Bison 2.3. # # Report bugs to . # @@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='GNU Bison' PACKAGE_TARNAME='bison' -PACKAGE_VERSION='2.1' -PACKAGE_STRING='GNU Bison 2.1' +PACKAGE_VERSION='2.3' +PACKAGE_STRING='GNU Bison 2.3' PACKAGE_BUGREPORT='bug-bison@gnu.org' # Factoring default headers for most tests. @@ -312,7 +312,7 @@ ac_includes_default="\ gl_header_list= gl_func_list= -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP WARNING_CFLAGS WERROR_CFLAGS WARNING_CXXFLAGS YACC_SCRIPT YACC_LIBRARY LEX LEXLIB LEX_OUTPUT_ROOT YACC RANLIB ac_ct_RANLIB M4 STDBOOL_H HAVE__BOOL ALLOCA ALLOCA_H LIBOBJS GETOPT_H MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE build build_cpu build_vendor build_os host host_cpu host_vendor host_os INTL_MACOSX_LIBS LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB BISON_LOCALEDIR aclocaldir VALGRIND CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE BISON_CXX_WORKS AUTOM4TE GCC O0CFLAGS O0CXXFLAGS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP WARNING_CFLAGS WERROR_CFLAGS WARNING_CXXFLAGS YACC_SCRIPT YACC_LIBRARY LEX LEXLIB LEX_OUTPUT_ROOT YACC RANLIB ac_ct_RANLIB M4 STDBOOL_H HAVE__BOOL LIBOBJS GETOPT_H MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE build build_cpu build_vendor build_os host host_cpu host_vendor host_os INTL_MACOSX_LIBS LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB UNISTD_H BISON_LOCALEDIR aclocaldir VALGRIND CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE BISON_CXX_WORKS BISON_CXX_WORKS_TRUE BISON_CXX_WORKS_FALSE AUTOM4TE GCC O0CFLAGS O0CXXFLAGS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -789,7 +789,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU Bison 2.1 to adapt to many kinds of systems. +\`configure' configures GNU Bison 2.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -855,7 +855,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Bison 2.1:";; + short | recursive ) echo "Configuration of GNU Bison 2.3:";; esac cat <<\_ACEOF @@ -990,7 +990,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -GNU Bison configure 2.1 +GNU Bison configure 2.3 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1004,7 +1004,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU Bison $as_me 2.1, which was +It was created by GNU Bison $as_me 2.3, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1322,7 +1322,6 @@ gl_header_list="$gl_header_list wctype.h" gl_func_list="$gl_func_list isascii" gl_func_list="$gl_func_list iswprint" gl_func_list="$gl_func_list mbsinit" -gl_header_list="$gl_header_list unistd.h" @@ -1668,7 +1667,7 @@ fi # Define the identity of the package. PACKAGE='bison' - VERSION='2.1' + VERSION='2.3' cat >>confdefs.h <<_ACEOF @@ -3592,7 +3591,62 @@ fi - cat >>confdefs.h <<\_ACEOF + echo "$as_me:$LINENO: checking whether it is safe to define __EXTENSIONS__" >&5 +echo $ECHO_N "checking whether it is safe to define __EXTENSIONS__... $ECHO_C" >&6 +if test "${ac_cv_safe_to_define___extensions__+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_safe_to_define___extensions__=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_safe_to_define___extensions__=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_safe_to_define___extensions__" >&5 +echo "${ECHO_T}$ac_cv_safe_to_define___extensions__" >&6 + test $ac_cv_safe_to_define___extensions__ = yes && + cat >>confdefs.h <<\_ACEOF #define __EXTENSIONS__ 1 _ACEOF @@ -5814,59 +5868,6 @@ else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -CFLAGS="$ac_save_CFLAGS" - echo "$as_me:$LINENO: checking whether compiler accepts -Wnested-externs" >&5 -echo $ECHO_N "checking whether compiler accepts -Wnested-externs... $ECHO_C" >&6 - -ac_save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wnested-externs" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -int x; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - WARNING_CFLAGS="$WARNING_CFLAGS -Wnested-externs" -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5985,6 +5986,58 @@ _ACEOF fi + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + int test_array[CHAR_BIT]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compile a simple C program +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compile a simple C program +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + # Check whether --enable-yacc or --disable-yacc was given. if test "${enable_yacc+set}" = set; then enableval="$enable_yacc" @@ -6669,22 +6722,51 @@ cat >>conftest.$ac_ext <<_ACEOF char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) -0.5 == true ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; bool e = &s; - char f[(_Bool) -0.0 == false ? 1 : -1]; + char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + #if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a run-time + test, and that would make cross-compilation harder. + Let us hope that IBM fixes the xlc bug, and also adds + support for this kind of constant expression. In the + meantime, this test will reject xlc, which is OK, since + our stdbool.h substitute should suffice. We also test + this with GCC, where it should work, to detect more + quickly whether someone messes up the test in the + future. */ + char digs[] = "0123456789"; + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); + #endif + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; int main () { - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + !l - + !m + !n + !o); + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); ; return 0; @@ -8610,362 +8692,6 @@ fi # gnulib and gettext. -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -echo "$as_me:$LINENO: checking for working alloca.h" >&5 -echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 -if test "${ac_cv_working_alloca_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_working_alloca_h=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_working_alloca_h=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 -echo "${ECHO_T}$ac_cv_working_alloca_h" >&6 -if test $ac_cv_working_alloca_h = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA_H 1 -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for alloca" >&5 -echo $ECHO_N "checking for alloca... $ECHO_C" >&6 -if test "${ac_cv_func_alloca_works+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# if HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_alloca_works=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_alloca_works=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 -echo "${ECHO_T}$ac_cv_func_alloca_works" >&6 - -if test $ac_cv_func_alloca_works = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA 1 -_ACEOF - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=alloca.$ac_objext - -cat >>confdefs.h <<\_ACEOF -#define C_ALLOCA 1 -_ACEOF - - -echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 -echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6 -if test "${ac_cv_os_cray+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if defined(CRAY) && ! defined(CRAY2) -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 -echo "${ECHO_T}$ac_cv_os_cray" >&6 -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 -echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 -if test "${ac_cv_c_stack_direction+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_c_stack_direction=0 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - exit (find_stack_direction () < 0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_stack_direction=1 -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_stack_direction=-1 -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 -echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 - -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - echo "$as_me:$LINENO: checking whether system is Windows or MSDOS" >&5 echo $ECHO_N "checking whether system is Windows or MSDOS... $ECHO_C" >&6 @@ -9784,6 +9510,80 @@ echo "${ECHO_T}$gl_cv_func_gnu_getopt" >&6 fi + echo "$as_me:$LINENO: checking whether getenv is declared" >&5 +echo $ECHO_N "checking whether getenv is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_getenv+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef getenv + char *p = (char *) getenv; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_getenv=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_getenv=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_getenv" >&5 +echo "${ECHO_T}$ac_cv_have_decl_getenv" >&6 +if test $ac_cv_have_decl_getenv = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETENV 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETENV 0 +_ACEOF + + +fi + + + + + MKINSTALLDIRS= if test -n "$ac_aux_dir"; then case "$ac_aux_dir" in @@ -9860,6 +9660,7 @@ else test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" @@ -9970,6 +9771,7 @@ else test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" @@ -10041,6 +9843,7 @@ else test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" break 2 @@ -10276,6 +10079,7 @@ with_gnu_ld=$acl_cv_prog_gnu_ld + echo "$as_me:$LINENO: checking for shared library run path origin" >&5 echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6 if test "${acl_cv_rpath+set}" = set; then @@ -10307,6 +10111,26 @@ else fi; + acl_libdirstem=lib + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + + + @@ -10348,7 +10172,7 @@ if test "${with_libiconv_prefix+set}" = set; then else additional_includedir="$withval/include" - additional_libdir="$withval/lib" + additional_libdir="$withval/$acl_libdirstem" fi fi @@ -10445,7 +10269,7 @@ fi; if test "X$found_dir" != "X"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then - if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= @@ -10510,8 +10334,8 @@ fi; fi additional_includedir= case "$found_dir" in - */lib | */lib/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` additional_includedir="$basedir/include" ;; esac @@ -10521,7 +10345,7 @@ fi; if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in - linux*) haveit=yes;; + linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi @@ -10560,12 +10384,12 @@ fi; case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/lib"; then + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= - if test "X$additional_libdir" = "X/usr/local/lib"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in - linux*) haveit=yes;; + linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi @@ -10928,12 +10752,6 @@ _ACEOF fi - - - - - - echo "$as_me:$LINENO: checking whether strdup is declared" >&5 echo $ECHO_N "checking whether strdup is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_strdup+set}" = set; then @@ -11007,6 +10825,79 @@ fi + echo "$as_me:$LINENO: checking whether strndup is declared" >&5 +echo $ECHO_N "checking whether strndup is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_strndup+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef strndup + char *p = (char *) strndup; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_strndup=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_strndup=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_strndup" >&5 +echo "${ECHO_T}$ac_cv_have_decl_strndup" >&6 +if test $ac_cv_have_decl_strndup = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRNDUP 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRNDUP 0 +_ACEOF + + +fi + + + + echo "$as_me:$LINENO: checking whether strnlen is declared" >&5 echo $ECHO_N "checking whether strnlen is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_strnlen+set}" = set; then @@ -11080,54 +10971,954 @@ fi - - - - - - - if test $ac_cv_func_alloca_works = no; then - : - fi - - # Define an additional variable used in the Makefile substitution. - if test $ac_cv_working_alloca_h = yes; then - cat >conftest.$ac_ext <<_ACEOF + echo "$as_me:$LINENO: checking whether clearerr_unlocked is declared" >&5 +echo $ECHO_N "checking whether clearerr_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_clearerr_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -#if defined __GNUC__ || defined _AIX || defined _MSC_VER - Need own alloca +$ac_includes_default +int +main () +{ +#ifndef clearerr_unlocked + char *p = (char *) clearerr_unlocked; #endif + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "Need own alloca" >/dev/null 2>&1; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA 1 -_ACEOF - - ALLOCA_H=alloca.h +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_clearerr_unlocked=yes else - ALLOCA_H= + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_clearerr_unlocked=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_clearerr_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_clearerr_unlocked" >&6 +if test $ac_cv_have_decl_clearerr_unlocked = yes; then - else - ALLOCA_H=alloca.h - fi - - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA_H 1 +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_CLEARERR_UNLOCKED 1 _ACEOF +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_CLEARERR_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether feof_unlocked is declared" >&5 +echo $ECHO_N "checking whether feof_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_feof_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef feof_unlocked + char *p = (char *) feof_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_feof_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_feof_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_feof_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_feof_unlocked" >&6 +if test $ac_cv_have_decl_feof_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FEOF_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FEOF_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether ferror_unlocked is declared" >&5 +echo $ECHO_N "checking whether ferror_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_ferror_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef ferror_unlocked + char *p = (char *) ferror_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_ferror_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_ferror_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_ferror_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_ferror_unlocked" >&6 +if test $ac_cv_have_decl_ferror_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FERROR_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FERROR_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether fflush_unlocked is declared" >&5 +echo $ECHO_N "checking whether fflush_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_fflush_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef fflush_unlocked + char *p = (char *) fflush_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_fflush_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_fflush_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_fflush_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_fflush_unlocked" >&6 +if test $ac_cv_have_decl_fflush_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FFLUSH_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FFLUSH_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether fgets_unlocked is declared" >&5 +echo $ECHO_N "checking whether fgets_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_fgets_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef fgets_unlocked + char *p = (char *) fgets_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_fgets_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_fgets_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_fgets_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_fgets_unlocked" >&6 +if test $ac_cv_have_decl_fgets_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FGETS_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FGETS_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether fputc_unlocked is declared" >&5 +echo $ECHO_N "checking whether fputc_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_fputc_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef fputc_unlocked + char *p = (char *) fputc_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_fputc_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_fputc_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_fputc_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_fputc_unlocked" >&6 +if test $ac_cv_have_decl_fputc_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FPUTC_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FPUTC_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether fputs_unlocked is declared" >&5 +echo $ECHO_N "checking whether fputs_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_fputs_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef fputs_unlocked + char *p = (char *) fputs_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_fputs_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_fputs_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_fputs_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_fputs_unlocked" >&6 +if test $ac_cv_have_decl_fputs_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FPUTS_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FPUTS_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether fread_unlocked is declared" >&5 +echo $ECHO_N "checking whether fread_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_fread_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef fread_unlocked + char *p = (char *) fread_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_fread_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_fread_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_fread_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_fread_unlocked" >&6 +if test $ac_cv_have_decl_fread_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FREAD_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FREAD_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether fwrite_unlocked is declared" >&5 +echo $ECHO_N "checking whether fwrite_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_fwrite_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef fwrite_unlocked + char *p = (char *) fwrite_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_fwrite_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_fwrite_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_fwrite_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_fwrite_unlocked" >&6 +if test $ac_cv_have_decl_fwrite_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FWRITE_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FWRITE_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether getc_unlocked is declared" >&5 +echo $ECHO_N "checking whether getc_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_getc_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef getc_unlocked + char *p = (char *) getc_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_getc_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_getc_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_getc_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_getc_unlocked" >&6 +if test $ac_cv_have_decl_getc_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETC_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETC_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether getchar_unlocked is declared" >&5 +echo $ECHO_N "checking whether getchar_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_getchar_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef getchar_unlocked + char *p = (char *) getchar_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_getchar_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_getchar_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_getchar_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_getchar_unlocked" >&6 +if test $ac_cv_have_decl_getchar_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETCHAR_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETCHAR_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether putc_unlocked is declared" >&5 +echo $ECHO_N "checking whether putc_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_putc_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef putc_unlocked + char *p = (char *) putc_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_putc_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_putc_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_putc_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_putc_unlocked" >&6 +if test $ac_cv_have_decl_putc_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PUTC_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PUTC_UNLOCKED 0 +_ACEOF + + +fi + + + + + echo "$as_me:$LINENO: checking whether putchar_unlocked is declared" >&5 +echo $ECHO_N "checking whether putchar_unlocked is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_putchar_unlocked+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef putchar_unlocked + char *p = (char *) putchar_unlocked; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_putchar_unlocked=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_putchar_unlocked=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_putchar_unlocked" >&5 +echo "${ECHO_T}$ac_cv_have_decl_putchar_unlocked" >&6 +if test $ac_cv_have_decl_putchar_unlocked = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PUTCHAR_UNLOCKED 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PUTCHAR_UNLOCKED 0 +_ACEOF + + +fi + + + @@ -11261,8 +12052,16 @@ _ACEOF + + : + + + + + + fi @@ -11673,6 +12472,7 @@ echo "${ECHO_T}$LIBICONV" >&6 + use_additional=yes acl_save_prefix="$prefix" @@ -11709,7 +12509,7 @@ if test "${with_libintl_prefix+set}" = set; then else additional_includedir="$withval/include" - additional_libdir="$withval/lib" + additional_libdir="$withval/$acl_libdirstem" fi fi @@ -11806,7 +12606,7 @@ fi; if test "X$found_dir" != "X"; then LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then - if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else haveit= @@ -11871,8 +12671,8 @@ fi; fi additional_includedir= case "$found_dir" in - */lib | */lib/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` additional_includedir="$basedir/include" ;; esac @@ -11882,7 +12682,7 @@ fi; if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in - linux*) haveit=yes;; + linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi @@ -11921,12 +12721,12 @@ fi; case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/lib"; then + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= - if test "X$additional_libdir" = "X/usr/local/lib"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in - linux*) haveit=yes;; + linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi @@ -12288,6 +13088,7 @@ _ACEOF + case $LIBOBJS in "hard-locale.$ac_objext" | \ *" hard-locale.$ac_objext" | \ @@ -13240,14 +14041,6 @@ esac - : - - - - - - - @@ -13495,11 +14288,7 @@ done - - - - -for ac_func in strndup +for ac_func in strerror do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -13609,7 +14398,123 @@ fi done - if test $ac_cv_func_strndup = no; then + if test $ac_cv_func_strerror = no; then + + : + + fi + + + + + + + + + : + + + + + + + # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. + echo "$as_me:$LINENO: checking for working strndup" >&5 +echo $ECHO_N "checking for working strndup... $ECHO_C" >&6 +if test "${gl_cv_func_strndup+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#ifdef _AIX + too risky +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "too risky" >/dev/null 2>&1; then + gl_cv_func_strndup=no +else + gl_cv_func_strndup=yes +fi +rm -f conftest* + +else + cat >conftest.$ac_ext <<_ACEOF + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef HAVE_DECL_STRNDUP + extern char *strndup (const char *, size_t); +#endif + char *s; + s = strndup ("some longer string", 15); + free (s); + s = strndup ("shorter string", 13); + return s[13] != '\0'; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + gl_cv_func_strndup=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +gl_cv_func_strndup=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $gl_cv_func_strndup" >&5 +echo "${ECHO_T}$gl_cv_func_strndup" >&6 + if test $gl_cv_func_strndup = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRNDUP 1 +_ACEOF + + else + case $LIBOBJS in + "strndup.$ac_objext" | \ + *" strndup.$ac_objext" | \ + "strndup.$ac_objext "* | \ + *" strndup.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strndup.$ac_objext" ;; +esac + + +cat >>confdefs.h <<\_ACEOF +#define strndup rpl_strndup +_ACEOF + : fi @@ -13715,6 +14620,542 @@ _ACEOF +for ac_func in strtol +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + case $LIBOBJS in + "$ac_func.$ac_objext" | \ + *" $ac_func.$ac_objext" | \ + "$ac_func.$ac_objext "* | \ + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" ;; +esac + +fi +done + + + if test $ac_cv_func_strtol = no; then + + + + : + + + + + + + fi + + + + +for ac_func in strtoul +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + case $LIBOBJS in + "$ac_func.$ac_objext" | \ + *" $ac_func.$ac_objext" | \ + "$ac_func.$ac_objext "* | \ + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" ;; +esac + +fi +done + + + if test $ac_cv_func_strtoul = no; then + + + + + : + + + + + + + + fi + + + + + + + + +for ac_func in strverscmp +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + case $LIBOBJS in + "$ac_func.$ac_objext" | \ + *" $ac_func.$ac_objext" | \ + "$ac_func.$ac_objext "* | \ + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" ;; +esac + +fi +done + + + if test $ac_cv_func_strverscmp = no; then + + : + + fi + + + + +for ac_header in unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## -------------------------------- ## +## Report this to bug-bison@gnu.org ## +## -------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + + UNISTD_H='' + +else + + UNISTD_H='unistd.h' + +fi + +done + + + + + + case $LIBOBJS in "dup-safer.$ac_objext" | \ *" dup-safer.$ac_objext" | \ @@ -13742,6 +15183,17 @@ esac + + + +cat >>confdefs.h <<\_ACEOF +#define USE_UNLOCKED_IO 1 +_ACEOF + + + + + : @@ -13749,6 +15201,81 @@ esac + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + + + + : + + + + : @@ -14365,48 +15892,84 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - if test "$cross_compiling" = yes; then - bison_cv_cxx_works=cross -else - cat >conftest.$ac_ext <<_ACEOF + bison_cv_cxx_works=no + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include + #include + #include + #include using namespace std; int main () { std::cerr << ""; cout << ""; + typedef std::pair uipair; + std::map m; + std::map::iterator i; + m.insert (uipair (4, -4)); + for (i = m.begin (); i != m.end (); ++i) + if (i->first != 4) + return 1; ; return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if { ac_try='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if test "$cross_compiling" = yes; then + bison_cv_cxx_works=cross +else + if { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then bison_cv_cxx_works=yes +fi + +fi + +fi + + rm -f conftest$ac_exeext else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -bison_cv_cxx_works=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -14427,6 +15990,16 @@ echo "${ECHO_T}$bison_cv_cxx_works" >&6 +if test $bison_cv_cxx_works = yes; then + BISON_CXX_WORKS_TRUE= + BISON_CXX_WORKS_FALSE='#' +else + BISON_CXX_WORKS_TRUE='#' + BISON_CXX_WORKS_FALSE= +fi + + + AUTOM4TE=${AUTOM4TE-"${am_missing_run}autom4te"} # Needed by tests/atlocal.in. @@ -14436,7 +16009,7 @@ O0CFLAGS=`echo $CFLAGS | sed 's/-O[0-9] *//'` O0CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[0-9] *//'` - ac_config_files="$ac_config_files Makefile config/Makefile po/Makefile.in data/Makefile examples/Makefile examples/calc++/Makefile lib/Makefile src/Makefile doc/Makefile" + ac_config_files="$ac_config_files Makefile build-aux/Makefile po/Makefile.in data/Makefile examples/Makefile examples/calc++/Makefile lib/Makefile src/Makefile doc/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -14564,6 +16137,13 @@ echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${BISON_CXX_WORKS_TRUE}" && test -z "${BISON_CXX_WORKS_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"BISON_CXX_WORKS\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"BISON_CXX_WORKS\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files @@ -14835,7 +16415,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by GNU Bison $as_me 2.1, which was +This file was extended by GNU Bison $as_me 2.3, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14898,7 +16478,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -GNU Bison config.status 2.1 +GNU Bison config.status 2.3 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -15020,7 +16600,7 @@ do "tests/atlocal" ) CONFIG_FILES="$CONFIG_FILES tests/atlocal" ;; "tests/bison" ) CONFIG_FILES="$CONFIG_FILES tests/bison" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "config/Makefile" ) CONFIG_FILES="$CONFIG_FILES config/Makefile" ;; + "build-aux/Makefile" ) CONFIG_FILES="$CONFIG_FILES build-aux/Makefile" ;; "po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "data/Makefile" ) CONFIG_FILES="$CONFIG_FILES data/Makefile" ;; "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; @@ -15171,8 +16751,6 @@ s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t s,@M4@,$M4,;t t s,@STDBOOL_H@,$STDBOOL_H,;t t s,@HAVE__BOOL@,$HAVE__BOOL,;t t -s,@ALLOCA@,$ALLOCA,;t t -s,@ALLOCA_H@,$ALLOCA_H,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@GETOPT_H@,$GETOPT_H,;t t s,@MKINSTALLDIRS@,$MKINSTALLDIRS,;t t @@ -15196,6 +16774,7 @@ s,@INTLLIBS@,$INTLLIBS,;t t s,@LIBINTL@,$LIBINTL,;t t s,@LTLIBINTL@,$LTLIBINTL,;t t s,@POSUB@,$POSUB,;t t +s,@UNISTD_H@,$UNISTD_H,;t t s,@BISON_LOCALEDIR@,$BISON_LOCALEDIR,;t t s,@aclocaldir@,$aclocaldir,;t t s,@VALGRIND@,$VALGRIND,;t t @@ -15206,6 +16785,8 @@ s,@CXXDEPMODE@,$CXXDEPMODE,;t t s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t s,@BISON_CXX_WORKS@,$BISON_CXX_WORKS,;t t +s,@BISON_CXX_WORKS_TRUE@,$BISON_CXX_WORKS_TRUE,;t t +s,@BISON_CXX_WORKS_FALSE@,$BISON_CXX_WORKS_FALSE,;t t s,@AUTOM4TE@,$AUTOM4TE,;t t s,@GCC@,$GCC,;t t s,@O0CFLAGS@,$O0CFLAGS,;t t diff --git a/src/bin/bison/configure.ac b/src/bin/bison/configure.ac index cf6b688047..7804b023f7 100644 --- a/src/bin/bison/configure.ac +++ b/src/bin/bison/configure.ac @@ -1,6 +1,7 @@ # Configure template for GNU Bison. -*-Autoconf-*- # -# Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,7 +24,7 @@ # least Autoconf 2.59. AC_PREREQ(2.59) -AC_INIT([GNU Bison], [2.1], [bug-bison@gnu.org]) +AC_INIT([GNU Bison], [2.3], [bug-bison@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) @@ -58,12 +59,13 @@ if test "${enableval}" = yes; then BISON_WARNING(-Wbad-function-cast) BISON_WARNING(-Wmissing-declarations) BISON_WARNING(-Wmissing-prototypes) - BISON_WARNING(-Wnested-externs) BISON_WARNING(-Wshadow) BISON_WARNING(-Wstrict-prototypes) AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.]) fi +BISON_TEST_FOR_WORKING_C_COMPILER + AC_ARG_ENABLE([yacc], [AC_HELP_STRING([--disable-yacc], [do not build a yacc command or an -ly library])], @@ -133,7 +135,7 @@ O0CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]] *//'` AC_SUBST([O0CXXFLAGS]) AC_CONFIG_FILES([Makefile - config/Makefile + build-aux/Makefile po/Makefile.in data/Makefile examples/Makefile diff --git a/src/bin/bison/data/Makefile.am b/src/bin/bison/data/Makefile.am index 26e0a00178..7c4ccf9661 100644 --- a/src/bin/bison/data/Makefile.am +++ b/src/bin/bison/data/Makefile.am @@ -17,7 +17,7 @@ dist_pkgdata_DATA = README \ c.m4 yacc.c glr.c \ - c++.m4 lalr1.cc + c++.m4 location.cc lalr1.cc glr.cc m4sugardir = $(pkgdatadir)/m4sugar dist_m4sugar_DATA = m4sugar/m4sugar.m4 diff --git a/src/bin/bison/data/Makefile.in b/src/bin/bison/data/Makefile.in index 89a8c32c5f..3a5f561513 100644 --- a/src/bin/bison/data/Makefile.in +++ b/src/bin/bison/data/Makefile.in @@ -40,8 +40,8 @@ subdir = data DIST_COMMON = README $(dist_m4sugar_DATA) $(dist_pkgdata_DATA) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ - $(top_srcdir)/m4/bison-i18n.m4 $(top_srcdir)/m4/cxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \ + $(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \ $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \ $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \ @@ -58,11 +58,14 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \ $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strndup.m4 \ - $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/subpipe.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ + $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \ + $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \ $(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \ $(top_srcdir)/m4/ulonglong_gl.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/warning.m4 \ + $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ + $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \ $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -84,8 +87,6 @@ dist_pkgdataDATA_INSTALL = $(INSTALL_DATA) DATA = $(dist_m4sugar_DATA) $(dist_pkgdata_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALLOCA_H = @ALLOCA_H@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ @@ -95,6 +96,8 @@ AUTOM4TE = @AUTOM4TE@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON_CXX_WORKS = @BISON_CXX_WORKS@ +BISON_CXX_WORKS_FALSE = @BISON_CXX_WORKS_FALSE@ +BISON_CXX_WORKS_TRUE = @BISON_CXX_WORKS_TRUE@ BISON_LOCALEDIR = @BISON_LOCALEDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -154,6 +157,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STDBOOL_H = @STDBOOL_H@ STRIP = @STRIP@ +UNISTD_H = @UNISTD_H@ USE_NLS = @USE_NLS@ VALGRIND = @VALGRIND@ VERSION = @VERSION@ @@ -208,7 +212,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ dist_pkgdata_DATA = README \ c.m4 yacc.c glr.c \ - c++.m4 lalr1.cc + c++.m4 location.cc lalr1.cc glr.cc m4sugardir = $(pkgdatadir)/m4sugar dist_m4sugar_DATA = m4sugar/m4sugar.m4 diff --git a/src/bin/bison/data/c++.m4 b/src/bin/bison/data/c++.m4 index 0f127b9354..57aee0ceb0 100644 --- a/src/bin/bison/data/c++.m4 +++ b/src/bin/bison/data/c++.m4 @@ -1,8 +1,8 @@ -m4_divert(-1) +m4_divert(-1) -*- Autoconf -*- # C++ skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ m4_divert(-1) # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA +m4_include(b4_pkgdatadir/[c.m4]) + ## ---------------- ## ## Default values. ## ## ---------------- ## @@ -27,21 +29,20 @@ m4_divert(-1) m4_define_default([b4_parser_class_name], [parser]) m4_define_default([b4_location_type], [location]) m4_define_default([b4_filename_type], [std::string]) - +m4_define_default([b4_namespace], m4_defn([b4_prefix])) # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) # ----------------------------------------------------- -# Output the definition of the tokens (if there are) as enums. +# Output the definition of the tokens as enums. m4_define([b4_token_enums], -[m4_if([$@], [[]], [], [/* Tokens. */ enum yytokentype { m4_map_sep([ b4_token_enum], [, ], [$@]) }; -])]) +]) ## ----------------- ## @@ -61,7 +62,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))]) +[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))]) # b4_lhs_location() # ----------------- @@ -75,7 +76,7 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[(yylocation_stack_@{m4_eval([$1 - $2])@})]) +[(yylocation_stack_@{($1) - ($2)@})]) # b4_parse_param_decl diff --git a/src/bin/bison/data/c.m4 b/src/bin/bison/data/c.m4 index d8dc6bc4bc..f10e090114 100644 --- a/src/bin/bison/data/c.m4 +++ b/src/bin/bison/data/c.m4 @@ -1,7 +1,7 @@ m4_divert(-1) -*- Autoconf -*- # C M4 Macros for Bison. -# Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,8 +28,9 @@ m4_divert(-1) -*- Autoconf -*- m4_define([b4_copyright], [/* A Bison parser, made by GNU Bison b4_version. */ -/* $1, - Copyright (C) $2 Free Software Foundation, Inc. +/* $1 + +m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ]) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +45,20 @@ m4_define([b4_copyright], You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */]) + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */]) # b4_identification @@ -60,7 +74,7 @@ m4_define([b4_identification], [#]define YYSKELETON_NAME b4_skeleton /* Pure parsers. */ -[#]define YYPURE b4_pure +[#]define YYPURE b4_pure_flag /* Using locations. */ [#]define YYLSP_NEEDED b4_locations_flag @@ -96,6 +110,26 @@ m4_define([b4_parse_param], b4_parse_param)) +# b4_parse_param_for(DECL, FORMAL, BODY) +# --------------------------------------- +# Iterate over the user parameters, binding the declaration to DECL, +# the formal name to FORMAL, and evaluating the BODY. +m4_define([b4_parse_param_for], +[m4_foreach([$1_$2], m4_defn([b4_parse_param]), +[m4_pushdef([$1], m4_fst($1_$2))dnl +m4_pushdef([$2], m4_shift($1_$2))dnl +$3[]dnl +m4_popdef([$2])dnl +m4_popdef([$1])dnl +])]) + +# b4_parse_param_use +# ------------------ +# `YYUSE' all the parse-params. +m4_define([b4_parse_param_use], +[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal); +])dnl +]) ## ------------ ## ## Data Types. ## @@ -122,7 +156,7 @@ m4_define([b4_int_type], m4_eval([0 <= $1]), [1], [unsigned int], - [int])]) + [int])]) # b4_int_type_for(NAME) @@ -137,23 +171,42 @@ m4_define([b4_int_type_for], ## Decoding options. ## ## ------------------ ## - -# b4_location_if(IF-TRUE, IF-FALSE) -# --------------------------------- -# Expand IF-TRUE, if locations are used, IF-FALSE otherwise. -m4_define([b4_location_if], -[m4_if(b4_locations_flag, [1], - [$1], - [$2])]) +# b4_flag_if(FLAG, IF-TRUE, IF-FALSE) +# ----------------------------------- +# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail. +m4_define([b4_flag_if], +[m4_case(b4_$1_flag, + [0], [$3], + [1], [$2], + [m4_fatal([invalid $1 value: ]$1)])]) -# b4_pure_if(IF-TRUE, IF-FALSE) +# b4_define_flag_if(FLAG) +# ----------------------- +# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the +# value of the Boolean FLAG. +m4_define([b4_define_flag_if], +[_b4_define_flag_if($[1], $[2], [$1])]) + +# _b4_define_flag_if($1, $2, FLAG) +# -------------------------------- +# This macro works around the impossibility to define macros +# inside macros, because issuing `[$1]' is not possible in M4 :(. +# This sucks hard, GNU M4 should really provide M5 like $$1. +m4_define([_b4_define_flag_if], +[m4_if([$1$2], $[1]$[2], [], + [m4_fatal([$0: Invalid arguments: $@])])dnl +m4_define([b4_$3_if], + [b4_flag_if([$3], [$1], [$2])])]) + + +# b4_FLAG_if(IF-TRUE, IF-FALSE) # ----------------------------- -# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise. -m4_define([b4_pure_if], -[m4_if(b4_pure, [1], - [$1], - [$2])]) +# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. +b4_define_flag_if([defines]) # Whether headers are requested. +b4_define_flag_if([error_verbose]) # Wheter error are verbose. +b4_define_flag_if([locations]) # Whether locations are tracked. +b4_define_flag_if([pure]) # Whether the interface is pure. @@ -199,7 +252,7 @@ m4_define([b4_token_enums], enum yytokentype { m4_map_sep([ b4_token_enum], [, ], - [$@]) + [$@]) }; #endif ])]) @@ -219,11 +272,25 @@ m4_define([b4_token_enums_defines], ## --------------------------------------------- ## +# b4_modern_c +# ----------- +# A predicate useful in #if to determine whether C is ancient or modern. +# +# If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run +# as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic +# reasons, but it defines __C99__FUNC__ so check that as well. +# Microsoft C normally doesn't define these macros, but it defines _MSC_VER. +# Consider a C++ compiler to be modern if it defines __cplusplus. +# +m4_define([b4_c_modern], + [[(defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER)]]) + # b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...) # ---------------------------------------------------------- # Declare the function NAME. m4_define([b4_c_function_def], -[#if defined (__STDC__) || defined (__cplusplus) +[#if b4_c_modern b4_c_ansi_function_def($@) #else $2 @@ -247,9 +314,9 @@ $1 (b4_c_ansi_formals(m4_shiftn(2, $@)))[]dnl # Output the arguments ANSI-C definition. m4_define([b4_c_ansi_formals], [m4_case([$@], - [], [void], - [[]], [void], - [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])]) + [], [void], + [[]], [void], + [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])]) m4_define([b4_c_ansi_formal], [$1]) @@ -270,9 +337,9 @@ m4_define([b4_c_knr_formal_name], # Output the K&R argument declarations. m4_define([b4_c_knr_formal_decls], [m4_map_sep([b4_c_knr_formal_decl], - [ + [ ], - [$@])]) + [$@])]) m4_define([b4_c_knr_formal_decl], [ $1;]) @@ -288,7 +355,7 @@ m4_define([b4_c_knr_formal_decl], # ----------------------------------------------------------- # Declare the function NAME. m4_define([b4_c_function_decl], -[#if defined (__STDC__) || defined (__cplusplus) +[#if defined __STDC__ || defined __cplusplus b4_c_ansi_function_decl($@) #else $2 $1 (); @@ -333,14 +400,17 @@ m4_define([b4_c_arg], ## Synclines. ## ## ----------- ## - # b4_syncline(LINE, FILE) # ----------------------- m4_define([b4_syncline], -[m4_if(b4_synclines_flag, 1, - [[#]line $1 $2])]) +[b4_flag_if([synclines], [[#]line $1 $2])]) + +## -------------- ## +## User actions. ## +## -------------- ## + # b4_symbol_actions(FILENAME, LINENO, # SYMBOL-TAG, SYMBOL-NUM, # SYMBOL-ACTION, SYMBOL-TYPENAME) @@ -351,9 +421,9 @@ m4_define([b4_symbol_actions], m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl case $4: /* $3 */ b4_syncline([$2], [$1]) - $5; + $5; b4_syncline([@oline@], [@ofile@]) - break; + break; m4_popdef([b4_at_dollar])dnl m4_popdef([b4_dollar_dollar])dnl ]) @@ -369,17 +439,20 @@ m4_define_default([b4_yydestruct_generate], | Release the memory associated to this symbol. | `-----------------------------------------------*/ +/*ARGSUSED*/ ]$1([yydestruct], [static void], [[const char *yymsg], [yymsg]], [[int yytype], [yytype]], - [[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([, - [[YYLTYPE *yylocationp], [yylocationp]]]))[ + [[YYSTYPE *yyvaluep], [yyvaluep]][]dnl +b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl +m4_ifset([b4_parse_param], [, b4_parse_param]))[ { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; -]b4_location_if([ (void) yylocationp; -])[ + YYUSE (yyvaluep); +]b4_locations_if([ YYUSE (yylocationp); +])dnl +b4_parse_param_use[]dnl +[ if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); @@ -388,53 +461,74 @@ m4_define_default([b4_yydestruct_generate], { ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ default: - break; + break; } }]dnl ]) -# b4_yysymprint_generate(FUNCTION-DECLARATOR) -# ------------------------------------------- -# Generate the "yysymprint" function, which declaration is issued using +# b4_yy_symbol_print_generate(FUNCTION-DECLARATOR) +# ------------------------------------------------ +# Generate the "yy_symbol_print" function, which declaration is issued using # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C # or "b4_c_function_def" for K&R. -m4_define_default([b4_yysymprint_generate], -[[/*--------------------------------. +m4_define_default([b4_yy_symbol_print_generate], +[[ +/*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ -]$1([yysymprint], +/*ARGSUSED*/ +]$1([yy_symbol_value_print], [static void], - [[FILE *yyoutput], [yyoutput]], - [[int yytype], [yytype]], - [[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([, - [[YYLTYPE *yylocationp], [yylocationp]]])) + [[FILE *yyoutput], [yyoutput]], + [[int yytype], [yytype]], + [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl +b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl +m4_ifset([b4_parse_param], [, b4_parse_param]))[ { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; -b4_location_if([ (void) yylocationp; + if (!yyvaluep) + return; +]b4_locations_if([ YYUSE (yylocationp); ])dnl -[ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - -]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp); - YYFPRINTF (yyoutput, ": "); -])dnl -[ -# ifdef YYPRINT +b4_parse_param_use[]dnl +[# ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); # endif switch (yytype) { ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl [ default: - break; + break; } - YYFPRINTF (yyoutput, ")"); } -]]) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +]$1([yy_symbol_print], + [static void], + [[FILE *yyoutput], [yyoutput]], + [[int yytype], [yytype]], + [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl +b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl +m4_ifset([b4_parse_param], [, b4_parse_param]))[ +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + +]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); +])dnl +[ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl +b4_locations_if([, yylocationp])[]b4_user_args[); + YYFPRINTF (yyoutput, ")"); +}]dnl +]) diff --git a/src/bin/bison/data/glr.c b/src/bin/bison/data/glr.c index 6d3ec6cc22..b872bf404a 100644 --- a/src/bin/bison/data/glr.c +++ b/src/bin/bison/data/glr.c @@ -1,7 +1,7 @@ m4_divert(-1) -*- C -*- # GLR skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ m4_divert(-1) -*- C -*- # 02110-1301 USA +m4_include(b4_pkgdatadir/[c.m4]) + ## ---------------- ## ## Default values. ## ## ---------------- ## @@ -34,64 +36,62 @@ m4_define_default([b4_stack_depth_init], [200]) ## ------------------------ ## +# b4_user_formals +# --------------- +# The possible parse-params formal arguments preceded by a comma. +# +# This is not shared with yacc.c in c.m4 because GLR relies on ISO C +# formal argument declarations. +m4_define([b4_user_formals], +[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])]) + + # b4_lex_param # ------------ # Accumule in b4_lex_param all the yylex arguments. # Yes, this is quite ugly... m4_define([b4_lex_param], -m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[yylvalp]]][]dnl -b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl +m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl +b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl m4_ifdef([b4_lex_param], [, ]b4_lex_param))) -# b4_user_formals -# --------------- -m4_define([b4_user_formals], -[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])]) - - # b4_yyerror_args # --------------- -# Arguments passed to yyerror: user args plus yylloc. +# Optional effective arguments passed to yyerror: user args plus yylloc, and +# a trailing comma. m4_define([b4_yyerror_args], -[b4_pure_if([b4_location_if([yylocp, ])])dnl +[b4_pure_if([b4_locations_if([yylocp, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) # b4_lyyerror_args # ---------------- -# Same as above, but on the look-ahead, hence yyllocp instead of yylocp. +# Same as above, but on the look-ahead, hence &yylloc instead of yylocp. m4_define([b4_lyyerror_args], -[b4_pure_if([b4_location_if([yyllocp, ])])dnl +[b4_pure_if([b4_locations_if([&yylloc, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) # b4_pure_args # ------------ -# Arguments needed by yyerror: user args plus yylloc. +# Same as b4_yyerror_args, but with a leading comma. m4_define([b4_pure_args], -[b4_pure_if([b4_location_if([, yylocp])])[]b4_user_args]) - - -# b4_pure_formals -# --------------- -# Arguments passed to yyerror: user formals plus yyllocp. -m4_define([b4_pure_formals], -[b4_pure_if([b4_location_if([, YYLTYPE *yylocp])])[]b4_user_formals]) +[b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args]) # b4_lpure_args # ------------- -# Same as above, but on the look-ahead, hence yyllocp instead of yylocp. +# Same as above, but on the look-ahead, hence &yylloc instead of yylocp. m4_define([b4_lpure_args], -[b4_pure_if([b4_location_if([, yyllocp])])[]b4_user_args]) +[b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args]) -# b4_lpure_formals -# ---------------- -# Same as above, but on the look-ahead, hence yyllocp instead of yylocp. -m4_define([b4_lpure_formals], -[b4_pure_if([b4_location_if([YYLTYPE *yyllocp])])[]b4_user_formals]) +# b4_pure_formals +# --------------- +# Arguments passed to yyerror: user formals plus yylocp. +m4_define([b4_pure_formals], +[b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals]) ## ----------------- ## @@ -111,7 +111,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[(((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))]) +[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))]) @@ -131,19 +131,26 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[(((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc)]) +[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)]) + + + +## -------------- ## +## Output files. ## +## -------------- ## # We do want M4 expansion after # for CPP macros. m4_changecom() m4_divert(0)dnl @output @output_parser_name@ -b4_copyright([Skeleton parser for GLR parsing with Bison], - [2002, 2003, 2004, 2005]) +b4_copyright([Skeleton implementation for Bison GLR parsers in C], + [2002, 2003, 2004, 2005, 2006]) [ -/* This is the parser code for GLR (Generalized LR) parser. */ +/* C GLR parser skeleton written by Paul Hilfinger. */ ]b4_identification -m4_if(b4_prefix[], [yy], [], + +m4_if(b4_prefix, [yy], [], [/* Substitute the variable and function names. */ #define yyparse b4_prefix[]parse #define yylex b4_prefix[]lex @@ -152,46 +159,34 @@ m4_if(b4_prefix[], [yy], [], #define yychar b4_prefix[]char #define yydebug b4_prefix[]debug #define yynerrs b4_prefix[]nerrs -#define yylloc b4_prefix[]lloc]) +#define yylloc b4_prefix[]lloc]) -b4_token_enums_defines(b4_tokens) +dnl # b4_shared_declarations +dnl # ---------------------- +dnl # Declaration that might either go into the header (if --defines) +dnl # or open coded in the parser body. +m4_define([b4_shared_declarations], +[b4_token_enums(b4_tokens)[ /* Copy the first part of user declarations. */ -b4_pre_prologue[ +]b4_pre_prologue[ -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE ]b4_error_verbose[ -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE ]b4_token_table[ -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; +[typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ]) +b4_stype /* Line __line__ of glr.c. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + YYSTYPE;], [typedef int YYSTYPE;])[ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif -#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { -]b4_location_if([ +]b4_locations_if([ int first_line; int first_column; int last_line; @@ -203,12 +198,34 @@ typedef struct YYLTYPE # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif +]]) + +b4_defines_if([#include @output_header_name@], + [b4_shared_declarations])[ + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG ]b4_debug_flag[ +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE ]b4_token_table[ +#endif /* Default (constant) value used for initialization for null right-hand sides. Unlike the standard yacc.c template, here we set the default value of $$ to a zeroed-out value. Since the default value is undefined, this behavior is - technically correct. */ + technically correct. */ static YYSTYPE yyval_default; /* Copy the second part of user declarations. */ @@ -234,6 +251,23 @@ b4_syncline([@oline@], [@ofile@]) # endif #endif +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +]b4_c_function_def([YYID], [static int], [[int i], [i]])[ +{ + return i; +} +#endif + #ifndef YYFREE # define YYFREE free #endif @@ -267,13 +301,13 @@ b4_syncline([@oline@], [@ofile@]) #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ -# if (!defined (__GNUC__) || __GNUC__ < 2 \ +# if (! defined __GNUC__ || __GNUC__ < 2 \ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__) # define __attribute__(Spec) /* empty */ # endif #endif -]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[ +]b4_locations_if([#define YYOPTIONAL_LOC(Name) Name],[ #ifdef __cplusplus # define YYOPTIONAL_LOC(Name) /* empty */ #else @@ -284,23 +318,23 @@ b4_syncline([@oline@], [@ofile@]) # define YYASSERT(condition) ((void) ((condition) || (abort (), 0))) #endif -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL ]b4_final_state_number[ /* YYLAST -- Last index in YYTABLE. */ #define YYLAST ]b4_last[ -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS ]b4_tokens_number[ -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS ]b4_nterms_number[ -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES ]b4_rules_number[ -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES ]b4_states_number[ -/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ +/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ #define YYMAXRHS ]b4_r2_max[ /* YYMAXLEFT -- Maximum number of symbols to the left of a handle - accessed by $0, $-1, etc., in any rule. */ + accessed by $0, $-1, etc., in any rule. */ #define YYMAXLEFT ]b4_max_left_semantic_context[ /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */ @@ -325,7 +359,7 @@ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = ]b4_prhs[ }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = { ]b4_rhs[ @@ -340,7 +374,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { ]b4_tname[ @@ -359,13 +393,13 @@ static const ]b4_int_type_for([b4_r2])[ yyr2[] = ]b4_r2[ }; -/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ +/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ static const ]b4_int_type_for([b4_dprec])[ yydprec[] = { ]b4_dprec[ }; -/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ +/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ static const ]b4_int_type_for([b4_merger])[ yymerger[] = { ]b4_merger[ @@ -379,7 +413,7 @@ static const ]b4_int_type_for([b4_defact])[ yydefact[] = ]b4_defact[ }; -/* YYPDEFGOTO[NTERM-NUM]. */ +/* YYPDEFGOTO[NTERM-NUM]. */ static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = { ]b4_defgoto[ @@ -451,12 +485,12 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ -]b4_location_if([[ +]b4_locations_if([[ #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ - if (N) \ + if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ @@ -470,7 +504,7 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (YYID (0)) /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know @@ -478,8 +512,8 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) #endif ]],[ #ifndef YYLLOC_DEFAULT @@ -498,9 +532,18 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = ]b4_pure_if( [ #undef yynerrs -#define yynerrs (yystack->yyerrcnt) +#define yynerrs (yystackp->yyerrcnt) #undef yychar -#define yychar (yystack->yyrawchar)], +#define yychar (yystackp->yyrawchar) +#undef yylval +#define yylval (yystackp->yyval) +#undef yylloc +#define yylloc (yystackp->yyloc) +m4_if(b4_prefix[], [yy], [], +[#define b4_prefix[]nerrs yynerrs +#define b4_prefix[]char yychar +#define b4_prefix[]lval yylval +#define b4_prefix[]lloc yylloc])], [YYSTYPE yylval; YYLTYPE yylloc; @@ -515,32 +558,32 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; #define YYCHK(YYE) \ do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ - while (0) + while (YYID (0)) #if YYDEBUG -#if ! defined (YYFPRINTF) +# ifndef YYFPRINTF # define YYFPRINTF fprintf -#endif +# endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -]b4_yysymprint_generate([b4_c_ansi_function_def])[ +]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[ -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value]b4_location_if([, Location])[); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, Type, \ + Value]b4_locations_if([, Location])[]b4_user_args[); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -573,23 +616,38 @@ int yydebug; allocation. This is to allow allocation and initialization to be completed by functions that call yyexpandGLRStack before the stack is expanded, thus insuring that all necessary pointers get - properly redirected to new data. */ + properly redirected to new data. */ #define YYHEADROOM 2 #ifndef YYSTACKEXPANDABLE -# if (! defined (__cplusplus) \ - || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \ - && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)) +# if (! defined __cplusplus \ + || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)) # define YYSTACKEXPANDABLE 1 # else # define YYSTACKEXPANDABLE 0 # endif #endif +#if YYSTACKEXPANDABLE +# define YY_RESERVE_GLRSTACK(Yystack) \ + do { \ + if (Yystack->yyspaceLeft < YYHEADROOM) \ + yyexpandGLRStack (Yystack); \ + } while (YYID (0)) +#else +# define YY_RESERVE_GLRSTACK(Yystack) \ + do { \ + if (Yystack->yyspaceLeft < YYHEADROOM) \ + yyMemoryExhausted (Yystack); \ + } while (YYID (0)) +#endif + + #if YYERROR_VERBOSE # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in @@ -671,18 +729,18 @@ typedef short int yySymbol; typedef short int yyItemNum; typedef struct yyGLRState yyGLRState; +typedef struct yyGLRStateSet yyGLRStateSet; typedef struct yySemanticOption yySemanticOption; typedef union yyGLRStackItem yyGLRStackItem; typedef struct yyGLRStack yyGLRStack; -typedef struct yyGLRStateSet yyGLRStateSet; struct yyGLRState { - /** Type tag: always true. */ + /** Type tag: always true. */ yybool yyisState; - /** Type tag for yysemantics. If true, yysval applies, otherwise - * yyfirstVal applies. */ + /** Type tag for yysemantics. If true, yysval applies, otherwise + * yyfirstVal applies. */ yybool yyresolved; - /** Number of corresponding LALR(1) machine state. */ + /** Number of corresponding LALR(1) machine state. */ yyStateNum yylrState; /** Preceding state in this stack */ yyGLRState* yypred; @@ -691,34 +749,43 @@ struct yyGLRState { union { /** First in a chain of alternative reductions producing the * non-terminal corresponding to this state, threaded through - * yynext. */ + * yynext. */ yySemanticOption* yyfirstVal; - /** Semantic value for this state. */ + /** Semantic value for this state. */ YYSTYPE yysval; } yysemantics; - /** Source location for this state. */ + /** Source location for this state. */ YYLTYPE yyloc; }; struct yyGLRStateSet { yyGLRState** yystates; + /** During nondeterministic operation, yylookaheadNeeds tracks which + * stacks have actually needed the current lookahead. During deterministic + * operation, yylookaheadNeeds[0] is not maintained since it would merely + * duplicate yychar != YYEMPTY. */ + yybool* yylookaheadNeeds; size_t yysize, yycapacity; }; struct yySemanticOption { - /** Type tag: always false. */ + /** Type tag: always false. */ yybool yyisState; /** Rule number for this reduction */ yyRuleNum yyrule; - /** The last RHS state in the list of states to be reduced. */ + /** The last RHS state in the list of states to be reduced. */ yyGLRState* yystate; - /** Next sibling in chain of options. To facilitate merging, - * options are chained in decreasing order by address. */ + /** The lookahead for this reduction. */ + int yyrawchar; + YYSTYPE yyval; + YYLTYPE yyloc; + /** Next sibling in chain of options. To facilitate merging, + * options are chained in decreasing order by address. */ yySemanticOption* yynext; }; -/** Type of the items in the GLR stack. The yyisState field - * indicates which item of the union is valid. */ +/** Type of the items in the GLR stack. The yyisState field + * indicates which item of the union is valid. */ union yyGLRStackItem { yyGLRState yystate; yySemanticOption yyoption; @@ -726,14 +793,15 @@ union yyGLRStackItem { struct yyGLRStack { int yyerrState; -]b4_location_if([[ /* To compute the location of the error token. */ +]b4_locations_if([[ /* To compute the location of the error token. */ yyGLRStackItem yyerror_range[3];]])[ ]b4_pure_if( [ int yyerrcnt; int yyrawchar; + YYSTYPE yyval; + YYLTYPE yyloc; ])[ - yySymbol* yytokenp; YYJMP_BUF yyexception_buffer; yyGLRStackItem* yyitems; yyGLRStackItem* yynextFree; @@ -743,24 +811,26 @@ struct yyGLRStack { yyGLRStateSet yytops; }; -static void yyexpandGLRStack (yyGLRStack* yystack); +#if YYSTACKEXPANDABLE +static void yyexpandGLRStack (yyGLRStack* yystackp); +#endif -static void yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg) +static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) __attribute__ ((__noreturn__)); static void -yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg) +yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) { if (yymsg != NULL) yyerror (]b4_yyerror_args[yymsg); - YYLONGJMP (yystack->yyexception_buffer, 1); + YYLONGJMP (yystackp->yyexception_buffer, 1); } -static void yyMemoryExhausted (yyGLRStack* yystack) +static void yyMemoryExhausted (yyGLRStack* yystackp) __attribute__ ((__noreturn__)); static void -yyMemoryExhausted (yyGLRStack* yystack) +yyMemoryExhausted (yyGLRStack* yystackp) { - YYLONGJMP (yystack->yyexception_buffer, 2); + YYLONGJMP (yystackp->yyexception_buffer, 2); } #if YYDEBUG || YYERROR_VERBOSE @@ -777,8 +847,7 @@ yytokenName (yySymbol yytoken) /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred - * containing the pointer to the next state in the chain. Assumes - * YYLOW1 < YYLOW0. */ + * containing the pointer to the next state in the chain. */ static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__)); static void yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) @@ -797,8 +866,8 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) } /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in - YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1. - For convenience, always return YYLOW1. */ + * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1. + * For convenience, always return YYLOW1. */ static inline int yyfill (yyGLRStackItem *, int *, int, yybool) __attribute__ ((__unused__)); static inline int @@ -815,21 +884,21 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal) /** Perform user action for rule number YYN, with RHS length YYRHSLEN, * and top stack item YYVSP. YYLVALP points to place to put semantic * value ($$), and yylocp points to place for location information - * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, - * yyerr for YYERROR, yyabort for YYABORT. */ -static YYRESULTTAG + * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, + * yyerr for YYERROR, yyabort for YYABORT. */ +/*ARGSUSED*/ static YYRESULTTAG yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, YYSTYPE* yyvalp, YYLTYPE* YYOPTIONAL_LOC (yylocp), - yyGLRStack* yystack - ]b4_user_formals[) + yyGLRStack* yystackp + ]b4_user_formals[) { yybool yynormal __attribute__ ((__unused__)) = - (yystack->yysplitPoint == NULL); + (yystackp->yysplitPoint == NULL); int yylow; - -# undef yyerrok -# define yyerrok (yystack->yyerrState = 0) +]b4_parse_param_use[]dnl +[# undef yyerrok +# define yyerrok (yystackp->yyerrState = 0) # undef YYACCEPT # define YYACCEPT return yyaccept # undef YYABORT @@ -837,9 +906,9 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, # undef YYERROR # define YYERROR return yyerrok, yyerr # undef YYRECOVERING -# define YYRECOVERING (yystack->yyerrState != 0) +# define YYRECOVERING() (yystackp->yyerrState != 0) # undef yyclearin -# define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY) +# define yyclearin (yychar = YYEMPTY) # undef YYFILL # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal) # undef YYBACKUP @@ -852,12 +921,14 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, *yyvalp = yyval_default; else *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval; - YYLLOC_DEFAULT (*yylocp, yyvsp - yyrhslen, yyrhslen); -]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = *yylocp; -]]) + YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen); +]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = *yylocp; +]])[ switch (yyn) { - b4_actions + ]b4_actions +/* Line __line__ of glr.c. */ +b4_syncline([@oline@], [@ofile@])[ default: break; } @@ -869,25 +940,22 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, # undef YYBACKUP # undef yyclearin # undef YYRECOVERING -/* Line __line__ of glr.c. */ -b4_syncline([@oline@], [@ofile@]) } -static void +/*ARGSUSED*/ static void yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) { - /* `Use' the arguments. */ - (void) yy0; - (void) yy1; + YYUSE (yy0); + YYUSE (yy1); switch (yyn) { - b4_mergers + ]b4_mergers[ default: break; } } -[ + /* Bison grammar-table manipulation. */ ]b4_yydestruct_generate([b4_c_ansi_function_def])[ @@ -900,37 +968,40 @@ yyrhsLength (yyRuleNum yyrule) } static void -yydestroyGLRState (char const *yymsg, yyGLRState *yys) +yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[) { if (yys->yyresolved) yydestruct (yymsg, yystos[yys->yylrState], - &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[); + &yys->yysemantics.yysval]b4_locations_if([, &yys->yyloc])[]b4_user_args[); else { #if YYDEBUG if (yydebug) { - YYFPRINTF (stderr, "%s unresolved ", yymsg); - yysymprint (stderr, yystos[yys->yylrState], - &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[); + if (yys->yysemantics.yyfirstVal) + YYFPRINTF (stderr, "%s unresolved ", yymsg); + else + YYFPRINTF (stderr, "%s incomplete ", yymsg); + yy_symbol_print (stderr, yystos[yys->yylrState], + NULL]b4_locations_if([, &yys->yyloc])[]b4_user_args[); YYFPRINTF (stderr, "\n"); } #endif if (yys->yysemantics.yyfirstVal) - { - yySemanticOption *yyoption = yys->yysemantics.yyfirstVal; - yyGLRState *yyrh; - int yyn; - for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule); - yyn > 0; - yyrh = yyrh->yypred, yyn -= 1) - yydestroyGLRState (yymsg, yyrh); - } + { + yySemanticOption *yyoption = yys->yysemantics.yyfirstVal; + yyGLRState *yyrh; + int yyn; + for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule); + yyn > 0; + yyrh = yyrh->yypred, yyn -= 1) + yydestroyGLRState (yymsg, yyrh]b4_user_args[); + } } } -/** Left-hand-side symbol for rule #RULE. */ +/** Left-hand-side symbol for rule #RULE. */ static inline yySymbol yylhsNonterm (yyRuleNum yyrule) { @@ -938,19 +1009,19 @@ yylhsNonterm (yyRuleNum yyrule) } #define yyis_pact_ninf(yystate) \ - ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1, - 0, - ((yystate) == YYPACT_NINF))[ + ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), [1], + [0], + [((yystate) == YYPACT_NINF)])[ /** True iff LR state STATE has only a default reduction (regardless - * of token). */ + * of token). */ static inline yybool yyisDefaultedState (yyStateNum yystate) { return yyis_pact_ninf (yypact[yystate]); } -/** The default reduction for STATE, assuming it has one. */ +/** The default reduction for STATE, assuming it has one. */ static inline yyRuleNum yydefaultAction (yyStateNum yystate) { @@ -958,9 +1029,9 @@ yydefaultAction (yyStateNum yystate) } #define yyis_table_ninf(yytable_value) \ - ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1, - 0, - ((yytable_value) == YYTABLE_NINF))[ + ]m4_if(m4_eval(b4_table_ninf < b4_table_min), [1], + [YYID (0)], + [((yytable_value) == YYTABLE_NINF)])[ /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. * Result R means @@ -972,7 +1043,7 @@ yydefaultAction (yyStateNum yystate) */ static inline void yygetLRActions (yyStateNum yystate, int yytoken, - int* yyaction, const short int** yyconflicts) + int* yyaction, const short int** yyconflicts) { int yyindex = yypact[yystate] + yytoken; if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) @@ -1017,26 +1088,49 @@ yyisErrorAction (int yyaction) /* GLRStates */ +/** Return a fresh GLRStackItem. Callers should call + * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient + * headroom. */ + +static inline yyGLRStackItem* +yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState) +{ + yyGLRStackItem* yynewItem = yystackp->yynextFree; + yystackp->yyspaceLeft -= 1; + yystackp->yynextFree += 1; + yynewItem->yystate.yyisState = yyisState; + return yynewItem; +} + +/** Add a new semantic action that will execute the action for rule + * RULENUM on the semantic values in RHS to the list of + * alternative actions for STATE. Assumes that RHS comes from + * stack #K of *STACKP. */ static void -yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate, +yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate, yyGLRState* rhs, yyRuleNum yyrule) { - yySemanticOption* yynewItem; - yynewItem = &yystack->yynextFree->yyoption; - yystack->yyspaceLeft -= 1; - yystack->yynextFree += 1; - yynewItem->yyisState = yyfalse; - yynewItem->yystate = rhs; - yynewItem->yyrule = yyrule; - yynewItem->yynext = yystate->yysemantics.yyfirstVal; - yystate->yysemantics.yyfirstVal = yynewItem; - if (yystack->yyspaceLeft < YYHEADROOM) - yyexpandGLRStack (yystack); + yySemanticOption* yynewOption = + &yynewGLRStackItem (yystackp, yyfalse)->yyoption; + yynewOption->yystate = rhs; + yynewOption->yyrule = yyrule; + if (yystackp->yytops.yylookaheadNeeds[yyk]) + { + yynewOption->yyrawchar = yychar; + yynewOption->yyval = yylval; + yynewOption->yyloc = yylloc; + } + else + yynewOption->yyrawchar = YYEMPTY; + yynewOption->yynext = yystate->yysemantics.yyfirstVal; + yystate->yysemantics.yyfirstVal = yynewOption; + + YY_RESERVE_GLRSTACK (yystackp); } /* GLRStacks */ -/** Initialize SET to a singleton set containing an empty stack. */ +/** Initialize SET to a singleton set containing an empty stack. */ static yybool yyinitStateSet (yyGLRStateSet* yyset) { @@ -1046,58 +1140,67 @@ yyinitStateSet (yyGLRStateSet* yyset) if (! yyset->yystates) return yyfalse; yyset->yystates[0] = NULL; + yyset->yylookaheadNeeds = + (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]); + if (! yyset->yylookaheadNeeds) + { + YYFREE (yyset->yystates); + return yyfalse; + } return yytrue; } static void yyfreeStateSet (yyGLRStateSet* yyset) { YYFREE (yyset->yystates); + YYFREE (yyset->yylookaheadNeeds); } /** Initialize STACK to a single empty stack, with total maximum - * capacity for all stacks of SIZE. */ + * capacity for all stacks of SIZE. */ static yybool -yyinitGLRStack (yyGLRStack* yystack, size_t yysize) +yyinitGLRStack (yyGLRStack* yystackp, size_t yysize) { - yystack->yyerrState = 0; + yystackp->yyerrState = 0; yynerrs = 0; - yystack->yyspaceLeft = yysize; - yystack->yyitems = - (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]); - if (!yystack->yyitems) + yystackp->yyspaceLeft = yysize; + yystackp->yyitems = + (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]); + if (!yystackp->yyitems) return yyfalse; - yystack->yynextFree = yystack->yyitems; - yystack->yysplitPoint = NULL; - yystack->yylastDeleted = NULL; - return yyinitStateSet (&yystack->yytops); + yystackp->yynextFree = yystackp->yyitems; + yystackp->yysplitPoint = NULL; + yystackp->yylastDeleted = NULL; + return yyinitStateSet (&yystackp->yytops); } -#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \ + +#if YYSTACKEXPANDABLE +# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \ &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE /** If STACK is expandable, extend it. WARNING: Pointers into the stack from outside should be considered invalid after this call. We always expand when there are 1 or fewer items left AFTER an allocation, so that we can avoid having external pointers exist - across an allocation. */ + across an allocation. */ static void -yyexpandGLRStack (yyGLRStack* yystack) +yyexpandGLRStack (yyGLRStack* yystackp) { -#if YYSTACKEXPANDABLE yyGLRStackItem* yynewItems; yyGLRStackItem* yyp0, *yyp1; size_t yysize, yynewSize; size_t yyn; - yysize = yystack->yynextFree - yystack->yyitems; - if (YYMAXDEPTH <= yysize) - yyMemoryExhausted (yystack); + yysize = yystackp->yynextFree - yystackp->yyitems; + if (YYMAXDEPTH - YYHEADROOM < yysize) + yyMemoryExhausted (yystackp); yynewSize = 2*yysize; if (YYMAXDEPTH < yynewSize) yynewSize = YYMAXDEPTH; yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]); if (! yynewItems) - yyMemoryExhausted (yystack); - for (yyp0 = yystack->yyitems, yyp1 = yynewItems, yyn = yysize; + yyMemoryExhausted (yystackp); + for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize; 0 < yyn; yyn -= 1, yyp0 += 1, yyp1 += 1) { @@ -1123,83 +1226,87 @@ yyexpandGLRStack (yyGLRStack* yystack) yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption); } } - if (yystack->yysplitPoint != NULL) - yystack->yysplitPoint = YYRELOC (yystack->yyitems, yynewItems, - yystack->yysplitPoint, yystate); + if (yystackp->yysplitPoint != NULL) + yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems, + yystackp->yysplitPoint, yystate); - for (yyn = 0; yyn < yystack->yytops.yysize; yyn += 1) - if (yystack->yytops.yystates[yyn] != NULL) - yystack->yytops.yystates[yyn] = - YYRELOC (yystack->yyitems, yynewItems, - yystack->yytops.yystates[yyn], yystate); - YYFREE (yystack->yyitems); - yystack->yyitems = yynewItems; - yystack->yynextFree = yynewItems + yysize; - yystack->yyspaceLeft = yynewSize - yysize; - -#else - yyMemoryExhausted (yystack); -#endif + for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1) + if (yystackp->yytops.yystates[yyn] != NULL) + yystackp->yytops.yystates[yyn] = + YYRELOC (yystackp->yyitems, yynewItems, + yystackp->yytops.yystates[yyn], yystate); + YYFREE (yystackp->yyitems); + yystackp->yyitems = yynewItems; + yystackp->yynextFree = yynewItems + yysize; + yystackp->yyspaceLeft = yynewSize - yysize; } +#endif static void -yyfreeGLRStack (yyGLRStack* yystack) +yyfreeGLRStack (yyGLRStack* yystackp) { - YYFREE (yystack->yyitems); - yyfreeStateSet (&yystack->yytops); + YYFREE (yystackp->yyitems); + yyfreeStateSet (&yystackp->yytops); } /** Assuming that S is a GLRState somewhere on STACK, update the * splitpoint of STACK, if needed, so that it is at least as deep as - * S. */ + * S. */ static inline void -yyupdateSplit (yyGLRStack* yystack, yyGLRState* yys) +yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) { - if (yystack->yysplitPoint != NULL && yystack->yysplitPoint > yys) - yystack->yysplitPoint = yys; + if (yystackp->yysplitPoint != NULL && yystackp->yysplitPoint > yys) + yystackp->yysplitPoint = yys; } -/** Invalidate stack #K in STACK. */ +/** Invalidate stack #K in STACK. */ static inline void -yymarkStackDeleted (yyGLRStack* yystack, size_t yyk) +yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk) { - if (yystack->yytops.yystates[yyk] != NULL) - yystack->yylastDeleted = yystack->yytops.yystates[yyk]; - yystack->yytops.yystates[yyk] = NULL; + if (yystackp->yytops.yystates[yyk] != NULL) + yystackp->yylastDeleted = yystackp->yytops.yystates[yyk]; + yystackp->yytops.yystates[yyk] = NULL; } /** Undelete the last stack that was marked as deleted. Can only be done once after a deletion, and only when all other stacks have - been deleted. */ + been deleted. */ static void -yyundeleteLastStack (yyGLRStack* yystack) +yyundeleteLastStack (yyGLRStack* yystackp) { - if (yystack->yylastDeleted == NULL || yystack->yytops.yysize != 0) + if (yystackp->yylastDeleted == NULL || yystackp->yytops.yysize != 0) return; - yystack->yytops.yystates[0] = yystack->yylastDeleted; - yystack->yytops.yysize = 1; + yystackp->yytops.yystates[0] = yystackp->yylastDeleted; + yystackp->yytops.yysize = 1; YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n")); - yystack->yylastDeleted = NULL; + yystackp->yylastDeleted = NULL; } static inline void -yyremoveDeletes (yyGLRStack* yystack) +yyremoveDeletes (yyGLRStack* yystackp) { size_t yyi, yyj; yyi = yyj = 0; - while (yyj < yystack->yytops.yysize) + while (yyj < yystackp->yytops.yysize) { - if (yystack->yytops.yystates[yyi] == NULL) + if (yystackp->yytops.yystates[yyi] == NULL) { if (yyi == yyj) { YYDPRINTF ((stderr, "Removing dead stacks.\n")); } - yystack->yytops.yysize -= 1; + yystackp->yytops.yysize -= 1; } else { - yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi]; + yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi]; + /* In the current implementation, it's unnecessary to copy + yystackp->yytops.yylookaheadNeeds[yyi] since, after + yyremoveDeletes returns, the parser immediately either enters + deterministic operation or shifts a token. However, it doesn't + hurt, and the code might evolve to need it. */ + yystackp->yytops.yylookaheadNeeds[yyj] = + yystackp->yytops.yylookaheadNeeds[yyi]; if (yyj != yyi) { YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n", @@ -1212,117 +1319,133 @@ yyremoveDeletes (yyGLRStack* yystack) } /** Shift to a new state on stack #K of STACK, corresponding to LR state - * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ + * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ static inline void -yyglrShift (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState, +yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, size_t yyposn, - YYSTYPE yysval, YYLTYPE* yylocp) + YYSTYPE* yyvalp, YYLTYPE* yylocp) { - yyGLRStackItem* yynewItem; + yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; - yynewItem = yystack->yynextFree; - yystack->yynextFree += 1; - yystack->yyspaceLeft -= 1; - yynewItem->yystate.yyisState = yytrue; - yynewItem->yystate.yylrState = yylrState; - yynewItem->yystate.yyposn = yyposn; - yynewItem->yystate.yyresolved = yytrue; - yynewItem->yystate.yypred = yystack->yytops.yystates[yyk]; - yystack->yytops.yystates[yyk] = &yynewItem->yystate; - yynewItem->yystate.yysemantics.yysval = yysval; - yynewItem->yystate.yyloc = *yylocp; - if (yystack->yyspaceLeft < YYHEADROOM) - yyexpandGLRStack (yystack); + yynewState->yylrState = yylrState; + yynewState->yyposn = yyposn; + yynewState->yyresolved = yytrue; + yynewState->yypred = yystackp->yytops.yystates[yyk]; + yynewState->yysemantics.yysval = *yyvalp; + yynewState->yyloc = *yylocp; + yystackp->yytops.yystates[yyk] = yynewState; + + YY_RESERVE_GLRSTACK (yystackp); } /** Shift stack #K of YYSTACK, to a new state corresponding to LR * state YYLRSTATE, at input position YYPOSN, with the (unresolved) - * semantic value of YYRHS under the action for YYRULE. */ + * semantic value of YYRHS under the action for YYRULE. */ static inline void -yyglrShiftDefer (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState, +yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) { - yyGLRStackItem* yynewItem; + yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; - yynewItem = yystack->yynextFree; - yynewItem->yystate.yyisState = yytrue; - yynewItem->yystate.yylrState = yylrState; - yynewItem->yystate.yyposn = yyposn; - yynewItem->yystate.yyresolved = yyfalse; - yynewItem->yystate.yypred = yystack->yytops.yystates[yyk]; - yynewItem->yystate.yysemantics.yyfirstVal = NULL; - yystack->yytops.yystates[yyk] = &yynewItem->yystate; - yystack->yynextFree += 1; - yystack->yyspaceLeft -= 1; - yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule); + yynewState->yylrState = yylrState; + yynewState->yyposn = yyposn; + yynewState->yyresolved = yyfalse; + yynewState->yypred = yystackp->yytops.yystates[yyk]; + yynewState->yysemantics.yyfirstVal = NULL; + yystackp->yytops.yystates[yyk] = yynewState; + + /* Invokes YY_RESERVE_GLRSTACK. */ + yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule); } /** Pop the symbols consumed by reduction #RULE from the top of stack * #K of STACK, and perform the appropriate semantic action on their * semantic values. Assumes that all ambiguities in semantic values - * have been previously resolved. Set *VALP to the resulting value, + * have been previously resolved. Set *VALP to the resulting value, * and *LOCP to the computed location (if any). Return value is as - * for userAction. */ + * for userAction. */ static inline YYRESULTTAG -yydoAction (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, +yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) { int yynrhs = yyrhsLength (yyrule); - if (yystack->yysplitPoint == NULL) + if (yystackp->yysplitPoint == NULL) { - /* Standard special case: single stack. */ - yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk]; + /* Standard special case: single stack. */ + yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; YYASSERT (yyk == 0); - yystack->yynextFree -= yynrhs; - yystack->yyspaceLeft += yynrhs; - yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate; + yystackp->yynextFree -= yynrhs; + yystackp->yyspaceLeft += yynrhs; + yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate; return yyuserAction (yyrule, yynrhs, rhs, - yyvalp, yylocp, yystack]b4_user_args[); + yyvalp, yylocp, yystackp]b4_user_args[); } else { + /* At present, doAction is never called in nondeterministic + * mode, so this branch is never taken. It is here in + * anticipation of a future feature that will allow immediate + * evaluation of selected actions in nondeterministic mode. */ int yyi; yyGLRState* yys; yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred - = yystack->yytops.yystates[yyk]; + = yystackp->yytops.yystates[yyk];]b4_locations_if([[ + if (yynrhs == 0) + /* Set default location. */ + yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[ for (yyi = 0; yyi < yynrhs; yyi += 1) { yys = yys->yypred; YYASSERT (yys); } - yyupdateSplit (yystack, yys); - yystack->yytops.yystates[yyk] = yys; + yyupdateSplit (yystackp, yys); + yystackp->yytops.yystates[yyk] = yys; return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, - yyvalp, yylocp, yystack]b4_user_args[); + yyvalp, yylocp, yystackp]b4_user_args[); } } #if !YYDEBUG -# define YY_REDUCE_PRINT(K, Rule) +# define YY_REDUCE_PRINT(Args) #else -# define YY_REDUCE_PRINT(K, Rule) \ +# define YY_REDUCE_PRINT(Args) \ do { \ if (yydebug) \ - yy_reduce_print (K, Rule); \ -} while (0) + yy_reduce_print Args; \ +} while (YYID (0)) /*----------------------------------------------------------. | Report that the RULE is going to be reduced on stack #K. | `----------------------------------------------------------*/ -static inline void -yy_reduce_print (size_t yyk, yyRuleNum yyrule) +/*ARGSUSED*/ static inline void +yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, + YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) { + int yynrhs = yyrhsLength (yyrule); + yybool yynormal __attribute__ ((__unused__)) = + (yystackp->yysplitPoint == NULL); + yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; + int yylow = 1; int yyi; - YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu), ", + YYUSE (yyvalp); + YYUSE (yylocp); +]b4_parse_param_use[]dnl +[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", (unsigned long int) yyk, yyrule - 1, (unsigned long int) yyrline[yyrule]); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi])); - YYFPRINTF (stderr, "-> %s\n", yytokenName (yyr1[yyrule])); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &]b4_rhs_value(yynrhs, yyi + 1)[ + ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl + b4_user_args[); + fprintf (stderr, "\n"); + } } #endif @@ -1334,56 +1457,58 @@ yy_reduce_print (size_t yyk, yyRuleNum yyrule) * the new state. If the new state would have an identical input * position, LR state, and predecessor to an existing state on the stack, * it is identified with that existing state, eliminating stack #K from - * the STACK. In this case, the (necessarily deferred) semantic value is + * the STACK. In this case, the (necessarily deferred) semantic value is * added to the options for the existing state's semantic value. */ static inline YYRESULTTAG -yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, - yybool yyforceEval]b4_user_formals[) +yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, + yybool yyforceEval]b4_user_formals[) { - size_t yyposn = yystack->yytops.yystates[yyk]->yyposn; + size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn; - if (yyforceEval || yystack->yysplitPoint == NULL) + if (yyforceEval || yystackp->yysplitPoint == NULL) { YYSTYPE yysval; YYLTYPE yyloc; - YY_REDUCE_PRINT (yyk, yyrule); - YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc]b4_user_args[)); - yyglrShift (yystack, yyk, - yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState, + YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval, &yyloc]b4_user_args[)); + YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval, + &yyloc]b4_user_args[)); + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc); + yyglrShift (yystackp, yyk, + yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState, yylhsNonterm (yyrule)), - yyposn, yysval, &yyloc); + yyposn, &yysval, &yyloc); } else { size_t yyi; int yyn; - yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk]; + yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk]; yyStateNum yynewLRState; - for (yys = yystack->yytops.yystates[yyk], yyn = yyrhsLength (yyrule); + for (yys = yystackp->yytops.yystates[yyk], yyn = yyrhsLength (yyrule); 0 < yyn; yyn -= 1) { yys = yys->yypred; YYASSERT (yys); } - yyupdateSplit (yystack, yys); + yyupdateSplit (yystackp, yys); yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); YYDPRINTF ((stderr, - "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", + "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", (unsigned long int) yyk, yyrule - 1, yynewLRState)); - for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) - if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL) + for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) + if (yyi != yyk && yystackp->yytops.yystates[yyi] != NULL) { - yyGLRState* yyp, *yysplit = yystack->yysplitPoint; - yyp = yystack->yytops.yystates[yyi]; + yyGLRState* yyp, *yysplit = yystackp->yysplitPoint; + yyp = yystackp->yytops.yystates[yyi]; while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn) { if (yyp->yylrState == yynewLRState && yyp->yypred == yys) { - yyaddDeferredAction (yystack, yyp, yys0, yyrule); - yymarkStackDeleted (yystack, yyk); + yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule); + yymarkStackDeleted (yystackp, yyk); YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n", (unsigned long int) yyk, (unsigned long int) yyi)); @@ -1392,41 +1517,59 @@ yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, yyp = yyp->yypred; } } - yystack->yytops.yystates[yyk] = yys; - yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule); + yystackp->yytops.yystates[yyk] = yys; + yyglrShiftDefer (yystackp, yyk, yynewLRState, yyposn, yys0, yyrule); } return yyok; } static size_t -yysplitStack (yyGLRStack* yystack, size_t yyk) +yysplitStack (yyGLRStack* yystackp, size_t yyk) { - if (yystack->yysplitPoint == NULL) + if (yystackp->yysplitPoint == NULL) { YYASSERT (yyk == 0); - yystack->yysplitPoint = yystack->yytops.yystates[yyk]; + yystackp->yysplitPoint = yystackp->yytops.yystates[yyk]; } - if (yystack->yytops.yysize >= yystack->yytops.yycapacity) + if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity) { yyGLRState** yynewStates; - if (! ((yystack->yytops.yycapacity - <= (YYSIZEMAX / (2 * sizeof yynewStates[0]))) - && (yynewStates = - (yyGLRState**) YYREALLOC (yystack->yytops.yystates, - ((yystack->yytops.yycapacity *= 2) - * sizeof yynewStates[0]))))) - yyMemoryExhausted (yystack); - yystack->yytops.yystates = yynewStates; + yybool* yynewLookaheadNeeds; + + yynewStates = NULL; + + if (yystackp->yytops.yycapacity + > (YYSIZEMAX / (2 * sizeof yynewStates[0]))) + yyMemoryExhausted (yystackp); + yystackp->yytops.yycapacity *= 2; + + yynewStates = + (yyGLRState**) YYREALLOC (yystackp->yytops.yystates, + (yystackp->yytops.yycapacity + * sizeof yynewStates[0])); + if (yynewStates == NULL) + yyMemoryExhausted (yystackp); + yystackp->yytops.yystates = yynewStates; + + yynewLookaheadNeeds = + (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds, + (yystackp->yytops.yycapacity + * sizeof yynewLookaheadNeeds[0])); + if (yynewLookaheadNeeds == NULL) + yyMemoryExhausted (yystackp); + yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds; } - yystack->yytops.yystates[yystack->yytops.yysize] - = yystack->yytops.yystates[yyk]; - yystack->yytops.yysize += 1; - return yystack->yytops.yysize-1; + yystackp->yytops.yystates[yystackp->yytops.yysize] + = yystackp->yytops.yystates[yyk]; + yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize] + = yystackp->yytops.yylookaheadNeeds[yyk]; + yystackp->yytops.yysize += 1; + return yystackp->yytops.yysize-1; } /** True iff Y0 and Y1 represent identical options at the top level. * That is, they represent the same rule applied to RHS symbols - * that produce the same terminal symbols. */ + * that produce the same terminal symbols. */ static yybool yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1) { @@ -1447,7 +1590,7 @@ yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1) } /** Assuming identicalOptions (Y0,Y1), destructively merge the - * alternative semantic values for the RHS-symbols of Y1 and Y0. */ + * alternative semantic values for the RHS-symbols of Y1 and Y0. */ static void yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) { @@ -1476,7 +1619,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) yySemanticOption* yyz1; yyz0p = &yys0->yysemantics.yyfirstVal; yyz1 = yys1->yysemantics.yyfirstVal; - while (yytrue) + while (YYID (yytrue)) { if (yyz1 == *yyz0p || yyz1 == NULL) break; @@ -1501,7 +1644,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) /** Y0 and Y1 represent two possible actions to take in a given * parsing state; return 0 if no combination is possible, - * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ + * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ static int yypreference (yySemanticOption* y0, yySemanticOption* y1) { @@ -1524,46 +1667,71 @@ yypreference (yySemanticOption* y0, yySemanticOption* y1) return 0; } -static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, - yyGLRStack* yystack, YYSTYPE* yyvalp, - YYLTYPE* yylocp]b4_user_formals[); +static YYRESULTTAG yyresolveValue (yyGLRState* yys, + yyGLRStack* yystackp]b4_user_formals[); + +/** Resolve the previous N states starting at and including state S. If result + * != yyok, some states may have been left unresolved possibly with empty + * semantic option chains. Regardless of whether result = yyok, each state + * has been left with consistent data so that yydestroyGLRState can be invoked + * if necessary. */ static YYRESULTTAG -yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack]b4_user_formals[) +yyresolveStates (yyGLRState* yys, int yyn, + yyGLRStack* yystackp]b4_user_formals[) { - YYRESULTTAG yyflag; if (0 < yyn) { YYASSERT (yys->yypred); - yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[); - if (yyflag != yyok) - return yyflag; + YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[)); if (! yys->yyresolved) - { - yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack, - &yys->yysemantics.yysval, &yys->yyloc - ]b4_user_args[); - if (yyflag != yyok) - return yyflag; - yys->yyresolved = yytrue; - } + YYCHK (yyresolveValue (yys, yystackp]b4_user_args[)); } return yyok; } +/** Resolve the states for the RHS of OPT, perform its user action, and return + * the semantic value and location. Regardless of whether result = yyok, all + * RHS states have been destroyed (assuming the user action destroys all RHS + * semantic values if invoked). */ static YYRESULTTAG -yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack, - YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) +yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, + YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) { yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; int yynrhs; + int yychar_current; + YYSTYPE yylval_current; + YYLTYPE yylloc_current; + YYRESULTTAG yyflag; yynrhs = yyrhsLength (yyopt->yyrule); - YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack]b4_user_args[)); - yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate; - return yyuserAction (yyopt->yyrule, yynrhs, - yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, - yyvalp, yylocp, yystack]b4_user_args[); + yyflag = yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[); + if (yyflag != yyok) + { + yyGLRState *yys; + for (yys = yyopt->yystate; yynrhs > 0; yys = yys->yypred, yynrhs -= 1) + yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); + return yyflag; + } + + yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[ + if (yynrhs == 0) + /* Set default location. */ + yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[ + yychar_current = yychar; + yylval_current = yylval; + yylloc_current = yylloc; + yychar = yyopt->yyrawchar; + yylval = yyopt->yyval; + yylloc = yyopt->yyloc; + yyflag = yyuserAction (yyopt->yyrule, yynrhs, + yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, + yyvalp, yylocp, yystackp]b4_user_args[); + yychar = yychar_current; + yylval = yylval_current; + yylloc = yylloc_current; + return yyflag; } #if YYDEBUG @@ -1573,7 +1741,7 @@ yyreportTree (yySemanticOption* yyx, int yyindent) int yynrhs = yyrhsLength (yyx->yyrule); int yyi; yyGLRState* yys; - yyGLRState* yystates[YYMAXRHS]; + yyGLRState* yystates[1 + YYMAXRHS]; yyGLRState yyleftmost_state; for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred) @@ -1589,11 +1757,11 @@ yyreportTree (yySemanticOption* yyx, int yyindent) if (yyx->yystate->yyposn < yys->yyposn + 1) YYFPRINTF (stderr, "%*s%s -> \n", yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), - yyx->yyrule); + yyx->yyrule - 1); else YYFPRINTF (stderr, "%*s%s -> \n", yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), - yyx->yyrule, (unsigned long int) (yys->yyposn + 1), + yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1), (unsigned long int) yyx->yystate->yyposn); for (yyi = 1; yyi <= yynrhs; yyi += 1) { @@ -1614,16 +1782,12 @@ yyreportTree (yySemanticOption* yyx, int yyindent) } #endif -static void yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, - yyGLRStack* yystack]b4_pure_formals[) - __attribute__ ((__noreturn__)); -static void -yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, - yyGLRStack* yystack]b4_pure_formals[) +/*ARGSUSED*/ static YYRESULTTAG +yyreportAmbiguity (yySemanticOption* yyx0, + yySemanticOption* yyx1]b4_pure_formals[) { - /* `Unused' warnings. */ - (void) yyx0; - (void) yyx1; + YYUSE (yyx0); + YYUSE (yyx1); #if YYDEBUG YYFPRINTF (stderr, "Ambiguity detected.\n"); @@ -1633,19 +1797,85 @@ yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, yyreportTree (yyx1, 2); YYFPRINTF (stderr, "\n"); #endif - yyFail (yystack][]b4_pure_args[, YY_("syntax is ambiguous")); + + yyerror (]b4_yyerror_args[YY_("syntax is ambiguous")); + return yyabort; } - -/** Resolve the ambiguity represented by OPTIONLIST, perform the indicated - * actions, and return the result. */ -static YYRESULTTAG -yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, - YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) +/** Starting at and including state S1, resolve the location for each of the + * previous N1 states that is unresolved. The first semantic option of a state + * is always chosen. */ +static void +yyresolveLocations (yyGLRState* yys1, int yyn1, + yyGLRStack *yystackp]b4_user_formals[) { + if (0 < yyn1) + { + yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[); + if (!yys1->yyresolved) + { + yySemanticOption *yyoption; + yyGLRStackItem yyrhsloc[1 + YYMAXRHS]; + int yynrhs; + int yychar_current; + YYSTYPE yylval_current; + YYLTYPE yylloc_current; + yyoption = yys1->yysemantics.yyfirstVal; + YYASSERT (yyoption != NULL); + yynrhs = yyrhsLength (yyoption->yyrule); + if (yynrhs > 0) + { + yyGLRState *yys; + int yyn; + yyresolveLocations (yyoption->yystate, yynrhs, + yystackp]b4_user_args[); + for (yys = yyoption->yystate, yyn = yynrhs; + yyn > 0; + yys = yys->yypred, yyn -= 1) + yyrhsloc[yyn].yystate.yyloc = yys->yyloc; + } + else + { + /* Both yyresolveAction and yyresolveLocations traverse the GSS + in reverse rightmost order. It is only necessary to invoke + yyresolveLocations on a subforest for which yyresolveAction + would have been invoked next had an ambiguity not been + detected. Thus the location of the previous state (but not + necessarily the previous state itself) is guaranteed to be + resolved already. */ + yyGLRState *yyprevious = yyoption->yystate; + yyrhsloc[0].yystate.yyloc = yyprevious->yyloc; + } + yychar_current = yychar; + yylval_current = yylval; + yylloc_current = yylloc; + yychar = yyoption->yyrawchar; + yylval = yyoption->yyval; + yylloc = yyoption->yyloc; + YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs); + yychar = yychar_current; + yylval = yylval_current; + yylloc = yylloc_current; + } + } +} + +/** Resolve the ambiguity represented in state S, perform the indicated + * actions, and set the semantic value of S. If result != yyok, the chain of + * semantic options in S has been cleared instead or it has been left + * unmodified except that redundant options may have been removed. Regardless + * of whether result = yyok, S has been left with consistent data so that + * yydestroyGLRState can be invoked if necessary. */ +static YYRESULTTAG +yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[) +{ + yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal; yySemanticOption* yybest; yySemanticOption** yypp; yybool yymerge; + YYSTYPE yysval; + YYRESULTTAG yyflag; + YYLTYPE *yylocp = &yys->yyloc; yybest = yyoptionList; yymerge = yyfalse; @@ -1663,7 +1893,8 @@ yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, switch (yypreference (yybest, yyp)) { case 0: - yyreportAmbiguity (yybest, yyp, yystack]b4_pure_args[); + yyresolveLocations (yys, 1, yystackp]b4_user_args[); + return yyreportAmbiguity (yybest, yyp]b4_pure_args[); break; case 1: yymerge = yytrue; @@ -1676,7 +1907,7 @@ yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, break; default: /* This cannot happen so it is not worth a YYASSERT (yyfalse), - but some compilers complain if the default case is + but some compilers complain if the default case is omitted. */ break; } @@ -1688,84 +1919,100 @@ yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, { yySemanticOption* yyp; int yyprec = yydprec[yybest->yyrule]; - YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[)); - for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) - { - if (yyprec == yydprec[yyp->yyrule]) - { - YYSTYPE yyval1; - YYLTYPE yydummy; - YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy]b4_user_args[)); - yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); - } - } - return yyok; + yyflag = yyresolveAction (yybest, yystackp, &yysval, + yylocp]b4_user_args[); + if (yyflag == yyok) + for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) + { + if (yyprec == yydprec[yyp->yyrule]) + { + YYSTYPE yysval_other; + YYLTYPE yydummy; + yyflag = yyresolveAction (yyp, yystackp, &yysval_other, + &yydummy]b4_user_args[); + if (yyflag != yyok) + { + yydestruct ("Cleanup: discarding incompletely merged value for", + yystos[yys->yylrState], + &yysval]b4_locations_if([, yylocp])[]b4_user_args[); + break; + } + yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other); + } + } } else - return yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[); + yyflag = yyresolveAction (yybest, yystackp, &yysval, yylocp]b4_user_args[); + + if (yyflag == yyok) + { + yys->yyresolved = yytrue; + yys->yysemantics.yysval = yysval; + } + else + yys->yysemantics.yyfirstVal = NULL; + return yyflag; } static YYRESULTTAG -yyresolveStack (yyGLRStack* yystack]b4_user_formals[) +yyresolveStack (yyGLRStack* yystackp]b4_user_formals[) { - if (yystack->yysplitPoint != NULL) + if (yystackp->yysplitPoint != NULL) { yyGLRState* yys; int yyn; - for (yyn = 0, yys = yystack->yytops.yystates[0]; - yys != yystack->yysplitPoint; + for (yyn = 0, yys = yystackp->yytops.yystates[0]; + yys != yystackp->yysplitPoint; yys = yys->yypred, yyn += 1) continue; - YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack + YYCHK (yyresolveStates (yystackp->yytops.yystates[0], yyn, yystackp ]b4_user_args[)); } return yyok; } static void -yycompressStack (yyGLRStack* yystack) +yycompressStack (yyGLRStack* yystackp) { yyGLRState* yyp, *yyq, *yyr; - if (yystack->yytops.yysize != 1 || yystack->yysplitPoint == NULL) + if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == NULL) return; - for (yyp = yystack->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL; - yyp != yystack->yysplitPoint; + for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL; + yyp != yystackp->yysplitPoint; yyr = yyp, yyp = yyq, yyq = yyp->yypred) yyp->yypred = yyr; - yystack->yyspaceLeft += yystack->yynextFree - yystack->yyitems; - yystack->yynextFree = ((yyGLRStackItem*) yystack->yysplitPoint) + 1; - yystack->yyspaceLeft -= yystack->yynextFree - yystack->yyitems; - yystack->yysplitPoint = NULL; - yystack->yylastDeleted = NULL; + yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems; + yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1; + yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems; + yystackp->yysplitPoint = NULL; + yystackp->yylastDeleted = NULL; while (yyr != NULL) { - yystack->yynextFree->yystate = *yyr; + yystackp->yynextFree->yystate = *yyr; yyr = yyr->yypred; - yystack->yynextFree->yystate.yypred = & yystack->yynextFree[-1].yystate; - yystack->yytops.yystates[0] = &yystack->yynextFree->yystate; - yystack->yynextFree += 1; - yystack->yyspaceLeft -= 1; + yystackp->yynextFree->yystate.yypred = &yystackp->yynextFree[-1].yystate; + yystackp->yytops.yystates[0] = &yystackp->yynextFree->yystate; + yystackp->yynextFree += 1; + yystackp->yyspaceLeft -= 1; } } static YYRESULTTAG -yyprocessOneStack (yyGLRStack* yystack, size_t yyk, - size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp - ]b4_pure_formals[) +yyprocessOneStack (yyGLRStack* yystackp, size_t yyk, + size_t yyposn]b4_pure_formals[) { int yyaction; const short int* yyconflicts; yyRuleNum yyrule; - yySymbol* const yytokenp = yystack->yytokenp; - while (yystack->yytops.yystates[yyk] != NULL) + while (yystackp->yytops.yystates[yyk] != NULL) { - yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState; + yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState; YYDPRINTF ((stderr, "Stack %lu Entering state %d\n", (unsigned long int) yyk, yystate)); @@ -1778,77 +2025,68 @@ yyprocessOneStack (yyGLRStack* yystack, size_t yyk, { YYDPRINTF ((stderr, "Stack %lu dies.\n", (unsigned long int) yyk)); - yymarkStackDeleted (yystack, yyk); + yymarkStackDeleted (yystackp, yyk); return yyok; } - YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse]b4_user_args[)); + YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[)); } else { - if (*yytokenp == YYEMPTY) + yySymbol yytoken; + yystackp->yytops.yylookaheadNeeds[yyk] = yytrue; + if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; - *yytokenp = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp); + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts); + else + yytoken = YYTRANSLATE (yychar); + yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); while (*yyconflicts != 0) { - size_t yynewStack = yysplitStack (yystack, yyk); + size_t yynewStack = yysplitStack (yystackp, yyk); YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n", (unsigned long int) yynewStack, (unsigned long int) yyk)); - YYCHK (yyglrReduce (yystack, yynewStack, + YYCHK (yyglrReduce (yystackp, yynewStack, *yyconflicts, yyfalse]b4_user_args[)); - YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn, - yylvalp, yyllocp]b4_pure_args[)); + YYCHK (yyprocessOneStack (yystackp, yynewStack, + yyposn]b4_pure_args[)); yyconflicts += 1; } if (yyisShiftAction (yyaction)) - { - YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yyk)); - YY_SYMBOL_PRINT ("shifting", *yytokenp, yylvalp, yyllocp); - yyglrShift (yystack, yyk, yyaction, yyposn+1, - *yylvalp, yyllocp); - YYDPRINTF ((stderr, "Stack %lu now in state #%d\n", - (unsigned long int) yyk, - yystack->yytops.yystates[yyk]->yylrState)); - break; - } + break; else if (yyisErrorAction (yyaction)) { YYDPRINTF ((stderr, "Stack %lu dies.\n", (unsigned long int) yyk)); - yymarkStackDeleted (yystack, yyk); + yymarkStackDeleted (yystackp, yyk); break; } else - YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse]b4_user_args[)); + YYCHK (yyglrReduce (yystackp, yyk, -yyaction, + yyfalse]b4_user_args[)); } } return yyok; } -static void -yyreportSyntaxError (yyGLRStack* yystack, - YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[) +/*ARGSUSED*/ static void +yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { - /* `Unused' warnings. */ - (void) yylvalp; - (void) yyllocp; - - if (yystack->yyerrState == 0) + if (yystackp->yyerrState == 0) { #if YYERROR_VERBOSE - yySymbol* const yytokenp = yystack->yytokenp; int yyn; - yyn = yypact[yystack->yytops.yystates[0]->yylrState]; - if (YYPACT_NINF < yyn && yyn < YYLAST) + yyn = yypact[yystackp->yytops.yystates[0]->yylrState]; + if (YYPACT_NINF < yyn && yyn <= YYLAST) { - size_t yysize0 = yytnamerr (NULL, yytokenName (*yytokenp)); + yySymbol yytoken = YYTRANSLATE (yychar); + size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken)); size_t yysize = yysize0; size_t yysize1; yybool yysize_overflow = yyfalse; @@ -1872,11 +2110,11 @@ yyreportSyntaxError (yyGLRStack* yystack, int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; + int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; - yyarg[0] = yytokenName (*yytokenp); + yyarg[0] = yytokenName (yytoken); yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) @@ -1928,7 +2166,7 @@ yyreportSyntaxError (yyGLRStack* yystack, else { yyerror (]b4_lyyerror_args[YY_("syntax error")); - yyMemoryExhausted (yystack); + yyMemoryExhausted (yystackp); } } else @@ -1938,49 +2176,47 @@ yyreportSyntaxError (yyGLRStack* yystack, } } -/* Recover from a syntax error on YYSTACK, assuming that YYTOKENP, - YYLVALP, and YYLLOCP point to the syntactic category, semantic - value, and location of the look-ahead. */ -static void -yyrecoverSyntaxError (yyGLRStack* yystack, - YYSTYPE* yylvalp, - YYLTYPE* YYOPTIONAL_LOC (yyllocp) - ]b4_user_formals[) +/* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP, + yylval, and yylloc are the syntactic category, semantic value, and location + of the look-ahead. */ +/*ARGSUSED*/ static void +yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { - yySymbol* const yytokenp = yystack->yytokenp; size_t yyk; int yyj; - if (yystack->yyerrState == 3) + if (yystackp->yyerrState == 3) /* We just shifted the error token and (perhaps) took some reductions. Skip tokens until we can proceed. */ - while (yytrue) + while (YYID (yytrue)) { - if (*yytokenp == YYEOF) - yyFail (yystack][]b4_lpure_args[, NULL); - if (*yytokenp != YYEMPTY) - {]b4_location_if([[ + yySymbol yytoken; + if (yychar == YYEOF) + yyFail (yystackp][]b4_lpure_args[, NULL); + if (yychar != YYEMPTY) + {]b4_locations_if([[ /* We throw away the lookahead, but the error range - of the shifted error token must take it into account. */ - yyGLRState *yys = yystack->yytops.yystates[0]; + of the shifted error token must take it into account. */ + yyGLRState *yys = yystackp->yytops.yystates[0]; yyGLRStackItem yyerror_range[3]; yyerror_range[1].yystate.yyloc = yys->yyloc; - yyerror_range[2].yystate.yyloc = *yyllocp; - YYLLOC_DEFAULT (yys->yyloc, yyerror_range, 2);]])[ + yyerror_range[2].yystate.yyloc = yylloc; + YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[ + yytoken = YYTRANSLATE (yychar); yydestruct ("Error: discarding", - *yytokenp, yylvalp]b4_location_if([, yyllocp])[); + yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); } YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; - *yytokenp = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp); - yyj = yypact[yystack->yytops.yystates[0]->yylrState]; + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + yyj = yypact[yystackp->yytops.yystates[0]->yylrState]; if (yyis_pact_ninf (yyj)) return; - yyj += *yytokenp; - if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp) + yyj += yytoken; + if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken) { - if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0) + if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0) return; } else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj])) @@ -1988,21 +2224,21 @@ yyrecoverSyntaxError (yyGLRStack* yystack, } /* Reduce to one stack. */ - for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1) - if (yystack->yytops.yystates[yyk] != NULL) + for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1) + if (yystackp->yytops.yystates[yyk] != NULL) break; - if (yyk >= yystack->yytops.yysize) - yyFail (yystack][]b4_lpure_args[, NULL); - for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1) - yymarkStackDeleted (yystack, yyk); - yyremoveDeletes (yystack); - yycompressStack (yystack); + if (yyk >= yystackp->yytops.yysize) + yyFail (yystackp][]b4_lpure_args[, NULL); + for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1) + yymarkStackDeleted (yystackp, yyk); + yyremoveDeletes (yystackp); + yycompressStack (yystackp); - /* Now pop stack until we find a state that shifts the error token. */ - yystack->yyerrState = 3; - while (yystack->yytops.yystates[0] != NULL) + /* Now pop stack until we find a state that shifts the error token. */ + yystackp->yyerrState = 3; + while (yystackp->yytops.yystates[0] != NULL) { - yyGLRState *yys = yystack->yytops.yystates[0]; + yyGLRState *yys = yystackp->yytops.yystates[0]; yyj = yypact[yys->yylrState]; if (! yyis_pact_ninf (yyj)) { @@ -2011,25 +2247,25 @@ yyrecoverSyntaxError (yyGLRStack* yystack, && yyisShiftAction (yytable[yyj])) { /* Shift the error token having adjusted its location. */ - YYLTYPE yyerrloc;]b4_location_if([[ - yystack->yyerror_range[2].yystate.yyloc = *yyllocp; - YYLLOC_DEFAULT (yyerrloc, yystack->yyerror_range, 2);]])[ + YYLTYPE yyerrloc;]b4_locations_if([[ + yystackp->yyerror_range[2].yystate.yyloc = yylloc; + YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[ YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]], - yylvalp, &yyerrloc); - yyglrShift (yystack, 0, yytable[yyj], - yys->yyposn, *yylvalp, &yyerrloc); - yys = yystack->yytops.yystates[0]; + &yylval, &yyerrloc); + yyglrShift (yystackp, 0, yytable[yyj], + yys->yyposn, &yylval, &yyerrloc); + yys = yystackp->yytops.yystates[0]; break; } } -]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ - yydestroyGLRState ("Error: popping", yys); - yystack->yytops.yystates[0] = yys->yypred; - yystack->yynextFree -= 1; - yystack->yyspaceLeft += 1; +]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ + yydestroyGLRState ("Error: popping", yys]b4_user_args[); + yystackp->yytops.yystates[0] = yys->yypred; + yystackp->yynextFree -= 1; + yystackp->yyspaceLeft += 1; } - if (yystack->yytops.yystates[0] == NULL) - yyFail (yystack][]b4_lpure_args[, NULL); + if (yystackp->yytops.yystates[0] == NULL) + yyFail (yystackp][]b4_lpure_args[, NULL); } #define YYCHK1(YYE) \ @@ -2046,7 +2282,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack, default: \ goto yybuglab; \ } \ - } while (0) + } while (YYID (0)) /*----------. @@ -2056,25 +2292,15 @@ yyrecoverSyntaxError (yyGLRStack* yystack, ]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[ { int yyresult; - yySymbol yytoken; yyGLRStack yystack; + yyGLRStack* const yystackp = &yystack; size_t yyposn; -]b4_pure_if( -[ - YYSTYPE yylval; - YYLTYPE yylloc; - #undef yychar - #define yychar (yystack.yyrawchar) -])[ - - YYSTYPE* const yylvalp = &yylval; - YYLTYPE* const yyllocp = &yylloc; YYDPRINTF ((stderr, "Starting parse\n")); - yytoken = YYEMPTY; + yychar = YYEMPTY; yylval = yyval_default; -]b4_location_if([ +]b4_locations_if([ #if YYLTYPE_IS_TRIVIAL yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 0; @@ -2083,14 +2309,14 @@ yyrecoverSyntaxError (yyGLRStack* yystack, m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [yylloc])dnl m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ + /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl /* Line __line__ of glr.c. */ b4_syncline([@oline@], [@ofile@])])dnl [ - if (! yyinitGLRStack (&yystack, YYINITDEPTH)) + if (! yyinitGLRStack (yystackp, YYINITDEPTH)) goto yyexhaustedlab; switch (YYSETJMP (yystack.yyexception_buffer)) { @@ -2099,24 +2325,23 @@ b4_syncline([@oline@], [@ofile@])])dnl case 2: goto yyexhaustedlab; default: goto yybuglab; } - yystack.yytokenp = &yytoken; - yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc); + yyglrShift (&yystack, 0, 0, 0, &yylval, &yylloc); yyposn = 0; - while (yytrue) + while (YYID (yytrue)) { /* For efficiency, we have two loops, the first of which is specialized to deterministic operation (single stack, no potential ambiguity). */ /* Standard mode */ - while (yytrue) + while (YYID (yytrue)) { yyRuleNum yyrule; int yyaction; const short int* yyconflicts; yyStateNum yystate = yystack.yytops.yystates[0]->yylrState; - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) goto yyacceptlab; if (yyisDefaultedState (yystate)) @@ -2124,38 +2349,41 @@ b4_syncline([@oline@], [@ofile@])])dnl yyrule = yydefaultAction (yystate); if (yyrule == 0) { -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[ - yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[); +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ + yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_user_args[)); } else { - if (yytoken == YYEMPTY) + yySymbol yytoken; + if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, yylvalp, yyllocp); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } + else + yytoken = YYTRANSLATE (yychar); yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); if (*yyconflicts != 0) break; if (yyisShiftAction (yyaction)) { - YY_SYMBOL_PRINT ("Shifting", yytoken, yylvalp, yyllocp); - if (yytoken != YYEOF) - yytoken = YYEMPTY; + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + if (yychar != YYEOF) + yychar = YYEMPTY; yyposn += 1; - yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp); + yyglrShift (&yystack, 0, yyaction, yyposn, &yylval, &yylloc); if (0 < yystack.yyerrState) yystack.yyerrState -= 1; } else if (yyisErrorAction (yyaction)) { -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[ - yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[); +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ + yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } else @@ -2163,15 +2391,35 @@ b4_syncline([@oline@], [@ofile@])])dnl } } - while (yytrue) + while (YYID (yytrue)) { + yySymbol yytoken_to_shift; size_t yys; - size_t yyn = yystack.yytops.yysize; - for (yys = 0; yys < yyn; yys += 1) - YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn, - yylvalp, yyllocp]b4_lpure_args[)); - yytoken = YYEMPTY; - yyposn += 1; + + for (yys = 0; yys < yystack.yytops.yysize; yys += 1) + yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY; + + /* yyprocessOneStack returns one of three things: + + - An error flag. If the caller is yyprocessOneStack, it + immediately returns as well. When the caller is finally + yyparse, it jumps to an error label via YYCHK1. + + - yyok, but yyprocessOneStack has invoked yymarkStackDeleted + (&yystack, yys), which sets the top state of yys to NULL. Thus, + yyparse's following invocation of yyremoveDeletes will remove + the stack. + + - yyok, when ready to shift a token. + + Except in the first case, yyparse will invoke yyremoveDeletes and + then shift the next token onto all remaining stacks. This + synchronization of the shift (that is, after all preceding + reductions on all stacks) helps prevent double destructor calls + on yylval in the event of memory exhaustion. */ + + for (yys = 0; yys < yystack.yytops.yysize; yys += 1) + YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn]b4_lpure_args[)); yyremoveDeletes (&yystack); if (yystack.yytops.yysize == 0) { @@ -2180,11 +2428,37 @@ b4_syncline([@oline@], [@ofile@])])dnl yyFail (&yystack][]b4_lpure_args[, YY_("syntax error")); YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[ - yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[); +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ + yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } - else if (yystack.yytops.yysize == 1) + + /* If any yyglrShift call fails, it will fail after shifting. Thus, + a copy of yylval will already be on stack 0 in the event of a + failure in the following loop. Thus, yychar is set to YYEMPTY + before the loop to make sure the user destructor for yylval isn't + called twice. */ + yytoken_to_shift = YYTRANSLATE (yychar); + yychar = YYEMPTY; + yyposn += 1; + for (yys = 0; yys < yystack.yytops.yysize; yys += 1) + { + int yyaction; + const short int* yyconflicts; + yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState; + yygetLRActions (yystate, yytoken_to_shift, &yyaction, + &yyconflicts); + /* Note that yyconflicts were handled by yyprocessOneStack. */ + YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys)); + YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc); + yyglrShift (&yystack, yys, yyaction, yyposn, + &yylval, &yylloc); + YYDPRINTF ((stderr, "Stack %lu now in state #%d\n", + (unsigned long int) yys, + yystack.yytops.yystates[yys]->yylrState)); + } + + if (yystack.yytops.yysize == 1) { YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); @@ -2194,7 +2468,7 @@ b4_syncline([@oline@], [@ofile@])])dnl } continue; yyuser_error: - yyrecoverSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[); + yyrecoverSyntaxError (&yystack]b4_user_args[); yyposn = yystack.yytops.yystates[0]->yyposn; } @@ -2204,7 +2478,7 @@ b4_syncline([@oline@], [@ofile@])])dnl yybuglab: YYASSERT (yyfalse); - /* Fall through. */ + goto yyabortlab; yyabortlab: yyresult = 1; @@ -2213,12 +2487,13 @@ b4_syncline([@oline@], [@ofile@])])dnl yyexhaustedlab: yyerror (]b4_lyyerror_args[YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ + goto yyreturn; yyreturn: - if (yytoken != YYEOF && yytoken != YYEMPTY) + if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, yylvalp]b4_location_if([, yyllocp])[); + YYTRANSLATE (yychar), + &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); /* If the stack is well-formed, pop the stack until it is empty, destroying its entries as we go. But free the stack regardless @@ -2227,26 +2502,36 @@ b4_syncline([@oline@], [@ofile@])])dnl { yyGLRState** yystates = yystack.yytops.yystates; if (yystates) - while (yystates[0]) - { - yyGLRState *yys = yystates[0]; -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] -)[ yydestroyGLRState ("Cleanup: popping", yys); - yystates[0] = yys->yypred; - yystack.yynextFree -= 1; - yystack.yyspaceLeft += 1; - } + { + size_t yysize = yystack.yytops.yysize; + size_t yyk; + for (yyk = 0; yyk < yysize; yyk += 1) + if (yystates[yyk]) + { + while (yystates[yyk]) + { + yyGLRState *yys = yystates[yyk]; +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] +)[ yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); + yystates[yyk] = yys->yypred; + yystack.yynextFree -= 1; + yystack.yyspaceLeft += 1; + } + break; + } + } yyfreeGLRStack (&yystack); } - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); } /* DEBUGGING ONLY */ #ifdef YYDEBUG -static void yypstack (yyGLRStack* yystack, size_t yyk) +static void yypstack (yyGLRStack* yystackp, size_t yyk) __attribute__ ((__unused__)); -static void yypdumpstack (yyGLRStack* yystack) __attribute__ ((__unused__)); +static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__)); static void yy_yypstack (yyGLRState* yys) @@ -2270,23 +2555,23 @@ yypstates (yyGLRState* yyst) } static void -yypstack (yyGLRStack* yystack, size_t yyk) +yypstack (yyGLRStack* yystackp, size_t yyk) { - yypstates (yystack->yytops.yystates[yyk]); + yypstates (yystackp->yytops.yystates[yyk]); } #define YYINDEX(YYX) \ - ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems) + ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems) static void -yypdumpstack (yyGLRStack* yystack) +yypdumpstack (yyGLRStack* yystackp) { yyGLRStackItem* yyp; size_t yyi; - for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1) + for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1) { - fprintf (stderr, "%3lu. ", (unsigned long int) (yyp - yystack->yyitems)); + fprintf (stderr, "%3lu. ", (unsigned long int) (yyp - yystackp->yyitems)); if (*(yybool *) yyp) { fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld", @@ -2300,60 +2585,32 @@ yypdumpstack (yyGLRStack* yystack) else { fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld", - yyp->yyoption.yyrule, + yyp->yyoption.yyrule - 1, (long int) YYINDEX (yyp->yyoption.yystate), (long int) YYINDEX (yyp->yyoption.yynext)); } fprintf (stderr, "\n"); } fprintf (stderr, "Tops:"); - for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) + for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) fprintf (stderr, "%lu: %ld; ", (unsigned long int) yyi, - (long int) YYINDEX (yystack->yytops.yystates[yyi])); + (long int) YYINDEX (yystackp->yytops.yystates[yyi])); fprintf (stderr, "\n"); } #endif ] b4_epilogue -m4_if(b4_defines_flag, 0, [], +b4_defines_if( [@output @output_header_name@ -b4_copyright([Skeleton parser for GLR parsing with Bison], - [2002, 2003, 2004, 2005]) +b4_copyright([Skeleton interface for Bison GLR parsers in C], + [2002, 2003, 2004, 2005, 2006]) -b4_token_enums_defines(b4_tokens) +b4_shared_declarations -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; -/* Line __line__ of glr.c. */ -b4_syncline([@oline@], [@ofile@])], -[typedef int YYSTYPE;]) -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif +extern YYSTYPE b4_prefix[]lval; -b4_pure_if([], -[extern YYSTYPE b4_prefix[]lval;]) - -#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) -typedef struct YYLTYPE -{ -b4_location_if([ - int first_line; - int first_column; - int last_line; - int last_column; -],[ - char yydummy; -]) -} YYLTYPE; -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - -b4_location_if([b4_pure_if([], +b4_locations_if([b4_pure_if([], [extern YYLTYPE b4_prefix[]lloc;]) ]) ]) diff --git a/src/bin/bison/data/glr.cc b/src/bin/bison/data/glr.cc new file mode 100644 index 0000000000..d07b5a48b8 --- /dev/null +++ b/src/bin/bison/data/glr.cc @@ -0,0 +1,389 @@ +m4_divert(-1) -*- C -*- + +# C++ GLR skeleton for Bison +# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + + +# This skeleton produces a C++ class that encapsulates a C glr parser. +# This is in order to reduce the maintenance burden. The glr.c +# skeleton is clean and pure enough so that there are no real +# problems. The C++ interface is the same as that of lalr1.cc. In +# fact, glr.c can replace yacc.c without the user noticing any +# difference, and similarly for glr.cc replacing lalr1.cc. +# +# The passing of parse-params +# +# The additional arguments are stored as members of the parser +# object, yyparser. The C routines need to carry yyparser +# throughout the C parser; that easy: just let yyparser become an +# additional parse-param. But because the C++ skeleton needs to +# know the "real" original parse-param, we save them +# (b4_parse_param_orig). Note that b4_parse_param is overquoted +# (and c.m4 strips one level of quotes). This is a PITA, and +# explains why there are so many levels of quotes. +# +# The locations +# +# We use location.cc just like lalr1.cc, but because glr.c stores +# the locations in a (C++) union, the position and location classes +# must not have a constructor. Therefore, contrary to lalr1.cc, we +# must not define "b4_location_constructors". As a consequence the +# user must initialize the first positions (in particular the +# filename member). + +# We require a pure interface using locations. +m4_define([b4_locations_flag], [1]) +m4_define([b4_pure_flag], [1]) + +# The header is mandatory. +b4_defines_if([], + [m4_fatal(b4_skeleton[: using %defines is mandatory])]) + +m4_include(b4_pkgdatadir/[c++.m4]) +m4_include(b4_pkgdatadir/[location.cc]) + + +# Save the parse parameters. +m4_define([b4_parse_param_orig], m4_defn([b4_parse_param])) + + +# b4_yy_symbol_print_generate +# --------------------------- +# Bypass the default implementation to generate the "yy_symbol_print" +# and "yy_symbol_value_print" functions. +m4_define([b4_yy_symbol_print_generate], +[[ +/*--------------------. +| Print this symbol. | +`--------------------*/ + +]b4_c_ansi_function_def([yy_symbol_print], + [static void], + [[FILE *], []], + [[int yytype], [yytype]], + [[const b4_namespace::b4_parser_class_name::semantic_type *yyvaluep], + [yyvaluep]], + [[const b4_namespace::b4_parser_class_name::location_type *yylocationp], + [yylocationp]], + b4_parse_param)[ +{ +]b4_parse_param_use[]dnl +[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[); +} +]]) + + +# Declare yyerror. +m4_append([b4_post_prologue], +[/* Line __line__ of glr.cc. */ +b4_syncline([@oline@], [@ofile@]) + +b4_c_ansi_function_decl([yyerror], + [static void], + [[b4_namespace::b4_parser_class_name::location_type *yylocationp], [yylocationp]], + b4_parse_param, + [[const char* msg], [msg]])]) + + +# Define yyerror. +m4_append([b4_epilogue], +[/* Line __line__ of glr.cc. */ +b4_syncline([@oline@], [@ofile@])[ +/*------------------. +| Report an error. | +`------------------*/ + +]b4_c_ansi_function_def([yyerror], + [static void], + [[b4_namespace::b4_parser_class_name::location_type *yylocationp], [yylocationp]], + b4_parse_param, + [[const char* msg], [msg]])[ +{ +]b4_parse_param_use[]dnl +[ yyparser.error (*yylocationp, msg); +} + + +namespace ]b4_namespace[ +{ +]dnl In this section, the parse param are the original parse_params. +m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl +[ /// Build a parser object. + ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[) + : yycdebug_ (&std::cerr)]b4_parse_param_cons[ + { + } + + ]b4_parser_class_name::~b4_parser_class_name[ () + { + } + + int + ]b4_parser_class_name[::parse () + { + return ::yyparse (*this]b4_user_args[); + } + +#if YYDEBUG + /*--------------------. + | Print this symbol. | + `--------------------*/ + + inline void + ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + /* Pacify ``unused variable'' warnings. */ + YYUSE (yyvaluep); + YYUSE (yylocationp); + switch (yytype) + { + ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl +[ default: + break; + } + } + + + void + ]b4_parser_class_name[::yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + *yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm") + << ' ' << yytname[yytype] << " (" + << *yylocationp << ": "; + yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); + *yycdebug_ << ')'; + } + + std::ostream& + ]b4_parser_class_name[::debug_stream () const + { + return *yycdebug_; + } + + void + ]b4_parser_class_name[::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + ]b4_parser_class_name[::debug_level_type + ]b4_parser_class_name[::debug_level () const + { + return ::yydebug; + } + + void + ]b4_parser_class_name[::set_debug_level (debug_level_type l) + { + ::yydebug = l; + } + +#endif /* ! YYDEBUG */ +]m4_popdef([b4_parse_param])dnl +[} // namespace ]b4_namespace[ + +]]) + + +# Let glr.c believe that the user arguments include the parser itself. +m4_ifset([b4_parse_param], +[m4_pushdef([b4_parse_param], + m4_dquote([[[b4_namespace::b4_parser_class_name& yyparser], [[yyparser]]],] +m4_defn([b4_parse_param])))], +[m4_pushdef([b4_parse_param], + [[[[b4_namespace::b4_parser_class_name& yyparser], [[yyparser]]]]]) +]) +m4_include(b4_pkgdatadir/[glr.c]) +m4_popdef([b4_parse_param]) + + +@output @output_header_name@ +b4_copyright([Skeleton interface for Bison GLR parsers in C++], + [2002, 2003, 2004, 2005, 2006])[ + +/* C++ GLR parser skeleton written by Akim Demaille. */ + +#ifndef PARSER_HEADER_H +# define PARSER_HEADER_H + +#include +#include + +/* Using locations. */ +#define YYLSP_NEEDED ]b4_locations_flag[ + +namespace ]b4_namespace[ +{ + class position; + class location; +} + +/* Copy the first part of user declarations. */ +]b4_pre_prologue[ + +]/* Line __line__ of glr.cc. */ +b4_syncline([@oline@], [@ofile@])[ + +#include "location.hh" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG ]b4_debug_flag[ +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE ]b4_token_table[ +#endif + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ 0) +#endif + +namespace ]b4_namespace[ +{ + /// A Bison parser. + class ]b4_parser_class_name[ + { + public: + /// Symbol semantic values. +#ifndef YYSTYPE +]m4_ifdef([b4_stype], +[ union semantic_type +b4_stype +/* Line __line__ of lalr1.cc. */ +b4_syncline([@oline@], [@ofile@]) + ;], +[ typedef int semantic_type;])[ +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef ]b4_location_type[ location_type; + /// Tokens. + struct token + { + ]b4_token_enums(b4_tokens)[ + }; + /// Token type. + typedef token::yytokentype token_type; + + /// Build a parser object. + ]b4_parser_class_name[ (]b4_parse_param_decl[); + virtual ~]b4_parser_class_name[ (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + + /// The current debugging stream. + std::ostream& debug_stream () const; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); + + private: + + public: + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + private: + +#if YYDEBUG + public: + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + /// \brief Report a symbol on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + private: +#endif /* ! YYDEBUG */ + + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// \param yytype The symbol type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + inline void yydestruct_ (const char* yymsg, + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); + + /* Debugging. */ + std::ostream* yycdebug_; +]b4_parse_param_vars[ + }; + +]dnl Redirections for glr.c. +m4_ifset([b4_global_tokens_and_yystype], +[b4_token_defines(b4_tokens)]) +[ +#ifndef YYSTYPE +# define YYSTYPE ]b4_namespace[::]b4_parser_class_name[::semantic_type +#endif +#ifndef YYLTYPE +# define YYLTYPE ]b4_namespace[::]b4_parser_class_name[::location_type +#endif + +} + +#endif /* ! defined PARSER_HEADER_H */] diff --git a/src/bin/bison/data/lalr1.cc b/src/bin/bison/data/lalr1.cc index 2ab900bed6..abcdcd5d60 100644 --- a/src/bin/bison/data/lalr1.cc +++ b/src/bin/bison/data/lalr1.cc @@ -2,7 +2,7 @@ m4_divert(-1) # C++ skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,44 +21,50 @@ m4_divert(-1) m4_include(b4_pkgdatadir/[c++.m4]) +# The header is mandatory. +b4_defines_if([], + [m4_fatal(b4_skeleton[: using %defines is mandatory])]) + +# Backward compatibility. +m4_define([b4_location_constructors]) +m4_include(b4_pkgdatadir/[location.cc]) + # We do want M4 expansion after # for CPP macros. m4_changecom() m4_divert(0)dnl -m4_if(b4_defines_flag, 0, [], +b4_defines_if( [@output @output_header_name@ -b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison], - [2002, 2003, 2004, 2005])[ -/* FIXME: This is wrong, we want computed header guards. - I don't know why the macros are missing now. :( */ +b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], + [2002, 2003, 2004, 2005, 2006]) +dnl FIXME: This is wrong, we want computed header guards. +[ +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + #ifndef PARSER_HEADER_H # define PARSER_HEADER_H #include #include +#include "stack.hh" -/* Using locations. */ -#define YYLSP_NEEDED ]b4_locations_flag[ - -namespace yy +namespace ]b4_namespace[ { class position; class location; } -]b4_token_enums(b4_tokens)[ - -/* Copy the first part of user declarations. */ +/* First part of user declarations. */ ]b4_pre_prologue[ ]/* Line __line__ of lalr1.cc. */ b4_syncline([@oline@], [@ofile@])[ -#include "stack.hh" -#include "location.hh" +]dnl Include location.hh here: it might depend on headers included above. +[#include "location.hh" /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ +# define YYDEBUG ]b4_debug_flag[ #endif /* Enabling verbose error messages. */ @@ -66,13 +72,7 @@ b4_syncline([@oline@], [@ofile@])[ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE ]b4_error_verbose[ -#endif - -#if YYERROR_VERBOSE -# define YYERROR_VERBOSE_IF(x) x -#else -# define YYERROR_VERBOSE_IF(x) /* empty */ +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif /* Enabling the token table. */ @@ -80,23 +80,6 @@ b4_syncline([@oline@], [@ofile@])[ # define YYTOKEN_TABLE ]b4_token_table[ #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -union YYSTYPE b4_stype; -/* Line __line__ of lalr1.cc. */ -b4_syncline([@oline@], [@ofile@])], -[typedef int YYSTYPE;])[ -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -/* Copy the second part of user declarations. */ -]b4_post_prologue[ - -]/* Line __line__ of lalr1.cc. */ -b4_syncline([@oline@], [@ofile@])[ /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ @@ -113,50 +96,41 @@ do { \ { \ (Current).begin = (Current).end = (Rhs)[0].end; \ } \ -} while (0) +} while (false) #endif -namespace yy +namespace ]b4_namespace[ { - class ]b4_parser_class_name[; - template - struct traits - { - }; - - template <> - struct traits<]b4_parser_class_name[> - { - typedef ]b4_int_type_for([b4_translate])[ token_number_type; - typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type; - typedef int state_type; - typedef YYSTYPE semantic_type; - typedef ]b4_location_type[ location_type; - }; -} - -namespace yy -{ /// A Bison parser. class ]b4_parser_class_name[ { - /// Symbol semantic values. - typedef traits<]b4_parser_class_name[>::semantic_type semantic_type; - /// Symbol locations. - typedef traits<]b4_parser_class_name[>::location_type location_type; - public: - /// Build a parser object. - ]b4_parser_class_name[ (]b4_parse_param_decl[) : - yydebug_ (false), - yycdebug_ (&std::cerr)]b4_parse_param_cons[ + /// Symbol semantic values. +#ifndef YYSTYPE +]m4_ifdef([b4_stype], +[ union semantic_type +b4_stype +/* Line __line__ of lalr1.cc. */ +b4_syncline([@oline@], [@ofile@]) + ;], +[ typedef int semantic_type;])[ +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef ]b4_location_type[ location_type; + /// Tokens. + struct token { - } + ]b4_token_enums(b4_tokens)[ + }; + /// Token type. + typedef token::yytokentype token_type; - virtual ~]b4_parser_class_name[ () - { - } + /// Build a parser object. + ]b4_parser_class_name[ (]b4_parse_param_decl[); + virtual ~]b4_parser_class_name[ (); /// Parse. /// \returns 0 iff parsing succeeded. @@ -181,22 +155,31 @@ namespace yy virtual void error (const location_type& loc, const std::string& msg); /// Generate an error message. - /// \param tok the look-ahead token. - virtual std::string yysyntax_error_ (YYERROR_VERBOSE_IF (int tok)); + /// \param state the state where the error occurred. + /// \param tok the look-ahead token. + virtual std::string yysyntax_error_ (int yystate]dnl +b4_error_verbose_if([, int tok])[); #if YYDEBUG + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); /// \brief Report a symbol on the debug stream. /// \param yytype The token type. /// \param yyvaluep Its semantic value. /// \param yylocationp Its location. - virtual void yysymprint_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); #endif /* ! YYDEBUG */ /// State numbers. - typedef traits<]b4_parser_class_name[>::state_type state_type; + typedef int state_type; /// State stack type. typedef stack state_stack_type; /// Semantic value stack type. @@ -212,7 +195,7 @@ namespace yy location_stack_type yylocation_stack_; /// Internal symbol numbers. - typedef traits<]b4_parser_class_name[>::token_number_type token_number_type; + typedef ]b4_int_type_for([b4_translate])[ token_number_type; /* Tables. */ /// For a state, the index in \a yytable_ of its portion. static const ]b4_int_type_for([b4_pact])[ yypact_[]; @@ -256,7 +239,7 @@ namespace yy #if YYDEBUG /// A type to store symbol numbers and -1. - typedef traits<]b4_parser_class_name[>::rhs_number_type rhs_number_type; + typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type; /// A `-1'-separated list of the rules' RHS. static const rhs_number_type yyrhs_[]; /// For each rule, the index of the first RHS symbol in \a yyrhs_. @@ -266,13 +249,13 @@ namespace yy /// For each scanner token number, its symbol number. static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[]; /// Report on the debug stream that the rule \a r is going to be reduced. - virtual void yyreduce_print_ (int r); + virtual void yy_reduce_print_ (int r); /// Print the state stack on the debug stream. virtual void yystack_print_ (); #endif - /// Convert a scanner token number to a symbol number. - inline token_number_type yytranslate_ (int token); + /// Convert a scanner token number \a t to a symbol number. + token_number_type yytranslate_ (int t); /// \brief Reclaim the memory associated to a symbol. /// \param yymsg Why this token is reclaimed. @@ -280,9 +263,9 @@ namespace yy /// \param yyvaluep Its semantic value. /// \param yylocationp Its location. inline void yydestruct_ (const char* yymsg, - int yytype, - semantic_type* yyvaluep, - location_type* yylocationp); + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); /// Pop \a n symbols the three stacks. inline void yypop_ (unsigned int n = 1); @@ -300,15 +283,6 @@ namespace yy static const unsigned int yyuser_token_number_max_; static const token_number_type yyundef_token_; - /* State. */ - int yyn_; - int yylen_; - int yystate_; - - /* Error handling. */ - int yynerrs_; - int yyerrstatus_; - /* Debugging. */ int yydebug_; std::ostream* yycdebug_; @@ -317,19 +291,32 @@ namespace yy }; } +]m4_ifset([b4_global_tokens_and_yystype], +[b4_token_defines(b4_tokens) + +#ifndef YYSTYPE + /* Redirection for backward compatibility. */ +# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type +#endif +])[ #endif /* ! defined PARSER_HEADER_H */] ])dnl @output @output_parser_name@ -b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison], - [2002, 2003, 2004, 2005]) -m4_if(b4_prefix[], [yy], [], +b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], + [2002, 2003, 2004, 2005, 2006]) +m4_if(b4_prefix, [yy], [], [ // Take the name prefix into account. #define yylex b4_prefix[]lex]) -m4_if(b4_defines_flag, 0, [], -[ +b4_defines_if([ #include @output_header_name@])[ +/* User implementation prologue. */ +]b4_post_prologue[ + +]/* Line __line__ of lalr1.cc. */ +b4_syncline([@oline@], [@ofile@])[ + #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS @@ -342,7 +329,10 @@ m4_if(b4_defines_flag, 0, [], # endif #endif -/* A pseudo ostream that takes yydebug_ into account. */ +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) ((void) (e)) + +/* A pseudo ostream that takes yydebug_ into account. */ # define YYCDEBUG \ for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \ (*yycdebug_) @@ -354,23 +344,23 @@ m4_if(b4_defines_flag, 0, [], do { \ if (yydebug_) \ { \ - *yycdebug_ << (Title) << ' '; \ - yysymprint_ ((Type), (Value), (Location)); \ + *yycdebug_ << Title << ' '; \ + yy_symbol_print_ ((Type), (Value), (Location)); \ *yycdebug_ << std::endl; \ } \ -} while (0) +} while (false) # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug_) \ - yyreduce_print_ (Rule); \ -} while (0) + yy_reduce_print_ (Rule); \ +} while (false) # define YY_STACK_PRINT() \ do { \ if (yydebug_) \ yystack_print_ (); \ -} while (0) +} while (false) #else /* !YYDEBUG */ @@ -384,670 +374,697 @@ do { \ #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab +namespace ]b4_namespace[ +{ #if YYERROR_VERBOSE -/* Return YYSTR after stripping away unnecessary quotes and - backslashes, so that it's suitable for yyerror. The heuristic is - that double-quoting is unnecessary unless the string contains an - apostrophe, a comma, or backslash (other than backslash-backslash). - YYSTR is taken from yytname. */ -std::string -yy::]b4_parser_class_name[::yytnamerr_ (const char *yystr) -{ - if (*yystr == '"') - { - std::string yyr = ""; - char const *yyp = yystr; + /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + ]b4_parser_class_name[::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr = ""; + char const *yyp = yystr; - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - yyr += *yyp; - break; + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + yyr += *yyp; + break; - case '"': - return yyr; - } - do_not_strip_quotes: ; - } + case '"': + return yyr; + } + do_not_strip_quotes: ; + } - return yystr; -} + return yystr; + } #endif + /// Build a parser object. + ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[) + : yydebug_ (false), + yycdebug_ (&std::cerr)]b4_parse_param_cons[ + { + } + + ]b4_parser_class_name::~b4_parser_class_name[ () + { + } + #if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ + /*--------------------------------. + | Print this symbol on YYOUTPUT. | + `--------------------------------*/ -void -yy::]b4_parser_class_name[::yysymprint_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - (void) yylocationp; - /* Backward compatibility, but should be removed eventually. */ - std::ostream& cdebug_ = *yycdebug_; - (void) cdebug_; + inline void + ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yyvaluep); + switch (yytype) + { + ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl +[ default: + break; + } + } - *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") - << ' ' << yytname_[yytype] << " (" - << *yylocationp << ": "; - switch (yytype) - { -]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl -[ default: - break; - } - *yycdebug_ << ')'; -} + + void + ]b4_parser_class_name[::yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " (" + << *yylocationp << ": "; + yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); + *yycdebug_ << ')'; + } #endif /* ! YYDEBUG */ -void -yy::]b4_parser_class_name[::yydestruct_ (const char* yymsg, - int yytype, semantic_type* yyvaluep, location_type* yylocationp) -{ - /* Pacify ``unused variable'' warnings. */ - (void) yymsg; - (void) yyvaluep; - (void) yylocationp; + void + ]b4_parser_class_name[::yydestruct_ (const char* yymsg, + int yytype, semantic_type* yyvaluep, location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yymsg); + YYUSE (yyvaluep); - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { -]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ - default: - break; - } -} + switch (yytype) + { + ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ + default: + break; + } + } -void -yy::]b4_parser_class_name[::yypop_ (unsigned int n) -{ - yystate_stack_.pop (n); - yysemantic_stack_.pop (n); - yylocation_stack_.pop (n); -} + void + ]b4_parser_class_name[::yypop_ (unsigned int n) + { + yystate_stack_.pop (n); + yysemantic_stack_.pop (n); + yylocation_stack_.pop (n); + } -std::ostream& -yy::]b4_parser_class_name[::debug_stream () const -{ - return *yycdebug_; -} + std::ostream& + ]b4_parser_class_name[::debug_stream () const + { + return *yycdebug_; + } -void -yy::]b4_parser_class_name[::set_debug_stream (std::ostream& o) -{ - yycdebug_ = &o; -} + void + ]b4_parser_class_name[::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } -yy::]b4_parser_class_name[::debug_level_type -yy::]b4_parser_class_name[::debug_level () const -{ - return yydebug_; -} + ]b4_parser_class_name[::debug_level_type + ]b4_parser_class_name[::debug_level () const + { + return yydebug_; + } -void -yy::]b4_parser_class_name[::set_debug_level (debug_level_type l) -{ - yydebug_ = l; -} + void + ]b4_parser_class_name[::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } -int -yy::]b4_parser_class_name[::parse () -{ - /* Look-ahead and look-ahead in internal form. */ - int yylooka; - int yyilooka; + int + ]b4_parser_class_name[::parse () + { + /// Look-ahead and look-ahead in internal form. + int yychar = yyempty_; + int yytoken = 0; - /// Semantic value of the look-ahead. - semantic_type yylval; - /// Location of the look-ahead. - location_type yylloc; - /// The locations where the error started and ended. - location yyerror_range[2]; + /* State. */ + int yyn; + int yylen = 0; + int yystate = 0; - /// $$. - semantic_type yyval; - /// @@$. - location_type yyloc; + /* Error handling. */ + int yynerrs_ = 0; + int yyerrstatus_ = 0; - int yyresult_; + /// Semantic value of the look-ahead. + semantic_type yylval; + /// Location of the look-ahead. + location_type yylloc; + /// The locations where the error started and ended. + location yyerror_range[2]; - YYCDEBUG << "Starting parse" << std::endl; + /// $$. + semantic_type yyval; + /// @@$. + location_type yyloc; - yynerrs_ = 0; - yyerrstatus_ = 0; + int yyresult; - /* Start. */ - yystate_ = 0; - yylooka = yyempty_; + YYCDEBUG << "Starting parse" << std::endl; ]m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [yylloc])dnl m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ - b4_initial_action + /* User initialization code. */ + b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl -/* Line __line__ of yacc.c. */ + /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])])dnl -[ /* Initialize the stacks. The initial state will be pushed in - yynewstate, since the latter expects the semantical and the - location values to have been already stored, initialize these - stacks with a primary value. */ - yystate_stack_ = state_stack_type (0); - yysemantic_stack_ = semantic_stack_type (0); - yylocation_stack_ = location_stack_type (0); - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yylloc); + [ /* Initialize the stacks. The initial state will be pushed in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); - /* New state. */ -yynewstate: - yystate_stack_.push (yystate_); - YYCDEBUG << "Entering state " << yystate_ << std::endl; - goto yybackup; + /* New state. */ + yynewstate: + yystate_stack_.push (yystate); + YYCDEBUG << "Entering state " << yystate << std::endl; + goto yybackup; - /* Backup. */ -yybackup: + /* Backup. */ + yybackup: - /* Try to take a decision without look-ahead. */ - yyn_ = yypact_[yystate_]; - if (yyn_ == yypact_ninf_) - goto yydefault; + /* Try to take a decision without look-ahead. */ + yyn = yypact_[yystate]; + if (yyn == yypact_ninf_) + goto yydefault; - /* Read a look-ahead token. */ - if (yylooka == yyempty_) - { - YYCDEBUG << "Reading a token: "; - yylooka = ]b4_c_function_call([yylex], [int], -[[YYSTYPE*], [&yylval]][]dnl -b4_location_if([, [[location*], [&yylloc]]])dnl + /* Read a look-ahead token. */ + if (yychar == yyempty_) + { + YYCDEBUG << "Reading a token: "; + yychar = ]b4_c_function_call([yylex], [int], + [[YYSTYPE*], [&yylval]][]dnl +b4_locations_if([, [[location*], [&yylloc]]])dnl m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; - } + } - /* Convert token to internal form. */ - if (yylooka <= yyeof_) - { - yylooka = yyilooka = yyeof_; - YYCDEBUG << "Now at end of input." << std::endl; - } - else - { - yyilooka = yytranslate_ (yylooka); - YY_SYMBOL_PRINT ("Next token is", yyilooka, &yylval, &yylloc); - } + /* Convert token to internal form. */ + if (yychar <= yyeof_) + { + yychar = yytoken = yyeof_; + YYCDEBUG << "Now at end of input." << std::endl; + } + else + { + yytoken = yytranslate_ (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } - /* If the proper action on seeing token ILOOKA_ is to reduce or to - detect an error, take that action. */ - yyn_ += yyilooka; - if (yyn_ < 0 || yylast_ < yyn_ || yycheck_[yyn_] != yyilooka) - goto yydefault; + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) + goto yydefault; - /* Reduce or error. */ - yyn_ = yytable_[yyn_]; - if (yyn_ < 0) - { - if (yyn_ == yytable_ninf_) + /* Reduce or error. */ + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == yytable_ninf_) goto yyerrlab; - else - { - yyn_ = -yyn_; - goto yyreduce; - } - } - else if (yyn_ == 0) - goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } - /* Accept? */ - if (yyn_ == yyfinal_) - goto yyacceptlab; + /* Accept? */ + if (yyn == yyfinal_) + goto yyacceptlab; - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yyilooka, &yylval, &yylloc); + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the token being shifted unless it is eof. */ - if (yylooka != yyeof_) - yylooka = yyempty_; + /* Discard the token being shifted unless it is eof. */ + if (yychar != yyeof_) + yychar = yyempty_; - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yylloc); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus_) - --yyerrstatus_; + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus_) + --yyerrstatus_; - yystate_ = yyn_; - goto yynewstate; + yystate = yyn; + goto yynewstate; -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn_ = yydefact_[yystate_]; - if (yyn_ == 0) - goto yyerrlab; - goto yyreduce; + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - yylen_ = yyr2_[yyn_]; - /* If LEN_ is nonzero, implement the default value of the action: - `$$ = $1'. Otherwise, use the top of the stack. + /*-----------------------------. + | yyreduce -- Do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. Otherwise, use the top of the stack. - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. */ - if (yylen_) - yyval = yysemantic_stack_[yylen_ - 1]; - else - yyval = yysemantic_stack_[0]; + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. */ + if (yylen) + yyval = yysemantic_stack_[yylen - 1]; + else + yyval = yysemantic_stack_[0]; - { - slice slice (yylocation_stack_, yylen_); - YYLLOC_DEFAULT (yyloc, slice, yylen_); - } - YY_REDUCE_PRINT (yyn_); - switch (yyn_) { - ]b4_actions[ - default: break; + slice slice (yylocation_stack_, yylen); + YYLLOC_DEFAULT (yyloc, slice, yylen); } - -]/* Line __line__ of lalr1.cc. */ + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + ]b4_actions + /* Line __line__ of lalr1.cc. */ b4_syncline([@oline@], [@ofile@])[ + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); - yypop_ (yylen_); + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); - YY_STACK_PRINT (); + yysemantic_stack_.push (yyval); + yylocation_stack_.push (yyloc); - yysemantic_stack_.push (yyval); - yylocation_stack_.push (yyloc); + /* Shift the result of the reduction. */ + yyn = yyr1_[yyn]; + yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; + if (0 <= yystate && yystate <= yylast_ + && yycheck_[yystate] == yystate_stack_[0]) + yystate = yytable_[yystate]; + else + yystate = yydefgoto_[yyn - yyntokens_]; + goto yynewstate; - /* Shift the result of the reduction. */ - yyn_ = yyr1_[yyn_]; - yystate_ = yypgoto_[yyn_ - yyntokens_] + yystate_stack_[0]; - if (0 <= yystate_ && yystate_ <= yylast_ - && yycheck_[yystate_] == yystate_stack_[0]) - yystate_ = yytable_[yystate_]; - else - yystate_ = yydefgoto_[yyn_ - yyntokens_]; - goto yynewstate; + /*------------------------------------. + | yyerrlab -- here on detecting error | + `------------------------------------*/ + yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus_) + { + ++yynerrs_; + error (yylloc, yysyntax_error_ (yystate]dnl +b4_error_verbose_if([, yytoken])[)); + } -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus_) - { - ++yynerrs_; - error (yylloc, yysyntax_error_ (YYERROR_VERBOSE_IF (yyilooka))); - } - - yyerror_range[0] = yylloc; - if (yyerrstatus_ == 3) - { - /* If just tried and failed to reuse look-ahead token after an + yyerror_range[0] = yylloc; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse look-ahead token after an error, discard it. */ - if (yylooka <= yyeof_) - { + if (yychar <= yyeof_) + { /* Return failure if at end of input. */ - if (yylooka == yyeof_) + if (yychar == yyeof_) YYABORT; - } - else - { - yydestruct_ ("Error: discarding", yyilooka, &yylval, &yylloc); - yylooka = yyempty_; - } - } + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } + } - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (false) - goto yyerrorlab; + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (false) + goto yyerrorlab; - yyerror_range[0] = yylocation_stack_[yylen_ - 1]; - yypop_ (yylen_); - yystate_ = yystate_stack_[0]; - goto yyerrlab1; + yyerror_range[0] = yylocation_stack_[yylen - 1]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + yystate = yystate_stack_[0]; + goto yyerrlab1; -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus_ = 3; /* Each real token shifted decrements this. */ + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; /* Each real token shifted decrements this. */ - for (;;) - { - yyn_ = yypact_[yystate_]; - if (yyn_ != yypact_ninf_) + for (;;) + { + yyn = yypact_[yystate]; + if (yyn != yypact_ninf_) { - yyn_ += yyterror_; - if (0 <= yyn_ && yyn_ <= yylast_ && yycheck_[yyn_] == yyterror_) + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) { - yyn_ = yytable_[yyn_]; - if (0 < yyn_) + yyn = yytable_[yyn]; + if (0 < yyn) break; } } - /* Pop the current state because it cannot handle the error token. */ - if (yystate_stack_.height () == 1) + /* Pop the current state because it cannot handle the error token. */ + if (yystate_stack_.height () == 1) YYABORT; - yyerror_range[0] = yylocation_stack_[0]; - yydestruct_ ("Error: popping", - yystos_[yystate_], - &yysemantic_stack_[0], &yylocation_stack_[0]); - yypop_ (); - yystate_ = yystate_stack_[0]; - YY_STACK_PRINT (); - } + yyerror_range[0] = yylocation_stack_[0]; + yydestruct_ ("Error: popping", + yystos_[yystate], + &yysemantic_stack_[0], &yylocation_stack_[0]); + yypop_ (); + yystate = yystate_stack_[0]; + YY_STACK_PRINT (); + } - if (yyn_ == yyfinal_) - goto yyacceptlab; + if (yyn == yyfinal_) + goto yyacceptlab; - yyerror_range[1] = yylloc; - // Using YYLLOC is tempting, but would change the location of - // the look-ahead. YYLOC is available though. - YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yyloc); + yyerror_range[1] = yylloc; + // Using YYLLOC is tempting, but would change the location of + // the look-ahead. YYLOC is available though. + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yyloc); - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos_[yyn_], + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], &yysemantic_stack_[0], &yylocation_stack_[0]); - yystate_ = yyn_; - goto yynewstate; + yystate = yyn; + goto yynewstate; - /* Accept. */ -yyacceptlab: - yyresult_ = 0; - goto yyreturn; + /* Accept. */ + yyacceptlab: + yyresult = 0; + goto yyreturn; - /* Abort. */ -yyabortlab: - yyresult_ = 1; - goto yyreturn; + /* Abort. */ + yyabortlab: + yyresult = 1; + goto yyreturn; -yyreturn: - if (yylooka != yyeof_ && yylooka != yyempty_) - yydestruct_ ("Cleanup: discarding lookahead", yyilooka, &yylval, &yylloc); + yyreturn: + if (yychar != yyeof_ && yychar != yyempty_) + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); - while (yystate_stack_.height () != 1) - { - yydestruct_ ("Cleanup: popping", + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + while (yystate_stack_.height () != 1) + { + yydestruct_ ("Cleanup: popping", yystos_[yystate_stack_[0]], &yysemantic_stack_[0], &yylocation_stack_[0]); - yypop_ (); - } + yypop_ (); + } - return yyresult_; -} + return yyresult; + } -// Generate an error message. -std::string -yy::]b4_parser_class_name[::yysyntax_error_ (YYERROR_VERBOSE_IF (int tok)) -{ - std::string res; + // Generate an error message. + std::string + ]b4_parser_class_name[::yysyntax_error_ (int yystate]dnl +b4_error_verbose_if([, int tok])[) + { + std::string res; + YYUSE (yystate); #if YYERROR_VERBOSE - yyn_ = yypact_[yystate_]; - if (yypact_ninf_ < yyn_ && yyn_ < yylast_) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn_ < 0 ? -yyn_ : 0; + int yyn = yypact_[yystate]; + if (yypact_ninf_ < yyn && yyn <= yylast_) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn_; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - int count = 0; - for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn_] == x && x != yyterror_) - ++count; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + int count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + ++count; - // FIXME: This method of building the message is not compatible - // with internationalization. It should work like yacc.c does it. - // That is, first build a string that looks like this: - // "syntax error, unexpected %s or %s or %s" - // Then, invoke YY_ on this string. - // Finally, use the string as a format to output - // yytname_[tok], etc. - // Until this gets fixed, this message appears in English only. - res = "syntax error, unexpected "; - res += yytnamerr_ (yytname_[tok]); - if (count < 5) - { - count = 0; - for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn_] == x && x != yyterror_) - { - res += (!count++) ? ", expecting " : " or "; - res += yytnamerr_ (yytname_[x]); - } - } - } - else + // FIXME: This method of building the message is not compatible + // with internationalization. It should work like yacc.c does it. + // That is, first build a string that looks like this: + // "syntax error, unexpected %s or %s or %s" + // Then, invoke YY_ on this string. + // Finally, use the string as a format to output + // yytname_[tok], etc. + // Until this gets fixed, this message appears in English only. + res = "syntax error, unexpected "; + res += yytnamerr_ (yytname_[tok]); + if (count < 5) + { + count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + { + res += (!count++) ? ", expecting " : " or "; + res += yytnamerr_ (yytname_[x]); + } + } + } + else #endif - res = YY_("syntax error"); - return res; -} + res = YY_("syntax error"); + return res; + } -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) yy::b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[; -const ]b4_int_type_for([b4_pact])[ -yy::]b4_parser_class_name[::yypact_[] = -{ - ]b4_pact[ -}; + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ + const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[; + const ]b4_int_type_for([b4_pact])[ + ]b4_parser_class_name[::yypact_[] = + { + ]b4_pact[ + }; -/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ -const ]b4_int_type_for([b4_defact])[ -yy::]b4_parser_class_name[::yydefact_[] = -{ - ]b4_defact[ -}; + /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ + const ]b4_int_type_for([b4_defact])[ + ]b4_parser_class_name[::yydefact_[] = + { + ]b4_defact[ + }; -/* YYPGOTO[NTERM-NUM]. */ -const ]b4_int_type_for([b4_pgoto])[ -yy::]b4_parser_class_name[::yypgoto_[] = -{ - ]b4_pgoto[ -}; + /* YYPGOTO[NTERM-NUM]. */ + const ]b4_int_type_for([b4_pgoto])[ + ]b4_parser_class_name[::yypgoto_[] = + { + ]b4_pgoto[ + }; -/* YYDEFGOTO[NTERM-NUM]. */ -const ]b4_int_type_for([b4_defgoto])[ -yy::]b4_parser_class_name[::yydefgoto_[] = -{ - ]b4_defgoto[ -}; + /* YYDEFGOTO[NTERM-NUM]. */ + const ]b4_int_type_for([b4_defgoto])[ + ]b4_parser_class_name[::yydefgoto_[] = + { + ]b4_defgoto[ + }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. */ -const ]b4_int_type(b4_table_ninf, b4_table_ninf) yy::b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; -const ]b4_int_type_for([b4_table])[ -yy::]b4_parser_class_name[::yytable_[] = -{ - ]b4_table[ -}; + /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. */ + const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; + const ]b4_int_type_for([b4_table])[ + ]b4_parser_class_name[::yytable_[] = + { + ]b4_table[ + }; -/* YYCHECK. */ -const ]b4_int_type_for([b4_check])[ -yy::]b4_parser_class_name[::yycheck_[] = -{ - ]b4_check[ -}; + /* YYCHECK. */ + const ]b4_int_type_for([b4_check])[ + ]b4_parser_class_name[::yycheck_[] = + { + ]b4_check[ + }; -/* STOS_[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -const ]b4_int_type_for([b4_stos])[ -yy::]b4_parser_class_name[::yystos_[] = -{ - ]b4_stos[ -}; + /* STOS_[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ + const ]b4_int_type_for([b4_stos])[ + ]b4_parser_class_name[::yystos_[] = + { + ]b4_stos[ + }; #if YYDEBUG -/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding - to YYLEX-NUM. */ -const ]b4_int_type_for([b4_toknum])[ -yy::]b4_parser_class_name[::yytoken_number_[] = -{ - ]b4_toknum[ -}; + /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding + to YYLEX-NUM. */ + const ]b4_int_type_for([b4_toknum])[ + ]b4_parser_class_name[::yytoken_number_[] = + { + ]b4_toknum[ + }; #endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -const ]b4_int_type_for([b4_r1])[ -yy::]b4_parser_class_name[::yyr1_[] = -{ - ]b4_r1[ -}; + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ + const ]b4_int_type_for([b4_r1])[ + ]b4_parser_class_name[::yyr1_[] = + { + ]b4_r1[ + }; -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -const ]b4_int_type_for([b4_r2])[ -yy::]b4_parser_class_name[::yyr2_[] = -{ - ]b4_r2[ -}; + /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ + const ]b4_int_type_for([b4_r2])[ + ]b4_parser_class_name[::yyr2_[] = + { + ]b4_r2[ + }; #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at \a yyntokens_, nonterminals. */ -const char* -const yy::]b4_parser_class_name[::yytname_[] = -{ - ]b4_tname[ -}; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at \a yyntokens_, nonterminals. */ + const char* + const ]b4_parser_class_name[::yytname_[] = + { + ]b4_tname[ + }; #endif #if YYDEBUG -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -const yy::]b4_parser_class_name[::rhs_number_type -yy::]b4_parser_class_name[::yyrhs_[] = -{ - ]b4_rhs[ -}; + /* YYRHS -- A `-1'-separated list of the rules' RHS. */ + const ]b4_parser_class_name[::rhs_number_type + ]b4_parser_class_name[::yyrhs_[] = + { + ]b4_rhs[ + }; -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -const ]b4_int_type_for([b4_prhs])[ -yy::]b4_parser_class_name[::yyprhs_[] = -{ - ]b4_prhs[ -}; + /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ + const ]b4_int_type_for([b4_prhs])[ + ]b4_parser_class_name[::yyprhs_[] = + { + ]b4_prhs[ + }; -/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -const ]b4_int_type_for([b4_rline])[ -yy::]b4_parser_class_name[::yyrline_[] = -{ - ]b4_rline[ -}; + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ + const ]b4_int_type_for([b4_rline])[ + ]b4_parser_class_name[::yyrline_[] = + { + ]b4_rline[ + }; -// Print the state stack on the debug stream. -void -yy::]b4_parser_class_name[::yystack_print_ () -{ - *yycdebug_ << "Stack now"; - for (state_stack_type::const_iterator i = yystate_stack_.begin (); - i != yystate_stack_.end (); ++i) - *yycdebug_ << ' ' << *i; - *yycdebug_ << std::endl; -} + // Print the state stack on the debug stream. + void + ]b4_parser_class_name[::yystack_print_ () + { + *yycdebug_ << "Stack now"; + for (state_stack_type::const_iterator i = yystate_stack_.begin (); + i != yystate_stack_.end (); ++i) + *yycdebug_ << ' ' << *i; + *yycdebug_ << std::endl; + } -// Report on the debug stream that the rule \a yyrule is going to be reduced. -void -yy::]b4_parser_class_name[::yyreduce_print_ (int yyrule) -{ - unsigned int yylno = yyrline_[yyrule]; - /* Print the symbols being reduced, and their result. */ - *yycdebug_ << "Reducing stack by rule " << yyn_ - 1 - << " (line " << yylno << "), "; - for (]b4_int_type_for([b4_prhs])[ i = yyprhs_[yyn_]; - 0 <= yyrhs_[i]; ++i) - *yycdebug_ << yytname_[yyrhs_[i]] << ' '; - *yycdebug_ << "-> " << yytname_[yyr1_[yyn_]] << std::endl; -} + // Report on the debug stream that the rule \a yyrule is going to be reduced. + void + ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) + { + unsigned int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + /* Print the symbols being reduced, and their result. */ + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "), "; + /* The symbols being reduced. */ + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yyrhs_[yyprhs_[yyrule] + yyi], + &]b4_rhs_value(yynrhs, yyi + 1)[, + &]b4_rhs_location(yynrhs, yyi + 1)[); + } #endif // YYDEBUG -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -yy::]b4_parser_class_name[::token_number_type -yy::]b4_parser_class_name[::yytranslate_ (int token) -{ - static - const token_number_type - translate_table[] = + /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ + ]b4_parser_class_name[::token_number_type + ]b4_parser_class_name[::yytranslate_ (int t) { - ]b4_translate[ - }; - if ((unsigned int) token <= yyuser_token_number_max_) - return translate_table[token]; - else - return yyundef_token_; -} + static + const token_number_type + translate_table[] = + { + ]b4_translate[ + }; + if ((unsigned int) t <= yyuser_token_number_max_) + return translate_table[t]; + else + return yyundef_token_; + } -const int yy::]b4_parser_class_name[::yyeof_ = 0; -const int yy::]b4_parser_class_name[::yylast_ = ]b4_last[; -const int yy::]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[; -const int yy::]b4_parser_class_name[::yyempty_ = -2; -const int yy::]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[; -const int yy::]b4_parser_class_name[::yyterror_ = 1; -const int yy::]b4_parser_class_name[::yyerrcode_ = 256; -const int yy::]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[; + const int ]b4_parser_class_name[::yyeof_ = 0; + const int ]b4_parser_class_name[::yylast_ = ]b4_last[; + const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[; + const int ]b4_parser_class_name[::yyempty_ = -2; + const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[; + const int ]b4_parser_class_name[::yyterror_ = 1; + const int ]b4_parser_class_name[::yyerrcode_ = 256; + const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[; -const unsigned int yy::]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[; -const yy::]b4_parser_class_name[::token_number_type yy::]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; + const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[; + const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; + +} // namespace ]b4_namespace[ ]b4_epilogue dnl -@output stack.hh -b4_copyright([stack handling for Bison C++ parsers], [2002, 2003, 2004, 2005])[ +@output b4_dir_prefix[]stack.hh +b4_copyright([Stack handling for Bison parsers in C++], + [2002, 2003, 2004, 2005, 2006])[ #ifndef BISON_STACK_HH # define BISON_STACK_HH #include -namespace yy +namespace ]b4_namespace[ { template > class stack @@ -1137,227 +1154,4 @@ namespace yy } #endif // not BISON_STACK_HH] -dnl -@output position.hh -b4_copyright([Position class for Bison C++ parsers], [2002, 2003, 2004, 2005])[ - -/** - ** \file position.hh - ** Define the position class. - */ - -#ifndef BISON_POSITION_HH -# define BISON_POSITION_HH - -# include -# include - -namespace yy -{ - /// Abstract a position. - class position - { - public: - /// Initial column number. - static const unsigned int initial_column = 0; - /// Initial line number. - static const unsigned int initial_line = 1; - - /** \name Ctor & dtor. - ** \{ */ - public: - /// Construct a position. - position () : - filename (0), - line (initial_line), - column (initial_column) - { - } - /** \} */ - - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// (line related) Advance to the COUNT next lines. - inline void lines (int count = 1) - { - column = initial_column; - line += count; - } - - /// (column related) Advance to the COUNT next columns. - inline void columns (int count = 1) - { - int leftmost = initial_column; - int current = column; - if (leftmost <= current + count) - column += count; - else - column = initial_column; - } - /** \} */ - - public: - /// File name to which this position refers. - ]b4_filename_type[* filename; - /// Current line number. - unsigned int line; - /// Current column number. - unsigned int column; - }; - - /// Add and assign a position. - inline const position& - operator+= (position& res, const int width) - { - res.columns (width); - return res; - } - - /// Add two position objects. - inline const position - operator+ (const position& begin, const int width) - { - position res = begin; - return res += width; - } - - /// Add and assign a position. - inline const position& - operator-= (position& res, const int width) - { - return res += -width; - } - - /// Add two position objects. - inline const position - operator- (const position& begin, const int width) - { - return begin + -width; - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param pos a reference to the position to redirect - */ - inline std::ostream& - operator<< (std::ostream& ostr, const position& pos) - { - if (pos.filename) - ostr << *pos.filename << ':'; - return ostr << pos.line << '.' << pos.column; - } - -} -#endif // not BISON_POSITION_HH] -@output location.hh -b4_copyright([Location class for Bison C++ parsers], [2002, 2003, 2004, 2005])[ - -/** - ** \file location.hh - ** Define the location class. - */ - -#ifndef BISON_LOCATION_HH -# define BISON_LOCATION_HH - -# include -# include -# include "position.hh" - -namespace yy -{ - - /// Abstract a location. - class location - { - /** \name Ctor & dtor. - ** \{ */ - public: - /// Construct a location. - location () : - begin (), - end () - { - } - /** \} */ - - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// Reset initial location to final location. - inline void step () - { - begin = end; - } - - /// Extend the current location to the COUNT next columns. - inline void columns (unsigned int count = 1) - { - end += count; - } - - /// Extend the current location to the COUNT next lines. - inline void lines (unsigned int count = 1) - { - end.lines (count); - } - /** \} */ - - - public: - /// Beginning of the located region. - position begin; - /// End of the located region. - position end; - }; - - /// Join two location objects to create a location. - inline const location operator+ (const location& begin, const location& end) - { - location res = begin; - res.end = end.end; - return res; - } - - /// Add two location objects. - inline const location operator+ (const location& begin, unsigned int width) - { - location res = begin; - res.columns (width); - return res; - } - - /// Add and assign a location. - inline location& operator+= (location& res, unsigned int width) - { - res.columns (width); - return res; - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param loc a reference to the location to redirect - ** - ** Avoid duplicate information. - */ - inline std::ostream& operator<< (std::ostream& ostr, const location& loc) - { - position last = loc.end - 1; - ostr << loc.begin; - if (last.filename - && (!loc.begin.filename - || *loc.begin.filename != *last.filename)) - ostr << '-' << last; - else if (loc.begin.line != last.line) - ostr << '-' << last.line << '.' << last.column; - else if (loc.begin.column != last.column) - ostr << '-' << last.column; - return ostr; - } - -} - -#endif // not BISON_LOCATION_HH] +m4_divert(-1) diff --git a/src/bin/bison/data/location.cc b/src/bin/bison/data/location.cc new file mode 100644 index 0000000000..869320e799 --- /dev/null +++ b/src/bin/bison/data/location.cc @@ -0,0 +1,253 @@ +m4_divert(-1) + +# C++ skeleton for Bison + +# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +# We do want M4 expansion after # for CPP macros. +m4_changecom() +m4_divert(0)dnl +@output b4_dir_prefix[]position.hh +b4_copyright([Positions for Bison parsers in C++], + [2002, 2003, 2004, 2005, 2006])[ + +/** + ** \file position.hh + ** Define the ]b4_namespace[::position class. + */ + +#ifndef BISON_POSITION_HH +# define BISON_POSITION_HH + +# include +# include + +namespace ]b4_namespace[ +{ + /// Abstract a position. + class position + { + public: +]m4_ifdef([b4_location_constructors], [ + /// Construct a position. + position () + : filename (0), line (1), column (0) + { + } + +])[ + /// Initialization. + inline void initialize (]b4_filename_type[* fn) + { + filename = fn; + line = 1; + column = 0; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// (line related) Advance to the COUNT next lines. + inline void lines (int count = 1) + { + column = 0; + line += count; + } + + /// (column related) Advance to the COUNT next columns. + inline void columns (int count = 1) + { + int leftmost = 0; + int current = column; + if (leftmost <= current + count) + column += count; + else + column = 0; + } + /** \} */ + + public: + /// File name to which this position refers. + ]b4_filename_type[* filename; + /// Current line number. + unsigned int line; + /// Current column number. + unsigned int column; + }; + + /// Add and assign a position. + inline const position& + operator+= (position& res, const int width) + { + res.columns (width); + return res; + } + + /// Add two position objects. + inline const position + operator+ (const position& begin, const int width) + { + position res = begin; + return res += width; + } + + /// Add and assign a position. + inline const position& + operator-= (position& res, const int width) + { + return res += -width; + } + + /// Add two position objects. + inline const position + operator- (const position& begin, const int width) + { + return begin + -width; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + inline std::ostream& + operator<< (std::ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + +} +#endif // not BISON_POSITION_HH] +@output b4_dir_prefix[]location.hh +b4_copyright([Locations for Bison parsers in C++], + [2002, 2003, 2004, 2005, 2006])[ + +/** + ** \file location.hh + ** Define the ]b4_namespace[::location class. + */ + +#ifndef BISON_LOCATION_HH +# define BISON_LOCATION_HH + +# include +# include +# include "position.hh" + +namespace ]b4_namespace[ +{ + + /// Abstract a location. + class location + { + public: +]m4_ifdef([b4_location_constructors], [ + /// Construct a location. + location () + : begin (), end () + { + } + +])[ + /// Initialization. + inline void initialize (]b4_filename_type[* fn) + { + begin.initialize (fn); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + inline void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + inline void columns (unsigned int count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + inline void lines (unsigned int count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two location objects to create a location. + inline const location operator+ (const location& begin, const location& end) + { + location res = begin; + res.end = end.end; + return res; + } + + /// Add two location objects. + inline const location operator+ (const location& begin, unsigned int width) + { + location res = begin; + res.columns (width); + return res; + } + + /// Add and assign a location. + inline location& operator+= (location& res, unsigned int width) + { + res.columns (width); + return res; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + inline std::ostream& operator<< (std::ostream& ostr, const location& loc) + { + position last = loc.end - 1; + ostr << loc.begin; + if (last.filename + && (!loc.begin.filename + || *loc.begin.filename != *last.filename)) + ostr << '-' << last; + else if (loc.begin.line != last.line) + ostr << '-' << last.line << '.' << last.column; + else if (loc.begin.column != last.column) + ostr << '-' << last.column; + return ostr; + } + +} + +#endif // not BISON_LOCATION_HH] +m4_divert(-1) +m4_changecom([#]) diff --git a/src/bin/bison/data/m4sugar/m4sugar.m4 b/src/bin/bison/data/m4sugar/m4sugar.m4 index bd6c8d68c1..225b7c7a54 100644 --- a/src/bin/bison/data/m4sugar/m4sugar.m4 +++ b/src/bin/bison/data/m4sugar/m4sugar.m4 @@ -398,8 +398,11 @@ m4_define([m4_cdr], # of LIST (which can be lists themselves, for multiple arguments MACROs). m4_define([m4_fst], [$1]) m4_define([m4_map], +[m4_if([$2], [[]], [], + [_m4_map([$1], [$2])])]) +m4_define([_m4_map], [m4_ifval([$2], - [$1(m4_fst($2))[]m4_map([$1], m4_cdr($2))])]) + [$1(m4_fst($2))[]_m4_map([$1], m4_cdr($2))])]) # m4_map_sep(MACRO, SEPARATOR, LIST) @@ -408,8 +411,8 @@ m4_define([m4_map], # are the elements of LIST (which can be lists themselves, for multiple # arguments MACROs). m4_define([m4_map_sep], -[m4_ifval([$3], - [$1(m4_fst($3))[]m4_map([$2[]$1], m4_cdr($3))])]) +[m4_if([$3], [[]], [], + [$1(m4_fst($3))[]_m4_map([$2[]$1], m4_cdr($3))])]) ## ---------------------------------------- ## @@ -1512,6 +1515,12 @@ m4_define([m4_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])$3])[$2])]) +# m4_prepend(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------- +# Same, but prepend. +m4_define([m4_prepend], +[m4_define([$1], + [$2]m4_ifdef([$1], [$3[]m4_defn([$1])]))]) # m4_append_uniq(MACRO-NAME, STRING, [SEPARATOR]) # ----------------------------------------------- diff --git a/src/bin/bison/data/yacc.c b/src/bin/bison/data/yacc.c index 7e7c44ac40..1e8fa56952 100644 --- a/src/bin/bison/data/yacc.c +++ b/src/bin/bison/data/yacc.c @@ -1,8 +1,8 @@ -m4_divert(-1) -*- C -*- +m4_divert(-1) -*- C -*- # Yacc compatible skeleton for Bison -# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 +# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -20,7 +20,7 @@ m4_divert(-1) -*- C -*- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA - +m4_include(b4_pkgdatadir/[c.m4]) ## ---------------- ## ## Default values. ## @@ -36,20 +36,20 @@ m4_define_default([b4_stack_depth_init], [200]) ## ------------------------ ## -# b4_pure_if(IF-TRUE, IF-FALSE) -# ----------------------------- +# b4_yacc_pure_if(IF-TRUE, IF-FALSE) +# ---------------------------------- # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise. -m4_define([b4_Pure_if], +m4_define([b4_yacc_pure_if], [b4_pure_if([m4_ifset([b4_parse_param], - [$1], [$2])], - [$2])]) + [$1], [$2])], + [$2])]) # b4_yyerror_args # --------------- # Arguments passed to yyerror: user args plus yylloc. m4_define([b4_yyerror_args], -[b4_Pure_if([b4_location_if([&yylloc, ])])dnl +[b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) @@ -59,7 +59,7 @@ m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) # b4_lex_param arrives quoted twice, but we want to keep only one level. m4_define([b4_lex_param], m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl -b4_location_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl +b4_locations_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl m4_ifdef([b4_lex_param], b4_lex_param))) @@ -71,18 +71,19 @@ m4_ifdef([b4_lex_param], b4_lex_param))) # b4_int_type(MIN, MAX) # --------------------- # Return the smallest int type able to handle numbers ranging from -# MIN to MAX (included). We overwrite the version from c.m4 which relies -# on "signed char" which is not portable to old K&R compilers. +# MIN to MAX (included). Overwrite the version from c.m4, which +# uses only C89 types, so that the user can override the shorter +# types, and so that pre-C89 compilers are handled correctly. m4_define([b4_int_type], -[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], - b4_ints_in($@, [-128], [127]), [1], [yysigned_char], +[m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8], + b4_ints_in($@, [-128], [127]), [1], [yytype_int8], - b4_ints_in($@, [0], [65535]), [1], [unsigned short int], - b4_ints_in($@, [-32768], [32767]), [1], [short int], + b4_ints_in($@, [0], [65535]), [1], [yytype_uint16], + b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16], m4_eval([0 <= $1]), [1], [unsigned int], - [int])]) + [int])]) ## ----------------- ## @@ -102,7 +103,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[(yyvsp@{m4_eval([$2 - $1])@}m4_ifval([$3], [.$3]))]) +[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))]) @@ -122,7 +123,7 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[(yylsp@{m4_eval([$2 - $1])@})]) +[(yylsp@{($2) - ($1)@})]) @@ -134,16 +135,11 @@ m4_define([b4_rhs_location], m4_changecom() m4_divert(0)dnl @output @output_parser_name@ -b4_copyright([Skeleton parser for Yacc-like parsing with Bison], - [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005])[ +b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' + [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])[ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -153,7 +149,7 @@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison], USER NAME SPACE" below. */ ]b4_identification -m4_if(b4_prefix[], [yy], [], +m4_if(b4_prefix, [yy], [], [/* Substitute the variable and function names. */ #define yyparse b4_prefix[]parse #define yylex b4_prefix[]lex @@ -162,7 +158,7 @@ m4_if(b4_prefix[], [yy], [], #define yychar b4_prefix[]char #define yydebug b4_prefix[]debug #define yynerrs b4_prefix[]nerrs -b4_location_if([#define yylloc b4_prefix[]lloc])])[ +b4_locations_if([#define yylloc b4_prefix[]lloc])])[ ]b4_token_enums_defines(b4_tokens)[ @@ -171,7 +167,7 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ +# define YYDEBUG ]b4_debug_flag[ #endif /* Enabling verbose error messages. */ @@ -179,7 +175,7 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE ]b4_error_verbose[ +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif /* Enabling the token table. */ @@ -187,19 +183,20 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ # define YYTOKEN_TABLE ]b4_token_table[ #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; +[typedef union[]m4_bregexp(b4_stype, [^{], [ YYSTYPE]) +b4_stype /* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + YYSTYPE;], [typedef int YYSTYPE;])[ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif -]b4_location_if([#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +]b4_locations_if([#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; @@ -219,20 +216,51 @@ typedef struct YYLTYPE /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])[ -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ +#ifdef short +# undef short #endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; #endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif ]b4_c_modern[ +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; #endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; #endif +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && ]b4_c_modern[ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS @@ -245,7 +273,24 @@ b4_syncline([@oline@], [@ofile@])[ # endif #endif -#if ! defined (yyoverflow) || YYERROR_VERBOSE +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +]b4_c_function_def([YYID], [static int], [[int i], [i]])[ +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -253,67 +298,76 @@ b4_syncline([@oline@], [@ofile@])[ # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && ]b4_c_modern[ # include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# ifdef __cplusplus -extern "C" { +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined malloc && ! defined _STDLIB_H && ]b4_c_modern[ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined free && ! defined _STDLIB_H && ]b4_c_modern[ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif -# ifdef __cplusplus -} -# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \ - && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short int yyss; + yytype_int16 yyss; YYSTYPE yyvs; - ]b4_location_if([ YYLTYPE yyls; + ]b4_locations_if([ YYLTYPE yyls; ])dnl [}; @@ -322,18 +376,18 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ -]b4_location_if( +]b4_locations_if( [# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)], [# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM)])[ /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ +# if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else @@ -344,7 +398,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif @@ -362,28 +416,22 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (YYID (0)) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL ]b4_final_state_number[ /* YYLAST -- Last index in YYTABLE. */ #define YYLAST ]b4_last[ -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS ]b4_tokens_number[ -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS ]b4_nterms_number[ -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES ]b4_rules_number[ -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES ]b4_states_number[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ @@ -407,7 +455,7 @@ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = ]b4_prhs[ }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = { ]b4_rhs[ @@ -422,7 +470,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { ]b4_tname[ @@ -458,7 +506,7 @@ static const ]b4_int_type_for([b4_defact])[ yydefact[] = ]b4_defact[ }; -/* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = { ]b4_defgoto[ @@ -525,7 +573,7 @@ do \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ + YYPOPSTACK (1); \ goto yybackup; \ } \ else \ @@ -533,7 +581,7 @@ do \ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (YYID (0)) #define YYTERROR 1 @@ -548,7 +596,7 @@ while (0) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ - if (N) \ + if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ @@ -562,7 +610,7 @@ while (0) (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (YYID (0)) #endif @@ -574,8 +622,8 @@ while (0) # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -585,7 +633,7 @@ while (0) /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM -# define YYLEX yylex (]b4_pure_if([&yylval[]b4_location_if([, &yylloc]), ])[YYLEX_PARAM) +# define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM) #else # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ #endif @@ -602,18 +650,20 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value]b4_location_if([, Location])[); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value]b4_locations_if([, Location])[]b4_user_args[); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + +]b4_yy_symbol_print_generate([b4_c_function_def])[ /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | @@ -621,11 +671,11 @@ do { \ `------------------------------------------------------------------*/ ]b4_c_function_def([yy_stack_print], [static void], - [[short int *bottom], [bottom]], - [[short int *top], [top]])[ + [[yytype_int16 *bottom], [bottom]], + [[yytype_int16 *top], [top]])[ { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) + for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -634,7 +684,7 @@ do { \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (YYID (0)) /*------------------------------------------------. @@ -642,23 +692,33 @@ do { \ `------------------------------------------------*/ ]b4_c_function_def([yy_reduce_print], [static void], - [[int yyrule], [yyrule]])[ + [[YYSTYPE *yyvsp], [yyvsp]], + b4_locations_if([[[YYLTYPE *yylsp], [yylsp]], + ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, + ])b4_parse_param)[ { + int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &]b4_rhs_value(yynrhs, yyi + 1)[ + ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl + b4_user_args[); + fprintf (stderr, "\n"); + } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) + yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -692,42 +752,29 @@ int yydebug; #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif +]b4_c_function_def([yystrlen], [static YYSIZE_T], + [[const char *yystr], [yystr]])[ { - const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif +]b4_c_function_def([yystpcpy], [static char *], + [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[ { char *yyd = yydest; const char *yys = yysrc; @@ -753,7 +800,7 @@ yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - size_t yyn = 0; + YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) @@ -788,30 +835,130 @@ yytnamerr (char *yyres, const char *yystr) } # endif -#endif /* YYERROR_VERBOSE */ +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ -#if YYDEBUG -]b4_yysymprint_generate([b4_c_function_def])[ -#endif /* ! YYDEBUG */ -]b4_yydestruct_generate([b4_c_function_def]) +]b4_yydestruct_generate([b4_c_function_def])[ /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif +]b4_c_function_decl([yyparse], [int], + [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[ #else /* ! YYPARSE_PARAM */ -b4_c_function_decl([yyparse], [int], b4_parse_param) +]b4_c_function_decl([yyparse], [int], b4_parse_param)[ #endif /* ! YYPARSE_PARAM */ -m4_divert_push([KILL])# ======================== M4 code. +]m4_divert_push([KILL])# ======================== M4 code. # b4_declare_parser_variables # --------------------------- # Declare the variables that are global, or local to YYPARSE if @@ -824,14 +971,14 @@ int yychar; YYSTYPE yylval; /* Number of syntax errors so far. */ -int yynerrs;b4_location_if([ +int yynerrs;b4_locations_if([ /* Location data for the look-ahead symbol. */ YYLTYPE yylloc;]) ]) m4_divert_pop([KILL])dnl# ====================== End of M4 code. b4_pure_if([], - [b4_declare_parser_variables]) + [b4_declare_parser_variables]) /*----------. @@ -839,12 +986,7 @@ b4_pure_if([], `----------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif +b4_c_function_def([yyparse], [int], [[void *YYPARSE_PARAM], [YYPARSE_PARAM]]) #else /* ! YYPARSE_PARAM */ b4_c_function_def([yyparse], [int], b4_parse_param) #endif @@ -857,6 +999,12 @@ b4_c_function_def([yyparse], [int], b4_parse_param) int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif /* Three stacks and their tools: `yyss': related to states, @@ -867,35 +1015,35 @@ b4_c_function_def([yyparse], [int], b4_parse_param) to reallocate them elsewhere. */ /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; YYSTYPE *yyvsp; -]b4_location_if( +]b4_locations_if( [[ /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; - /* The locations where the error started and ended. */ + /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2];]])[ -#define YYPOPSTACK (yyvsp--, yyssp--]b4_location_if([, yylsp--])[) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -]b4_location_if([ YYLTYPE yyloc;])[ +]b4_locations_if([ YYLTYPE yyloc;])[ - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); @@ -911,7 +1059,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) yyssp = yyss; yyvsp = yyvs; -]b4_location_if([[ yylsp = yyls; +]b4_locations_if([[ yylsp = yyls; #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; @@ -921,7 +1069,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl - /* User initialization code. */ + /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl @@ -939,8 +1087,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -953,12 +1100,12 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; -]b4_location_if([ YYLTYPE *yyls1 = yyls;])[ + yytype_int16 *yyss1 = yyss; +]b4_locations_if([ YYLTYPE *yyls1 = yyls;])[ /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a @@ -967,9 +1114,9 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), -]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[ +]b4_locations_if([ &yyls1, yysize * sizeof (*yylsp),])[ &yystacksize); -]b4_location_if([ yyls = yyls1;])[ +]b4_locations_if([ yyls = yyls1;])[ yyss = yyss1; yyvs = yyvs1; } @@ -985,14 +1132,14 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; yystacksize = YYMAXDEPTH; { - short int *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); -]b4_location_if([ YYSTACK_RELOCATE (yyls);])[ +]b4_locations_if([ YYSTACK_RELOCATE (yyls);])[ # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1002,7 +1149,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; -]b4_location_if([ yylsp = yyls + yysize - 1;])[ +]b4_locations_if([ yylsp = yyls + yysize - 1;])[ YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1020,12 +1167,10 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ -/* yyresume: */ + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; @@ -1067,22 +1212,21 @@ yybackup: if (yyn == YYFINAL) YYACCEPT; - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -]b4_location_if([ *++yylsp = yylloc;])[ - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + yystate = yyn; + *++yyvsp = yylval; +]b4_locations_if([ *++yylsp = yylloc;])[ goto yynewstate; @@ -1113,27 +1257,25 @@ yyreduce: GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; -]b4_location_if( -[[ /* Default location. */ - YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[ +]b4_locations_if( +[[ /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[ YY_REDUCE_PRINT (yyn); switch (yyn) - ]{ - b4_actions + { + ]b4_actions +/* Line __line__ of yacc.c. */ +b4_syncline([@oline@], [@ofile@])[ default: break; } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@]) - -[ yyvsp -= yylen; - yyssp -= yylen; -]b4_location_if([ yylsp -= yylen;])[ - + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -]b4_location_if([ *++yylsp = yyloc;])[ +]b4_locations_if([ *++yylsp = yyloc;])[ /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -1158,113 +1300,44 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - char *yymsg = 0; -# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - - if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yymsg; - int yyi = 0; - while ((*yyp = *yyf)) - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - yyerror (]b4_yyerror_args[yymsg); +#if ! YYERROR_VERBOSE + yyerror (]b4_yyerror_args[YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - } - else - { - yyerror (]b4_yyerror_args[YY_("syntax error")); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (]b4_yyerror_args[yymsg); + } + else + { + yyerror (]b4_yyerror_args[YY_("syntax error")); + if (yysize != 0) goto yyexhaustedlab; - } - } - else -#endif /* YYERROR_VERBOSE */ - yyerror (]b4_yyerror_args[YY_("syntax error")); + } + } +#endif } -]b4_location_if([[ yyerror_range[0] = yylloc;]])[ +]b4_locations_if([[ yyerror_range[0] = yylloc;]])[ if (yyerrstatus == 3) { @@ -1272,14 +1345,15 @@ yyerrlab: error, discard it. */ if (yychar <= YYEOF) - { + { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; - } + } else { - yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[); + yydestruct ("Error: discarding", + yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); yychar = YYEMPTY; } } @@ -1297,13 +1371,15 @@ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (0) + if (/*CONSTCOND*/ 0) goto yyerrorlab; -]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen]; - yylsp -= yylen; - ]])[yyvsp -= yylen; - yyssp -= yylen; +]b4_locations_if([[ yyerror_range[0] = yylsp[1-yylen]; +]])[ /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -1332,9 +1408,10 @@ yyerrlab1: if (yyssp == yyss) YYABORT; -]b4_location_if([[ yyerror_range[0] = *yylsp;]])[ - yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[); - YYPOPSTACK; +]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[ + yydestruct ("Error: popping", + yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } @@ -1343,14 +1420,14 @@ yyerrlab1: YYACCEPT; *++yyvsp = yylval; -]b4_location_if([[ +]b4_locations_if([[ yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); + the look-ahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc;]])[ - /* Shift the error token. */ + /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; @@ -1384,40 +1461,45 @@ yyexhaustedlab: yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval]b4_location_if([, &yylloc])[); + yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[); - YYPOPSTACK; + yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); + YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif - return yyresult; +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); ]} b4_epilogue -m4_if(b4_defines_flag, 0, [], +b4_defines_if( [@output @output_header_name@ -b4_copyright([Skeleton parser for Yacc-like parsing with Bison], - [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005]) - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' + [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) b4_token_enums_defines(b4_tokens) -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; +[typedef union[]m4_bregexp(b4_stype, [^{], [ YYSTYPE]) +b4_stype /* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + YYSTYPE;], [typedef int YYSTYPE;]) # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -1427,8 +1509,8 @@ b4_syncline([@oline@], [@ofile@])], b4_pure_if([], [extern YYSTYPE b4_prefix[]lval;]) -b4_location_if( -[#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +b4_locations_if( +[#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; @@ -1441,7 +1523,7 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif -m4_if(b4_pure, [0], -[extern YYLTYPE b4_prefix[]lloc;]) -]) -]) +b4_pure_if([], + [extern YYLTYPE b4_prefix[]lloc;]) +])dnl b4_locations_if +])dnl b4_defines_if diff --git a/src/bin/bison/doc/FAQ b/src/bin/bison/doc/FAQ deleted file mode 100644 index 37aea57cb9..0000000000 --- a/src/bin/bison/doc/FAQ +++ /dev/null @@ -1,109 +0,0 @@ -Frequently Asked Questions about Bison: - ----------------------------------------------------------------------- - -Q1. Is Bison Y2K compliant? - -A1. If you're looking for a guarantee or certification, I can't - provide it. With a little thought you can answer this one for - yourself, though. (Hint: does a parser generator rely on the - date or time for anything?) If you're still confused, see - http://www.gnu.org/software/year2000.html for more information. - ----------------------------------------------------------------------- - -Q2. I can't build Bison because "make" complains that "msgfmt" is not - found. What should I do? - -A2. Like most GNU packages with internationalization support, that - feature is turned on by default. If you have problems building - in the "po" subdirectory, it indicates that your system's - internationalization support is lacking. You can re-configure - Bison with "--disable-nls" to turn off this support, or you can - install GNU gettext from ftp://ftp.gnu.org/gnu/gettext/ and - re-configure Bison. See the file "ABOUT-NLS" for more - information. - ----------------------------------------------------------------------- - -Q3. I'm having trouble using Bison. Where can I find help? - -A3. First, read the fine manual which comes with bison. Beyond that, - you can send mail to . This mailing list is - intended to be populated with people who are willing to answer - questions about using and installing Bison. Please keep in mind - that (most of) the people on the list have aspects of their lives - which are not related to Bison (!), so you may not receive an - answer to your question right away. This can be frustrating, but - please try not to honk them off; remember that any help they - provide is purely voluntary and out of the kindness of their - hearts. - ----------------------------------------------------------------------- - -Q4. I found a bug. What should I include in the bug report? - -A4. Before you send a bug report, make sure you are using the latest - version. Check ftp://ftp.gnu.org/pub/gnu/bison/ or one of its - mirrors. Be sure to include the version number in your bug - report. If the bug is present in the latest version but not in a - previous version, try to determine the most recent version which - did not contain the bug. - - If the bug is parser-related, you should include the smallest - grammar you can which demonstrates the bug. The grammar file - should also be complete (i.e., I should be able to run it through - Bison without having to edit or add anything). The smaller and - simpler the grammar, the easier it will be to fix the bug. - - Include information about your compilation environment, including - your operating system's name and version and your compiler's name - and version. If you have trouble compiling, you should also - include a transcript of the build session, starting with the - invocation of `configure'. Depending on the nature of the bug, - you may be asked to send additional files as well (such as - `config.h' or `config.cache'). - - Patches are most welcome, but not required. That is, do not - hesitate to send a bug report just because you can not provide a - fix. - - Send bug reports to . - ----------------------------------------------------------------------- - -Q5. Will Bison ever have C++ support? - -A5. Yes, it's in the works. Things are very chaotic right now, but - what little information floats around is posted to the bug-bison - mailing list. If you're interested in testing C++ support when - it becomes available, please consider subscribing to the list, - especially if you are willing to beta test other releases as - well. - ----------------------------------------------------------------------- - -Q6. What is involved in being a beta tester? - -A6. It's not terribly involved. Basically, you would download a test - release, compile it, and use it to build and run a parser or two. - After that, you would submit either a bug report or a message - saying that everything is okay. It is important to report - successes as well as failures because test releases eventually - become mainstream releases, but only if they are adequately - tested. If no one tests, development is essentially halted. - - Beta testers are particularly needed for operating systems to - which I do not have access. I currently have easy access to - Linux (x86 glibc 2.1), Solaris (SPARC) 2.6 and 2.7, and HP-UX - 10.20. Reports about other operating systems are especially - welcome. - ----------------------------------------------------------------------- - -Q7. How do I join the help-bison and bug-bison mailing lists? - -A7. See http://www.gnu.org/ (the section about "GNU mailing lists") - for more information. - ----------------------------------------------------------------------- diff --git a/src/bin/bison/doc/Makefile.am b/src/bin/bison/doc/Makefile.am index b7b2d4ea03..2466b26af8 100644 --- a/src/bin/bison/doc/Makefile.am +++ b/src/bin/bison/doc/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -*-Makefile-*- -## Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +## Copyright (C) 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ info_TEXINFOS = bison.texinfo man_MANS = bison.1 bison_TEXINFOS = gpl.texi fdl.texi -EXTRA_DIST = FAQ bison.1 refcard.tex +EXTRA_DIST = bison.1 refcard.tex CLEANFILES = refcard.dvi refcard.log refcard.ps bison.fns diff --git a/src/bin/bison/doc/Makefile.in b/src/bin/bison/doc/Makefile.in index ab28cb94cf..6c87d7b8b3 100644 --- a/src/bin/bison/doc/Makefile.in +++ b/src/bin/bison/doc/Makefile.in @@ -40,8 +40,8 @@ DIST_COMMON = $(bison_TEXINFOS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/stamp-vti \ $(srcdir)/version.texi ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ - $(top_srcdir)/m4/bison-i18n.m4 $(top_srcdir)/m4/cxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \ + $(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \ $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \ $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \ @@ -58,11 +58,14 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \ $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strndup.m4 \ - $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/subpipe.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ + $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \ + $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \ $(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \ $(top_srcdir)/m4/ulonglong_gl.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/warning.m4 \ + $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ + $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \ $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -91,8 +94,6 @@ NROFF = nroff MANS = $(man_MANS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALLOCA_H = @ALLOCA_H@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ @@ -102,6 +103,8 @@ AUTOM4TE = @AUTOM4TE@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON_CXX_WORKS = @BISON_CXX_WORKS@ +BISON_CXX_WORKS_FALSE = @BISON_CXX_WORKS_FALSE@ +BISON_CXX_WORKS_TRUE = @BISON_CXX_WORKS_TRUE@ BISON_LOCALEDIR = @BISON_LOCALEDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -161,6 +164,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STDBOOL_H = @STDBOOL_H@ STRIP = @STRIP@ +UNISTD_H = @UNISTD_H@ USE_NLS = @USE_NLS@ VALGRIND = @VALGRIND@ VERSION = @VERSION@ @@ -217,7 +221,7 @@ AM_MAKEINFOFLAGS = --no-split info_TEXINFOS = bison.texinfo man_MANS = bison.1 bison_TEXINFOS = gpl.texi fdl.texi -EXTRA_DIST = FAQ bison.1 refcard.tex +EXTRA_DIST = bison.1 refcard.tex CLEANFILES = refcard.dvi refcard.log refcard.ps bison.fns all: all-am diff --git a/src/bin/bison/doc/bison.info b/src/bin/bison/doc/bison.info index 86206de832..7907515fcf 100644 --- a/src/bin/bison/doc/bison.info +++ b/src/bin/bison/doc/bison.info @@ -1,10 +1,10 @@ -This is bison.info, produced by makeinfo version 4.7 from bison.texinfo. +This is bison.info, produced by makeinfo version 4.8 from bison.texinfo. - This manual is for GNU Bison (version 2.1, 16 September 2005), the -GNU parser generator. + This manual is for GNU Bison (version 2.3, 30 May 2006), the GNU +parser generator. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, 1999, -2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -29,11 +29,11 @@ File: bison.info, Node: Top, Next: Introduction, Up: (dir) Bison ***** -This manual is for GNU Bison (version 2.1, 16 September 2005), the GNU -parser generator. +This manual is for GNU Bison (version 2.3, 30 May 2006), the GNU parser +generator. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, 1999, -2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -94,9 +94,10 @@ The Concepts of Bison Writing GLR Parsers -* Simple GLR Parsers:: Using GLR parsers on unambiguous grammars -* Merging GLR Parses:: Using GLR parsers to resolve ambiguities -* Compiler Requirements:: GLR parsers require a modern C compiler +* Simple GLR Parsers:: Using GLR parsers on unambiguous grammars. +* Merging GLR Parses:: Using GLR parsers to resolve ambiguities. +* GLR Semantic Actions:: Deferred semantic actions have special concerns. +* Compiler Requirements:: GLR parsers require a modern C compiler. Examples @@ -174,6 +175,7 @@ Tracking Locations Bison Declarations +* Require Decl:: Requiring a Bison version. * Token Decl:: Declaring terminal symbols. * Precedence Decl:: Declaring terminals with precedence and associativity. * Union Decl:: Declaring the set of all semantic value types. @@ -271,6 +273,14 @@ Frequently Asked Questions * How Can I Reset the Parser:: `yyparse' Keeps some State * Strings are Destroyed:: `yylval' Loses Track of Strings * Implementing Gotos/Loops:: Control Flow in the Calculator +* Multiple start-symbols:: Factoring closely related grammars +* Secure? Conform?:: Is Bison POSIX safe? +* I can't build Bison:: Troubleshooting +* Where can I find help?:: Troubleshouting +* Bug Reports:: Troublereporting +* Other Languages:: Parsers in Java and others +* Beta Testing:: Experimenting development versions +* Mailing Lists:: Meeting other Bison users Copying This Manual @@ -282,17 +292,17 @@ File: bison.info, Node: Introduction, Next: Conditions, Prev: Top, Up: Top Introduction ************ -"Bison" is a general-purpose parser generator that converts a grammar -description for an LALR(1) context-free grammar into a C program to -parse that grammar. Once you are proficient with Bison, you may use it -to develop a wide range of language parsers, from those used in simple -desk calculators to complex programming languages. +"Bison" is a general-purpose parser generator that converts an +annotated context-free grammar into an LALR(1) or GLR parser for that +grammar. Once you are proficient with Bison, you can use it to develop +a wide range of language parsers, from those used in simple desk +calculators to complex programming languages. Bison is upward compatible with Yacc: all properly-written Yacc grammars ought to work with Bison with no change. Anyone familiar with Yacc should be able to use Bison with little trouble. You need to be -fluent in C programming in order to use Bison or to understand this -manual. +fluent in C or C++ programming in order to use Bison or to understand +this manual. We begin with tutorial chapters that explain the basic concepts of using Bison and show three explained examples, each building on the @@ -304,7 +314,7 @@ Bison in detail. it Yacc-compatible. Wilfred Hansen of Carnegie Mellon University added multi-character string literals and other features. - This edition corresponds to version 2.1 of Bison. + This edition corresponds to version 2.3 of Bison.  File: bison.info, Node: Conditions, Next: Copying, Prev: Introduction, Up: Top @@ -312,10 +322,11 @@ File: bison.info, Node: Conditions, Next: Copying, Prev: Introduction, Up: T Conditions for Using Bison ************************** -As of Bison version 1.24, we have changed the distribution terms for -`yyparse' to permit using Bison's output in nonfree programs when Bison -is generating C code for LALR(1) parsers. Formerly, these parsers -could be used only in programs that were free software. +The distribution terms for Bison-generated parsers permit using the +parsers in nonfree programs. Before Bison version 2.2, these extra +permissions applied only when Bison was generating LALR(1) parsers in +C. And before Bison version 1.24, Bison-generated parsers could be +used only in programs that were free software. The other GNU programming tools, such as the GNU C compiler, have never had such a requirement. They could always be used for nonfree @@ -325,10 +336,11 @@ License to all of the Bison source code. The output of the Bison utility--the Bison parser file--contains a verbatim copy of a sizable piece of Bison, which is the code for the -`yyparse' function. (The actions from your grammar are inserted into -this function at one point, but the rest of the function is not -changed.) When we applied the GPL terms to the code for `yyparse', the -effect was to restrict the use of Bison output to free software. +parser's implementation. (The actions from your grammar are inserted +into this implementation at one point, but most of the rest of the +implementation is not changed.) When we applied the GPL terms to the +skeleton code for the parser's implementation, the effect was to +restrict the use of Bison output to free software. We didn't change the terms because of sympathy for people who want to make software proprietary. *Software should be free.* But we @@ -337,12 +349,10 @@ encourage people to make other software free. So we decided to make the practical conditions for using Bison match the practical conditions for using the other GNU tools. - This exception applies only when Bison is generating C code for an -LALR(1) parser; otherwise, the GPL terms operate as usual. You can -tell whether the exception applies to your `.c' output file by -inspecting it to see whether it says "As a special exception, when this -file is copied by Bison into a Bison output file, you may use that -output file without restriction." + This exception applies when Bison is generating code for a parser. +You can tell whether the exception applies to a Bison output file by +inspecting the file for text beginning with "As a special +exception...". The text spells out the exact terms of the exception.  File: bison.info, Node: Copying, Next: Concepts, Prev: Conditions, Up: Top @@ -768,8 +778,8 @@ uniquely determined by the preceding input and a fixed, finite portion (called a "look-ahead") of the remaining input. A context-free grammar can be "ambiguous", meaning that there are multiple ways to apply the grammar rules to get the same inputs. Even unambiguous grammars can be -"non-deterministic", meaning that no fixed look-ahead always suffices -to determine the next grammar rule to apply. With the proper +"nondeterministic", meaning that no fixed look-ahead always suffices to +determine the next grammar rule to apply. With the proper declarations, Bison is also able to parse these more general context-free grammars, using a technique known as GLR parsing (for Generalized LR). Bison's GLR parsers are able to handle any @@ -1004,9 +1014,10 @@ merged result. * Menu: -* Simple GLR Parsers:: Using GLR parsers on unambiguous grammars -* Merging GLR Parses:: Using GLR parsers to resolve ambiguities -* Compiler Requirements:: GLR parsers require a modern C compiler +* Simple GLR Parsers:: Using GLR parsers on unambiguous grammars. +* Merging GLR Parses:: Using GLR parsers to resolve ambiguities. +* GLR Semantic Actions:: Deferred semantic actions have special concerns. +* Compiler Requirements:: GLR parsers require a modern C compiler.  File: bison.info, Node: Simple GLR Parsers, Next: Merging GLR Parses, Up: GLR Parsers @@ -1164,7 +1175,7 @@ difference since they cannot be used within the same enumerated type declaration.  -File: bison.info, Node: Merging GLR Parses, Next: Compiler Requirements, Prev: Simple GLR Parsers, Up: GLR Parsers +File: bison.info, Node: Merging GLR Parses, Next: GLR Semantic Actions, Prev: Simple GLR Parsers, Up: GLR Parsers 1.5.2 Using GLR to Resolve Ambiguities -------------------------------------- @@ -1294,9 +1305,47 @@ ambiguity would be unresolvable, and the parser will report an error during any parse that results in the offending merge.  -File: bison.info, Node: Compiler Requirements, Prev: Merging GLR Parses, Up: GLR Parsers +File: bison.info, Node: GLR Semantic Actions, Next: Compiler Requirements, Prev: Merging GLR Parses, Up: GLR Parsers -1.5.3 Considerations when Compiling GLR Parsers +1.5.3 GLR Semantic Actions +-------------------------- + +By definition, a deferred semantic action is not performed at the same +time as the associated reduction. This raises caveats for several +Bison features you might use in a semantic action in a GLR parser. + + In any semantic action, you can examine `yychar' to determine the +type of the look-ahead token present at the time of the associated +reduction. After checking that `yychar' is not set to `YYEMPTY' or +`YYEOF', you can then examine `yylval' and `yylloc' to determine the +look-ahead token's semantic value and location, if any. In a +nondeferred semantic action, you can also modify any of these variables +to influence syntax analysis. *Note Look-Ahead Tokens: Look-Ahead. + + In a deferred semantic action, it's too late to influence syntax +analysis. In this case, `yychar', `yylval', and `yylloc' are set to +shallow copies of the values they had at the time of the associated +reduction. For this reason alone, modifying them is dangerous. +Moreover, the result of modifying them is undefined and subject to +change with future versions of Bison. For example, if a semantic +action might be deferred, you should never write it to invoke +`yyclearin' (*note Action Features::) or to attempt to free memory +referenced by `yylval'. + + Another Bison feature requiring special consideration is `YYERROR' +(*note Action Features::), which you can invoke in a semantic action to +initiate error recovery. During deterministic GLR operation, the +effect of `YYERROR' is the same as its effect in an LALR(1) parser. In +a deferred semantic action, its effect is undefined. + + Also, see *Note Default Action for Locations: Location Default +Action, which describes a special usage of `YYLLOC_DEFAULT' in GLR +parsers. + + +File: bison.info, Node: Compiler Requirements, Prev: GLR Semantic Actions, Up: GLR Parsers + +1.5.4 Considerations when Compiling GLR Parsers ----------------------------------------------- The GLR parsers require a compiler for ISO C89 or later. In addition, @@ -1391,16 +1440,18 @@ analyzer function `yylex', the error reporting function `yyerror' and the parser function `yyparse' itself. This also includes numerous identifiers used for internal purposes. Therefore, you should avoid using C identifiers starting with `yy' or `YY' in the Bison grammar -file except for the ones defined in this manual. +file except for the ones defined in this manual. Also, you should +avoid using the C identifiers `malloc' and `free' for anything other +than their usual meanings. In some cases the Bison parser file includes system headers, and in those cases your code should respect the identifiers reserved by those -headers. On some non-GNU hosts, `', `', and -`' are included as needed to declare memory allocators and -related types. `' is included if message translation is in -use (*note Internationalization::). Other system headers may be -included if you define `YYDEBUG' to a nonzero value (*note Tracing Your -Parser: Tracing.). +headers. On some non-GNU hosts, `', `', +`', and `' are included as needed to declare memory +allocators and related types. `' is included if message +translation is in use (*note Internationalization::). Other system +headers may be included if you define `YYDEBUG' to a nonzero value +(*note Tracing Your Parser: Tracing.).  File: bison.info, Node: Stages, Next: Grammar Layout, Prev: Bison Parser, Up: Concepts @@ -1491,8 +1542,8 @@ under BSD Unix 4.3; each produces a usable, though limited, interactive desk-top calculator. These examples are simple, but Bison grammars for real programming -languages are written the same way. You can copy these examples out of -the Info file and into a source file to try them. +languages are written the same way. You can copy these examples into a +source file to try them. * Menu: @@ -1611,8 +1662,8 @@ Here are the grammar rules for the reverse polish notation calculator. The groupings of the rpcalc "language" defined here are the expression (given the name `exp'), the line of input (`line'), and the complete input transcript (`input'). Each of these nonterminal symbols -has several alternate rules, joined by the `|' punctuator which is read -as "or". The following sections explain what these rules mean. +has several alternate rules, joined by the vertical bar `|' which is +read as "or". The following sections explain what these rules mean. The semantics of the language is determined by the actions taken when a grouping is recognized. The actions are the C code that appears @@ -2242,7 +2293,7 @@ calculator that provides other mathematical functions such as `sin', It is easy to add new operators to the infix calculator as long as they are only single-character literals. The lexical analyzer `yylex' -passes back all nonnumber characters as tokens, so new grammar rules +passes back all nonnumeric characters as tokens, so new grammar rules suffice for adding a new operator. But we want something more flexible: built-in functions whose syntax has this form: @@ -2491,8 +2542,8 @@ found, a pointer to that symbol is returned; otherwise zero is returned. The function `yylex' must now recognize variables, numeric values, and the single-character arithmetic operators. Strings of alphanumeric -characters with a leading non-digit are recognized as either variables -or functions depending on what the symbol table says about them. +characters with a leading letter are recognized as either variables or +functions depending on what the symbol table says about them. The string is passed to `getsym' for look up in the symbol table. If the name appears in the table, a pointer to its location and its type @@ -2655,6 +2706,10 @@ get the declarations from a header file. If you don't need any C declarations, you may omit the `%{' and `%}' delimiters that bracket this section. + The PROLOGUE section is terminated by the the first occurrence of +`%}' that is outside a comment, a string literal, or a character +constant. + You may have more than one PROLOGUE section, intermixed with the BISON DECLARATIONS. This allows you to have C and Bison declarations that refer to each other. For example, the `%union' declaration may @@ -2744,9 +2799,9 @@ function returns a token type code to indicate what kind of token has been read. You don't need to know what the code value is; you can use the symbol to stand for it. - A "nonterminal symbol" stands for a class of syntactically equivalent -groupings. The symbol name is used in writing grammar rules. By -convention, it should be all lower case. + A "nonterminal symbol" stands for a class of syntactically +equivalent groupings. The symbol name is used in writing grammar rules. +By convention, it should be all lower case. Symbol names can contain letters, digits (not at the beginning), underscores and periods. Periods make sense only in nonterminals. @@ -2832,7 +2887,7 @@ into a separate header file `NAME.tab.h' which you can include in the other source files that need it. *Note Invoking Bison: Invocation. If you want to write a grammar that is portable to any Standard C -host, you must use only non-null character tokens taken from the basic +host, you must use only nonnull character tokens taken from the basic execution character set of Standard C. This set consists of the ten digits, the 52 lower- and upper-case English letters, and the characters in the following C-language string: @@ -2887,13 +2942,28 @@ semantics of the rule. An action looks like this: {C STATEMENTS} -Usually there is only one action and it follows the components. *Note -Actions::. +This is an example of "braced code", that is, C code surrounded by +braces, much like a compound statement in C. Braced code can contain +any sequence of C tokens, so long as its braces are balanced. Bison +does not check the braced code for correctness directly; it merely +copies the code to the output file, where the C compiler can check it. + + Within braced code, the balanced-brace count is not affected by +braces within comments, string literals, or character constants, but it +is affected by the C digraphs `<%' and `%>' that represent braces. At +the top level braced code must be terminated by `}' and not by a +digraph. Bison does not look for trigraphs, so if braced code uses +trigraphs you should ensure that they do not affect the nesting of +braces or the boundaries of comments, string literals, or character +constants. + + Usually there is only one action and it follows the components. +*Note Actions::. Multiple rules for the same RESULT can be written separately or can be joined with the vertical-bar character `|' as follows: - RESULT: RULE1-COMPONENTS... + RESULT: RULE1-COMPONENTS... | RULE2-COMPONENTS... ... ; @@ -3006,8 +3076,10 @@ specify some other type, define `YYSTYPE' as a macro, like this: #define YYSTYPE double -This macro definition must go in the prologue of the grammar file -(*note Outline of a Bison Grammar: Grammar Outline.). +`YYSTYPE''s replacement list should be a type name that does not +contain parentheses or square brackets. This macro definition must go +in the prologue of the grammar file (*note Outline of a Bison Grammar: +Grammar Outline.).  File: bison.info, Node: Multiple Types, Next: Actions, Prev: Value Type, Up: Semantics @@ -3045,18 +3117,12 @@ most actions is to compute a semantic value for the grouping built by the rule from the semantic values associated with tokens or smaller groupings. - An action consists of C statements surrounded by braces, much like a -compound statement in C. An action can contain any sequence of C -statements. Bison does not look for trigraphs, though, so if your C -code uses trigraphs you should ensure that they do not affect the -nesting of braces or the boundaries of comments, strings, or character -literals. - - An action can be placed at any position in the rule; it is executed -at that position. Most rules have just one action at the end of the -rule, following all the components. Actions in the middle of a rule -are tricky and used only for special purposes (*note Actions in -Mid-Rule: Mid-Rule Actions.). + An action consists of braced code containing C statements, and can be +placed at any position in the rule; it is executed at that position. +Most rules have just one action at the end of the rule, following all +the components. Actions in the middle of a rule are tricky and used +only for special purposes (*note Actions in Mid-Rule: Mid-Rule +Actions.). The C code in an action can refer to the semantic values of the components matched by the rule with the construct `$N', which stands for @@ -3113,6 +3179,11 @@ which you can use this reliably: As long as `bar' is used only in the fashion shown here, `$0' always refers to the `expr' which precedes `bar' in the definition of `foo'. + It is also possible to access the semantic value of the look-ahead +token, if any, from a semantic action. This semantic value is stored +in `yylval'. *Note Special Features for Use in Actions: Action +Features. +  File: bison.info, Node: Action Types, Next: Mid-Rule Actions, Prev: Actions, Up: Semantics @@ -3208,6 +3279,36 @@ the earlier action is used to restore the prior list of variables. This removes the temporary `let'-variable from the list so that it won't appear to exist while the rest of the program is parsed. + In the above example, if the parser initiates error recovery (*note +Error Recovery::) while parsing the tokens in the embedded statement +`stmt', it might discard the previous semantic context `$5' +without restoring it. Thus, `$5' needs a destructor (*note +Freeing Discarded Symbols: Destructor Decl.). However, Bison currently +provides no means to declare a destructor for a mid-rule action's +semantic value. + + One solution is to bury the mid-rule action inside a nonterminal +symbol and to declare a destructor for that symbol: + + %type let + %destructor { pop_context ($$); } let + + %% + + stmt: let stmt + { $$ = $2; + pop_context ($1); } + ; + + let: LET '(' var ')' + { $$ = push_context (); + declare_variable ($3); } + ; + +Note that the action is now at the end of its rule. Any mid-rule +action can be converted to an end-of-rule action in this way, and this +is what Bison actually does to implement mid-rule actions. + Taking action before a rule is completely recognized often leads to conflicts since the parser must commit to a parse in order to execute the action. For example, the following two rules, without mid-rule @@ -3273,10 +3374,7 @@ which serves as a subroutine: ; Now Bison can execute the action in the rule for `subroutine' without -deciding which rule for `compound' it will eventually use. Note that -the action is now at the end of its rule. Any mid-rule action can be -converted to an end-of-rule action in this way, and this is what Bison -actually does to implement mid-rule actions. +deciding which rule for `compound' it will eventually use.  File: bison.info, Node: Locations, Next: Declarations, Prev: Semantics, Up: Grammar File @@ -3306,9 +3404,10 @@ File: bison.info, Node: Location Type, Next: Actions and Locations, Up: Locat Defining a data type for locations is much simpler than for semantic values, since all tokens and groupings always use the same type. - The type of locations is specified by defining a macro called -`YYLTYPE'. When `YYLTYPE' is not defined, Bison uses a default -structure type with four members: + You can specify the type of locations by defining a macro called +`YYLTYPE', just as you can specify the semantic value type by defining +`YYSTYPE' (*note Value Type::). When `YYLTYPE' is not defined, Bison +uses a default structure type with four members: typedef struct YYLTYPE { @@ -3378,6 +3477,10 @@ automatic. The example above simply rewrites this way: } } + It is also possible to access the location of the look-ahead token, +if any, from a semantic action. This location is stored in `yylloc'. +*Note Special Features for Use in Actions: Action Features. +  File: bison.info, Node: Location Default Action, Prev: Actions and Locations, Up: Locations @@ -3389,7 +3492,9 @@ locations are much more general than semantic values, there is room in the output parser to redefine the default action to take for each rule. The `YYLLOC_DEFAULT' macro is invoked each time a rule is matched, before the associated action is run. It is also invoked while -processing a syntax error, to compute the error's location. +processing a syntax error, to compute the error's location. Before +reporting an unresolvable syntactic ambiguity, a GLR parser invokes +`YYLLOC_DEFAULT' recursively to compute the location of that ambiguity. Most of the time, this macro is general enough to suppress location dedicated code from semantic actions. @@ -3398,9 +3503,11 @@ dedicated code from semantic actions. the location of the grouping (the result of the computation). When a rule is matched, the second parameter identifies locations of all right hand side elements of the rule being matched, and the third parameter -is the size of the rule's right hand side. When processing a syntax -error, the second parameter identifies locations of the symbols that -were discarded during error processing, and the third parameter is the +is the size of the rule's right hand side. When a GLR parser reports +an ambiguity, which of multiple candidate right hand sides it passes to +`YYLLOC_DEFAULT' is undefined. When processing a syntax error, the +second parameter identifies locations of the symbols that were +discarded during error processing, and the third parameter is the number of discarded symbols. By default, `YYLLOC_DEFAULT' is defined this way: @@ -3464,6 +3571,7 @@ Language and Grammar.). * Menu: +* Require Decl:: Requiring a Bison version. * Token Decl:: Declaring terminal symbols. * Precedence Decl:: Declaring terminals with precedence and associativity. * Union Decl:: Declaring the set of all semantic value types. @@ -3476,9 +3584,21 @@ Language and Grammar.). * Decl Summary:: Table of all Bison declarations.  -File: bison.info, Node: Token Decl, Next: Precedence Decl, Up: Declarations +File: bison.info, Node: Require Decl, Next: Token Decl, Up: Declarations -3.7.1 Token Type Names +3.7.1 Require a Version of Bison +-------------------------------- + +You may require the minimum version of Bison to process the grammar. If +the requirement is not met, `bison' exits with an error (exit status +63). + + %require "VERSION" + + +File: bison.info, Node: Token Decl, Next: Precedence Decl, Prev: Require Decl, Up: Declarations + +3.7.2 Token Type Names ---------------------- The basic way to declare a token type name (terminal symbol) is as @@ -3539,7 +3659,7 @@ the token type code number (*note Calling Convention::).  File: bison.info, Node: Precedence Decl, Next: Union Decl, Prev: Token Decl, Up: Declarations -3.7.2 Operator Precedence +3.7.3 Operator Precedence ------------------------- Use the `%left', `%right' or `%nonassoc' declaration to declare a token @@ -3578,13 +3698,12 @@ for all the SYMBOLS:  File: bison.info, Node: Union Decl, Next: Type Decl, Prev: Precedence Decl, Up: Declarations -3.7.3 The Collection of Value Types +3.7.4 The Collection of Value Types ----------------------------------- The `%union' declaration specifies the entire collection of possible -data types for semantic values. The keyword `%union' is followed by a -pair of braces containing the same thing that goes inside a `union' in -C. +data types for semantic values. The keyword `%union' is followed by +braced code containing the same thing that goes inside a `union' in C. For example: @@ -3606,8 +3725,12 @@ example: symrec *tptr; } - specifies the union tag `value', so the corresponding C type is -`union value'. If you do not specify a tag, it defaults to `YYSTYPE'. +specifies the union tag `value', so the corresponding C type is `union +value'. If you do not specify a tag, it defaults to `YYSTYPE'. + + As another extension to POSIX, you may specify multiple `%union' +declarations; their contents are concatenated. However, only the first +`%union' declaration can specify a tag. Note that, unlike making a `union' declaration in C, you need not write a semicolon after the closing brace. @@ -3615,7 +3738,7 @@ write a semicolon after the closing brace.  File: bison.info, Node: Type Decl, Next: Initial Action Decl, Prev: Union Decl, Up: Declarations -3.7.4 Nonterminal Symbols +3.7.5 Nonterminal Symbols ------------------------- When you use `%union' to specify multiple value types, you must declare @@ -3637,7 +3760,7 @@ terminal symbol. All kinds of token declarations allow `'.  File: bison.info, Node: Initial Action Decl, Next: Destructor Decl, Prev: Type Decl, Up: Declarations -3.7.5 Performing Actions before Parsing +3.7.6 Performing Actions before Parsing --------------------------------------- Sometimes your parser needs to perform some initializations before @@ -3645,48 +3768,46 @@ parsing. The `%initial-action' directive allows for such arbitrary code. -- Directive: %initial-action { CODE } - Declare that the CODE must be invoked before parsing each time - `yyparse' is called. The CODE may use `$$' and `@$' -- initial - value and location of the look-ahead -- and the `%parse-param'. + Declare that the braced CODE must be invoked before parsing each + time `yyparse' is called. The CODE may use `$$' and `@$' -- + initial value and location of the look-ahead -- and the + `%parse-param'. For instance, if your locations use a file name, you may use %parse-param { char const *file_name }; %initial-action { - @$.begin.filename = @$.end.filename = file_name; + @$.initialize (file_name); };  File: bison.info, Node: Destructor Decl, Next: Expect Decl, Prev: Initial Action Decl, Up: Declarations -3.7.6 Freeing Discarded Symbols +3.7.7 Freeing Discarded Symbols ------------------------------- -Some symbols can be discarded by the parser. During error recovery -(*note Error Recovery::), symbols already pushed on the stack and -tokens coming from the rest of the file are discarded until the parser -falls on its feet. If the parser runs out of memory, all the symbols -on the stack must be discarded. Even if the parser succeeds, it must -discard the start symbol. +During error recovery (*note Error Recovery::), symbols already pushed +on the stack and tokens coming from the rest of the file are discarded +until the parser falls on its feet. If the parser runs out of memory, +or if it returns via `YYABORT' or `YYACCEPT', all the symbols on the +stack must be discarded. Even if the parser succeeds, it must discard +the start symbol. When discarded symbols convey heap based information, this memory is lost. While this behavior can be tolerable for batch parsers, such as -in traditional compilers, it is unacceptable for programs like shells -or protocol implementations that may parse and execute indefinitely. +in traditional compilers, it is unacceptable for programs like shells or +protocol implementations that may parse and execute indefinitely. The `%destructor' directive defines code that is called when a -symbol is discarded. +symbol is automatically discarded. -- Directive: %destructor { CODE } SYMBOLS - Invoke CODE whenever the parser discards one of the SYMBOLS. - Within CODE, `$$' designates the semantic value associated with - the discarded symbol. The additional parser parameters are also - available (*note The Parser Function `yyparse': Parser Function.). - - *Warning:* as of Bison 2.1, this feature is still experimental, as - there has not been enough user feedback. In particular, the - syntax might still change. + Invoke the braced CODE whenever the parser discards one of the + SYMBOLS. Within CODE, `$$' designates the semantic value + associated with the discarded symbol. The additional parser + parameters are also available (*note The Parser Function + `yyparse': Parser Function.). For instance: @@ -3701,18 +3822,6 @@ symbol is discarded. guarantees that when a `STRING' or a `string' is discarded, its associated memory will be freed. - Note that in the future, Bison might also consider that right hand -side members that are not mentioned in the action can be destroyed. For -instance, in: - - comment: "/*" STRING "*/"; - -the parser is entitled to destroy the semantic value of the `string'. -Of course, this will not apply to the default action; compare: - - typeless: string; // $$ = $1 does not apply; $1 is destroyed. - typefull: string; // $$ = $1 applies, $1 is not destroyed. - "Discarded symbols" are the following: @@ -3720,16 +3829,23 @@ Of course, this will not apply to the default action; compare: * incoming terminals during the second phase of error recovery, - * the current look-ahead and the entire stack when the parser aborts - (either via an explicit call to `YYABORT', or as a consequence of - a failed error recovery or of memory exhaustion), and + * the current look-ahead and the entire stack (except the current + right-hand side symbols) when the parser returns immediately, and * the start symbol, when the parser succeeds. + The parser can "return immediately" because of an explicit call to +`YYABORT' or `YYACCEPT', or failed error recovery, or memory exhaustion. + + Right-hand size symbols of a rule that explicitly triggers a syntax +error via `YYERROR' are not discarded automatically. As a rule of +thumb, destructors are invoked only when user actions cannot manage the +memory. +  File: bison.info, Node: Expect Decl, Next: Start Decl, Prev: Destructor Decl, Up: Declarations -3.7.7 Suppressing Conflict Warnings +3.7.8 Suppressing Conflict Warnings ----------------------------------- Bison normally warns if there are any conflicts in the grammar (*note @@ -3743,18 +3859,18 @@ You can do this with the `%expect' declaration. %expect N - Here N is a decimal integer. The declaration says there should be -no warning if there are N shift/reduce conflicts and no reduce/reduce -conflicts. The usual warning is given if there are either more or -fewer conflicts, or if there are any reduce/reduce conflicts. + Here N is a decimal integer. The declaration says there should be N +shift/reduce conflicts and no reduce/reduce conflicts. Bison reports +an error if the number of shift/reduce conflicts differs from N, or if +there are any reduce/reduce conflicts. - For normal LALR(1) parsers, reduce/reduce conflicts are more serious, -and should be eliminated entirely. Bison will always report + For normal LALR(1) parsers, reduce/reduce conflicts are more +serious, and should be eliminated entirely. Bison will always report reduce/reduce conflicts for these parsers. With GLR parsers, however, -both shift/reduce and reduce/reduce are routine (otherwise, there would -be no need to use GLR parsing). Therefore, it is also possible to -specify an expected number of reduce/reduce conflicts in GLR parsers, -using the declaration: +both kinds of conflicts are routine; otherwise, there would be no need +to use GLR parsing. Therefore, it is also possible to specify an +expected number of reduce/reduce conflicts in GLR parsers, using the +declaration: %expect-rr N @@ -3769,16 +3885,16 @@ using the declaration: and go back to the beginning. * Add an `%expect' declaration, copying the number N from the number - which Bison printed. + which Bison printed. With GLR parsers, add an `%expect-rr' + declaration as well. - Now Bison will stop annoying you if you do not change the number of -conflicts, but it will warn you again if changes in the grammar result -in more or fewer conflicts. + Now Bison will warn you if you introduce an unexpected conflict, but +will keep silent otherwise.  File: bison.info, Node: Start Decl, Next: Pure Decl, Prev: Expect Decl, Up: Declarations -3.7.8 The Start-Symbol +3.7.9 The Start-Symbol ---------------------- Bison assumes by default that the start symbol for the grammar is the @@ -3791,15 +3907,15 @@ as follows:  File: bison.info, Node: Pure Decl, Next: Decl Summary, Prev: Start Decl, Up: Declarations -3.7.9 A Pure (Reentrant) Parser -------------------------------- +3.7.10 A Pure (Reentrant) Parser +-------------------------------- A "reentrant" program is one which does not alter in the course of execution; in other words, it consists entirely of "pure" (read-only) code. Reentrancy is important whenever asynchronous execution is -possible; for example, a non-reentrant program may not be safe to call +possible; for example, a nonreentrant program may not be safe to call from a signal handler. In systems with multiple threads of control, a -non-reentrant program must be called only within interlocks. +nonreentrant program must be called only within interlocks. Normally, Bison generates a parser which is not reentrant. This is suitable for most uses, and it permits compatibility with Yacc. (The @@ -3828,7 +3944,7 @@ valid grammar.  File: bison.info, Node: Decl Summary, Prev: Pure Decl, Up: Declarations -3.7.10 Bison Declaration Summary +3.7.11 Bison Declaration Summary -------------------------------- Here is a summary of the declarations used to define a grammar: @@ -3884,9 +4000,9 @@ directives: Unless `YYSTYPE' is already defined as a macro, the output header declares `YYSTYPE'. Therefore, if you are using a `%union' (*note More Than One Value Type: Multiple Types.) with components that - require other definitions, or if you have defined a `YYSTYPE' - macro (*note Data Types of Semantic Values: Value Type.), you need - to arrange for these definitions to be propagated to all modules, + require other definitions, or if you have defined a `YYSTYPE' macro + (*note Data Types of Semantic Values: Value Type.), you need to + arrange for these definitions to be propagated to all modules, e.g., by putting them in a prerequisite header that is included both by your parser and by any other module that needs `YYSTYPE'. @@ -3922,11 +4038,12 @@ directives: -- Directive: %name-prefix="PREFIX" Rename the external symbols used in the parser so that they start with PREFIX instead of `yy'. The precise list of symbols renamed - is `yyparse', `yylex', `yyerror', `yynerrs', `yylval', `yylloc', - `yychar', `yydebug', and possible `yylloc'. For example, if you - use `%name-prefix="c_"', the names become `c_parse', `c_lex', and - so on. *Note Multiple Parsers in the Same Program: Multiple - Parsers. + in C parsers is `yyparse', `yylex', `yyerror', `yynerrs', + `yylval', `yychar', `yydebug', and (if locations are used) + `yylloc'. For example, if you use `%name-prefix="c_"', the names + become `c_parse', `c_lex', and so on. In C++ parsers, it is only + the surrounding namespace which is named PREFIX instead of `yy'. + *Note Multiple Parsers in the Same Program: Multiple Parsers. -- Directive: %no-parser Do not include any C code in the parser file; generate tables @@ -3952,6 +4069,10 @@ directives: Request a pure (reentrant) parser program (*note A Pure (Reentrant) Parser: Pure Decl.). + -- Directive: %require "VERSION" + Require version VERSION or higher of Bison. *Note Require a + Version of Bison: Require Decl. + -- Directive: %token-table Generate an array of token names in the parser file. The name of the array is `yytname'; `yytname[I]' is the name of the token @@ -4090,10 +4211,11 @@ parameter information to it in a reentrant way. To do so, use the declaration `%parse-param': -- Directive: %parse-param {ARGUMENT-DECLARATION} - Declare that an argument declared by `argument-declaration' is an - additional `yyparse' argument. The ARGUMENT-DECLARATION is used - when declaring functions or prototypes. The last identifier in - ARGUMENT-DECLARATION must be the argument name. + Declare that an argument declared by the braced-code + ARGUMENT-DECLARATION is an additional `yyparse' argument. The + ARGUMENT-DECLARATION is used when declaring functions or + prototypes. The last identifier in ARGUMENT-DECLARATION must be + the argument name. Here's an example. Write this in the parser: @@ -4224,7 +4346,7 @@ File: bison.info, Node: Token Values, Next: Token Locations, Prev: Calling Co 4.2.2 Semantic Values of Tokens ------------------------------- -In an ordinary (non-reentrant) parser, the semantic value of the token +In an ordinary (nonreentrant) parser, the semantic value of the token must be stored into the global variable `yylval'. When you are using just one data type for semantic values, `yylval' has that type. Thus, if the type is `int' (the default), you might write this in `yylex': @@ -4305,8 +4427,8 @@ one argument. `%lex-param' just like `%parse-param' (*note Parser Function::). -- Directive: lex-param {ARGUMENT-DECLARATION} - Declare that `argument-declaration' is an additional `yylex' - argument declaration. + Declare that the braced-code ARGUMENT-DECLARATION is an additional + `yylex' argument declaration. For instance: @@ -4421,10 +4543,10 @@ passed last. this is purely for historical reasons, and `void' is preferable since it more accurately describes the return type for `yyerror'. - The variable `yynerrs' contains the number of syntax errors -encountered so far. Normally this variable is global; but if you -request a pure parser (*note A Pure (Reentrant) Parser: Pure Decl.) -then it is a local variable which only the actions can access. + The variable `yynerrs' contains the number of syntax errors reported +so far. Normally this variable is global; but if you request a pure +parser (*note A Pure (Reentrant) Parser: Pure Decl.) then it is a +local variable which only the actions can access.  File: bison.info, Node: Action Features, Next: Internationalization, Prev: Error Reporting, Up: Interface @@ -4477,6 +4599,10 @@ useful in actions. -- Macro: YYEMPTY Value stored in `yychar' when there is no look-ahead token. + -- Macro: YYEOF + Value stored in `yychar' when the look-ahead is the end of the + input stream. + -- Macro: YYERROR; Cause an immediate syntax error. This statement initiates error recovery just as if the parser itself had detected an error; @@ -4486,25 +4612,40 @@ useful in actions. Recovery::. -- Macro: YYRECOVERING - This macro stands for an expression that has the value 1 when the - parser is recovering from a syntax error, and 0 the rest of the - time. *Note Error Recovery::. + The expression `YYRECOVERING ()' yields 1 when the parser is + recovering from a syntax error, and 0 otherwise. *Note Error + Recovery::. -- Variable: yychar - Variable containing the current look-ahead token. (In a pure - parser, this is actually a local variable within `yyparse'.) When - there is no look-ahead token, the value `YYEMPTY' is stored in the - variable. *Note Look-Ahead Tokens: Look-Ahead. + Variable containing either the look-ahead token, or `YYEOF' when + the look-ahead is the end of the input stream, or `YYEMPTY' when + no look-ahead has been performed so the next token is not yet + known. Do not modify `yychar' in a deferred semantic action + (*note GLR Semantic Actions::). *Note Look-Ahead Tokens: + Look-Ahead. -- Macro: yyclearin; Discard the current look-ahead token. This is useful primarily in - error rules. *Note Error Recovery::. + error rules. Do not invoke `yyclearin' in a deferred semantic + action (*note GLR Semantic Actions::). *Note Error Recovery::. -- Macro: yyerrok; Resume generating error messages immediately for subsequent syntax errors. This is useful primarily in error rules. *Note Error Recovery::. + -- Variable: yylloc + Variable containing the look-ahead token location when `yychar' is + not set to `YYEMPTY' or `YYEOF'. Do not modify `yylloc' in a + deferred semantic action (*note GLR Semantic Actions::). *Note + Actions and Locations: Actions and Locations. + + -- Variable: yylval + Variable containing the look-ahead token semantic value when + `yychar' is not set to `YYEMPTY' or `YYEOF'. Do not modify + `yylval' in a deferred semantic action (*note GLR Semantic + Actions::). *Note Actions: Actions. + -- Value: @$ Acts like a structure variable containing information on the textual location of the grouping made by the current rule. *Note @@ -4679,8 +4820,10 @@ then be impossible to shift the `!' because doing so would produce on the stack the sequence of symbols `expr '!''. No rule allows that sequence. - The current look-ahead token is stored in the variable `yychar'. -*Note Special Features for Use in Actions: Action Features. + The look-ahead token is stored in the variable `yychar'. Its +semantic value and location, if any, are stored in the variables +`yylval' and `yylloc'. *Note Special Features for Use in Actions: +Action Features.  File: bison.info, Node: Shift/Reduce, Next: Precedence, Prev: Look-Ahead, Up: Algorithm @@ -5230,14 +5373,14 @@ quadratic worst-case time, and any general (possibly ambiguous) context-free grammar in cubic worst-case time. However, Bison currently uses a simpler data structure that requires time proportional to the length of the input times the maximum number of stacks required for any -prefix of the input. Thus, really ambiguous or non-deterministic +prefix of the input. Thus, really ambiguous or nondeterministic grammars can require exponential time and space to process. Such badly behaving examples, however, are not generally of practical interest. -Usually, non-determinism in a grammar is local--the parser is "in -doubt" only for a few tokens at a time. Therefore, the current data -structure should generally be adequate. On LALR(1) portions of a -grammar, in particular, it is only slightly slower than with the default -Bison parser. +Usually, nondeterminism in a grammar is local--the parser is "in doubt" +only for a few tokens at a time. Therefore, the current data structure +should generally be adequate. On LALR(1) portions of a grammar, in +particular, it is only slightly slower than with the default Bison +parser. For a more detailed exposition of GLR parsers, please see: Elizabeth Scott, Adrian Johnstone and Shamsa Sadaf Hussain, Tomita-Style @@ -5392,7 +5535,8 @@ error messages will be suppressed. This macro requires no arguments; The previous look-ahead token is reanalyzed immediately after an error. If this is unacceptable, then the macro `yyclearin' may be used to clear this token. Write the statement `yyclearin;' in the error -rule's action. +rule's action. *Note Special Features for Use in Actions: Action +Features. For example, suppose that on a syntax error, an error handling routine is called that advances the input stream to some point where @@ -5400,10 +5544,9 @@ parsing should once again commence. The next symbol returned by the lexical scanner is probably correct. The previous look-ahead token ought to be discarded with `yyclearin;'. - The macro `YYRECOVERING' stands for an expression that has the value -1 when the parser is recovering from a syntax error, and 0 the rest of -the time. A value of 1 indicates that error messages are currently -suppressed for new syntax errors. + The expression `YYRECOVERING ()' yields 1 when the parser is +recovering from a syntax error, and 0 otherwise. Syntax error +diagnostics are suppressed while recovering from a syntax error.  File: bison.info, Node: Context Dependency, Next: Debugging, Prev: Error Recovery, Up: Top @@ -6131,16 +6274,24 @@ Operations modes: `-y' `--yacc' - Equivalent to `-o y.tab.c'; the parser output file is called + Act more like the traditional Yacc command. This can cause + different diagnostics to be generated, and may change behavior in + other minor ways. Most importantly, imitate Yacc's output file + name conventions, so that the parser output file is called `y.tab.c', and the other outputs are called `y.output' and - `y.tab.h'. The purpose of this option is to imitate Yacc's output - file name conventions. Thus, the following shell script can - substitute for Yacc, and the Bison distribution contains such a - script for compatibility with POSIX: + `y.tab.h'. Thus, the following shell script can substitute for + Yacc, and the Bison distribution contains such a script for + compatibility with POSIX: #! /bin/sh bison -y "$@" + The `-y'/`--yacc' option is intended for use with traditional Yacc + grammars. If your grammar uses a Bison extension like + `%glr-parser', Bison might not be Yacc-compatible even if this + option is specified. + + Tuning the parser: `-S FILE' @@ -6193,8 +6344,8 @@ Adjust the output: `-b FILE-PREFIX' `--file-prefix=PREFIX' - Pretend that `%verbose' was specified, i.e, specify prefix to use - for all Bison output file names. *Note Decl Summary::. + Pretend that `%file-prefix' was specified, i.e, specify prefix to + use for all Bison output file names. *Note Decl Summary::. `-r THINGS' `--report=THINGS' @@ -6214,8 +6365,6 @@ Adjust the output: with the full set of items for each state, instead of its core only. - For instance, on the following grammar - `-v' `--verbose' Pretend that `%verbose' was specified, i.e, write an extra output @@ -6248,20 +6397,22 @@ File: bison.info, Node: Option Cross Key, Next: Yacc Library, Prev: Bison Opt Here is a list of options, alphabetized by long option, to help you find the corresponding short option. - --debug -t - --defines=DEFINES-FILE -d - --file-prefix=PREFIX -b FILE-PREFIX - --graph=GRAPH-FILE -d - --help -h - --name-prefix=PREFIX -p NAME-PREFIX - --no-lines -l - --no-parser -n - --output=OUTFILE -o OUTFILE - --print-localedir - --token-table -k - --verbose -v - --version -V - --yacc -y +Long Option Short Option +------------------------------------------------- +`--debug' `-t' +`--defines=DEFINES-FILE' `-d' +`--file-prefix=PREFIX' `-b FILE-PREFIX' +`--graph=GRAPH-FILE' `-d' +`--help' `-h' +`--name-prefix=PREFIX' `-p NAME-PREFIX' +`--no-lines' `-l' +`--no-parser' `-n' +`--output=OUTFILE' `-o OUTFILE' +`--print-localedir' +`--token-table' `-k' +`--verbose' `-v' +`--version' `-V' +`--yacc' `-y'  File: bison.info, Node: Yacc Library, Prev: Option Cross Key, Up: Invocation @@ -6321,7 +6472,11 @@ File: bison.info, Node: C++ Bison Interface, Next: C++ Semantic Values, Up: C The C++ parser LALR(1) skeleton is named `lalr1.cc'. To select it, you may either pass the option `--skeleton=lalr1.cc' to Bison, or include the directive `%skeleton "lalr1.cc"' in the grammar preamble. When -run, `bison' will create several files: +run, `bison' will create several entities in the `yy' namespace. Use +the `%name-prefix' directive to change the namespace name, see *Note +Decl Summary::. The various classes are generated in the following +files: + `position.hh' `location.hh' The definition of the classes `position' and `location', used for @@ -6332,13 +6487,13 @@ run, `bison' will create several files: `FILE.hh' `FILE.cc' - The declaration and implementation of the C++ parser class. FILE - is the name of the output file. It follows the same rules as with - regular C parsers. + (Assuming the extension of the input file was `.yy'.) The + declaration and implementation of the C++ parser class. The + basename and extension of these two files follow the same rules as + with regular C parsers (*note Invocation::). - Note that `FILE.hh' is _mandatory_, the C++ cannot work without - the parser class declaration. Therefore, you must either pass - `-d'/`--defines' to `bison', or use the `%defines' directive. + The header is _mandatory_; you must either pass `-d'/`--defines' + to `bison', or use the `%defines' directive. All these files are documented using Doxygen; run `doxygen' for a complete and accurate documentation. @@ -6352,8 +6507,9 @@ File: bison.info, Node: C++ Semantic Values, Next: C++ Location Values, Prev: The `%union' directive works as for C, see *Note The Collection of Value Types: Union Decl. In particular it produces a genuine `union'(1), which have a few specific features in C++. - - The name `YYSTYPE' also denotes `union YYSTYPE'. You may forward - declare it just with `union YYSTYPE;'. + - The type `YYSTYPE' is defined but its use is discouraged: rather + you should refer to the parser's encapsulated type + `yy::parser::semantic_type'. - Non POD (Plain Old Data) types cannot be used. C++ forbids any instance of classes with constructors in unions: only _pointers_ @@ -6366,7 +6522,8 @@ means to avoid leaks. *Note Freeing Discarded Symbols: Destructor Decl. ---------- Footnotes ---------- (1) In the future techniques to allow complex types within -pseudo-unions (variants) might be implemented to alleviate these issues. +pseudo-unions (similar to Boost variants) might be implemented to +alleviate these issues.  File: bison.info, Node: C++ Location Values, Next: C++ Parser Interface, Prev: C++ Semantic Values, Up: C++ Parsers @@ -6439,7 +6596,7 @@ File: bison.info, Node: C++ Parser Interface, Next: C++ Scanner Interface, Pr The output files `OUTPUT.hh' and `OUTPUT.cc' declare and define the parser class in the namespace `yy'. The class name defaults to `parser', but may be changed using `%define "parser_class_name" -"NAME"'. The interface of this class is detailled below. It can be +"NAME"'. The interface of this class is detailed below. It can be extended using the `%parse-param' feature: its semantics is slightly changed since it describes an additional member of the parser class, and an additional argument for its constructor. @@ -6463,7 +6620,7 @@ and an additional argument for its constructor. -- Method on parser: debug_level_type debug_level () -- Method on parser: void set_debug_level (debug_level L) Get or set the tracing level. Currently its value is either 0, no - trace, or non-zero, full tracing. + trace, or nonzero, full tracing. -- Method on parser: void error (const location_type& L, const std::string& M) @@ -6517,7 +6674,7 @@ File: bison.info, Node: Calc++ --- C++ Calculator, Next: Calc++ Parsing Driver ------------------------------- Of course the grammar is dedicated to arithmetics, a single expression, -possibily preceded by variable assignments. An environment containing +possibly preceded by variable assignments. An environment containing possibly predefined variables such as `one' and `two', is exchanged with the parser. An example of valid input follows. @@ -6541,35 +6698,25 @@ transforming the simple parsing context structure into a fully blown The declaration of this driver class, `calc++-driver.hh', is as follows. The first part includes the CPP guard and imports the -required standard library components. +required standard library components, and the declaration of the parser +class. #ifndef CALCXX_DRIVER_HH # define CALCXX_DRIVER_HH # include # include - -Then come forward declarations. Because the parser uses the parsing -driver and reciprocally, simple inclusions of header files will not do. -Because the driver's declaration is the one that will be imported by -the rest of the project, it is saner to forward declare the parser's -information here. - - // Forward declarations. - union YYSTYPE; - namespace yy - { - class location; - class calcxx_parser; - } - class calcxx_driver; + # include "calc++-parser.hh" Then comes the declaration of the scanning function. Flex expects the signature of `yylex' to be defined in the macro `YY_DECL', and the C++ parser expects it to be declared. We can factor both as follows. // Announce to Flex the prototype we want for lexing function, ... - # define YY_DECL \ - int yylex (YYSTYPE* yylval, yy::location* yylloc, calcxx_driver& driver) + # define YY_DECL \ + yy::calcxx_parser::token_type \ + yylex (yy::calcxx_parser::semantic_type* yylval, \ + yy::calcxx_parser::location_type* yylloc, \ + calcxx_driver& driver) // ... and declare it for the parser's sake. YY_DECL; @@ -6663,15 +6810,26 @@ File: bison.info, Node: Calc++ Parser, Next: Calc++ Scanner, Prev: Calc++ Par -------------------- The parser definition file `calc++-parser.yy' starts by asking for the -C++ skeleton, the creation of the parser header file, and specifies the -name of the parser class. It then includes the required headers. +C++ LALR(1) skeleton, the creation of the parser header file, and +specifies the name of the parser class. Because the C++ skeleton +changed several times, it is safer to require the version you designed +the grammar for. %skeleton "lalr1.cc" /* -*- C++ -*- */ - %define "parser_class_name" "calcxx_parser" + %require "2.1a" %defines + %define "parser_class_name" "calcxx_parser" + +Then come the declarations/inclusions needed to define the `%union'. +Because the parser uses the parsing driver and reciprocally, both +cannot include the header of the other. Because the driver's header +needs detailed knowledge about the parser class (in particular its +inner types), it is the parser's header which will simply use a forward +declaration of the driver. + %{ # include - # include "calc++-driver.hh" + class calcxx_driver; %} The driver is passed by reference to the parser and to the scanner. @@ -6709,17 +6867,25 @@ Semantic values cannot use "real" objects, but only pointers to them. std::string *sval; }; +The code between `%{' and `%}' after the introduction of the `%union' +is output in the `*.cc' file; it needs detailed knowledge about the +driver. + + %{ + # include "calc++-driver.hh" + %} + The token numbered as 0 corresponds to end of file; the following line allows for nicer error messages referring to "end of file" instead of "$end". Similarly user friendly named are provided for each symbol. Note that the tokens names are prefixed by `TOKEN_' to avoid name clashes. - %token TOKEN_EOF 0 "end of file" - %token TOKEN_ASSIGN ":=" - %token TOKEN_IDENTIFIER "identifier" - %token TOKEN_NUMBER "number" - %type exp "expression" + %token END 0 "end of file" + %token ASSIGN ":=" + %token IDENTIFIER "identifier" + %token NUMBER "number" + %type exp "expression" To enable memory deallocation during error recovery, use `%destructor'. @@ -6735,9 +6901,9 @@ The grammar itself is straightforward. unit: assignments exp { driver.result = $2; }; assignments: assignments assignment {} - | /* Nothing. */ {}; + | /* Nothing. */ {}; - assignment: TOKEN_IDENTIFIER ":=" exp { driver.variables[*$1] = $3; }; + assignment: "identifier" ":=" exp { driver.variables[*$1] = $3; }; %left '+' '-'; %left '*' '/'; @@ -6745,8 +6911,8 @@ The grammar itself is straightforward. | exp '-' exp { $$ = $1 - $3; } | exp '*' exp { $$ = $1 * $3; } | exp '/' exp { $$ = $1 / $3; } - | TOKEN_IDENTIFIER { $$ = driver.variables[*$1]; } - | TOKEN_NUMBER { $$ = $1; }; + | "identifier" { $$ = driver.variables[*$1]; } + | "number" { $$ = $1; }; %% Finally the `error' member function registers the errors to the driver. @@ -6774,6 +6940,18 @@ parser's to get the set of defined tokens. # include # include "calc++-driver.hh" # include "calc++-parser.hh" + + /* Work around an incompatibility in flex (at least versions + 2.5.31 through 2.5.33): it generates code that does + not conform to C89. See Debian bug 333231 + . */ + # undef yywrap + # define yywrap() 1 + + /* By default yylex returns int, we use token_type. + Unfortunately yyterminate by default returns 0, which is + not of token_type. */ + #define yyterminate() return token::END %} Because there is no `#include'-like feature we don't need `yywrap', we @@ -6789,7 +6967,7 @@ Abbreviations allow for more readable rules. int [0-9]+ blank [ \t] -The following paragraph suffices to track locations acurately. Each +The following paragraph suffices to track locations accurately. Each time `yylex' is invoked, the begin position is moved onto the end position. Then when a pattern is matched, the end position is advanced of its width. In case it matched ends of lines, the end cursor is @@ -6808,18 +6986,25 @@ Comments would be treated equally. [\n]+ yylloc->lines (yyleng); yylloc->step (); The rules are simple, just note the use of the driver to report errors. +It is convenient to use a typedef to shorten +`yy::calcxx_parser::token::identifier' into `token::identifier' for +instance. - [-+*/] return yytext[0]; - ":=" return TOKEN_ASSIGN; + %{ + typedef yy::calcxx_parser::token token; + %} + /* Convert ints to the actual type of tokens. */ + [-+*/] return yy::calcxx_parser::token_type (yytext[0]); + ":=" return token::ASSIGN; {int} { errno = 0; long n = strtol (yytext, NULL, 10); if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) driver.error (*yylloc, "integer is out of range"); yylval->ival = n; - return TOKEN_NUMBER; + return token::NUMBER; } - {id} yylval->sval = new std::string (yytext); return TOKEN_IDENTIFIER; + {id} yylval->sval = new std::string (yytext); return token::IDENTIFIER; . driver.error (*yylloc, "invalid character"); %% @@ -6878,10 +7063,18 @@ are addressed. * Menu: -* Memory Exhausted:: Breaking the Stack Limits -* How Can I Reset the Parser:: `yyparse' Keeps some State -* Strings are Destroyed:: `yylval' Loses Track of Strings -* Implementing Gotos/Loops:: Control Flow in the Calculator +* Memory Exhausted:: Breaking the Stack Limits +* How Can I Reset the Parser:: `yyparse' Keeps some State +* Strings are Destroyed:: `yylval' Loses Track of Strings +* Implementing Gotos/Loops:: Control Flow in the Calculator +* Multiple start-symbols:: Factoring closely related grammars +* Secure? Conform?:: Is Bison POSIX safe? +* I can't build Bison:: Troubleshooting +* Where can I find help?:: Troubleshouting +* Bug Reports:: Troublereporting +* Other Languages:: Parsers in Java and others +* Beta Testing:: Experimenting development versions +* Mailing Lists:: Meeting other Bison users  File: bison.info, Node: Memory Exhausted, Next: How Can I Reset the Parser, Up: FAQ @@ -6988,7 +7181,7 @@ File: bison.info, Node: Strings are Destroyed, Next: Implementing Gotos/Loops, This error is probably the single most frequent "bug report" sent to Bison lists, but is only concerned with a misunderstanding of the role -of scanner. Consider the following Lex code: +of the scanner. Consider the following Lex code: %{ @@ -7030,7 +7223,7 @@ generates a different behavior: "two", "two"  -File: bison.info, Node: Implementing Gotos/Loops, Prev: Strings are Destroyed, Up: FAQ +File: bison.info, Node: Implementing Gotos/Loops, Next: Multiple start-symbols, Prev: Strings are Destroyed, Up: FAQ 11.4 Implementing Gotos/Loops ============================= @@ -7056,6 +7249,174 @@ will result in an interpreter or a compiler. This topic is way beyond the scope of this manual, and the reader is invited to consult the dedicated literature. + +File: bison.info, Node: Multiple start-symbols, Next: Secure? Conform?, Prev: Implementing Gotos/Loops, Up: FAQ + +11.5 Multiple start-symbols +=========================== + + I have several closely related grammars, and I would like to share their + implementations. In fact, I could use a single grammar but with + multiple entry points. + + Bison does not support multiple start-symbols, but there is a very +simple means to simulate them. If `foo' and `bar' are the two pseudo +start-symbols, then introduce two new tokens, say `START_FOO' and +`START_BAR', and use them as switches from the real start-symbol: + + %token START_FOO START_BAR; + %start start; + start: START_FOO foo + | START_BAR bar; + + These tokens prevents the introduction of new conflicts. As far as +the parser goes, that is all that is needed. + + Now the difficult part is ensuring that the scanner will send these +tokens first. If your scanner is hand-written, that should be +straightforward. If your scanner is generated by Lex, them there is +simple means to do it: recall that anything between `%{ ... %}' after +the first `%%' is copied verbatim in the top of the generated `yylex' +function. Make sure a variable `start_token' is available in the +scanner (e.g., a global variable or using `%lex-param' etc.), and use +the following: + + /* Prologue. */ + %% + %{ + if (start_token) + { + int t = start_token; + start_token = 0; + return t; + } + %} + /* The rules. */ + + +File: bison.info, Node: Secure? Conform?, Next: I can't build Bison, Prev: Multiple start-symbols, Up: FAQ + +11.6 Secure? Conform? +====================== + + Is Bison secure? Does it conform to POSIX? + + If you're looking for a guarantee or certification, we don't provide +it. However, Bison is intended to be a reliable program that conforms +to the POSIX specification for Yacc. If you run into problems, please +send us a bug report. + + +File: bison.info, Node: I can't build Bison, Next: Where can I find help?, Prev: Secure? Conform?, Up: FAQ + +11.7 I can't build Bison +======================== + + I can't build Bison because `make' complains that + `msgfmt' is not found. + What should I do? + + Like most GNU packages with internationalization support, that +feature is turned on by default. If you have problems building in the +`po' subdirectory, it indicates that your system's internationalization +support is lacking. You can re-configure Bison with `--disable-nls' to +turn off this support, or you can install GNU gettext from +`ftp://ftp.gnu.org/gnu/gettext/' and re-configure Bison. See the file +`ABOUT-NLS' for more information. + + +File: bison.info, Node: Where can I find help?, Next: Bug Reports, Prev: I can't build Bison, Up: FAQ + +11.8 Where can I find help? +=========================== + + I'm having trouble using Bison. Where can I find help? + + First, read this fine manual. Beyond that, you can send mail to +. This mailing list is intended to be populated +with people who are willing to answer questions about using and +installing Bison. Please keep in mind that (most of) the people on the +list have aspects of their lives which are not related to Bison (!), so +you may not receive an answer to your question right away. This can be +frustrating, but please try not to honk them off; remember that any +help they provide is purely voluntary and out of the kindness of their +hearts. + + +File: bison.info, Node: Bug Reports, Next: Other Languages, Prev: Where can I find help?, Up: FAQ + +11.9 Bug Reports +================ + + I found a bug. What should I include in the bug report? + + Before you send a bug report, make sure you are using the latest +version. Check `ftp://ftp.gnu.org/pub/gnu/bison/' or one of its +mirrors. Be sure to include the version number in your bug report. If +the bug is present in the latest version but not in a previous version, +try to determine the most recent version which did not contain the bug. + + If the bug is parser-related, you should include the smallest grammar +you can which demonstrates the bug. The grammar file should also be +complete (i.e., I should be able to run it through Bison without having +to edit or add anything). The smaller and simpler the grammar, the +easier it will be to fix the bug. + + Include information about your compilation environment, including +your operating system's name and version and your compiler's name and +version. If you have trouble compiling, you should also include a +transcript of the build session, starting with the invocation of +`configure'. Depending on the nature of the bug, you may be asked to +send additional files as well (such as `config.h' or `config.cache'). + + Patches are most welcome, but not required. That is, do not +hesitate to send a bug report just because you can not provide a fix. + + Send bug reports to . + + +File: bison.info, Node: Other Languages, Next: Beta Testing, Prev: Bug Reports, Up: FAQ + +11.10 Other Languages +===================== + + Will Bison ever have C++ support? How about Java or INSERT YOUR + FAVORITE LANGUAGE HERE? + + C++ support is there now, and is documented. We'd love to add other +languages; contributions are welcome. + + +File: bison.info, Node: Beta Testing, Next: Mailing Lists, Prev: Other Languages, Up: FAQ + +11.11 Beta Testing +================== + + What is involved in being a beta tester? + + It's not terribly involved. Basically, you would download a test +release, compile it, and use it to build and run a parser or two. After +that, you would submit either a bug report or a message saying that +everything is okay. It is important to report successes as well as +failures because test releases eventually become mainstream releases, +but only if they are adequately tested. If no one tests, development is +essentially halted. + + Beta testers are particularly needed for operating systems to which +the developers do not have easy access. They currently have easy +access to recent GNU/Linux and Solaris versions. Reports about other +operating systems are especially welcome. + + +File: bison.info, Node: Mailing Lists, Prev: Beta Testing, Up: FAQ + +11.12 Mailing Lists +=================== + + How do I join the help-bison and bug-bison mailing lists? + + See `http://lists.gnu.org/'. +  File: bison.info, Node: Table of Symbols, Next: Glossary, Prev: FAQ, Up: Top @@ -7179,7 +7540,7 @@ Appendix A Bison Symbols parser file. *Note Decl Summary::. -- Directive: %nonassoc - Bison declaration to assign non-associativity to token(s). *Note + Bison declaration to assign nonassociativity to token(s). *Note Operator Precedence: Precedence Decl. -- Directive: %output="FILE" @@ -7199,6 +7560,10 @@ Appendix A Bison Symbols Bison declaration to request a pure (reentrant) parser. *Note A Pure (Reentrant) Parser: Pure Decl. + -- Directive: %require "VERSION" + Require version VERSION or higher of Bison. *Note Require a + Version of Bison: Require Decl. + -- Directive: %right Bison declaration to assign right associativity to token(s). *Note Operator Precedence: Precedence Decl. @@ -7246,10 +7611,9 @@ Appendix A Bison Symbols -- Variable: yychar External integer variable that contains the integer value of the - current look-ahead token. (In a pure parser, it is a local - variable within `yyparse'.) Error-recovery rule actions may - examine this variable. *Note Special Features for Use in Actions: - Action Features. + look-ahead token. (In a pure parser, it is a local variable within + `yyparse'.) Error-recovery rule actions may examine this variable. + *Note Special Features for Use in Actions: Action Features. -- Variable: yyclearin Macro used in error-recovery rule actions. It clears the previous @@ -7296,7 +7660,7 @@ Appendix A Bison Symbols -- Macro: YYLEX_PARAM An obsolete macro for specifying an extra argument (or list of - extra arguments) for `yyparse' to pass to `yylex'. he use of this + extra arguments) for `yyparse' to pass to `yylex'. The use of this macro is deprecated, and is supported only for Yacc like parsers. *Note Calling Conventions for Pure Parsers: Pure Calling. @@ -7306,6 +7670,8 @@ Appendix A Bison Symbols variable within `yyparse', and its address is passed to `yylex'.) You can ignore this variable if you don't use the `@' feature in the grammar actions. *Note Textual Locations of Tokens: Token + Locations. In semantic actions, it stores the location of the + look-ahead token. *Note Actions and Locations: Actions and Locations. -- Type: YYLTYPE @@ -7316,15 +7682,17 @@ Appendix A Bison Symbols External variable in which `yylex' should place the semantic value associated with a token. (In a pure parser, it is a local variable within `yyparse', and its address is passed to `yylex'.) - *Note Semantic Values of Tokens: Token Values. + *Note Semantic Values of Tokens: Token Values. In semantic + actions, it stores the semantic value of the look-ahead token. + *Note Actions: Actions. -- Macro: YYMAXDEPTH Macro for specifying the maximum size of the parser stack. *Note Memory Management::. -- Variable: yynerrs - Global variable which Bison increments each time there is a syntax - error. (In a pure parser, it is a local variable within + Global variable which Bison increments each time it reports a + syntax error. (In a pure parser, it is a local variable within `yyparse'.) *Note The Error Reporting Function `yyerror': Error Reporting. @@ -7339,9 +7707,9 @@ Appendix A Bison Symbols Conventions for Pure Parsers: Pure Calling. -- Macro: YYRECOVERING - Macro whose value indicates whether the parser is recovering from a - syntax error. *Note Special Features for Use in Actions: Action - Features. + The expression `YYRECOVERING ()' yields 1 when the parser is + recovering from a syntax error, and 0 otherwise. *Note Special + Features for Use in Actions: Action Features. -- Macro: YYSTACK_USE_ALLOCA Macro used to control the use of `alloca' when the C LALR(1) @@ -7351,16 +7719,13 @@ Appendix A Bison Symbols for future Bison extensions. If not defined, `YYSTACK_USE_ALLOCA' defaults to 0. - If you define `YYSTACK_USE_ALLOCA' to 1, it is your responsibility - to make sure that `alloca' is visible, e.g., by using GCC or by - including `'. Furthermore, in the all-too-common case - where your code may run on a host with a limited stack and with - unreliable stack-overflow checking, you should set `YYMAXDEPTH' to - a value that cannot possibly result in unchecked stack overflow on - any of your target hosts when `alloca' is called. You can inspect - the code that Bison generates in order to determine the proper - numeric values. This will require some expertise in low-level - implementation details. + In the all-too-common case where your code may run on a host with a + limited stack and with unreliable stack-overflow checking, you + should set `YYMAXDEPTH' to a value that cannot possibly result in + unchecked stack overflow on any of your target hosts when `alloca' + is called. You can inspect the code that Bison generates in order + to determine the proper numeric values. This will require some + expertise in low-level implementation details. -- Type: YYSTYPE Data type of semantic values; `int' by default. *Note Data Types @@ -8002,7 +8367,7 @@ Index * $accept: Table of Symbols. (line 47) * $end: Table of Symbols. (line 69) * $N: Actions. (line 6) -* $undefined: Table of Symbols. (line 164) +* $undefined: Table of Symbols. (line 168) * %: Table of Symbols. (line 28) * %%: Table of Symbols. (line 23) * %debug <1>: Table of Symbols. (line 52) @@ -8012,7 +8377,8 @@ Index * %defines: Decl Summary. (line 51) * %destructor <1>: Table of Symbols. (line 59) * %destructor <2>: Decl Summary. (line 79) -* %destructor: Destructor Decl. (line 6) +* %destructor <3>: Destructor Decl. (line 6) +* %destructor: Mid-Rule Actions. (line 59) * %dprec <1>: Table of Symbols. (line 64) * %dprec: Merging GLR Parses. (line 6) * %error-verbose <1>: Table of Symbols. (line 83) @@ -8039,49 +8405,52 @@ Index * %name-prefix=" <1>: Table of Symbols. (line 115) * %name-prefix=": Decl Summary. (line 95) * %no-lines <1>: Table of Symbols. (line 119) -* %no-lines: Decl Summary. (line 113) -* %no-parser: Decl Summary. (line 104) +* %no-lines: Decl Summary. (line 114) +* %no-parser: Decl Summary. (line 105) * %nonassoc <1>: Table of Symbols. (line 123) * %nonassoc <2>: Using Precedence. (line 6) * %nonassoc: Decl Summary. (line 25) * %output=" <1>: Table of Symbols. (line 127) -* %output=": Decl Summary. (line 121) +* %output=": Decl Summary. (line 122) * %parse-param <1>: Table of Symbols. (line 131) * %parse-param: Parser Function. (line 36) * %prec <1>: Table of Symbols. (line 136) * %prec: Contextual Precedence. (line 6) * %pure-parser <1>: Table of Symbols. (line 140) -* %pure-parser <2>: Decl Summary. (line 124) +* %pure-parser <2>: Decl Summary. (line 125) * %pure-parser: Pure Decl. (line 6) -* %right <1>: Table of Symbols. (line 144) +* %require <1>: Table of Symbols. (line 144) +* %require <2>: Decl Summary. (line 129) +* %require: Require Decl. (line 6) +* %right <1>: Table of Symbols. (line 148) * %right <2>: Using Precedence. (line 6) * %right: Decl Summary. (line 17) -* %start <1>: Table of Symbols. (line 148) +* %start <1>: Table of Symbols. (line 152) * %start <2>: Decl Summary. (line 34) * %start: Start Decl. (line 6) -* %token <1>: Table of Symbols. (line 152) +* %token <1>: Table of Symbols. (line 156) * %token <2>: Decl Summary. (line 13) * %token: Token Decl. (line 6) -* %token-table <1>: Table of Symbols. (line 156) -* %token-table: Decl Summary. (line 128) -* %type <1>: Table of Symbols. (line 160) +* %token-table <1>: Table of Symbols. (line 160) +* %token-table: Decl Summary. (line 133) +* %type <1>: Table of Symbols. (line 164) * %type <2>: Decl Summary. (line 30) * %type: Type Decl. (line 6) -* %union <1>: Table of Symbols. (line 169) +* %union <1>: Table of Symbols. (line 173) * %union <2>: Decl Summary. (line 9) * %union: Union Decl. (line 6) -* %verbose: Decl Summary. (line 161) -* %yacc: Decl Summary. (line 167) +* %verbose: Decl Summary. (line 166) +* %yacc: Decl Summary. (line 172) * /*: Table of Symbols. (line 33) * :: Table of Symbols. (line 36) * ;: Table of Symbols. (line 40) * @$ <1>: Table of Symbols. (line 7) -* @$ <2>: Action Features. (line 80) +* @$ <2>: Action Features. (line 99) * @$: Actions and Locations. (line 6) * @N <1>: Table of Symbols. (line 11) -* @N <2>: Action Features. (line 86) +* @N <2>: Action Features. (line 105) * @N: Actions and Locations. (line 6) * abstract syntax tree: Implementing Gotos/Loops. @@ -8124,6 +8493,7 @@ Index (line 27) * BNF: Language and Grammar. (line 16) +* braced code: Rules. (line 31) * C code, section for additional: Epilogue. (line 6) * C-language interface: Interface. (line 6) * calc: Infix Calc. (line 6) @@ -8169,13 +8539,16 @@ Index * declaring token type names: Token Decl. (line 6) * declaring value types: Union Decl. (line 6) * declaring value types, nonterminals: Type Decl. (line 6) -* default action: Actions. (line 56) +* default action: Actions. (line 50) * default data type: Value Type. (line 6) * default location type: Location Type. (line 6) * default stack limit: Memory Management. (line 30) * default start symbol: Start Decl. (line 6) +* deferred semantic actions: GLR Semantic Actions. + (line 6) * defining language semantics: Semantics. (line 6) -* discarded symbols: Destructor Decl. (line 57) +* discarded symbols: Destructor Decl. (line 42) +* discarded symbols, mid-rule actions: Mid-Rule Actions. (line 59) * else, dangling: Shift/Reduce. (line 6) * end on location: C++ Location Values. (line 45) * epilogue: Epilogue. (line 6) @@ -8184,6 +8557,7 @@ Index * error on parser: C++ Parser Interface. (line 37) * error recovery: Error Recovery. (line 6) +* error recovery, mid-rule actions: Mid-Rule Actions. (line 59) * error recovery, simple: Simple Error Recovery. (line 6) * error reporting function: Error Reporting. (line 6) @@ -8213,6 +8587,18 @@ Index * glossary: Glossary. (line 6) * GLR parsers and inline: Compiler Requirements. (line 6) +* GLR parsers and yychar: GLR Semantic Actions. + (line 10) +* GLR parsers and yyclearin: GLR Semantic Actions. + (line 18) +* GLR parsers and YYERROR: GLR Semantic Actions. + (line 28) +* GLR parsers and yylloc: GLR Semantic Actions. + (line 10) +* GLR parsers and YYLLOC_DEFAULT: Location Default Action. + (line 6) +* GLR parsers and yylval: GLR Semantic Actions. + (line 10) * GLR parsing <1>: Generalized LR Parsing. (line 6) * GLR parsing <2>: GLR Parsers. (line 6) @@ -8283,9 +8669,9 @@ Index * mutual recursion: Recursion. (line 32) * NLS: Internationalization. (line 6) -* non-deterministic parsing <1>: Generalized LR Parsing. +* nondeterministic parsing <1>: Generalized LR Parsing. (line 6) -* non-deterministic parsing: Language and Grammar. +* nondeterministic parsing: Language and Grammar. (line 33) * nonterminal symbol: Symbols. (line 6) * nonterminal, useless: Understanding. (line 62) @@ -8329,6 +8715,7 @@ Index * reduce/reduce conflicts: GLR Parsers. (line 6) * reduction: Algorithm. (line 6) * reentrant parser: Pure Decl. (line 6) +* requiring a version of Bison: Require Decl. (line 6) * reverse polish notation: RPN Calc. (line 6) * right recursion: Recursion. (line 16) * rpcalc: RPN Calc. (line 6) @@ -8392,202 +8779,231 @@ Index * value types, declaring: Union Decl. (line 6) * value types, nonterminals, declaring: Type Decl. (line 6) * value, semantic: Semantic Values. (line 6) +* version requirement: Require Decl. (line 6) * warnings, preventing: Expect Decl. (line 6) * writing a lexical analyzer: Rpcalc Lexer. (line 6) -* YYABORT <1>: Table of Symbols. (line 173) +* YYABORT <1>: Table of Symbols. (line 177) * YYABORT: Parser Function. (line 29) * YYABORT;: Action Features. (line 28) -* YYACCEPT <1>: Table of Symbols. (line 179) +* YYACCEPT <1>: Table of Symbols. (line 183) * YYACCEPT: Parser Function. (line 26) * YYACCEPT;: Action Features. (line 32) -* YYBACKUP <1>: Table of Symbols. (line 184) +* YYBACKUP <1>: Table of Symbols. (line 188) * YYBACKUP: Action Features. (line 36) -* yychar <1>: Table of Symbols. (line 189) +* yychar <1>: Table of Symbols. (line 193) * yychar <2>: Look-Ahead. (line 47) -* yychar: Action Features. (line 65) -* yyclearin <1>: Table of Symbols. (line 196) -* yyclearin: Error Recovery. (line 97) -* yyclearin;: Action Features. (line 71) -* yydebug: Table of Symbols. (line 204) -* YYDEBUG <1>: Table of Symbols. (line 200) +* yychar <3>: Action Features. (line 69) +* yychar: GLR Semantic Actions. + (line 10) +* yyclearin <1>: Table of Symbols. (line 199) +* yyclearin <2>: Error Recovery. (line 97) +* yyclearin: GLR Semantic Actions. + (line 18) +* yyclearin;: Action Features. (line 77) +* yydebug: Table of Symbols. (line 207) +* YYDEBUG <1>: Table of Symbols. (line 203) * YYDEBUG: Tracing. (line 12) * yydebug: Tracing. (line 6) * YYEMPTY: Action Features. (line 49) * YYENABLE_NLS: Internationalization. (line 27) -* yyerrok <1>: Table of Symbols. (line 209) +* YYEOF: Action Features. (line 52) +* yyerrok <1>: Table of Symbols. (line 212) * yyerrok: Error Recovery. (line 92) -* yyerrok;: Action Features. (line 75) -* yyerror: Table of Symbols. (line 219) -* YYERROR <1>: Table of Symbols. (line 213) -* YYERROR: Action Features. (line 52) +* yyerrok;: Action Features. (line 82) +* yyerror: Table of Symbols. (line 222) +* YYERROR <1>: Table of Symbols. (line 216) +* YYERROR: Action Features. (line 56) * yyerror: Error Reporting. (line 6) -* YYERROR;: Action Features. (line 52) -* YYERROR_VERBOSE: Table of Symbols. (line 223) -* YYINITDEPTH <1>: Table of Symbols. (line 230) +* YYERROR: GLR Semantic Actions. + (line 28) +* YYERROR;: Action Features. (line 56) +* YYERROR_VERBOSE: Table of Symbols. (line 226) +* YYINITDEPTH <1>: Table of Symbols. (line 233) * YYINITDEPTH: Memory Management. (line 32) -* yylex <1>: Table of Symbols. (line 234) +* yylex <1>: Table of Symbols. (line 237) * yylex: Lexical. (line 6) * yylex on parser: C++ Scanner Interface. (line 12) -* YYLEX_PARAM: Table of Symbols. (line 239) -* yylloc <1>: Table of Symbols. (line 245) -* yylloc: Token Locations. (line 6) +* YYLEX_PARAM: Table of Symbols. (line 242) +* yylloc <1>: Table of Symbols. (line 248) +* yylloc <2>: Look-Ahead. (line 47) +* yylloc <3>: Action Features. (line 87) +* yylloc <4>: Token Locations. (line 6) +* yylloc <5>: Actions and Locations. + (line 60) +* yylloc: GLR Semantic Actions. + (line 10) * YYLLOC_DEFAULT: Location Default Action. (line 6) -* YYLTYPE <1>: Table of Symbols. (line 253) +* YYLTYPE <1>: Table of Symbols. (line 258) * YYLTYPE: Token Locations. (line 19) -* yylval <1>: Table of Symbols. (line 257) -* yylval: Token Values. (line 6) -* YYMAXDEPTH <1>: Table of Symbols. (line 263) +* yylval <1>: Table of Symbols. (line 262) +* yylval <2>: Look-Ahead. (line 47) +* yylval <3>: Action Features. (line 93) +* yylval <4>: Token Values. (line 6) +* yylval <5>: Actions. (line 74) +* yylval: GLR Semantic Actions. + (line 10) +* YYMAXDEPTH <1>: Table of Symbols. (line 270) * YYMAXDEPTH: Memory Management. (line 14) -* yynerrs <1>: Table of Symbols. (line 267) +* yynerrs <1>: Table of Symbols. (line 274) * yynerrs: Error Reporting. (line 92) -* yyparse <1>: Table of Symbols. (line 273) +* yyparse <1>: Table of Symbols. (line 280) * yyparse: Parser Function. (line 6) -* YYPARSE_PARAM: Table of Symbols. (line 277) +* YYPARSE_PARAM: Table of Symbols. (line 284) * YYPRINT: Tracing. (line 71) -* YYRECOVERING <1>: Table of Symbols. (line 283) -* YYRECOVERING <2>: Error Recovery. (line 108) -* YYRECOVERING: Action Features. (line 60) -* YYSTACK_USE_ALLOCA: Table of Symbols. (line 288) -* YYSTYPE: Table of Symbols. (line 307) +* YYRECOVERING <1>: Table of Symbols. (line 290) +* YYRECOVERING <2>: Error Recovery. (line 109) +* YYRECOVERING: Action Features. (line 64) +* YYSTACK_USE_ALLOCA: Table of Symbols. (line 295) +* YYSTYPE: Table of Symbols. (line 311) * | <1>: Table of Symbols. (line 43) -* |: Rules. (line 34) +* |: Rules. (line 49)  Tag Table: Node: Top1110 -Node: Introduction11831 -Node: Conditions13101 -Node: Copying14990 -Node: Concepts34168 -Node: Language and Grammar35322 -Node: Grammar in Bison41216 -Node: Semantic Values43145 -Node: Semantic Actions45251 -Node: GLR Parsers46438 -Node: Simple GLR Parsers49121 -Node: Merging GLR Parses55776 -Node: Compiler Requirements60346 -Node: Locations Overview61080 -Node: Bison Parser62533 -Node: Stages65345 -Node: Grammar Layout66633 -Node: Examples67965 -Node: RPN Calc69164 -Node: Rpcalc Decls70143 -Node: Rpcalc Rules72064 -Node: Rpcalc Input73871 -Node: Rpcalc Line75346 -Node: Rpcalc Expr76474 -Node: Rpcalc Lexer78441 -Node: Rpcalc Main81028 -Node: Rpcalc Error81435 -Node: Rpcalc Gen82463 -Node: Rpcalc Compile83593 -Node: Infix Calc84467 -Node: Simple Error Recovery87230 -Node: Location Tracking Calc89125 -Node: Ltcalc Decls89812 -Node: Ltcalc Rules90765 -Node: Ltcalc Lexer92774 -Node: Multi-function Calc95097 -Node: Mfcalc Decl96669 -Node: Mfcalc Rules98708 -Node: Mfcalc Symtab100089 -Node: Exercises106262 -Node: Grammar File106776 -Node: Grammar Outline107625 -Node: Prologue108385 -Node: Bison Declarations109666 -Node: Grammar Rules110081 -Node: Epilogue110552 -Node: Symbols111568 -Node: Rules118273 -Node: Recursion119914 -Node: Semantics121632 -Node: Value Type122731 -Node: Multiple Types123398 -Node: Actions124428 -Node: Action Types127932 -Node: Mid-Rule Actions129244 -Node: Locations134818 -Node: Location Type135469 -Node: Actions and Locations136061 -Node: Location Default Action138321 -Node: Declarations141763 -Node: Token Decl143193 -Node: Precedence Decl145280 -Node: Union Decl146840 -Node: Type Decl147982 -Node: Initial Action Decl148908 -Node: Destructor Decl149690 -Node: Expect Decl152263 -Node: Start Decl154291 -Node: Pure Decl154679 -Node: Decl Summary156365 -Node: Multiple Parsers163438 -Node: Interface164947 -Node: Parser Function165920 -Node: Lexical167904 -Node: Calling Convention169315 -Node: Token Values172275 -Node: Token Locations173440 -Node: Pure Calling174334 -Node: Error Reporting176189 -Node: Action Features180309 -Node: Internationalization183828 -Node: Algorithm186369 -Node: Look-Ahead188736 -Node: Shift/Reduce190868 -Node: Precedence193765 -Node: Why Precedence194421 -Node: Using Precedence196295 -Node: Precedence Examples197272 -Node: How Precedence197982 -Node: Contextual Precedence199141 -Node: Parser States200937 -Node: Reduce/Reduce202185 -Node: Mystery Conflicts205726 -Node: Generalized LR Parsing209435 -Node: Memory Management214058 -Node: Error Recovery216271 -Node: Context Dependency221569 -Node: Semantic Tokens222418 -Node: Lexical Tie-ins225488 -Node: Tie-in Recovery227065 -Node: Debugging229242 -Node: Understanding229908 -Node: Tracing241054 -Node: Invocation245138 -Node: Bison Options246544 -Node: Option Cross Key250830 -Node: Yacc Library251726 -Node: C++ Language Interface252551 -Node: C++ Parsers252839 -Node: C++ Bison Interface253297 -Node: C++ Semantic Values254414 -Ref: C++ Semantic Values-Footnote-1255311 -Node: C++ Location Values255447 -Node: C++ Parser Interface257822 -Node: C++ Scanner Interface259544 -Node: A Complete C++ Example260211 -Node: Calc++ --- C++ Calculator261150 -Node: Calc++ Parsing Driver261661 -Node: Calc++ Parser265635 -Node: Calc++ Scanner268780 -Node: Calc++ Top Level271324 -Node: FAQ271991 -Node: Memory Exhausted272487 -Node: How Can I Reset the Parser272797 -Node: Strings are Destroyed275073 -Node: Implementing Gotos/Loops276658 -Node: Table of Symbols277910 -Node: Glossary289938 -Node: Copying This Manual296839 -Node: GNU Free Documentation License297070 -Node: Index319479 +Node: Introduction12389 +Node: Conditions13650 +Node: Copying15541 +Node: Concepts34719 +Node: Language and Grammar35873 +Node: Grammar in Bison41766 +Node: Semantic Values43695 +Node: Semantic Actions45801 +Node: GLR Parsers46988 +Node: Simple GLR Parsers49739 +Node: Merging GLR Parses56394 +Node: GLR Semantic Actions60963 +Node: Compiler Requirements62857 +Node: Locations Overview63593 +Node: Bison Parser65046 +Node: Stages67986 +Node: Grammar Layout69274 +Node: Examples70606 +Node: RPN Calc71780 +Node: Rpcalc Decls72759 +Node: Rpcalc Rules74680 +Node: Rpcalc Input76489 +Node: Rpcalc Line77964 +Node: Rpcalc Expr79092 +Node: Rpcalc Lexer81059 +Node: Rpcalc Main83646 +Node: Rpcalc Error84053 +Node: Rpcalc Gen85081 +Node: Rpcalc Compile86211 +Node: Infix Calc87085 +Node: Simple Error Recovery89848 +Node: Location Tracking Calc91743 +Node: Ltcalc Decls92430 +Node: Ltcalc Rules93383 +Node: Ltcalc Lexer95392 +Node: Multi-function Calc97715 +Node: Mfcalc Decl99288 +Node: Mfcalc Rules101327 +Node: Mfcalc Symtab102708 +Node: Exercises108878 +Node: Grammar File109392 +Node: Grammar Outline110241 +Node: Prologue111001 +Node: Bison Declarations112427 +Node: Grammar Rules112842 +Node: Epilogue113313 +Node: Symbols114329 +Node: Rules121032 +Node: Recursion123511 +Node: Semantics125229 +Node: Value Type126328 +Node: Multiple Types127101 +Node: Actions128131 +Node: Action Types131547 +Node: Mid-Rule Actions132859 +Node: Locations139308 +Node: Location Type139959 +Node: Actions and Locations140646 +Node: Location Default Action143108 +Node: Declarations146828 +Node: Require Decl148307 +Node: Token Decl148626 +Node: Precedence Decl150734 +Node: Union Decl152294 +Node: Type Decl153609 +Node: Initial Action Decl154535 +Node: Destructor Decl155307 +Node: Expect Decl157582 +Node: Start Decl159575 +Node: Pure Decl159963 +Node: Decl Summary161649 +Node: Multiple Parsers168975 +Node: Interface170484 +Node: Parser Function171457 +Node: Lexical173460 +Node: Calling Convention174871 +Node: Token Values177831 +Node: Token Locations178995 +Node: Pure Calling179889 +Node: Error Reporting181758 +Node: Action Features185876 +Node: Internationalization190197 +Node: Algorithm192738 +Node: Look-Ahead195105 +Node: Shift/Reduce197323 +Node: Precedence200220 +Node: Why Precedence200876 +Node: Using Precedence202750 +Node: Precedence Examples203727 +Node: How Precedence204437 +Node: Contextual Precedence205596 +Node: Parser States207392 +Node: Reduce/Reduce208640 +Node: Mystery Conflicts212181 +Node: Generalized LR Parsing215890 +Node: Memory Management220511 +Node: Error Recovery222724 +Node: Context Dependency228030 +Node: Semantic Tokens228879 +Node: Lexical Tie-ins231949 +Node: Tie-in Recovery233526 +Node: Debugging235703 +Node: Understanding236369 +Node: Tracing247515 +Node: Invocation251599 +Node: Bison Options253005 +Node: Option Cross Key257597 +Node: Yacc Library258419 +Node: C++ Language Interface259244 +Node: C++ Parsers259532 +Node: C++ Bison Interface259990 +Node: C++ Semantic Values261283 +Ref: C++ Semantic Values-Footnote-1262225 +Node: C++ Location Values262378 +Node: C++ Parser Interface264753 +Node: C++ Scanner Interface266473 +Node: A Complete C++ Example267140 +Node: Calc++ --- C++ Calculator268079 +Node: Calc++ Parsing Driver268589 +Node: Calc++ Parser272324 +Node: Calc++ Scanner276092 +Node: Calc++ Top Level279417 +Node: FAQ280084 +Node: Memory Exhausted281033 +Node: How Can I Reset the Parser281343 +Node: Strings are Destroyed283619 +Node: Implementing Gotos/Loops285208 +Node: Multiple start-symbols286491 +Node: Secure? Conform?288036 +Node: I can't build Bison288484 +Node: Where can I find help?289202 +Node: Bug Reports289995 +Node: Other Languages291457 +Node: Beta Testing291808 +Node: Mailing Lists292683 +Node: Table of Symbols292894 +Node: Glossary305135 +Node: Copying This Manual312036 +Node: GNU Free Documentation License312267 +Node: Index334676  End Tag Table diff --git a/src/bin/bison/doc/bison.texinfo b/src/bin/bison/doc/bison.texinfo index c384d2d416..6c67b59392 100644 --- a/src/bin/bison/doc/bison.texinfo +++ b/src/bin/bison/doc/bison.texinfo @@ -12,25 +12,15 @@ @c the smallbook format. @c @smallbook -@c Set following if you have the new `shorttitlepage' command -@c @clear shorttitlepage-enabled -@c @set shorttitlepage-enabled - @c Set following if you want to document %default-prec and %no-default-prec. @c This feature is experimental and may change in future Bison versions. @c @set defaultprec -@c ISPELL CHECK: done, 14 Jan 1993 --bob - -@c Check COPYRIGHT dates. should be updated in the titlepage, ifinfo -@c titlepage; should NOT be changed in the GPL. --mew - -@c FIXME: I don't understand this `iftex'. Obsolete? --akim. -@iftex +@ifnotinfo @syncodeindex fn cp @syncodeindex vr cp @syncodeindex tp cp -@end iftex +@end ifnotinfo @ifinfo @synindex fn cp @synindex vr cp @@ -44,7 +34,7 @@ This manual is for @acronym{GNU} Bison (version @value{VERSION}, @value{UPDATED}), the @acronym{GNU} parser generator. Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, -1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -67,9 +57,6 @@ Copies published by the Free Software Foundation raise funds for * bison: (bison). @acronym{GNU} parser generator (Yacc replacement). @end direntry -@ifset shorttitlepage-enabled -@shorttitlepage Bison -@end ifset @titlepage @title Bison @subtitle The Yacc-compatible Parser Generator @@ -145,9 +132,10 @@ The Concepts of Bison Writing @acronym{GLR} Parsers -* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars -* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities -* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler +* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars. +* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities. +* GLR Semantic Actions:: Deferred semantic actions have special concerns. +* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler. Examples @@ -225,6 +213,7 @@ Tracking Locations Bison Declarations +* Require Decl:: Requiring a Bison version. * Token Decl:: Declaring terminal symbols. * Precedence Decl:: Declaring terminals with precedence and associativity. * Union Decl:: Declaring the set of all semantic value types. @@ -322,6 +311,14 @@ Frequently Asked Questions * How Can I Reset the Parser:: @code{yyparse} Keeps some State * Strings are Destroyed:: @code{yylval} Loses Track of Strings * Implementing Gotos/Loops:: Control Flow in the Calculator +* Multiple start-symbols:: Factoring closely related grammars +* Secure? Conform?:: Is Bison @acronym{POSIX} safe? +* I can't build Bison:: Troubleshooting +* Where can I find help?:: Troubleshouting +* Bug Reports:: Troublereporting +* Other Languages:: Parsers in Java and others +* Beta Testing:: Experimenting development versions +* Mailing Lists:: Meeting other Bison users Copying This Manual @@ -334,16 +331,16 @@ Copying This Manual @unnumbered Introduction @cindex introduction -@dfn{Bison} is a general-purpose parser generator that converts a -grammar description for an @acronym{LALR}(1) context-free grammar into a C -program to parse that grammar. Once you are proficient with Bison, -you may use it to develop a wide range of language parsers, from those +@dfn{Bison} is a general-purpose parser generator that converts an +annotated context-free grammar into an @acronym{LALR}(1) or +@acronym{GLR} parser for that grammar. Once you are proficient with +Bison, you can use it to develop a wide range of language parsers, from those used in simple desk calculators to complex programming languages. Bison is upward compatible with Yacc: all properly-written Yacc grammars ought to work with Bison with no change. Anyone familiar with Yacc should be able to use Bison with little trouble. You need to be fluent in -C programming in order to use Bison or to understand this manual. +C or C++ programming in order to use Bison or to understand this manual. We begin with tutorial chapters that explain the basic concepts of using Bison and show three explained examples, each building on the last. If you @@ -359,9 +356,10 @@ This edition corresponds to version @value{VERSION} of Bison. @node Conditions @unnumbered Conditions for Using Bison -As of Bison version 1.24, we have changed the distribution terms for -@code{yyparse} to permit using Bison's output in nonfree programs when -Bison is generating C code for @acronym{LALR}(1) parsers. Formerly, these +The distribution terms for Bison-generated parsers permit using the +parsers in nonfree programs. Before Bison version 2.2, these extra +permissions applied only when Bison was generating @acronym{LALR}(1) +parsers in C@. And before Bison version 1.24, Bison-generated parsers could be used only in programs that were free software. The other @acronym{GNU} programming tools, such as the @acronym{GNU} C @@ -373,10 +371,10 @@ License to all of the Bison source code. The output of the Bison utility---the Bison parser file---contains a verbatim copy of a sizable piece of Bison, which is the code for the -@code{yyparse} function. (The actions from your grammar are inserted -into this function at one point, but the rest of the function is not -changed.) When we applied the @acronym{GPL} terms to the code for -@code{yyparse}, +parser's implementation. (The actions from your grammar are inserted +into this implementation at one point, but most of the rest of the +implementation is not changed.) When we applied the @acronym{GPL} +terms to the skeleton code for the parser's implementation, the effect was to restrict the use of Bison output to free software. We didn't change the terms because of sympathy for people who want to @@ -386,13 +384,11 @@ encourage people to make other software free. So we decided to make the practical conditions for using Bison match the practical conditions for using the other @acronym{GNU} tools. -This exception applies only when Bison is generating C code for an -@acronym{LALR}(1) parser; otherwise, the @acronym{GPL} terms operate -as usual. You can -tell whether the exception applies to your @samp{.c} output file by -inspecting it to see whether it says ``As a special exception, when -this file is copied by Bison into a Bison output file, you may use -that output file without restriction.'' +This exception applies when Bison is generating code for a parser. +You can tell whether the exception applies to a Bison output file by +inspecting the file for text beginning with ``As a special +exception@dots{}''. The text spells out the exact terms of the +exception. @include gpl.texi @@ -460,7 +456,7 @@ more information on this. @cindex @acronym{GLR} parsing @cindex generalized @acronym{LR} (@acronym{GLR}) parsing @cindex ambiguous grammars -@cindex non-deterministic parsing +@cindex nondeterministic parsing Parsers for @acronym{LALR}(1) grammars are @dfn{deterministic}, meaning roughly that the next grammar rule to apply at any point in the input is @@ -468,7 +464,7 @@ uniquely determined by the preceding input and a fixed, finite portion (called a @dfn{look-ahead}) of the remaining input. A context-free grammar can be @dfn{ambiguous}, meaning that there are multiple ways to apply the grammar rules to get the same inputs. Even unambiguous -grammars can be @dfn{non-deterministic}, meaning that no fixed +grammars can be @dfn{nondeterministic}, meaning that no fixed look-ahead always suffices to determine the next grammar rule to apply. With the proper declarations, Bison is also able to parse these more general context-free grammars, using a technique known as @acronym{GLR} @@ -506,8 +502,8 @@ int /* @r{keyword `int'} */ square (int x) /* @r{identifier, open-paren, keyword `int',} @r{identifier, close-paren} */ @{ /* @r{open-brace} */ - return x * x; /* @r{keyword `return', identifier, asterisk, - identifier, semicolon} */ + return x * x; /* @r{keyword `return', identifier, asterisk,} + @r{identifier, semicolon} */ @} /* @r{close-brace} */ @end example @end ifinfo @@ -732,9 +728,10 @@ user-defined function on the resulting values to produce an arbitrary merged result. @menu -* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars -* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities -* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler +* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars. +* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities. +* GLR Semantic Actions:: Deferred semantic actions have special concerns. +* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler. @end menu @node Simple GLR Parsers @@ -909,29 +906,27 @@ parser recognizes all valid declarations, according to the limited syntax above, transparently. In fact, the user does not even notice when the parser splits. -So here we have a case where we can use the benefits of @acronym{GLR}, almost -without disadvantages. Even in simple cases like this, however, there -are at least two potential problems to beware. -First, always analyze the conflicts reported by -Bison to make sure that @acronym{GLR} splitting is only done where it is -intended. A @acronym{GLR} parser splitting inadvertently may cause -problems less obvious than an @acronym{LALR} parser statically choosing the -wrong alternative in a conflict. -Second, consider interactions with the lexer (@pxref{Semantic Tokens}) -with great care. Since a split parser consumes tokens -without performing any actions during the split, the lexer cannot -obtain information via parser actions. Some cases of -lexer interactions can be eliminated by using @acronym{GLR} to -shift the complications from the lexer to the parser. You must check -the remaining cases for correctness. +So here we have a case where we can use the benefits of @acronym{GLR}, +almost without disadvantages. Even in simple cases like this, however, +there are at least two potential problems to beware. First, always +analyze the conflicts reported by Bison to make sure that @acronym{GLR} +splitting is only done where it is intended. A @acronym{GLR} parser +splitting inadvertently may cause problems less obvious than an +@acronym{LALR} parser statically choosing the wrong alternative in a +conflict. Second, consider interactions with the lexer (@pxref{Semantic +Tokens}) with great care. Since a split parser consumes tokens without +performing any actions during the split, the lexer cannot obtain +information via parser actions. Some cases of lexer interactions can be +eliminated by using @acronym{GLR} to shift the complications from the +lexer to the parser. You must check the remaining cases for +correctness. -In our example, it would be safe for the lexer to return tokens -based on their current meanings in some symbol table, because no new -symbols are defined in the middle of a type declaration. Though it -is possible for a parser to define the enumeration -constants as they are parsed, before the type declaration is -completed, it actually makes no difference since they cannot be used -within the same enumerated type declaration. +In our example, it would be safe for the lexer to return tokens based on +their current meanings in some symbol table, because no new symbols are +defined in the middle of a type declaration. Though it is possible for +a parser to define the enumeration constants as they are parsed, before +the type declaration is completed, it actually makes no difference since +they cannot be used within the same enumerated type declaration. @node Merging GLR Parses @subsection Using @acronym{GLR} to Resolve Ambiguities @@ -1095,6 +1090,55 @@ productions that participate in any particular merge have identical and the parser will report an error during any parse that results in the offending merge. +@node GLR Semantic Actions +@subsection GLR Semantic Actions + +@cindex deferred semantic actions +By definition, a deferred semantic action is not performed at the same time as +the associated reduction. +This raises caveats for several Bison features you might use in a semantic +action in a @acronym{GLR} parser. + +@vindex yychar +@cindex @acronym{GLR} parsers and @code{yychar} +@vindex yylval +@cindex @acronym{GLR} parsers and @code{yylval} +@vindex yylloc +@cindex @acronym{GLR} parsers and @code{yylloc} +In any semantic action, you can examine @code{yychar} to determine the type of +the look-ahead token present at the time of the associated reduction. +After checking that @code{yychar} is not set to @code{YYEMPTY} or @code{YYEOF}, +you can then examine @code{yylval} and @code{yylloc} to determine the +look-ahead token's semantic value and location, if any. +In a nondeferred semantic action, you can also modify any of these variables to +influence syntax analysis. +@xref{Look-Ahead, ,Look-Ahead Tokens}. + +@findex yyclearin +@cindex @acronym{GLR} parsers and @code{yyclearin} +In a deferred semantic action, it's too late to influence syntax analysis. +In this case, @code{yychar}, @code{yylval}, and @code{yylloc} are set to +shallow copies of the values they had at the time of the associated reduction. +For this reason alone, modifying them is dangerous. +Moreover, the result of modifying them is undefined and subject to change with +future versions of Bison. +For example, if a semantic action might be deferred, you should never write it +to invoke @code{yyclearin} (@pxref{Action Features}) or to attempt to free +memory referenced by @code{yylval}. + +@findex YYERROR +@cindex @acronym{GLR} parsers and @code{YYERROR} +Another Bison feature requiring special consideration is @code{YYERROR} +(@pxref{Action Features}), which you can invoke in a semantic action to +initiate error recovery. +During deterministic @acronym{GLR} operation, the effect of @code{YYERROR} is +the same as its effect in an @acronym{LALR}(1) parser. +In a deferred semantic action, its effect is undefined. +@c The effect is probably a syntax error at the split point. + +Also, see @ref{Location Default Action, ,Default Action for Locations}, which +describes a special usage of @code{YYLLOC_DEFAULT} in @acronym{GLR} parsers. + @node Compiler Requirements @subsection Considerations when Compiling @acronym{GLR} Parsers @cindex @code{inline} @@ -1197,11 +1241,13 @@ function @code{yyerror} and the parser function @code{yyparse} itself. This also includes numerous identifiers used for internal purposes. Therefore, you should avoid using C identifiers starting with @samp{yy} or @samp{YY} in the Bison grammar file except for the ones defined in -this manual. +this manual. Also, you should avoid using the C identifiers +@samp{malloc} and @samp{free} for anything other than their usual +meanings. In some cases the Bison parser file includes system headers, and in those cases your code should respect the identifiers reserved by those -headers. On some non-@acronym{GNU} hosts, @code{}, +headers. On some non-@acronym{GNU} hosts, @code{}, @code{}, @code{}, and @code{} are included as needed to declare memory allocators and related types. @code{} is included if message translation is in use @@ -1309,11 +1355,8 @@ under BSD Unix 4.3; each produces a usable, though limited, interactive desk-top calculator. These examples are simple, but Bison grammars for real programming -languages are written the same way. -@ifinfo -You can copy these examples out of the Info file and into a source file -to try them. -@end ifinfo +languages are written the same way. You can copy these examples into a +source file to try them. @menu * RPN Calc:: Reverse polish notation calculator; @@ -1432,7 +1475,7 @@ exp: NUM @{ $$ = $1; @} The groupings of the rpcalc ``language'' defined here are the expression (given the name @code{exp}), the line of input (@code{line}), and the complete input transcript (@code{input}). Each of these nonterminal -symbols has several alternate rules, joined by the @samp{|} punctuator +symbols has several alternate rules, joined by the vertical bar @samp{|} which is read as ``or''. The following sections explain what these rules mean. @@ -2123,7 +2166,7 @@ as @code{sin}, @code{cos}, etc. It is easy to add new operators to the infix calculator as long as they are only single-character literals. The lexical analyzer @code{yylex} passes -back all nonnumber characters as tokens, so new grammar rules suffice for +back all nonnumeric characters as tokens, so new grammar rules suffice for adding a new operator. But we want something more flexible: built-in functions whose syntax has this form: @@ -2408,7 +2451,7 @@ getsym (char const *sym_name) The function @code{yylex} must now recognize variables, numeric values, and the single-character arithmetic operators. Strings of alphanumeric -characters with a leading non-digit are recognized as either variables or +characters with a leading letter are recognized as either variables or functions depending on what the symbol table says about them. The string is passed to @code{getsym} for look up in the symbol table. If @@ -2582,13 +2625,17 @@ continues until end of line. @cindex Prologue @cindex declarations -The @var{Prologue} section contains macro definitions and -declarations of functions and variables that are used in the actions in the -grammar rules. These are copied to the beginning of the parser file so -that they precede the definition of @code{yyparse}. You can use -@samp{#include} to get the declarations from a header file. If you don't -need any C declarations, you may omit the @samp{%@{} and @samp{%@}} -delimiters that bracket this section. +The @var{Prologue} section contains macro definitions and declarations +of functions and variables that are used in the actions in the grammar +rules. These are copied to the beginning of the parser file so that +they precede the definition of @code{yyparse}. You can use +@samp{#include} to get the declarations from a header file. If you +don't need any C declarations, you may omit the @samp{%@{} and +@samp{%@}} delimiters that bracket this section. + +The @var{Prologue} section is terminated by the the first occurrence +of @samp{%@}} that is outside a comment, a string literal, or a +character constant. You may have more than one @var{Prologue} section, intermixed with the @var{Bison declarations}. This allows you to have C and Bison @@ -2658,10 +2705,10 @@ even if you define them in the Epilogue. If the last section is empty, you may omit the @samp{%%} that separates it from the grammar rules. -The Bison parser itself contains many macros and identifiers whose -names start with @samp{yy} or @samp{YY}, so it is a -good idea to avoid using any such names (except those documented in this -manual) in the epilogue of the grammar file. +The Bison parser itself contains many macros and identifiers whose names +start with @samp{yy} or @samp{YY}, so it is a good idea to avoid using +any such names (except those documented in this manual) in the epilogue +of the grammar file. @node Symbols @section Symbols, Terminal and Nonterminal @@ -2677,13 +2724,13 @@ A @dfn{terminal symbol} (also known as a @dfn{token type}) represents a class of syntactically equivalent tokens. You use the symbol in grammar rules to mean that a token in that class is allowed. The symbol is represented in the Bison parser by a numeric code, and the @code{yylex} -function returns a token type code to indicate what kind of token has been -read. You don't need to know what the code value is; you can use the -symbol to stand for it. +function returns a token type code to indicate what kind of token has +been read. You don't need to know what the code value is; you can use +the symbol to stand for it. -A @dfn{nonterminal symbol} stands for a class of syntactically equivalent -groupings. The symbol name is used in writing grammar rules. By convention, -it should be all lower case. +A @dfn{nonterminal symbol} stands for a class of syntactically +equivalent groupings. The symbol name is used in writing grammar rules. +By convention, it should be all lower case. Symbol names can contain letters, digits (not at the beginning), underscores and periods. Periods make sense only in nonterminals. @@ -2779,7 +2826,7 @@ into a separate header file @file{@var{name}.tab.h} which you can include in the other source files that need it. @xref{Invocation, ,Invoking Bison}. If you want to write a grammar that is portable to any Standard C -host, you must use only non-null character tokens taken from the basic +host, you must use only nonnull character tokens taken from the basic execution character set of Standard C@. This set consists of the ten digits, the 52 lower- and upper-case English letters, and the characters in the following C-language string: @@ -2788,17 +2835,17 @@ characters in the following C-language string: "\a\b\t\n\v\f\r !\"#%&'()*+,-./:;<=>?[\\]^_@{|@}~" @end example -The @code{yylex} function and Bison must use a consistent character -set and encoding for character tokens. For example, if you run Bison in an -@acronym{ASCII} environment, but then compile and run the resulting program -in an environment that uses an incompatible character set like -@acronym{EBCDIC}, the resulting program may not work because the -tables generated by Bison will assume @acronym{ASCII} numeric values for -character tokens. It is standard -practice for software distributions to contain C source files that -were generated by Bison in an @acronym{ASCII} environment, so installers on -platforms that are incompatible with @acronym{ASCII} must rebuild those -files before compiling them. +The @code{yylex} function and Bison must use a consistent character set +and encoding for character tokens. For example, if you run Bison in an +@acronym{ASCII} environment, but then compile and run the resulting +program in an environment that uses an incompatible character set like +@acronym{EBCDIC}, the resulting program may not work because the tables +generated by Bison will assume @acronym{ASCII} numeric values for +character tokens. It is standard practice for software distributions to +contain C source files that were generated by Bison in an +@acronym{ASCII} environment, so installers on platforms that are +incompatible with @acronym{ASCII} must rebuild those files before +compiling them. The symbol @code{error} is a terminal symbol reserved for error recovery (@pxref{Error Recovery}); you shouldn't use it for any other purpose. @@ -2850,6 +2897,22 @@ the semantics of the rule. An action looks like this: @end example @noindent +@cindex braced code +This is an example of @dfn{braced code}, that is, C code surrounded by +braces, much like a compound statement in C@. Braced code can contain +any sequence of C tokens, so long as its braces are balanced. Bison +does not check the braced code for correctness directly; it merely +copies the code to the output file, where the C compiler can check it. + +Within braced code, the balanced-brace count is not affected by braces +within comments, string literals, or character constants, but it is +affected by the C digraphs @samp{<%} and @samp{%>} that represent +braces. At the top level braced code must be terminated by @samp{@}} +and not by a digraph. Bison does not look for trigraphs, so if braced +code uses trigraphs you should ensure that they do not affect the +nesting of braces or the boundaries of comments, string literals, or +character constants. + Usually there is only one action and it follows the components. @xref{Actions}. @@ -2857,15 +2920,6 @@ Usually there is only one action and it follows the components. Multiple rules for the same @var{result} can be written separately or can be joined with the vertical-bar character @samp{|} as follows: -@ifinfo -@example -@var{result}: @var{rule1-components}@dots{} - | @var{rule2-components}@dots{} - @dots{} - ; -@end example -@end ifinfo -@iftex @example @group @var{result}: @var{rule1-components}@dots{} @@ -2874,7 +2928,6 @@ be joined with the vertical-bar character @samp{|} as follows: ; @end group @end example -@end iftex @noindent They are still considered distinct rules even when joined in this way. @@ -2905,10 +2958,10 @@ with no components. @section Recursive Rules @cindex recursive rule -A rule is called @dfn{recursive} when its @var{result} nonterminal appears -also on its right hand side. Nearly all Bison grammars need to use -recursion, because that is the only way to define a sequence of any number -of a particular thing. Consider this recursive definition of a +A rule is called @dfn{recursive} when its @var{result} nonterminal +appears also on its right hand side. Nearly all Bison grammars need to +use recursion, because that is the only way to define a sequence of any +number of a particular thing. Consider this recursive definition of a comma-separated sequence of one or more expressions: @example @@ -3014,6 +3067,8 @@ specify some other type, define @code{YYSTYPE} as a macro, like this: @end example @noindent +@code{YYSTYPE}'s replacement list should be a type name +that does not contain parentheses or square brackets. This macro definition must go in the prologue of the grammar file (@pxref{Grammar Outline, ,Outline of a Bison Grammar}). @@ -3022,8 +3077,9 @@ This macro definition must go in the prologue of the grammar file In most programs, you will need different data types for different kinds of tokens and groupings. For example, a numeric constant may need type -@code{int} or @code{long int}, while a string constant needs type @code{char *}, -and an identifier might need a pointer to an entry in the symbol table. +@code{int} or @code{long int}, while a string constant needs type +@code{char *}, and an identifier might need a pointer to an entry in the +symbol table. To use more than one data type for semantic values in one parser, Bison requires you to do two things: @@ -3053,14 +3109,8 @@ each time an instance of that rule is recognized. The task of most actions is to compute a semantic value for the grouping built by the rule from the semantic values associated with tokens or smaller groupings. -An action consists of C statements surrounded by braces, much like a -compound statement in C@. An action can contain any sequence of C -statements. Bison does not look for trigraphs, though, so if your C -code uses trigraphs you should ensure that they do not affect the -nesting of braces or the boundaries of comments, strings, or character -literals. - -An action can be placed at any position in the rule; +An action consists of braced code containing C statements, and can be +placed at any position in the rule; it is executed at that position. Most rules have just one action at the end of the rule, following all the components. Actions in the middle of a rule are tricky and used only for special purposes (@pxref{Mid-Rule @@ -3138,6 +3188,12 @@ As long as @code{bar} is used only in the fashion shown here, @code{$0} always refers to the @code{expr} which precedes @code{bar} in the definition of @code{foo}. +@vindex yylval +It is also possible to access the semantic value of the look-ahead token, if +any, from a semantic action. +This semantic value is stored in @code{yylval}. +@xref{Action Features, ,Special Features for Use in Actions}. + @node Action Types @subsection Data Types of Values in Actions @cindex action data types @@ -3247,6 +3303,46 @@ earlier action is used to restore the prior list of variables. This removes the temporary @code{let}-variable from the list so that it won't appear to exist while the rest of the program is parsed. +@findex %destructor +@cindex discarded symbols, mid-rule actions +@cindex error recovery, mid-rule actions +In the above example, if the parser initiates error recovery (@pxref{Error +Recovery}) while parsing the tokens in the embedded statement @code{stmt}, +it might discard the previous semantic context @code{$5} without +restoring it. +Thus, @code{$5} needs a destructor (@pxref{Destructor Decl, , Freeing +Discarded Symbols}). +However, Bison currently provides no means to declare a destructor for a +mid-rule action's semantic value. + +One solution is to bury the mid-rule action inside a nonterminal symbol and to +declare a destructor for that symbol: + +@example +@group +%type let +%destructor @{ pop_context ($$); @} let + +%% + +stmt: let stmt + @{ $$ = $2; + pop_context ($1); @} + ; + +let: LET '(' var ')' + @{ $$ = push_context (); + declare_variable ($3); @} + ; + +@end group +@end example + +@noindent +Note that the action is now at the end of its rule. +Any mid-rule action can be converted to an end-of-rule action in this way, and +this is what Bison actually does to implement mid-rule actions. + Taking action before a rule is completely recognized often leads to conflicts since the parser must commit to a parse in order to execute the action. For example, the following two rules, without mid-rule actions, @@ -3340,10 +3436,7 @@ compound: subroutine @noindent Now Bison can execute the action in the rule for @code{subroutine} without -deciding which rule for @code{compound} it will eventually use. Note that -the action is now at the end of its rule. Any mid-rule action can be -converted to an end-of-rule action in this way, and this is what Bison -actually does to implement mid-rule actions. +deciding which rule for @code{compound} it will eventually use. @node Locations @section Tracking Locations @@ -3372,7 +3465,9 @@ actions to take when rules are matched. Defining a data type for locations is much simpler than for semantic values, since all tokens and groupings always use the same type. -The type of locations is specified by defining a macro called @code{YYLTYPE}. +You can specify the type of locations by defining a macro called +@code{YYLTYPE}, just as you can specify the semantic value type by +defining @code{YYSTYPE} (@pxref{Value Type}). When @code{YYLTYPE} is not defined, Bison uses a default structure type with four members: @@ -3455,9 +3550,16 @@ exp: @dots{} @end group @end example +@vindex yylloc +It is also possible to access the location of the look-ahead token, if any, +from a semantic action. +This location is stored in @code{yylloc}. +@xref{Action Features, ,Special Features for Use in Actions}. + @node Location Default Action @subsection Default Action for Locations @vindex YYLLOC_DEFAULT +@cindex @acronym{GLR} parsers and @code{YYLLOC_DEFAULT} Actually, actions are not the best place to compute locations. Since locations are much more general than semantic values, there is room in @@ -3465,6 +3567,9 @@ the output parser to redefine the default action to take for each rule. The @code{YYLLOC_DEFAULT} macro is invoked each time a rule is matched, before the associated action is run. It is also invoked while processing a syntax error, to compute the error's location. +Before reporting an unresolvable syntactic ambiguity, a @acronym{GLR} +parser invokes @code{YYLLOC_DEFAULT} recursively to compute the location +of that ambiguity. Most of the time, this macro is general enough to suppress location dedicated code from semantic actions. @@ -3473,9 +3578,11 @@ The @code{YYLLOC_DEFAULT} macro takes three parameters. The first one is the location of the grouping (the result of the computation). When a rule is matched, the second parameter identifies locations of all right hand side elements of the rule being matched, and the third -parameter is the size of the rule's right hand side. When processing -a syntax error, the second parameter identifies locations of -the symbols that were discarded during error processing, and the third +parameter is the size of the rule's right hand side. +When a @acronym{GLR} parser reports an ambiguity, which of multiple candidate +right hand sides it passes to @code{YYLLOC_DEFAULT} is undefined. +When processing a syntax error, the second parameter identifies locations +of the symbols that were discarded during error processing, and the third parameter is the number of discarded symbols. By default, @code{YYLLOC_DEFAULT} is defined this way: @@ -3546,6 +3653,7 @@ it explicitly (@pxref{Language and Grammar, ,Languages and Context-Free Grammars}). @menu +* Require Decl:: Requiring a Bison version. * Token Decl:: Declaring terminal symbols. * Precedence Decl:: Declaring terminals with precedence and associativity. * Union Decl:: Declaring the set of all semantic value types. @@ -3558,6 +3666,20 @@ Grammars}). * Decl Summary:: Table of all Bison declarations. @end menu +@node Require Decl +@subsection Require a Version of Bison +@cindex version requirement +@cindex requiring a version of Bison +@findex %require + +You may require the minimum version of Bison to process the grammar. If +the requirement is not met, @command{bison} exits with an error (exit +status 63). + +@example +%require "@var{version}" +@end example + @node Token Decl @subsection Token Type Names @cindex declaring token type names @@ -3691,10 +3813,10 @@ the one declared later has the higher precedence and is grouped first. @cindex value types, declaring @findex %union -The @code{%union} declaration specifies the entire collection of possible -data types for semantic values. The keyword @code{%union} is followed by a -pair of braces containing the same thing that goes inside a @code{union} in -C. +The @code{%union} declaration specifies the entire collection of +possible data types for semantic values. The keyword @code{%union} is +followed by braced code containing the same thing that goes inside a +@code{union} in C@. For example: @@ -3725,10 +3847,15 @@ As an extension to @acronym{POSIX}, a tag is allowed after the @end group @end example +@noindent specifies the union tag @code{value}, so the corresponding C type is @code{union value}. If you do not specify a tag, it defaults to @code{YYSTYPE}. +As another extension to @acronym{POSIX}, you may specify multiple +@code{%union} declarations; their contents are concatenated. However, +only the first @code{%union} declaration can specify a tag. + Note that, unlike making a @code{union} declaration in C, you need not write a semicolon after the closing brace. @@ -3770,7 +3897,7 @@ code. @deffn {Directive} %initial-action @{ @var{code} @} @findex %initial-action -Declare that the @var{code} must be invoked before parsing each time +Declare that the braced @var{code} must be invoked before parsing each time @code{yyparse} is called. The @var{code} may use @code{$$} and @code{@@$} --- initial value and location of the look-ahead --- and the @code{%parse-param}. @@ -3782,7 +3909,7 @@ For instance, if your locations use a file name, you may use %parse-param @{ char const *file_name @}; %initial-action @{ - @@$.begin.filename = @@$.end.filename = file_name; + @@$.initialize (file_name); @}; @end example @@ -3792,32 +3919,29 @@ For instance, if your locations use a file name, you may use @cindex freeing discarded symbols @findex %destructor -Some symbols can be discarded by the parser. During error -recovery (@pxref{Error Recovery}), symbols already pushed -on the stack and tokens coming from the rest of the file -are discarded until the parser falls on its feet. If the parser -runs out of memory, all the symbols on the stack must be discarded. -Even if the parser succeeds, it must discard the start symbol. +During error recovery (@pxref{Error Recovery}), symbols already pushed +on the stack and tokens coming from the rest of the file are discarded +until the parser falls on its feet. If the parser runs out of memory, +or if it returns via @code{YYABORT} or @code{YYACCEPT}, all the +symbols on the stack must be discarded. Even if the parser succeeds, it +must discard the start symbol. When discarded symbols convey heap based information, this memory is lost. While this behavior can be tolerable for batch parsers, such as -in traditional compilers, it is unacceptable for programs like shells -or protocol implementations that may parse and execute indefinitely. +in traditional compilers, it is unacceptable for programs like shells or +protocol implementations that may parse and execute indefinitely. -The @code{%destructor} directive defines code that -is called when a symbol is discarded. +The @code{%destructor} directive defines code that is called when a +symbol is automatically discarded. @deffn {Directive} %destructor @{ @var{code} @} @var{symbols} @findex %destructor -Invoke @var{code} whenever the parser discards one of the -@var{symbols}. Within @var{code}, @code{$$} designates the semantic -value associated with the discarded symbol. The additional -parser parameters are also available -(@pxref{Parser Function, , The Parser Function @code{yyparse}}). - -@strong{Warning:} as of Bison 2.1, this feature is still -experimental, as there has not been enough user feedback. In particular, -the syntax might still change. +Invoke the braced @var{code} whenever the parser discards one of the +@var{symbols}. +Within @var{code}, @code{$$} designates the semantic value associated +with the discarded symbol. The additional parser parameters are also +available (@pxref{Parser Function, , The Parser Function +@code{yyparse}}). @end deffn For instance: @@ -3836,24 +3960,6 @@ For instance: guarantees that when a @code{STRING} or a @code{string} is discarded, its associated memory will be freed. -Note that in the future, Bison might also consider that right hand side -members that are not mentioned in the action can be destroyed. For -instance, in: - -@smallexample -comment: "/*" STRING "*/"; -@end smallexample - -@noindent -the parser is entitled to destroy the semantic value of the -@code{string}. Of course, this will not apply to the default action; -compare: - -@smallexample -typeless: string; // $$ = $1 does not apply; $1 is destroyed. -typefull: string; // $$ = $1 applies, $1 is not destroyed. -@end smallexample - @sp 1 @cindex discarded symbols @@ -3865,13 +3971,20 @@ stacked symbols popped during the first phase of error recovery, @item incoming terminals during the second phase of error recovery, @item -the current look-ahead and the entire stack when the parser aborts -(either via an explicit call to @code{YYABORT}, or as a consequence of -a failed error recovery or of memory exhaustion), and +the current look-ahead and the entire stack (except the current +right-hand side symbols) when the parser returns immediately, and @item the start symbol, when the parser succeeds. @end itemize +The parser can @dfn{return immediately} because of an explicit call to +@code{YYABORT} or @code{YYACCEPT}, or failed error recovery, or memory +exhaustion. + +Right-hand size symbols of a rule that explicitly triggers a syntax +error via @code{YYERROR} are not discarded automatically. As a rule +of thumb, destructors are invoked only when user actions cannot manage +the memory. @node Expect Decl @subsection Suppressing Conflict Warnings @@ -3895,19 +4008,18 @@ The declaration looks like this: %expect @var{n} @end example -Here @var{n} is a decimal integer. The declaration says there should be -no warning if there are @var{n} shift/reduce conflicts and no -reduce/reduce conflicts. The usual warning is -given if there are either more or fewer conflicts, or if there are any -reduce/reduce conflicts. +Here @var{n} is a decimal integer. The declaration says there should +be @var{n} shift/reduce conflicts and no reduce/reduce conflicts. +Bison reports an error if the number of shift/reduce conflicts differs +from @var{n}, or if there are any reduce/reduce conflicts. -For normal @acronym{LALR}(1) parsers, reduce/reduce conflicts are more serious, -and should be eliminated entirely. Bison will always report -reduce/reduce conflicts for these parsers. With @acronym{GLR} parsers, however, -both shift/reduce and reduce/reduce are routine (otherwise, there -would be no need to use @acronym{GLR} parsing). Therefore, it is also possible -to specify an expected number of reduce/reduce conflicts in @acronym{GLR} -parsers, using the declaration: +For normal @acronym{LALR}(1) parsers, reduce/reduce conflicts are more +serious, and should be eliminated entirely. Bison will always report +reduce/reduce conflicts for these parsers. With @acronym{GLR} +parsers, however, both kinds of conflicts are routine; otherwise, +there would be no need to use @acronym{GLR} parsing. Therefore, it is +also possible to specify an expected number of reduce/reduce conflicts +in @acronym{GLR} parsers, using the declaration: @example %expect-rr @var{n} @@ -3928,12 +4040,12 @@ go back to the beginning. @item Add an @code{%expect} declaration, copying the number @var{n} from the -number which Bison printed. +number which Bison printed. With @acronym{GLR} parsers, add an +@code{%expect-rr} declaration as well. @end itemize -Now Bison will stop annoying you if you do not change the number of -conflicts, but it will warn you again if changes in the grammar result -in more or fewer conflicts. +Now Bison will warn you if you introduce an unexpected conflict, but +will keep silent otherwise. @node Start Decl @subsection The Start-Symbol @@ -3959,8 +4071,8 @@ may override this restriction with the @code{%start} declaration as follows: A @dfn{reentrant} program is one which does not alter in the course of execution; in other words, it consists entirely of @dfn{pure} (read-only) code. Reentrancy is important whenever asynchronous execution is possible; -for example, a non-reentrant program may not be safe to call from a signal -handler. In systems with multiple threads of control, a non-reentrant +for example, a nonreentrant program may not be safe to call from a signal +handler. In systems with multiple threads of control, a nonreentrant program must be called only within interlocks. Normally, Bison generates a parser which is not reentrant. This is @@ -4066,13 +4178,12 @@ is named @file{@var{name}.h}. Unless @code{YYSTYPE} is already defined as a macro, the output header declares @code{YYSTYPE}. Therefore, if you are using a @code{%union} -(@pxref{Multiple Types, ,More Than One Value Type}) with components -that require other definitions, or if you have defined a -@code{YYSTYPE} macro (@pxref{Value Type, ,Data Types of Semantic -Values}), you need to arrange for these definitions to be propagated to -all modules, e.g., by putting them in a -prerequisite header that is included both by your parser and by any -other module that needs @code{YYSTYPE}. +(@pxref{Multiple Types, ,More Than One Value Type}) with components that +require other definitions, or if you have defined a @code{YYSTYPE} macro +(@pxref{Value Type, ,Data Types of Semantic Values}), you need to +arrange for these definitions to be propagated to all modules, e.g., by +putting them in a prerequisite header that is included both by your +parser and by any other module that needs @code{YYSTYPE}. Unless your parser is pure, the output header declares @code{yylval} as an external variable. @xref{Pure Decl, ,A Pure (Reentrant) @@ -4083,11 +4194,11 @@ If you have also used locations, the output header declares @code{YYSTYPE} and @code{yylval}. @xref{Locations, ,Tracking Locations}. -This output file is normally essential if you wish to put the -definition of @code{yylex} in a separate source file, because -@code{yylex} typically needs to be able to refer to the -above-mentioned declarations and to the token type codes. -@xref{Token Values, ,Semantic Values of Tokens}. +This output file is normally essential if you wish to put the definition +of @code{yylex} in a separate source file, because @code{yylex} +typically needs to be able to refer to the above-mentioned declarations +and to the token type codes. @xref{Token Values, ,Semantic Values of +Tokens}. @end deffn @deffn {Directive} %destructor @@ -4111,12 +4222,14 @@ accurate syntax error messages. @deffn {Directive} %name-prefix="@var{prefix}" Rename the external symbols used in the parser so that they start with @var{prefix} instead of @samp{yy}. The precise list of symbols renamed +in C parsers is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs}, -@code{yylval}, @code{yylloc}, @code{yychar}, @code{yydebug}, and -possible @code{yylloc}. For example, if you use +@code{yylval}, @code{yychar}, @code{yydebug}, and +(if locations are used) @code{yylloc}. For example, if you use @samp{%name-prefix="c_"}, the names become @code{c_parse}, @code{c_lex}, -and so on. @xref{Multiple Parsers, ,Multiple Parsers in the Same -Program}. +and so on. In C++ parsers, it is only the surrounding namespace which is +named @var{prefix} instead of @samp{yy}. +@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}. @end deffn @ifset defaultprec @@ -4155,6 +4268,11 @@ Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure (Reentrant) Parser}). @end deffn +@deffn {Directive} %require "@var{version}" +Require version @var{version} or higher of Bison. @xref{Require Decl, , +Require a Version of Bison}. +@end deffn + @deffn {Directive} %token-table Generate an array of token names in the parser file. The name of the array is @code{yytname}; @code{yytname[@var{i}]} is the name of the @@ -4297,8 +4415,8 @@ declaration @code{%parse-param}: @deffn {Directive} %parse-param @{@var{argument-declaration}@} @findex %parse-param -Declare that an argument declared by @code{argument-declaration} is an -additional @code{yyparse} argument. +Declare that an argument declared by the braced-code +@var{argument-declaration} is an additional @code{yyparse} argument. The @var{argument-declaration} is used when declaring functions or prototypes. The last identifier in @var{argument-declaration} must be the argument name. @@ -4445,7 +4563,7 @@ The @code{yytname} table is generated only if you use the @subsection Semantic Values of Tokens @vindex yylval -In an ordinary (non-reentrant) parser, the semantic value of the token must +In an ordinary (nonreentrant) parser, the semantic value of the token must be stored into the global variable @code{yylval}. When you are using just one data type for semantic values, @code{yylval} has that type. Thus, if the type is @code{int} (the default), you might write this in @@ -4493,12 +4611,11 @@ then the code in @code{yylex} might look like this: @vindex yylloc If you are using the @samp{@@@var{n}}-feature (@pxref{Locations, , -Tracking Locations}) in actions to keep track of the -textual locations of tokens and groupings, then you must provide this -information in @code{yylex}. The function @code{yyparse} expects to -find the textual location of a token just parsed in the global variable -@code{yylloc}. So @code{yylex} must store the proper data in that -variable. +Tracking Locations}) in actions to keep track of the textual locations +of tokens and groupings, then you must provide this information in +@code{yylex}. The function @code{yyparse} expects to find the textual +location of a token just parsed in the global variable @code{yylloc}. +So @code{yylex} must store the proper data in that variable. By default, the value of @code{yylloc} is a structure and you need only initialize the members that are going to be used by the actions. The @@ -4543,8 +4660,8 @@ Function}). @deffn {Directive} lex-param @{@var{argument-declaration}@} @findex %lex-param -Declare that @code{argument-declaration} is an additional @code{yylex} -argument declaration. +Declare that the braced-code @var{argument-declaration} is an +additional @code{yylex} argument declaration. @end deffn For instance: @@ -4693,7 +4810,7 @@ preferable since it more accurately describes the return type for @vindex yynerrs The variable @code{yynerrs} contains the number of syntax errors -encountered so far. Normally this variable is global; but if you +reported so far. Normally this variable is global; but if you request a pure parser (@pxref{Pure Decl, ,A Pure (Reentrant) Parser}) then it is a local variable which only the actions can access. @@ -4759,6 +4876,12 @@ In either case, the rest of the action is not executed. Value stored in @code{yychar} when there is no look-ahead token. @end deffn +@deffn {Macro} YYEOF +@vindex YYEOF +Value stored in @code{yychar} when the look-ahead is the end of the input +stream. +@end deffn + @deffn {Macro} YYERROR; @findex YYERROR Cause an immediate syntax error. This statement initiates error @@ -4769,21 +4892,27 @@ the @samp{YYERROR;} statement. @xref{Error Recovery}. @end deffn @deffn {Macro} YYRECOVERING -This macro stands for an expression that has the value 1 when the parser -is recovering from a syntax error, and 0 the rest of the time. +@findex YYRECOVERING +The expression @code{YYRECOVERING ()} yields 1 when the parser +is recovering from a syntax error, and 0 otherwise. @xref{Error Recovery}. @end deffn @deffn {Variable} yychar -Variable containing the current look-ahead token. (In a pure parser, -this is actually a local variable within @code{yyparse}.) When there is -no look-ahead token, the value @code{YYEMPTY} is stored in the variable. +Variable containing either the look-ahead token, or @code{YYEOF} when the +look-ahead is the end of the input stream, or @code{YYEMPTY} when no look-ahead +has been performed so the next token is not yet known. +Do not modify @code{yychar} in a deferred semantic action (@pxref{GLR Semantic +Actions}). @xref{Look-Ahead, ,Look-Ahead Tokens}. @end deffn @deffn {Macro} yyclearin; Discard the current look-ahead token. This is useful primarily in -error rules. @xref{Error Recovery}. +error rules. +Do not invoke @code{yyclearin} in a deferred semantic action (@pxref{GLR +Semantic Actions}). +@xref{Error Recovery}. @end deffn @deffn {Macro} yyerrok; @@ -4792,6 +4921,22 @@ errors. This is useful primarily in error rules. @xref{Error Recovery}. @end deffn +@deffn {Variable} yylloc +Variable containing the look-ahead token location when @code{yychar} is not set +to @code{YYEMPTY} or @code{YYEOF}. +Do not modify @code{yylloc} in a deferred semantic action (@pxref{GLR Semantic +Actions}). +@xref{Actions and Locations, ,Actions and Locations}. +@end deffn + +@deffn {Variable} yylval +Variable containing the look-ahead token semantic value when @code{yychar} is +not set to @code{YYEMPTY} or @code{YYEOF}. +Do not modify @code{yylval} in a deferred semantic action (@pxref{GLR Semantic +Actions}). +@xref{Actions, ,Actions}. +@end deffn + @deffn {Value} @@$ @findex @@$ Acts like a structure variable containing information on the textual location @@ -4835,12 +4980,11 @@ Tracking Locations}. A Bison-generated parser can print diagnostics, including error and tracing messages. By default, they appear in English. However, Bison -also supports outputting diagnostics in the user's native language. -To make this work, the user should set the usual environment -variables. @xref{Users, , The User's View, gettext, GNU -@code{gettext} utilities}. For -example, the shell command @samp{export LC_ALL=fr_CA.UTF-8} might set -the user's locale to French Canadian using the @acronym{UTF}-8 +also supports outputting diagnostics in the user's native language. To +make this work, the user should set the usual environment variables. +@xref{Users, , The User's View, gettext, GNU @code{gettext} utilities}. +For example, the shell command @samp{export LC_ALL=fr_CA.UTF-8} might +set the user's locale to French Canadian using the @acronym{UTF}-8 encoding. The exact set of available locales depends on the user's installation. @@ -5030,7 +5174,11 @@ doing so would produce on the stack the sequence of symbols @code{expr '!'}. No rule allows that sequence. @vindex yychar -The current look-ahead token is stored in the variable @code{yychar}. +@vindex yylval +@vindex yylloc +The look-ahead token is stored in the variable @code{yychar}. +Its semantic value and location, if any, are stored in the variables +@code{yylval} and @code{yylloc}. @xref{Action Features, ,Special Features for Use in Actions}. @node Shift/Reduce @@ -5605,7 +5753,7 @@ pp.@: 615--649 @uref{http://doi.acm.org/10.1145/69622.357187}. @cindex @acronym{GLR} parsing @cindex generalized @acronym{LR} (@acronym{GLR}) parsing @cindex ambiguous grammars -@cindex non-deterministic parsing +@cindex nondeterministic parsing Bison produces @emph{deterministic} parsers that choose uniquely when to reduce and which reduction to apply @@ -5670,10 +5818,10 @@ quadratic worst-case time, and any general (possibly ambiguous) context-free grammar in cubic worst-case time. However, Bison currently uses a simpler data structure that requires time proportional to the length of the input times the maximum number of stacks required for any -prefix of the input. Thus, really ambiguous or non-deterministic +prefix of the input. Thus, really ambiguous or nondeterministic grammars can require exponential time and space to process. Such badly behaving examples, however, are not generally of practical interest. -Usually, non-determinism in a grammar is local---the parser is ``in +Usually, nondeterminism in a grammar is local---the parser is ``in doubt'' only for a few tokens at a time. Therefore, the current data structure should generally be adequate. On @acronym{LALR}(1) portions of a grammar, in particular, it is only slightly slower than with the default @@ -5847,6 +5995,7 @@ The previous look-ahead token is reanalyzed immediately after an error. If this is unacceptable, then the macro @code{yyclearin} may be used to clear this token. Write the statement @samp{yyclearin;} in the error rule's action. +@xref{Action Features, ,Special Features for Use in Actions}. For example, suppose that on a syntax error, an error handling routine is called that advances the input stream to some point where parsing should @@ -5855,10 +6004,10 @@ probably correct. The previous look-ahead token ought to be discarded with @samp{yyclearin;}. @vindex YYRECOVERING -The macro @code{YYRECOVERING} stands for an expression that has the -value 1 when the parser is recovering from a syntax error, and 0 the -rest of the time. A value of 1 indicates that error messages are -currently suppressed for new syntax errors. +The expression @code{YYRECOVERING ()} yields 1 when the parser +is recovering from a syntax error, and 0 otherwise. +Syntax error diagnostics are suppressed while recovering from a syntax +error. @node Context Dependency @chapter Handling Context Dependencies @@ -6674,13 +6823,14 @@ Print the version number of Bison and exit. @item --print-localedir Print the name of the directory containing locale-dependent data. -@need 1750 @item -y @itemx --yacc -Equivalent to @samp{-o y.tab.c}; the parser output file is called +Act more like the traditional Yacc command. This can cause +different diagnostics to be generated, and may change behavior in +other minor ways. Most importantly, imitate Yacc's output +file name conventions, so that the parser output file is called @file{y.tab.c}, and the other outputs are called @file{y.output} and -@file{y.tab.h}. The purpose of this option is to imitate Yacc's output -file name conventions. Thus, the following shell script can substitute +@file{y.tab.h}. Thus, the following shell script can substitute for Yacc, and the Bison distribution contains such a script for compatibility with @acronym{POSIX}: @@ -6688,6 +6838,12 @@ compatibility with @acronym{POSIX}: #! /bin/sh bison -y "$@@" @end example + +The @option{-y}/@option{--yacc} option is intended for use with +traditional Yacc grammars. If your grammar uses a Bison extension +like @samp{%glr-parser}, Bison might not be Yacc-compatible even if +this option is specified. + @end table @noindent @@ -6745,7 +6901,7 @@ Same as above, but save in the file @var{defines-file}. @item -b @var{file-prefix} @itemx --file-prefix=@var{prefix} -Pretend that @code{%verbose} was specified, i.e, specify prefix to use +Pretend that @code{%file-prefix} was specified, i.e, specify prefix to use for all Bison output file names. @xref{Decl Summary}. @item -r @var{things} @@ -6767,8 +6923,6 @@ Implies @code{state} and augments the description of the automaton with the full set of items for each state, instead of its core only. @end table -For instance, on the following grammar - @item -v @itemx --verbose Pretend that @code{%verbose} was specified, i.e, write an extra output @@ -6797,48 +6951,27 @@ the output graph file. @node Option Cross Key @section Option Cross Key +@c FIXME: How about putting the directives too? Here is a list of options, alphabetized by long option, to help you find the corresponding short option. -@tex -\def\leaderfill{\leaders\hbox to 1em{\hss.\hss}\hfill} - -{\tt -\line{ --debug \leaderfill -t} -\line{ --defines \leaderfill -d} -\line{ --file-prefix \leaderfill -b} -\line{ --graph \leaderfill -g} -\line{ --help \leaderfill -h} -\line{ --name-prefix \leaderfill -p} -\line{ --no-lines \leaderfill -l} -\line{ --no-parser \leaderfill -n} -\line{ --output \leaderfill -o} -\line{ --print-localedir} -\line{ --token-table \leaderfill -k} -\line{ --verbose \leaderfill -v} -\line{ --version \leaderfill -V} -\line{ --yacc \leaderfill -y} -} -@end tex - -@ifinfo -@example ---debug -t ---defines=@var{defines-file} -d ---file-prefix=@var{prefix} -b @var{file-prefix} ---graph=@var{graph-file} -d ---help -h ---name-prefix=@var{prefix} -p @var{name-prefix} ---no-lines -l ---no-parser -n ---output=@var{outfile} -o @var{outfile} ---print-localedir ---token-table -k ---verbose -v ---version -V ---yacc -y -@end example -@end ifinfo +@multitable {@option{--defines=@var{defines-file}}} {@option{-b @var{file-prefix}XXX}} +@headitem Long Option @tab Short Option +@item @option{--debug} @tab @option{-t} +@item @option{--defines=@var{defines-file}} @tab @option{-d} +@item @option{--file-prefix=@var{prefix}} @tab @option{-b @var{file-prefix}} +@item @option{--graph=@var{graph-file}} @tab @option{-d} +@item @option{--help} @tab @option{-h} +@item @option{--name-prefix=@var{prefix}} @tab @option{-p @var{name-prefix}} +@item @option{--no-lines} @tab @option{-l} +@item @option{--no-parser} @tab @option{-n} +@item @option{--output=@var{outfile}} @tab @option{-o @var{outfile}} +@item @option{--print-localedir} @tab +@item @option{--token-table} @tab @option{-k} +@item @option{--verbose} @tab @option{-v} +@item @option{--version} @tab @option{-V} +@item @option{--yacc} @tab @option{-y} +@end multitable @node Yacc Library @section Yacc Library @@ -6893,11 +7026,14 @@ int yyparse (void); @c - Always pure @c - initial action -The C++ parser @acronym{LALR}(1) skeleton is named @file{lalr1.cc}. To select -it, you may either pass the option @option{--skeleton=lalr1.cc} to -Bison, or include the directive @samp{%skeleton "lalr1.cc"} in the +The C++ parser @acronym{LALR}(1) skeleton is named @file{lalr1.cc}. To +select it, you may either pass the option @option{--skeleton=lalr1.cc} +to Bison, or include the directive @samp{%skeleton "lalr1.cc"} in the grammar preamble. When run, @command{bison} will create several -files: +entities in the @samp{yy} namespace. Use the @samp{%name-prefix} +directive to change the namespace name, see @ref{Decl Summary}. The +various classes are generated in the following files: + @table @file @item position.hh @itemx location.hh @@ -6909,13 +7045,13 @@ An auxiliary class @code{stack} used by the parser. @item @var{file}.hh @itemx @var{file}.cc -The declaration and implementation of the C++ parser class. -@var{file} is the name of the output file. It follows the same -rules as with regular C parsers. +(Assuming the extension of the input file was @samp{.yy}.) The +declaration and implementation of the C++ parser class. The basename +and extension of these two files follow the same rules as with regular C +parsers (@pxref{Invocation}). -Note that @file{@var{file}.hh} is @emph{mandatory}, the C++ cannot -work without the parser class declaration. Therefore, you must either -pass @option{-d}/@option{--defines} to @command{bison}, or use the +The header is @emph{mandatory}; you must either pass +@option{-d}/@option{--defines} to @command{bison}, or use the @samp{%defines} directive. @end table @@ -6931,12 +7067,13 @@ for a complete and accurate documentation. The @code{%union} directive works as for C, see @ref{Union Decl, ,The Collection of Value Types}. In particular it produces a genuine @code{union}@footnote{In the future techniques to allow complex types -within pseudo-unions (variants) might be implemented to alleviate -these issues.}, which have a few specific features in C++. +within pseudo-unions (similar to Boost variants) might be implemented to +alleviate these issues.}, which have a few specific features in C++. @itemize @minus @item -The name @code{YYSTYPE} also denotes @samp{union YYSTYPE}. You may -forward declare it just with @samp{union YYSTYPE;}. +The type @code{YYSTYPE} is defined but its use is discouraged: rather +you should refer to the parser's encapsulated type +@code{yy::parser::semantic_type}. @item Non POD (Plain Old Data) types cannot be used. C++ forbids any instance of classes with constructors in unions: only @emph{pointers} @@ -7031,7 +7168,7 @@ The output files @file{@var{output}.hh} and @file{@var{output}.cc} declare and define the parser class in the namespace @code{yy}. The class name defaults to @code{parser}, but may be changed using @samp{%define "parser_class_name" "@var{name}"}. The interface of -this class is detailled below. It can be extended using the +this class is detailed below. It can be extended using the @code{%parse-param} feature: its semantics is slightly changed since it describes an additional member of the parser class, and an additional argument for its constructor. @@ -7059,7 +7196,7 @@ Get or set the stream used for tracing the parsing. It defaults to @deftypemethod {parser} {debug_level_type} debug_level () @deftypemethodx {parser} {void} set_debug_level (debug_level @var{l}) Get or set the tracing level. Currently its value is either 0, no trace, -or non-zero, full tracing. +or nonzero, full tracing. @end deftypemethod @deftypemethod {parser} {void} error (const location_type& @var{l}, const std::string& @var{m}) @@ -7110,7 +7247,7 @@ actually easier to interface with. @subsection Calc++ --- C++ Calculator Of course the grammar is dedicated to arithmetics, a single -expression, possibily preceded by variable assignments. An +expression, possibly preceded by variable assignments. An environment containing possibly predefined variables such as @code{one} and @code{two}, is exchanged with the parser. An example of valid input follows. @@ -7137,7 +7274,8 @@ transforming the simple parsing context structure into a fully blown The declaration of this driver class, @file{calc++-driver.hh}, is as follows. The first part includes the CPP guard and imports the -required standard library components. +required standard library components, and the declaration of the parser +class. @comment file: calc++-driver.hh @example @@ -7145,26 +7283,9 @@ required standard library components. # define CALCXX_DRIVER_HH # include # include +# include "calc++-parser.hh" @end example -@noindent -Then come forward declarations. Because the parser uses the parsing -driver and reciprocally, simple inclusions of header files will not -do. Because the driver's declaration is the one that will be imported -by the rest of the project, it is saner to forward declare the -parser's information here. - -@comment file: calc++-driver.hh -@example -// Forward declarations. -union YYSTYPE; -namespace yy -@{ - class location; - class calcxx_parser; -@} -class calcxx_driver; -@end example @noindent Then comes the declaration of the scanning function. Flex expects @@ -7175,8 +7296,11 @@ factor both as follows. @comment file: calc++-driver.hh @example // Announce to Flex the prototype we want for lexing function, ... -# define YY_DECL \ - int yylex (YYSTYPE* yylval, yy::location* yylloc, calcxx_driver& driver) +# define YY_DECL \ + yy::calcxx_parser::token_type \ + yylex (yy::calcxx_parser::semantic_type* yylval, \ + yy::calcxx_parser::location_type* yylloc, \ + calcxx_driver& driver) // ... and declare it for the parser's sake. YY_DECL; @end example @@ -7286,19 +7410,33 @@ calcxx_driver::error (const std::string& m) @node Calc++ Parser @subsection Calc++ Parser -The parser definition file @file{calc++-parser.yy} starts by asking -for the C++ skeleton, the creation of the parser header file, and -specifies the name of the parser class. It then includes the required -headers. +The parser definition file @file{calc++-parser.yy} starts by asking for +the C++ LALR(1) skeleton, the creation of the parser header file, and +specifies the name of the parser class. Because the C++ skeleton +changed several times, it is safer to require the version you designed +the grammar for. @comment file: calc++-parser.yy @example %skeleton "lalr1.cc" /* -*- C++ -*- */ -%define "parser_class_name" "calcxx_parser" +%require "2.1a" %defines +%define "parser_class_name" "calcxx_parser" +@end example + +@noindent +Then come the declarations/inclusions needed to define the +@code{%union}. Because the parser uses the parsing driver and +reciprocally, both cannot include the header of the other. Because the +driver's header needs detailed knowledge about the parser class (in +particular its inner types), it is the parser's header which will simply +use a forward declaration of the driver. + +@comment file: calc++-parser.yy +@example %@{ # include -# include "calc++-driver.hh" +class calcxx_driver; %@} @end example @@ -7354,6 +7492,19 @@ them. @}; @end example +@noindent +The code between @samp{%@{} and @samp{%@}} after the introduction of the +@samp{%union} is output in the @file{*.cc} file; it needs detailed +knowledge about the driver. + +@comment file: calc++-parser.yy +@example +%@{ +# include "calc++-driver.hh" +%@} +@end example + + @noindent The token numbered as 0 corresponds to end of file; the following line allows for nicer error messages referring to ``end of file'' instead @@ -7363,17 +7514,18 @@ avoid name clashes. @comment file: calc++-parser.yy @example -%token TOKEN_EOF 0 "end of file" -%token TOKEN_ASSIGN ":=" -%token TOKEN_IDENTIFIER "identifier" -%token TOKEN_NUMBER "number" -%type exp "expression" +%token END 0 "end of file" +%token ASSIGN ":=" +%token IDENTIFIER "identifier" +%token NUMBER "number" +%type exp "expression" @end example @noindent To enable memory deallocation during error recovery, use @code{%destructor}. +@c FIXME: Document %printer, and mention that it takes a braced-code operand. @comment file: calc++-parser.yy @example %printer @{ debug_stream () << *$$; @} "identifier" @@ -7392,9 +7544,9 @@ The grammar itself is straightforward. unit: assignments exp @{ driver.result = $2; @}; assignments: assignments assignment @{@} - | /* Nothing. */ @{@}; + | /* Nothing. */ @{@}; -assignment: TOKEN_IDENTIFIER ":=" exp @{ driver.variables[*$1] = $3; @}; +assignment: "identifier" ":=" exp @{ driver.variables[*$1] = $3; @}; %left '+' '-'; %left '*' '/'; @@ -7402,8 +7554,8 @@ exp: exp '+' exp @{ $$ = $1 + $3; @} | exp '-' exp @{ $$ = $1 - $3; @} | exp '*' exp @{ $$ = $1 * $3; @} | exp '/' exp @{ $$ = $1 / $3; @} - | TOKEN_IDENTIFIER @{ $$ = driver.variables[*$1]; @} - | TOKEN_NUMBER @{ $$ = $1; @}; + | "identifier" @{ $$ = driver.variables[*$1]; @} + | "number" @{ $$ = $1; @}; %% @end example @@ -7436,6 +7588,18 @@ parser's to get the set of defined tokens. # include # include "calc++-driver.hh" # include "calc++-parser.hh" + +/* Work around an incompatibility in flex (at least versions + 2.5.31 through 2.5.33): it generates code that does + not conform to C89. See Debian bug 333231 + . */ +# undef yywrap +# define yywrap() 1 + +/* By default yylex returns int, we use token_type. + Unfortunately yyterminate by default returns 0, which is + not of token_type. */ +#define yyterminate() return token::END %@} @end example @@ -7461,7 +7625,7 @@ blank [ \t] @end example @noindent -The following paragraph suffices to track locations acurately. Each +The following paragraph suffices to track locations accurately. Each time @code{yylex} is invoked, the begin position is moved onto the end position. Then when a pattern is matched, the end position is advanced of its width. In case it matched ends of lines, the end @@ -7483,22 +7647,28 @@ preceding tokens. Comments would be treated equally. @end example @noindent -The rules are simple, just note the use of the driver to report -errors. +The rules are simple, just note the use of the driver to report errors. +It is convenient to use a typedef to shorten +@code{yy::calcxx_parser::token::identifier} into +@code{token::identifier} for instance. @comment file: calc++-scanner.ll @example -[-+*/] return yytext[0]; -":=" return TOKEN_ASSIGN; +%@{ + typedef yy::calcxx_parser::token token; +%@} + /* Convert ints to the actual type of tokens. */ +[-+*/] return yy::calcxx_parser::token_type (yytext[0]); +":=" return token::ASSIGN; @{int@} @{ errno = 0; long n = strtol (yytext, NULL, 10); if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) driver.error (*yylloc, "integer is out of range"); yylval->ival = n; - return TOKEN_NUMBER; + return token::NUMBER; @} -@{id@} yylval->sval = new std::string (yytext); return TOKEN_IDENTIFIER; +@{id@} yylval->sval = new std::string (yytext); return token::IDENTIFIER; . driver.error (*yylloc, "invalid character"); %% @end example @@ -7562,10 +7732,18 @@ Several questions about Bison come up occasionally. Here some of them are addressed. @menu -* Memory Exhausted:: Breaking the Stack Limits -* How Can I Reset the Parser:: @code{yyparse} Keeps some State -* Strings are Destroyed:: @code{yylval} Loses Track of Strings -* Implementing Gotos/Loops:: Control Flow in the Calculator +* Memory Exhausted:: Breaking the Stack Limits +* How Can I Reset the Parser:: @code{yyparse} Keeps some State +* Strings are Destroyed:: @code{yylval} Loses Track of Strings +* Implementing Gotos/Loops:: Control Flow in the Calculator +* Multiple start-symbols:: Factoring closely related grammars +* Secure? Conform?:: Is Bison @acronym{POSIX} safe? +* I can't build Bison:: Troubleshooting +* Where can I find help?:: Troubleshouting +* Bug Reports:: Troublereporting +* Other Languages:: Parsers in Java and others +* Beta Testing:: Experimenting development versions +* Mailing Lists:: Meeting other Bison users @end menu @node Memory Exhausted @@ -7681,7 +7859,7 @@ them. Instead of reporting @samp{"foo", "bar"}, it reports This error is probably the single most frequent ``bug report'' sent to Bison lists, but is only concerned with a misunderstanding of the role -of scanner. Consider the following Lex code: +of the scanner. Consider the following Lex code: @verbatim %{ @@ -7759,6 +7937,172 @@ This topic is way beyond the scope of this manual, and the reader is invited to consult the dedicated literature. +@node Multiple start-symbols +@section Multiple start-symbols + +@display +I have several closely related grammars, and I would like to share their +implementations. In fact, I could use a single grammar but with +multiple entry points. +@end display + +Bison does not support multiple start-symbols, but there is a very +simple means to simulate them. If @code{foo} and @code{bar} are the two +pseudo start-symbols, then introduce two new tokens, say +@code{START_FOO} and @code{START_BAR}, and use them as switches from the +real start-symbol: + +@example +%token START_FOO START_BAR; +%start start; +start: START_FOO foo + | START_BAR bar; +@end example + +These tokens prevents the introduction of new conflicts. As far as the +parser goes, that is all that is needed. + +Now the difficult part is ensuring that the scanner will send these +tokens first. If your scanner is hand-written, that should be +straightforward. If your scanner is generated by Lex, them there is +simple means to do it: recall that anything between @samp{%@{ ... %@}} +after the first @code{%%} is copied verbatim in the top of the generated +@code{yylex} function. Make sure a variable @code{start_token} is +available in the scanner (e.g., a global variable or using +@code{%lex-param} etc.), and use the following: + +@example + /* @r{Prologue.} */ +%% +%@{ + if (start_token) + @{ + int t = start_token; + start_token = 0; + return t; + @} +%@} + /* @r{The rules.} */ +@end example + + +@node Secure? Conform? +@section Secure? Conform? + +@display +Is Bison secure? Does it conform to POSIX? +@end display + +If you're looking for a guarantee or certification, we don't provide it. +However, Bison is intended to be a reliable program that conforms to the +@acronym{POSIX} specification for Yacc. If you run into problems, +please send us a bug report. + +@node I can't build Bison +@section I can't build Bison + +@display +I can't build Bison because @command{make} complains that +@code{msgfmt} is not found. +What should I do? +@end display + +Like most GNU packages with internationalization support, that feature +is turned on by default. If you have problems building in the @file{po} +subdirectory, it indicates that your system's internationalization +support is lacking. You can re-configure Bison with +@option{--disable-nls} to turn off this support, or you can install GNU +gettext from @url{ftp://ftp.gnu.org/gnu/gettext/} and re-configure +Bison. See the file @file{ABOUT-NLS} for more information. + + +@node Where can I find help? +@section Where can I find help? + +@display +I'm having trouble using Bison. Where can I find help? +@end display + +First, read this fine manual. Beyond that, you can send mail to +@email{help-bison@@gnu.org}. This mailing list is intended to be +populated with people who are willing to answer questions about using +and installing Bison. Please keep in mind that (most of) the people on +the list have aspects of their lives which are not related to Bison (!), +so you may not receive an answer to your question right away. This can +be frustrating, but please try not to honk them off; remember that any +help they provide is purely voluntary and out of the kindness of their +hearts. + +@node Bug Reports +@section Bug Reports + +@display +I found a bug. What should I include in the bug report? +@end display + +Before you send a bug report, make sure you are using the latest +version. Check @url{ftp://ftp.gnu.org/pub/gnu/bison/} or one of its +mirrors. Be sure to include the version number in your bug report. If +the bug is present in the latest version but not in a previous version, +try to determine the most recent version which did not contain the bug. + +If the bug is parser-related, you should include the smallest grammar +you can which demonstrates the bug. The grammar file should also be +complete (i.e., I should be able to run it through Bison without having +to edit or add anything). The smaller and simpler the grammar, the +easier it will be to fix the bug. + +Include information about your compilation environment, including your +operating system's name and version and your compiler's name and +version. If you have trouble compiling, you should also include a +transcript of the build session, starting with the invocation of +`configure'. Depending on the nature of the bug, you may be asked to +send additional files as well (such as `config.h' or `config.cache'). + +Patches are most welcome, but not required. That is, do not hesitate to +send a bug report just because you can not provide a fix. + +Send bug reports to @email{bug-bison@@gnu.org}. + +@node Other Languages +@section Other Languages + +@display +Will Bison ever have C++ support? How about Java or @var{insert your +favorite language here}? +@end display + +C++ support is there now, and is documented. We'd love to add other +languages; contributions are welcome. + +@node Beta Testing +@section Beta Testing + +@display +What is involved in being a beta tester? +@end display + +It's not terribly involved. Basically, you would download a test +release, compile it, and use it to build and run a parser or two. After +that, you would submit either a bug report or a message saying that +everything is okay. It is important to report successes as well as +failures because test releases eventually become mainstream releases, +but only if they are adequately tested. If no one tests, development is +essentially halted. + +Beta testers are particularly needed for operating systems to which the +developers do not have easy access. They currently have easy access to +recent GNU/Linux and Solaris versions. Reports about other operating +systems are especially welcome. + +@node Mailing Lists +@section Mailing Lists + +@display +How do I join the help-bison and bug-bison mailing lists? +@end display + +See @url{http://lists.gnu.org/}. @c ================================================= Table of Symbols @@ -7924,7 +8268,7 @@ parser file. @xref{Decl Summary}. @end deffn @deffn {Directive} %nonassoc -Bison declaration to assign non-associativity to token(s). +Bison declaration to assign nonassociativity to token(s). @xref{Precedence Decl, ,Operator Precedence}. @end deffn @@ -7949,6 +8293,11 @@ Bison declaration to request a pure (reentrant) parser. @xref{Pure Decl, ,A Pure (Reentrant) Parser}. @end deffn +@deffn {Directive} %require "@var{version}" +Require version @var{version} or higher of Bison. @xref{Require Decl, , +Require a Version of Bison}. +@end deffn + @deffn {Directive} %right Bison declaration to assign right associativity to token(s). @xref{Precedence Decl, ,Operator Precedence}. @@ -8004,7 +8353,7 @@ token. @xref{Action Features, ,Special Features for Use in Actions}. @end deffn @deffn {Variable} yychar -External integer variable that contains the integer value of the current +External integer variable that contains the integer value of the look-ahead token. (In a pure parser, it is a local variable within @code{yyparse}.) Error-recovery rule actions may examine this variable. @xref{Action Features, ,Special Features for Use in Actions}. @@ -8065,7 +8414,7 @@ the next token. @xref{Lexical, ,The Lexical Analyzer Function @deffn {Macro} YYLEX_PARAM An obsolete macro for specifying an extra argument (or list of extra -arguments) for @code{yyparse} to pass to @code{yylex}. he use of this +arguments) for @code{yyparse} to pass to @code{yylex}. The use of this macro is deprecated, and is supported only for Yacc like parsers. @xref{Pure Calling,, Calling Conventions for Pure Parsers}. @end deffn @@ -8074,9 +8423,12 @@ macro is deprecated, and is supported only for Yacc like parsers. External variable in which @code{yylex} should place the line and column numbers associated with a token. (In a pure parser, it is a local variable within @code{yyparse}, and its address is passed to -@code{yylex}.) You can ignore this variable if you don't use the -@samp{@@} feature in the grammar actions. @xref{Token Locations, -,Textual Locations of Tokens}. +@code{yylex}.) +You can ignore this variable if you don't use the @samp{@@} feature in the +grammar actions. +@xref{Token Locations, ,Textual Locations of Tokens}. +In semantic actions, it stores the location of the look-ahead token. +@xref{Actions and Locations, ,Actions and Locations}. @end deffn @deffn {Type} YYLTYPE @@ -8088,7 +8440,10 @@ members. @xref{Location Type, , Data Types of Locations}. External variable in which @code{yylex} should place the semantic value associated with a token. (In a pure parser, it is a local variable within @code{yyparse}, and its address is passed to -@code{yylex}.) @xref{Token Values, ,Semantic Values of Tokens}. +@code{yylex}.) +@xref{Token Values, ,Semantic Values of Tokens}. +In semantic actions, it stores the semantic value of the look-ahead token. +@xref{Actions, ,Actions}. @end deffn @deffn {Macro} YYMAXDEPTH @@ -8097,7 +8452,7 @@ Management}. @end deffn @deffn {Variable} yynerrs -Global variable which Bison increments each time there is a syntax error. +Global variable which Bison increments each time it reports a syntax error. (In a pure parser, it is a local variable within @code{yyparse}.) @xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}. @end deffn @@ -8115,8 +8470,9 @@ Conventions for Pure Parsers}. @end deffn @deffn {Macro} YYRECOVERING -Macro whose value indicates whether the parser is recovering from a -syntax error. @xref{Action Features, ,Special Features for Use in Actions}. +The expression @code{YYRECOVERING ()} yields 1 when the parser +is recovering from a syntax error, and 0 otherwise. +@xref{Action Features, ,Special Features for Use in Actions}. @end deffn @deffn {Macro} YYSTACK_USE_ALLOCA @@ -8127,10 +8483,7 @@ the parser will use @code{malloc} to extend its stacks. If defined to reserved for future Bison extensions. If not defined, @code{YYSTACK_USE_ALLOCA} defaults to 0. -If you define @code{YYSTACK_USE_ALLOCA} to 1, it is your -responsibility to make sure that @code{alloca} is visible, e.g., by -using @acronym{GCC} or by including @code{}. Furthermore, -in the all-too-common case where your code may run on a host with a +In the all-too-common case where your code may run on a host with a limited stack and with unreliable stack-overflow checking, you should set @code{YYMAXDEPTH} to a value that cannot possibly result in unchecked stack overflow on any of your target hosts when @@ -8352,7 +8705,7 @@ grammatically indivisible. The piece of text it represents is a token. @c LocalWords: yychar yydebug msg YYNTOKENS YYNNTS YYNRULES YYNSTATES @c LocalWords: cparse clex deftypefun NE defmac YYACCEPT YYABORT param @c LocalWords: strncmp intval tindex lvalp locp llocp typealt YYBACKUP -@c LocalWords: YYEMPTY YYRECOVERING yyclearin GE def UMINUS maybeword +@c LocalWords: YYEMPTY YYEOF YYRECOVERING yyclearin GE def UMINUS maybeword @c LocalWords: Johnstone Shamsa Sadaf Hussain Tomita TR uref YYMAXDEPTH @c LocalWords: YYINITDEPTH stmnts ref stmnt initdcl maybeasm VCG notype @c LocalWords: hexflag STR exdent itemset asis DYYDEBUG YYFPRINTF args diff --git a/src/bin/bison/doc/stamp-vti b/src/bin/bison/doc/stamp-vti index 29c953db1c..e3b7603fcc 100644 --- a/src/bin/bison/doc/stamp-vti +++ b/src/bin/bison/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 16 September 2005 -@set UPDATED-MONTH September 2005 -@set EDITION 2.1 -@set VERSION 2.1 +@set UPDATED 30 May 2006 +@set UPDATED-MONTH May 2006 +@set EDITION 2.3 +@set VERSION 2.3 diff --git a/src/bin/bison/doc/version.texi b/src/bin/bison/doc/version.texi index 29c953db1c..e3b7603fcc 100644 --- a/src/bin/bison/doc/version.texi +++ b/src/bin/bison/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 16 September 2005 -@set UPDATED-MONTH September 2005 -@set EDITION 2.1 -@set VERSION 2.1 +@set UPDATED 30 May 2006 +@set UPDATED-MONTH May 2006 +@set EDITION 2.3 +@set VERSION 2.3 diff --git a/src/bin/bison/lib/Jamfile b/src/bin/bison/lib/Jamfile index 914389f6de..e6086e9826 100644 --- a/src/bin/bison/lib/Jamfile +++ b/src/bin/bison/lib/Jamfile @@ -32,16 +32,15 @@ StaticLibrary libbison.a : obstack.c quote.c quotearg.c - realloc.c stpcpy.c stripslash.c strndup.c strnlen.c + strverscmp.c subpipe.c timevar.c vbitset.c xmalloc.c xalloc-die.c - xstrdup.c xstrndup.c ; diff --git a/src/bin/bison/lib/Makefile.in b/src/bin/bison/lib/Makefile.in index e5525e35ab..d3613e96bc 100644 --- a/src/bin/bison/lib/Makefile.in +++ b/src/bin/bison/lib/Makefile.in @@ -14,8 +14,6 @@ @SET_MAKE@ -# This file is generated automatically by "bootstrap". - srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -39,17 +37,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/gnulib.mk alloca.c dirname.c dirname.h dup-safer.c \ - error.c error.h exitfail.c exitfail.h fd-safer.c fopen-safer.c \ + $(srcdir)/gnulib.mk dirname.c dirname.h dup-safer.c error.c \ + error.h exitfail.c exitfail.h fd-safer.c fopen-safer.c \ getopt.c getopt1.c hard-locale.c hard-locale.h hash.c hash.h \ malloc.c obstack.c obstack.h pipe-safer.c quote.c quote.h \ quotearg.c quotearg.h stdio--.h stdio-safer.h stpcpy.c \ - strdup.c strdup.h strndup.c strndup.h strnlen.c strnlen.h \ - unistd--.h unistd-safer.h xalloc.h xmalloc.c + strdup.c strdup.h strerror.c strndup.c strndup.h strnlen.c \ + strnlen.h strtol.c strtoul.c strverscmp.c strverscmp.h \ + unistd--.h unistd-safer.h unlocked-io.h xalloc.h xmalloc.c subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ - $(top_srcdir)/m4/bison-i18n.m4 $(top_srcdir)/m4/cxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \ + $(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \ $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \ $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \ @@ -66,11 +65,14 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \ $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strndup.m4 \ - $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/subpipe.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ + $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \ + $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \ $(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \ $(top_srcdir)/m4/ulonglong_gl.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/warning.m4 \ + $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ + $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \ $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -91,7 +93,6 @@ AR = ar ARFLAGS = cru libbison_a_AR = $(AR) $(ARFLAGS) am__DEPENDENCIES_1 = @LIBOBJS@ -am__DEPENDENCIES_2 = @ALLOCA@ am__objects_1 = abitset.$(OBJEXT) bitset.$(OBJEXT) \ bitset_stats.$(OBJEXT) bitsetv.$(OBJEXT) ebitset.$(OBJEXT) \ lbitset.$(OBJEXT) vbitset.$(OBJEXT) @@ -120,8 +121,6 @@ ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALLOCA_H = @ALLOCA_H@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ @@ -131,6 +130,8 @@ AUTOM4TE = @AUTOM4TE@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON_CXX_WORKS = @BISON_CXX_WORKS@ +BISON_CXX_WORKS_FALSE = @BISON_CXX_WORKS_FALSE@ +BISON_CXX_WORKS_TRUE = @BISON_CXX_WORKS_TRUE@ BISON_LOCALEDIR = @BISON_LOCALEDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -190,6 +191,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STDBOOL_H = @STDBOOL_H@ STRIP = @STRIP@ +UNISTD_H = @UNISTD_H@ USE_NLS = @USE_NLS@ VALGRIND = @VALGRIND@ VERSION = @VERSION@ @@ -243,20 +245,31 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AM_CFLAGS = $(WARNING_CFLAGS) -BUILT_SOURCES = $(ALLOCA_H) $(GETOPT_H) $(STDBOOL_H) -EXTRA_DIST = alloca_.h getopt_.h getopt_int.h stdbool_.h -MOSTLYCLEANFILES = alloca.h alloca.h-t getopt.h getopt.h-t stdbool.h \ - stdbool.h-t +BUILT_SOURCES = $(GETOPT_H) $(STDBOOL_H) $(UNISTD_H) +EXTRA_DIST = getopt_.h getopt_int.h stdbool_.h +MOSTLYCLEANFILES = getopt.h getopt.h-t stdbool.h stdbool.h-t unistd.h lib_LIBRARIES = $(YACC_LIBRARY) EXTRA_LIBRARIES = liby.a noinst_LIBRARIES = libbison.a liby_a_SOURCES = main.c yyerror.c libbison_a_SOURCES = $(lib_SOURCES) + +# This file is generated automatically by "bootstrap". + +# This is for those projects which use "gettextize --intl" to put a source-code +# copy of libintl into their package. In such projects, every Makefile.am needs +# -I$(top_builddir)/intl, so that can be found in this directory. +# For the Makefile.ams in other directories it is the maintainer's +# responsibility; for the one from gnulib we do it here. +# This option has no effect when the user disables NLS (because then the intl +# directory contains no libintl.h file) or when the project does not use +# "gettextize --intl". +# (commented out by bootstrap) AM_CPPFLAGS += -I$(top_builddir)/intl lib_SOURCES = get-errno.h get-errno.c subpipe.h subpipe.c \ $(bitsets_sources) $(additional_bitsets_sources) \ $(timevars_sources) argmatch.h argmatch.c basename.c \ stripslash.c exit.h gettext.h mbswidth.h mbswidth.c stpcpy.h \ - xalloc-die.c xstrndup.h xstrndup.c + verify.h xalloc-die.c xstrndup.h xstrndup.c # Implementation of bitsets bitsets_sources = \ @@ -357,7 +370,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dirname.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dup-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/error.Po@am__quote@ @@ -375,8 +387,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/quotearg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/stpcpy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strdup.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strerror.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strndup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strnlen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoul.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strverscmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/xmalloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abitset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch.Po@am__quote@ @@ -586,12 +602,6 @@ uninstall-am: uninstall-info-am uninstall-libLIBRARIES uninstall-libLIBRARIES -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -alloca.h: alloca_.h - cp $(srcdir)/alloca_.h $@-t - mv $@-t $@ - # We need the following in order to create when the system # doesn't have one that works with the given compiler. getopt.h: getopt_.h @@ -603,6 +613,11 @@ getopt.h: getopt_.h stdbool.h: stdbool_.h sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > $@-t mv $@-t $@ + +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +unistd.h: + echo '/* Empty placeholder for $@. */' >$@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/bin/bison/lib/abitset.c b/src/bin/bison/lib/abitset.c index ec5bf6a0f1..17c0a4af5a 100644 --- a/src/bin/bison/lib/abitset.c +++ b/src/bin/bison/lib/abitset.c @@ -1,5 +1,5 @@ /* Array bitsets. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -13,12 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include "abitset.h" @@ -34,14 +33,13 @@ static bitset_bindex -abitset_resize (bitset src ATTRIBUTE_UNUSED, - bitset_bindex size ATTRIBUTE_UNUSED) +abitset_resize (bitset src, bitset_bindex size) { - if (BITSET_SIZE_ (src) == size) - return size; - /* These bitsets have a fixed size. */ - abort (); + if (BITSET_SIZE_ (src) != size) + abort (); + + return size; } /* Find list of up to NUM bits set in BSET starting from and including diff --git a/src/bin/bison/lib/alloca.c b/src/bin/bison/lib/alloca.c deleted file mode 100644 index d1d54475bb..0000000000 --- a/src/bin/bison/lib/alloca.c +++ /dev/null @@ -1,491 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include -#include - -#ifdef emacs -# include "lisp.h" -# include "blockinput.h" -# ifdef EMACS_FREE -# undef free -# define free EMACS_FREE -# endif -#else -# define memory_full() abort () -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -# ifndef alloca - -# ifdef emacs -# ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -# ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -/* Using #error here is not wise since this file should work for - old and obscure compilers. */ -# endif /* STACK_DIRECTION undefined */ -# endif /* static */ -# endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -# if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -# else -# define ADDRESS_FUNCTION(arg) &(arg) -# endif - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -# ifndef STACK_DIRECTION -# define STACK_DIRECTION 0 /* Direction unknown. */ -# endif - -# if STACK_DIRECTION != 0 - -# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -# else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -# define STACK_DIR stack_dir - -static void -find_stack_direction (void) -{ - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ - - if (addr == NULL) - { /* Initial entry. */ - addr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } -} - -# endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -# ifndef ALIGN_SIZE -# define ALIGN_SIZE sizeof(double) -# endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -void * -alloca (size_t size) -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -# if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - find_stack_direction (); -# endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -# ifdef emacs - BLOCK_INPUT; -# endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free (hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -# ifdef emacs - UNBLOCK_INPUT; -# endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - /* Address of header. */ - register header *new; - - size_t combined_size = sizeof (header) + size; - if (combined_size < sizeof (header)) - memory_full (); - - new = malloc (combined_size); - - if (! new) - memory_full (); - - new->h.next = last_alloca_header; - new->h.deep = depth; - - last_alloca_header = new; - - /* User storage begins just after header. */ - - return (void *) (new + 1); - } -} - -# if defined (CRAY) && defined (CRAY_STACKSEG_END) - -# ifdef DEBUG_I00AFUNC -# include -# endif - -# ifndef CRAY_STACK -# define CRAY_STACK -# ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -# else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -# endif /* CRAY2 */ -# endif /* not CRAY_STACK */ - -# ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -# else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -# ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -# endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -# ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -# endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -# endif /* not CRAY2 */ -# endif /* CRAY */ - -# endif /* no alloca */ -#endif /* not GCC version 2 */ diff --git a/src/bin/bison/lib/alloca_.h b/src/bin/bison/lib/alloca_.h deleted file mode 100644 index 3e3fdf43f8..0000000000 --- a/src/bin/bison/lib/alloca_.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Memory allocation on the stack. - - Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H - means there is a real alloca function. */ -#ifndef _GNULIB_ALLOCA_H -# define _GNULIB_ALLOCA_H - -/* alloca (N) returns a pointer to N bytes of memory - allocated on the stack, which will last until the function returns. - Use of alloca should be avoided: - - inside arguments of function calls - undefined behaviour, - - in inline functions - the allocation may actually last until the - calling function returns, - - for huge N (say, N >= 65536) - you never know how large (or small) - the stack is, and when the stack cannot fulfill the memory allocation - request, the program just crashes. - */ - -#ifdef __GNUC__ -# define alloca __builtin_alloca -#elif defined _AIX -# define alloca __alloca -#elif defined _MSC_VER -# include -# define alloca _alloca -#else -# include -# ifdef __cplusplus -extern "C" -# endif -void *alloca (size_t); -#endif - -#endif /* _GNULIB_ALLOCA_H */ diff --git a/src/bin/bison/lib/argmatch.c b/src/bin/bison/lib/argmatch.c index db883ac41c..36d5845acb 100644 --- a/src/bin/bison/lib/argmatch.c +++ b/src/bin/bison/lib/argmatch.c @@ -20,7 +20,7 @@ /* Written by David MacKenzie Modified by Akim Demaille */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/argmatch.h b/src/bin/bison/lib/argmatch.h index ea0f46800e..f2dfe59bda 100644 --- a/src/bin/bison/lib/argmatch.h +++ b/src/bin/bison/lib/argmatch.h @@ -1,6 +1,6 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004 Free Software + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -25,24 +25,15 @@ # include +# include "verify.h" + # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) -# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \ - (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1) - /* Assert there are as many real arguments as there are values - (argument list ends with a NULL guard). ARGMATCH_VERIFY is - preferred, since it is guaranteed to be checked at compile-time. - ARGMATCH_ASSERT is for backward compatibility only. */ + (argument list ends with a NULL guard). */ -# define ARGMATCH_VERIFY(Arglist, Vallist) \ - struct argmatch_verify \ - { \ - char argmatch_verify[ARGMATCH_CONSTRAINT(Arglist, Vallist) ? 1 : -1]; \ - } - -# define ARGMATCH_ASSERT(Arglist, Vallist) \ - assert (ARGMATCH_CONSTRAINT (Arglist, Vallist)) +# define ARGMATCH_VERIFY(Arglist, Vallist) \ + verify (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1) /* Return the index of the element of ARGLIST (NULL terminated) that matches with ARG. If VALLIST is not NULL, then use it to resolve diff --git a/src/bin/bison/lib/basename.c b/src/bin/bison/lib/basename.c index 00adc0015e..5cc97cd4a4 100644 --- a/src/bin/bison/lib/basename.c +++ b/src/bin/bison/lib/basename.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/bbitset.h b/src/bin/bison/lib/bbitset.h index f06a4e2733..956fc5c6db 100644 --- a/src/bin/bison/lib/bbitset.h +++ b/src/bin/bison/lib/bbitset.h @@ -1,5 +1,5 @@ /* Base bitset stuff. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -126,16 +126,16 @@ struct bitset_vtable void (*copy) (bitset, bitset); bool (*disjoint_p) (bitset, bitset); bool (*equal_p) (bitset, bitset); - void (*not) (bitset, bitset); + void (*not_) (bitset, bitset); bool (*subset_p) (bitset, bitset); - void (*and) (bitset, bitset, bitset); + void (*and_) (bitset, bitset, bitset); bool (*and_cmp) (bitset, bitset, bitset); void (*andn) (bitset, bitset, bitset); bool (*andn_cmp) (bitset, bitset, bitset); - void (*or) (bitset, bitset, bitset); + void (*or_) (bitset, bitset, bitset); bool (*or_cmp) (bitset, bitset, bitset); - void (*xor) (bitset, bitset, bitset); + void (*xor_) (bitset, bitset, bitset); bool (*xor_cmp) (bitset, bitset, bitset); void (*and_or) (bitset, bitset, bitset, bitset); @@ -218,14 +218,14 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \ #define BITSET_EQUAL_P_(DST, SRC) (SRC)->b.vtable->equal_p (DST, SRC) /* DST = ~SRC. */ -#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not (DST, SRC) +#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not_ (DST, SRC) /* Return DST == DST | SRC. */ #define BITSET_SUBSET_P_(DST, SRC) (SRC)->b.vtable->subset_p (DST, SRC) /* DST = SRC1 & SRC2. */ -#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and (DST, SRC1, SRC2) +#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_ (DST, SRC1, SRC2) #define BITSET_AND_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_cmp (DST, SRC1, SRC2) /* DST = SRC1 & ~SRC2. */ @@ -233,11 +233,11 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \ #define BITSET_ANDN_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn_cmp (DST, SRC1, SRC2) /* DST = SRC1 | SRC2. */ -#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or (DST, SRC1, SRC2) +#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_ (DST, SRC1, SRC2) #define BITSET_OR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_cmp (DST, SRC1, SRC2) /* DST = SRC1 ^ SRC2. */ -#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor (DST, SRC1, SRC2) +#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_ (DST, SRC1, SRC2) #define BITSET_XOR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_cmp (DST, SRC1, SRC2) diff --git a/src/bin/bison/lib/bitset.c b/src/bin/bison/lib/bitset.c index ddbef84366..2924567e9f 100644 --- a/src/bin/bison/lib/bitset.c +++ b/src/bin/bison/lib/bitset.c @@ -1,5 +1,5 @@ /* General bitsets. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -13,11 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include @@ -45,6 +45,9 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits) switch (type) { + default: + abort (); + case BITSET_ARRAY: bytes = abitset_bytes (n_bits); break; @@ -60,9 +63,6 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits) case BITSET_VARRAY: bytes = vbitset_bytes (n_bits); break; - - default: - abort (); } return bytes; @@ -78,6 +78,9 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) switch (type) { + default: + abort (); + case BITSET_ARRAY: return abitset_init (bset, n_bits); @@ -89,9 +92,6 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) case BITSET_VARRAY: return vbitset_init (bset, n_bits); - - default: - abort (); } } @@ -421,6 +421,9 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3, switch (op) { + default: + abort (); + case BITSET_OP_OR_AND: bitset_or (tmp, src1, src2); changed = bitset_and_cmp (dst, src3, tmp); @@ -435,9 +438,6 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3, bitset_andn (tmp, src1, src2); changed = bitset_or_cmp (dst, src3, tmp); break; - - default: - abort (); } bitset_free (tmp); diff --git a/src/bin/bison/lib/bitset.h b/src/bin/bison/lib/bitset.h index 0b6aa6b336..45c8818cc9 100644 --- a/src/bin/bison/lib/bitset.h +++ b/src/bin/bison/lib/bitset.h @@ -26,6 +26,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "obstack.h" #include +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + /* Attributes used to select a bitset implementation. */ enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */ BITSET_VARIABLE = 2, /* Bitset size variable. */ diff --git a/src/bin/bison/lib/bitset_stats.c b/src/bin/bison/lib/bitset_stats.c index 0b59865d7f..7b7fb341d9 100644 --- a/src/bin/bison/lib/bitset_stats.c +++ b/src/bin/bison/lib/bitset_stats.c @@ -1,5 +1,5 @@ /* Bitset statistics. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -13,20 +13,18 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file is a wrapper bitset implementation for the other bitset implementations. It provides bitset compatibility checking and statistics gathering without having to instrument the bitset implementations. When statistics gathering is enabled, the bitset operations get vectored through here and we then call the appropriate - routines. -*/ + routines. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include "bbitset.h" @@ -696,6 +694,9 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) we are a wrapper over. */ switch (type) { + default: + abort (); + case BITSET_ARRAY: bytes = abitset_bytes (n_bits); sbset = xcalloc (1, bytes); @@ -719,9 +720,6 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) sbset = xcalloc (1, bytes); vbitset_init (sbset, n_bits); break; - - default: - abort (); } bset->s.bset = sbset; diff --git a/src/bin/bison/lib/bitsetv-print.c b/src/bin/bison/lib/bitsetv-print.c index 4763c75fe4..00838713e4 100644 --- a/src/bin/bison/lib/bitsetv-print.c +++ b/src/bin/bison/lib/bitsetv-print.c @@ -1,25 +1,22 @@ /* Bitset vectors. - Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc. -This file is part of Bison. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -Bison is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -Bison is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Bison; see the file COPYING. If not, write to the Free -Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include diff --git a/src/bin/bison/lib/bitsetv.c b/src/bin/bison/lib/bitsetv.c index db2aa1af2c..ae79853c8b 100644 --- a/src/bin/bison/lib/bitsetv.c +++ b/src/bin/bison/lib/bitsetv.c @@ -1,25 +1,22 @@ /* Bitset vectors. - Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. -This file is part of GCC. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING. If not, write to the Free -Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include diff --git a/src/bin/bison/lib/dirname.c b/src/bin/bison/lib/dirname.c index f1930c8d2f..e2b9d648c3 100644 --- a/src/bin/bison/lib/dirname.c +++ b/src/bin/bison/lib/dirname.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/dup-safer.c b/src/bin/bison/lib/dup-safer.c index 1c46b6e722..8cbee7007b 100644 --- a/src/bin/bison/lib/dup-safer.c +++ b/src/bin/bison/lib/dup-safer.c @@ -17,7 +17,7 @@ /* Written by Paul Eggert. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/ebitset.c b/src/bin/bison/lib/ebitset.c index 9ac85a2c1b..cedf0e2823 100644 --- a/src/bin/bison/lib/ebitset.c +++ b/src/bin/bison/lib/ebitset.c @@ -1,5 +1,5 @@ /* Functions to support expandable bitsets. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -13,12 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include "ebitset.h" @@ -210,7 +209,7 @@ ebitset_elt_alloc (void) #define OBSTACK_CHUNK_FREE free #endif -#if !defined(__GNUC__) || (__GNUC__ < 2) +#if ! defined __GNUC__ || __GNUC__ < 2 #define __alignof__(type) 0 #endif @@ -322,6 +321,9 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex, switch (mode) { + default: + abort (); + case EBITSET_FIND: return 0; @@ -337,9 +339,6 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex, case EBITSET_SUBST: return &ebitset_zero_elts[0]; - - default: - abort (); } } @@ -1090,6 +1089,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) dstp = EBITSET_WORDS (delt); switch (op) { + default: + abort (); + case BITSET_OP_OR: for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++) { @@ -1141,9 +1143,6 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) } } break; - - default: - abort (); } if (!ebitset_elt_zero_p (delt)) diff --git a/src/bin/bison/lib/exitfail.c b/src/bin/bison/lib/exitfail.c index 1c5997b8ac..27d38c32a4 100644 --- a/src/bin/bison/lib/exitfail.c +++ b/src/bin/bison/lib/exitfail.c @@ -17,7 +17,7 @@ If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/fd-safer.c b/src/bin/bison/lib/fd-safer.c index 6b50451338..5933bcbd12 100644 --- a/src/bin/bison/lib/fd-safer.c +++ b/src/bin/bison/lib/fd-safer.c @@ -18,7 +18,7 @@ /* Written by Paul Eggert. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/fopen-safer.c b/src/bin/bison/lib/fopen-safer.c index ccaf1219f0..4f2ffa1b85 100644 --- a/src/bin/bison/lib/fopen-safer.c +++ b/src/bin/bison/lib/fopen-safer.c @@ -17,7 +17,7 @@ /* Written by Paul Eggert. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/get-errno.c b/src/bin/bison/lib/get-errno.c index 78b3674aee..8e8ef58209 100644 --- a/src/bin/bison/lib/get-errno.c +++ b/src/bin/bison/lib/get-errno.c @@ -1,6 +1,6 @@ -/* get-errno.h - get and set errno. +/* get-errno.c - get and set errno. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ /* Written by Paul Eggert. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/getopt.c b/src/bin/bison/lib/getopt.c index bcb81c83fe..83bd6db430 100644 --- a/src/bin/bison/lib/getopt.c +++ b/src/bin/bison/lib/getopt.c @@ -2,7 +2,7 @@ NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004 + Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,28 +20,16 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* This tells Alpha OSF/1 not to define a getopt prototype in . - Ditto for AIX 3.2 and . */ -#ifndef _NO_PROTO -# define _NO_PROTO -#endif - #ifdef HAVE_CONFIG_H # include #endif +#include "getopt.h" + #include - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -# include -# include -#endif /* GNU C library. */ - +#include #include +#include #ifdef VMS # include @@ -76,7 +64,6 @@ GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ -#include "getopt.h" #include "getopt_int.h" /* For communication from `getopt' to the caller. @@ -118,16 +105,9 @@ int optopt = '?'; static struct _getopt_data getopt_data; -#ifndef __GNU_LIBRARY__ - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv +#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV extern char *getenv (); #endif - -#endif /* not __GNU_LIBRARY__ */ #ifdef _LIBC /* Stored original parameters. @@ -556,10 +536,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -634,10 +611,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -674,10 +648,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -751,10 +722,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -817,10 +785,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -868,10 +833,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -940,10 +902,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -985,10 +944,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -1027,10 +983,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); @@ -1101,10 +1054,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); diff --git a/src/bin/bison/lib/getopt.h b/src/bin/bison/lib/getopt.h index a4e78cb06b..3c406e53dc 100644 --- a/src/bin/bison/lib/getopt.h +++ b/src/bin/bison/lib/getopt.h @@ -1,5 +1,5 @@ /* Declarations for getopt. - Copyright (C) 1989-1994,1996-1999,2001,2003,2004 + Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -34,9 +34,7 @@ #if defined __GETOPT_PREFIX && !defined __need_getopt # include # include -# if HAVE_UNISTD_H -# include -# endif +# include # undef __need_getopt # undef getopt # undef getopt_long diff --git a/src/bin/bison/lib/getopt1.c b/src/bin/bison/lib/getopt1.c index 5acd2245af..25d792650f 100644 --- a/src/bin/bison/lib/getopt1.c +++ b/src/bin/bison/lib/getopt1.c @@ -18,7 +18,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include +# include #endif #ifdef _LIBC diff --git a/src/bin/bison/lib/gnulib.mk b/src/bin/bison/lib/gnulib.mk index 7359b728df..3e7b28d4ec 100644 --- a/src/bin/bison/lib/gnulib.mk +++ b/src/bin/bison/lib/gnulib.mk @@ -1,15 +1,4 @@ # This file is generated automatically by "bootstrap". - -BUILT_SOURCES += $(ALLOCA_H) -EXTRA_DIST += alloca_.h - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -alloca.h: alloca_.h - cp $(srcdir)/alloca_.h $@-t - mv $@-t $@ -MOSTLYCLEANFILES += alloca.h alloca.h-t - lib_SOURCES += argmatch.h argmatch.c lib_SOURCES += basename.c stripslash.c @@ -29,6 +18,15 @@ getopt.h: getopt_.h mv $@-t $@ MOSTLYCLEANFILES += getopt.h getopt.h-t +# This is for those projects which use "gettextize --intl" to put a source-code +# copy of libintl into their package. In such projects, every Makefile.am needs +# -I$(top_builddir)/intl, so that can be found in this directory. +# For the Makefile.ams in other directories it is the maintainer's +# responsibility; for the one from gnulib we do it here. +# This option has no effect when the user disables NLS (because then the intl +# directory contains no libintl.h file) or when the project does not use +# "gettextize --intl". +# (commented out by bootstrap) AM_CPPFLAGS += -I$(top_builddir)/intl lib_SOURCES += gettext.h @@ -59,6 +57,21 @@ lib_SOURCES += stpcpy.h + + +BUILT_SOURCES += $(UNISTD_H) + +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +unistd.h: + echo '/* Empty placeholder for $@. */' >$@ +MOSTLYCLEANFILES += unistd.h + + + +lib_SOURCES += verify.h + + lib_SOURCES += xalloc-die.c lib_SOURCES += xstrndup.h xstrndup.c diff --git a/src/bin/bison/lib/hard-locale.c b/src/bin/bison/lib/hard-locale.c index b0566ec218..98530fcd5e 100644 --- a/src/bin/bison/lib/hard-locale.c +++ b/src/bin/bison/lib/hard-locale.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/hash.c b/src/bin/bison/lib/hash.c index 2b5d5c255d..f85bd519bf 100644 --- a/src/bin/bison/lib/hash.c +++ b/src/bin/bison/lib/hash.c @@ -24,7 +24,7 @@ /* Define USE_OBSTACK to 1 if you want the allocator to use obstacks instead of malloc. If you change USE_OBSTACK, you have to recompile! */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/lbitset.c b/src/bin/bison/lib/lbitset.c index 9d3d957342..7d47a052a8 100644 --- a/src/bin/bison/lib/lbitset.c +++ b/src/bin/bison/lib/lbitset.c @@ -1,5 +1,5 @@ /* Functions to support link list bitsets. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -13,12 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include "lbitset.h" @@ -121,7 +120,7 @@ lbitset_elt_alloc (void) #define OBSTACK_CHUNK_FREE free #endif -#if !defined(__GNUC__) || (__GNUC__ < 2) +#if ! defined __GNUC__ || __GNUC__ < 2 #define __alignof__(type) 0 #endif @@ -363,6 +362,9 @@ lbitset_elt_find (bitset bset, bitset_windex windex, switch (mode) { + default: + abort (); + case LBITSET_FIND: return 0; @@ -376,9 +378,6 @@ lbitset_elt_find (bitset bset, bitset_windex windex, case LBITSET_SUBST: return &lbitset_zero_elts[0]; - - default: - abort (); } } @@ -1117,6 +1116,9 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) dstp = dtmp->words; switch (op) { + default: + abort (); + case BITSET_OP_OR: for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++) { @@ -1168,9 +1170,6 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) } } break; - - default: - abort (); } if (!lbitset_elt_zero_p (dtmp)) diff --git a/src/bin/bison/lib/malloc.c b/src/bin/bison/lib/malloc.c index a75da9b795..58fa611682 100644 --- a/src/bin/bison/lib/malloc.c +++ b/src/bin/bison/lib/malloc.c @@ -17,7 +17,7 @@ /* written by Jim Meyering */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif #undef malloc diff --git a/src/bin/bison/lib/obstack.c b/src/bin/bison/lib/obstack.c index f3ca2c2e06..6df0611d26 100644 --- a/src/bin/bison/lib/obstack.c +++ b/src/bin/bison/lib/obstack.c @@ -51,10 +51,6 @@ # endif #endif -#if defined _LIBC && defined USE_IN_LIBIO -# include -#endif - #include #ifndef ELIDE_CODE @@ -433,12 +429,11 @@ print_and_abort (void) happen because the "memory exhausted" message appears in other places like this and the translation should be reused instead of creating a very similar string which requires a separate translation. */ -# if defined _LIBC && defined USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s\n", _("memory exhausted")); - else +# ifdef _LIBC + (void) __fxprintf (NULL, "%s\n", _("memory exhausted")); +# else + fprintf (stderr, "%s\n", _("memory exhausted")); # endif - fprintf (stderr, "%s\n", _("memory exhausted")); exit (obstack_exit_failure); } diff --git a/src/bin/bison/lib/obstack.h b/src/bin/bison/lib/obstack.h index 940bc8051e..95dd438ff7 100644 --- a/src/bin/bison/lib/obstack.h +++ b/src/bin/bison/lib/obstack.h @@ -1,11 +1,7 @@ /* obstack.h - object stack macros - Copyright (C) 1988-1994,1996-1999,2003,2004 Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. + Copyright (C) 1988-1994,1996-1999,2003,2004,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -464,7 +460,7 @@ __extension__ \ (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) # define obstack_int_grow_fast(h,aint) \ - (((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr)) + (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) # define obstack_blank(h,length) \ ( (h)->temp.tempint = (length), \ diff --git a/src/bin/bison/lib/pipe-safer.c b/src/bin/bison/lib/pipe-safer.c index 5791657654..fb02d72177 100644 --- a/src/bin/bison/lib/pipe-safer.c +++ b/src/bin/bison/lib/pipe-safer.c @@ -17,7 +17,7 @@ /* Written by Jim Meyering. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/quote.c b/src/bin/bison/lib/quote.c index 4c75029a33..16cc939c16 100644 --- a/src/bin/bison/lib/quote.c +++ b/src/bin/bison/lib/quote.c @@ -17,7 +17,7 @@ /* Written by Paul Eggert */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/quotearg.c b/src/bin/bison/lib/quotearg.c index eef237f0e6..113239fb14 100644 --- a/src/bin/bison/lib/quotearg.c +++ b/src/bin/bison/lib/quotearg.c @@ -1,7 +1,7 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free Software - Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free + Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ /* Written by Paul Eggert */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif @@ -307,6 +307,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, STORE ('\\'); STORE ('?'); break; + + default: + break; } break; @@ -454,6 +457,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '[': case '\\': case '^': case '`': case '|': goto use_shell_always_quoting_style; + + default: + break; } } @@ -586,7 +592,12 @@ quotearg_n_options (int n, char const *arg, size_t argsize, if (nslots <= n0) { - unsigned int n1 = n0 + 1; + /* FIXME: technically, the type of n1 should be `unsigned int', + but that evokes an unsuppressible warning from gcc-4.0.1 and + older. If gcc ever provides an option to suppress that warning, + revert to the original type, so that the test in xalloc_oversized + is once again performed only at compile time. */ + size_t n1 = n0 + 1; if (xalloc_oversized (n1, sizeof *slotvec)) xalloc_die (); diff --git a/src/bin/bison/lib/realloc.c b/src/bin/bison/lib/realloc.c deleted file mode 100644 index ccbf991388..0000000000 --- a/src/bin/bison/lib/realloc.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Work around bug on some systems where realloc (NULL, 0) fails. - Copyright (C) 1997, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* written by Jim Meyering */ - -#if HAVE_CONFIG_H -# include -#endif -#undef realloc - -#include - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. If N is zero, change it to 1. If P is NULL, - use malloc. */ - -void * -rpl_realloc (void *p, size_t n) -{ - if (n == 0) - n = 1; - if (p == 0) - return malloc (n); - return realloc (p, n); -} diff --git a/src/bin/bison/lib/stdbool_.h b/src/bin/bison/lib/stdbool_.h index 3177ae03cf..efa80ba921 100644 --- a/src/bin/bison/lib/stdbool_.h +++ b/src/bin/bison/lib/stdbool_.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -70,18 +70,40 @@ (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the enum; this ensures that '_Bool' promotes to 'int'. */ -#if !(defined __cplusplus || defined __BEOS__) +#if defined __cplusplus || defined __BEOS__ + /* A compiler known to have 'bool'. */ + /* If the compiler already has both 'bool' and '_Bool', we can assume they + are the same types. */ # if !@HAVE__BOOL@ -# if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1) - /* Avoid stupid "warning: _Bool is a keyword in ISO C99". */ -# define _Bool signed char +typedef bool _Bool; +# endif +#else +# if !defined __GNUC__ + /* If @HAVE__BOOL@: + Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when + the built-in _Bool type is used. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + Similar bugs are likely with other compilers as well; this file + wouldn't be used if was working. + So we override the _Bool type. + If !@HAVE__BOOL@: + Need to define _Bool ourselves. As 'signed char' or as an enum type? + Use of a typedef, with SunPRO C, leads to a stupid + "warning: _Bool is a keyword in ISO C99". + Use of an enum type, with IRIX cc, leads to a stupid + "warning(1185): enumerated type mixed with another type". + The only benefit of the enum type, debuggability, is not important + with these compilers. So use 'signed char' and no typedef. */ +# define _Bool signed char enum { false = 0, true = 1 }; -# else +# else + /* With this compiler, trust the _Bool type if the compiler has it. */ +# if !@HAVE__BOOL@ typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; # endif # endif -#else -typedef bool _Bool; #endif #define bool _Bool diff --git a/src/bin/bison/lib/strerror.c b/src/bin/bison/lib/strerror.c new file mode 100644 index 0000000000..623821d2e3 --- /dev/null +++ b/src/bin/bison/lib/strerror.c @@ -0,0 +1,49 @@ +/* strerror.c --- ANSI C compatible system error routine + + Copyright (C) 1986, 1988, 1989, 1991, 2002, 2003 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +/* Don't include , since it may or may not declare + sys_errlist and its declarations may collide with ours. Just + declare the stuff that we need directly. Standard hosted C89 + implementations define strerror and they don't need this strerror + function, so take some liberties with the standard to cater to + ancient or limited freestanding implementations. */ +int sprintf (char *, char const *, ...); +extern int sys_nerr; +extern char *sys_errlist[]; + +char * +strerror (int n) +{ + static char const fmt[] = "Unknown error (%d)"; + static char mesg[sizeof fmt + sizeof n * CHAR_BIT / 3]; + + if (n < 0 || n >= sys_nerr) + { + sprintf (mesg, fmt, n); + return mesg; + } + else + return sys_errlist[n]; +} diff --git a/src/bin/bison/lib/stripslash.c b/src/bin/bison/lib/stripslash.c index 870a66f387..9b55da48ed 100644 --- a/src/bin/bison/lib/stripslash.c +++ b/src/bin/bison/lib/stripslash.c @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/strndup.c b/src/bin/bison/lib/strndup.c index b2d7c0e0bb..2626373f26 100644 --- a/src/bin/bison/lib/strndup.c +++ b/src/bin/bison/lib/strndup.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006 Free + Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -18,26 +19,37 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -# include "config.h" +# include +#endif +#if !_LIBC +# include "strndup.h" #endif #include #include -/* Get strnlen. */ -#include "strnlen.h" +#if !_LIBC +# include "strnlen.h" +# ifndef __strnlen +# define __strnlen strnlen +# endif +#endif #undef __strndup -#undef strndup +#if _LIBC +# undef strndup +#endif #ifndef weak_alias # define __strndup strndup #endif char * -__strndup (const char *s, size_t n) +__strndup (s, n) + const char *s; + size_t n; { - size_t len = strnlen (s, n); + size_t len = __strnlen (s, n); char *new = malloc (len + 1); if (new == NULL) @@ -46,6 +58,9 @@ __strndup (const char *s, size_t n) new[len] = '\0'; return memcpy (new, s, len); } +#ifdef libc_hidden_def +libc_hidden_def (__strndup) +#endif #ifdef weak_alias weak_alias (__strndup, strndup) #endif diff --git a/src/bin/bison/lib/strnlen.c b/src/bin/bison/lib/strnlen.c index 642c66fac8..09ba788ab0 100644 --- a/src/bin/bison/lib/strnlen.c +++ b/src/bin/bison/lib/strnlen.c @@ -1,6 +1,6 @@ /* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 1996, 1997, 1998, 2000-2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,37 +12,22 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif -#undef strnlen -#include - -#undef __strnlen -#undef strnlen - -#ifndef _LIBC -# define strnlen rpl_strnlen -#endif - -#ifndef weak_alias -# define __strnlen strnlen -#endif +#include "strnlen.h" /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t -__strnlen (const char *string, size_t maxlen) +strnlen (const char *string, size_t maxlen) { const char *end = memchr (string, '\0', maxlen); return end ? (size_t) (end - string) : maxlen; } -#ifdef weak_alias -weak_alias (__strnlen, strnlen) -#endif diff --git a/src/bin/bison/lib/strtol.c b/src/bin/bison/lib/strtol.c new file mode 100644 index 0000000000..9bfbe3c1af --- /dev/null +++ b/src/bin/bison/lib/strtol.c @@ -0,0 +1,447 @@ +/* Convert string representation of a number into an integer value. + + Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005 + Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C + Library. Bugs can be reported to bug-glibc@gnu.org. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef _LIBC +# define USE_NUMBER_GROUPING +#endif + +#include +#include +#ifndef errno +extern int errno; +#endif +#ifndef __set_errno +# define __set_errno(Val) errno = (Val) +#endif + +#include +#include +#include +#include + +#ifdef USE_NUMBER_GROUPING +# include "../locale/localeinfo.h" +#endif + +/* Nonzero if we are defining `strtoul' or `strtoull', operating on + unsigned integers. */ +#ifndef UNSIGNED +# define UNSIGNED 0 +# define INT LONG int +#else +# define INT unsigned LONG int +#endif + +/* Determine the name. */ +#ifdef USE_IN_EXTENDED_LOCALE_MODEL +# if UNSIGNED +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol __wcstoull_l +# else +# define strtol __wcstoul_l +# endif +# else +# ifdef QUAD +# define strtol __strtoull_l +# else +# define strtol __strtoul_l +# endif +# endif +# else +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol __wcstoll_l +# else +# define strtol __wcstol_l +# endif +# else +# ifdef QUAD +# define strtol __strtoll_l +# else +# define strtol __strtol_l +# endif +# endif +# endif +#else +# if UNSIGNED +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol wcstoull +# else +# define strtol wcstoul +# endif +# else +# ifdef QUAD +# define strtol strtoull +# else +# define strtol strtoul +# endif +# endif +# else +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol wcstoll +# else +# define strtol wcstol +# endif +# else +# ifdef QUAD +# define strtol strtoll +# endif +# endif +# endif +#endif + +/* If QUAD is defined, we are defining `strtoll' or `strtoull', + operating on `long long int's. */ +#ifdef QUAD +# define LONG long long +# define STRTOL_LONG_MIN LONG_LONG_MIN +# define STRTOL_LONG_MAX LONG_LONG_MAX +# define STRTOL_ULONG_MAX ULONG_LONG_MAX + +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if negative values of the signed integer type T use two's + complement, ones' complement, or signed magnitude representation, + respectively. Much GNU code assumes two's complement, but some + people like to be portable to all possible C hosts. */ +# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) +# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) +# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) + +/* True if the arithmetic type T is signed. */ +# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + +/* The maximum and minimum values for the integer type T. These + macros have undefined behavior if T is signed and has padding bits. + If this is a problem for you, please let us know how to fix it for + your host. */ +# define TYPE_MINIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) +# define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + +# ifndef ULONG_LONG_MAX +# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long) +# endif +# ifndef LONG_LONG_MAX +# define LONG_LONG_MAX TYPE_MAXIMUM (long long int) +# endif +# ifndef LONG_LONG_MIN +# define LONG_LONG_MIN TYPE_MINIMUM (long long int) +# endif + +# if __GNUC__ == 2 && __GNUC_MINOR__ < 7 + /* Work around gcc bug with using this constant. */ + static const unsigned long long int maxquad = ULONG_LONG_MAX; +# undef STRTOL_ULONG_MAX +# define STRTOL_ULONG_MAX maxquad +# endif +#else +# define LONG long +# define STRTOL_LONG_MIN LONG_MIN +# define STRTOL_LONG_MAX LONG_MAX +# define STRTOL_ULONG_MAX ULONG_MAX +#endif + + +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +#ifdef USE_IN_EXTENDED_LOCALE_MODEL +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# define LOCALE_PARAM , loc +# define LOCALE_PARAM_PROTO , __locale_t loc +#else +# define LOCALE_PARAM +# define LOCALE_PARAM_PROTO +#endif + +#if defined _LIBC || defined HAVE_WCHAR_H +# include +#endif + +#ifdef USE_WIDE_CHAR +# include +# define L_(Ch) L##Ch +# define UCHAR_TYPE wint_t +# define STRING_TYPE wchar_t +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define ISSPACE(Ch) __iswspace_l ((Ch), loc) +# define ISALPHA(Ch) __iswalpha_l ((Ch), loc) +# define TOUPPER(Ch) __towupper_l ((Ch), loc) +# else +# define ISSPACE(Ch) iswspace (Ch) +# define ISALPHA(Ch) iswalpha (Ch) +# define TOUPPER(Ch) towupper (Ch) +# endif +#else +# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII) +# define IN_CTYPE_DOMAIN(c) 1 +# else +# define IN_CTYPE_DOMAIN(c) isascii(c) +# endif +# define L_(Ch) Ch +# define UCHAR_TYPE unsigned char +# define STRING_TYPE char +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define ISSPACE(Ch) __isspace_l ((Ch), loc) +# define ISALPHA(Ch) __isalpha_l ((Ch), loc) +# define TOUPPER(Ch) __toupper_l ((Ch), loc) +# else +# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch)) +# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch)) +# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch)) +# endif +#endif + +#define INTERNAL(X) INTERNAL1(X) +#define INTERNAL1(X) __##X##_internal +#define WEAKNAME(X) WEAKNAME1(X) + +#ifdef USE_NUMBER_GROUPING +/* This file defines a function to check for correct grouping. */ +# include "grouping.h" +#endif + + + +/* Convert NPTR to an `unsigned long int' or `long int' in base BASE. + If BASE is 0 the base is determined by the presence of a leading + zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. + If BASE is < 2 or > 36, it is reset to 10. + If ENDPTR is not NULL, a pointer to the character after the last + one converted is stored in *ENDPTR. */ + +INT +INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, + int base, int group LOCALE_PARAM_PROTO) +{ + int negative; + register unsigned LONG int cutoff; + register unsigned int cutlim; + register unsigned LONG int i; + register const STRING_TYPE *s; + register UCHAR_TYPE c; + const STRING_TYPE *save, *end; + int overflow; + +#ifdef USE_NUMBER_GROUPING +# ifdef USE_IN_EXTENDED_LOCALE_MODEL + struct locale_data *current = loc->__locales[LC_NUMERIC]; +# endif + /* The thousands character of the current locale. */ + wchar_t thousands = L'\0'; + /* The numeric grouping specification of the current locale, + in the format described in . */ + const char *grouping; + + if (group) + { + grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); + if (*grouping <= 0 || *grouping == CHAR_MAX) + grouping = NULL; + else + { + /* Figure out the thousands separator character. */ +# if defined _LIBC || defined _HAVE_BTOWC + thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); + if (thousands == WEOF) + thousands = L'\0'; +# endif + if (thousands == L'\0') + grouping = NULL; + } + } + else + grouping = NULL; +#endif + + if (base < 0 || base == 1 || base > 36) + { + __set_errno (EINVAL); + return 0; + } + + save = s = nptr; + + /* Skip white space. */ + while (ISSPACE (*s)) + ++s; + if (*s == L_('\0')) + goto noconv; + + /* Check for a sign. */ + if (*s == L_('-')) + { + negative = 1; + ++s; + } + else if (*s == L_('+')) + { + negative = 0; + ++s; + } + else + negative = 0; + + /* Recognize number prefix and if BASE is zero, figure it out ourselves. */ + if (*s == L_('0')) + { + if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X')) + { + s += 2; + base = 16; + } + else if (base == 0) + base = 8; + } + else if (base == 0) + base = 10; + + /* Save the pointer so we can check later if anything happened. */ + save = s; + +#ifdef USE_NUMBER_GROUPING + if (group) + { + /* Find the end of the digit string and check its grouping. */ + end = s; + for (c = *end; c != L_('\0'); c = *++end) + if ((wchar_t) c != thousands + && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) + && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) + break; + if (*s == thousands) + end = s; + else + end = correctly_grouped_prefix (s, end, thousands, grouping); + } + else +#endif + end = NULL; + + cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base; + cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base; + + overflow = 0; + i = 0; + for (c = *s; c != L_('\0'); c = *++s) + { + if (s == end) + break; + if (c >= L_('0') && c <= L_('9')) + c -= L_('0'); + else if (ISALPHA (c)) + c = TOUPPER (c) - L_('A') + 10; + else + break; + if ((int) c >= base) + break; + /* Check for overflow. */ + if (i > cutoff || (i == cutoff && c > cutlim)) + overflow = 1; + else + { + i *= (unsigned LONG int) base; + i += c; + } + } + + /* Check if anything actually happened. */ + if (s == save) + goto noconv; + + /* Store in ENDPTR the address of one character + past the last character we converted. */ + if (endptr != NULL) + *endptr = (STRING_TYPE *) s; + +#if !UNSIGNED + /* Check for a value that is within the range of + `unsigned LONG int', but outside the range of `LONG int'. */ + if (overflow == 0 + && i > (negative + ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1 + : (unsigned LONG int) STRTOL_LONG_MAX)) + overflow = 1; +#endif + + if (overflow) + { + __set_errno (ERANGE); +#if UNSIGNED + return STRTOL_ULONG_MAX; +#else + return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX; +#endif + } + + /* Return the result of the appropriate sign. */ + return negative ? -i : i; + +noconv: + /* We must handle a special case here: the base is 0 or 16 and the + first two characters are '0' and 'x', but the rest are no + hexadecimal digits. This is no error case. We return 0 and + ENDPTR points to the `x`. */ + if (endptr != NULL) + { + if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') + && save[-2] == L_('0')) + *endptr = (STRING_TYPE *) &save[-1]; + else + /* There was no number to convert. */ + *endptr = (STRING_TYPE *) nptr; + } + + return 0L; +} + +/* External user entry point. */ + + +INT +#ifdef weak_function +weak_function +#endif +strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, + int base LOCALE_PARAM_PROTO) +{ + return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); +} diff --git a/src/bin/bison/lib/strtoul.c b/src/bin/bison/lib/strtoul.c new file mode 100644 index 0000000000..79ceed2f31 --- /dev/null +++ b/src/bin/bison/lib/strtoul.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1991, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#define UNSIGNED 1 + +#include "strtol.c" diff --git a/src/bin/bison/lib/strverscmp.c b/src/bin/bison/lib/strverscmp.c new file mode 100644 index 0000000000..6276bca0fa --- /dev/null +++ b/src/bin/bison/lib/strverscmp.c @@ -0,0 +1,131 @@ +/* Compare strings while treating digits characters numerically. + Copyright (C) 1997, 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jean-François Bignolles , 1997. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +/* states: S_N: normal, S_I: comparing integral part, S_F: comparing + fractional parts, S_Z: idem but with leading Zeroes only */ +#define S_N 0x0 +#define S_I 0x4 +#define S_F 0x8 +#define S_Z 0xC + +/* result_type: CMP: return diff; LEN: compare using len_diff/diff */ +#define CMP 2 +#define LEN 3 + + +/* ISDIGIT differs from isdigit, as follows: + - Its arg may be any int or unsigned int; it need not be an unsigned char. + - It's guaranteed to evaluate its argument exactly once. + - It's typically faster. + POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to + ISDIGIT_LOCALE unless it's important to use the locale's definition + of `digit' even when the host does not conform to POSIX. */ +#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) + +#undef __strverscmp +#undef strverscmp + +#ifndef weak_alias +# define __strverscmp strverscmp +#endif + +/* Compare S1 and S2 as strings holding indices/version numbers, + returning less than, equal to or greater than zero if S1 is less than, + equal to or greater than S2 (for more info, see the texinfo doc). +*/ + +int +__strverscmp (const char *s1, const char *s2) +{ + const unsigned char *p1 = (const unsigned char *) s1; + const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + int state; + int diff; + + /* Symbol(s) 0 [1-9] others (padding) + Transition (10) 0 (01) d (00) x (11) - */ + static const unsigned int next_state[] = + { + /* state x d 0 - */ + /* S_N */ S_N, S_I, S_Z, S_N, + /* S_I */ S_N, S_I, S_I, S_I, + /* S_F */ S_N, S_F, S_F, S_F, + /* S_Z */ S_N, S_F, S_Z, S_Z + }; + + static const int result_type[] = + { + /* state x/x x/d x/0 x/- d/x d/d d/0 d/- + 0/x 0/d 0/0 0/- -/x -/d -/0 -/- */ + + /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, + CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, + /* S_I */ CMP, -1, -1, CMP, 1, LEN, LEN, CMP, + 1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, + /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, + CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, + /* S_Z */ CMP, 1, 1, CMP, -1, CMP, CMP, CMP, + -1, CMP, CMP, CMP + }; + + if (p1 == p2) + return 0; + + c1 = *p1++; + c2 = *p2++; + /* Hint: '0' is a digit too. */ + state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0)); + + while ((diff = c1 - c2) == 0 && c1 != '\0') + { + state = next_state[state]; + c1 = *p1++; + c2 = *p2++; + state |= (c1 == '0') + (ISDIGIT (c1) != 0); + } + + state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))]; + + switch (state) + { + case CMP: + return diff; + + case LEN: + while (ISDIGIT (*p1++)) + if (!ISDIGIT (*p2++)) + return 1; + + return ISDIGIT (*p2) ? -1 : diff; + + default: + return state; + } +} +#ifdef weak_alias +weak_alias (__strverscmp, strverscmp) +#endif diff --git a/src/bin/bison/lib/xstrdup.c b/src/bin/bison/lib/strverscmp.h similarity index 58% rename from src/bin/bison/lib/xstrdup.c rename to src/bin/bison/lib/strverscmp.h index 58f18beb6f..7edeac5e4c 100644 --- a/src/bin/bison/lib/xstrdup.c +++ b/src/bin/bison/lib/strverscmp.h @@ -1,5 +1,6 @@ -/* xstrdup.c -- copy a string with out of memory checking - Copyright (C) 1990, 1996, 1998, 2001, 2003 Free Software Foundation, Inc. +/* Compare strings while treating digits characters numerically. + + Copyright (C) 1997, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,21 +14,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H -# include -#endif +#ifndef STRVERSCMP_H_ +# define STRVERSCMP_H_ -/* Specification. */ -#include "xalloc.h" +int strverscmp (const char *, const char *); -#include - -/* Return a newly allocated copy of STRING. */ - -char * -xstrdup (const char *string) -{ - return xclone (string, strlen (string) + 1); -} +#endif /* not STRVERSCMP_H_ */ diff --git a/src/bin/bison/lib/subpipe.c b/src/bin/bison/lib/subpipe.c index 7f8e44f2a1..646aa8ec22 100644 --- a/src/bin/bison/lib/subpipe.c +++ b/src/bin/bison/lib/subpipe.c @@ -1,6 +1,6 @@ /* Subprocesses with pipes. - Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ /* Written by Paul Eggert and Florian Krohm . */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif @@ -71,6 +71,18 @@ #include "gettext.h" #define _(Msgid) gettext (Msgid) +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if ! defined __GNUC__ || __GNUC__ < 2 || \ +(__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +# define __attribute__(Spec) /* empty */ +# endif +#endif + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + /* Initialize this module. */ @@ -166,3 +178,9 @@ reap_subpipe (pid_t pid, char const *program) } #endif } + +void +end_of_output_subpipe (pid_t pid ATTRIBUTE_UNUSED, + int fd[2] ATTRIBUTE_UNUSED) +{ +} diff --git a/src/bin/bison/lib/subpipe.h b/src/bin/bison/lib/subpipe.h index 7b76bdae41..1083d32e24 100644 --- a/src/bin/bison/lib/subpipe.h +++ b/src/bin/bison/lib/subpipe.h @@ -1,22 +1,19 @@ /* Subprocesses with pipes. - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. - This file is part of Bison, the GNU Compiler Compiler. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - Bison is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - Bison is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bison; see the file COPYING. If not, write to the Free - Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Written by Paul Eggert and Florian Krohm . */ @@ -27,4 +24,5 @@ void init_subpipe (void); pid_t create_subpipe (char const * const *, int[2]); +void end_of_output_subpipe (pid_t, int[2]); void reap_subpipe (pid_t, char const *); diff --git a/src/bin/bison/lib/timevar.c b/src/bin/bison/lib/timevar.c index d647687fea..d9b533ce8c 100644 --- a/src/bin/bison/lib/timevar.c +++ b/src/bin/bison/lib/timevar.c @@ -1,27 +1,27 @@ /* Timing variables for measuring compiler performance. - Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Alex Samuel -This file is part of Bison, the GNU Compiler Compiler. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -Bison is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -Bison is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -You should have received a copy of the GNU General Public License -along with Bison; see the file COPYING. If not, write to the Free -Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. */ +#ifdef HAVE_CONFIG_H +# include +#endif #if IN_GCC -#include "config.h" #include "system.h" #include "intl.h" #include "rtl.h" @@ -447,7 +447,7 @@ timevar_print (fp) FILE *fp; { /* Only print stuff if we have some sort of time information. */ -#if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME) +#if defined HAVE_USER_TIME || defined HAVE_SYS_TIME || defined HAVE_WALL_TIME unsigned int /* timevar_id_t */ id; struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed; struct timevar_time_def now; @@ -488,7 +488,7 @@ timevar_print (fp) continue; /* Don't print timing variables if we're going to get a row of - zeroes. */ + zeroes. */ if (tv->elapsed.user < tiny && tv->elapsed.sys < tiny && tv->elapsed.wall < tiny) diff --git a/src/bin/bison/lib/timevar.h b/src/bin/bison/lib/timevar.h index bb9b0c89c6..bbeb40214d 100644 --- a/src/bin/bison/lib/timevar.h +++ b/src/bin/bison/lib/timevar.h @@ -2,22 +2,19 @@ Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. Contributed by Alex Samuel - This file is part of Bison, the GNU Compiler Compiler. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - Bison is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - Bison is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bison; see the file COPYING. If not, write to the Free - Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef GCC_TIMEVAR_H #define GCC_TIMEVAR_H diff --git a/src/bin/bison/lib/unlocked-io.h b/src/bin/bison/lib/unlocked-io.h index 36a7a4885d..d00930361c 100644 --- a/src/bin/bison/lib/unlocked-io.h +++ b/src/bin/bison/lib/unlocked-io.h @@ -1,6 +1,6 @@ /* Prefer faster, non-thread-safe stdio functions if available. - Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,19 +14,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Written by Jim Meyering. */ #ifndef UNLOCKED_IO_H # define UNLOCKED_IO_H 1 -# ifndef USE_UNLOCKED_IO -# define USE_UNLOCKED_IO 1 -# endif - -# if USE_UNLOCKED_IO - /* These are wrappers for functions/macros from the GNU C library, and from other C libraries supporting POSIX's optional thread-safe functions. @@ -38,95 +32,106 @@ the *_unlocked functions directly. On hosts that lack those functions, invoke the non-thread-safe versions instead. */ -# include +# include -# if HAVE_DECL_CLEARERR_UNLOCKED -# undef clearerr -# define clearerr(x) clearerr_unlocked (x) -# else -# define clearerr_unlocked(x) clearerr (x) -# endif -# if HAVE_DECL_FEOF_UNLOCKED -# undef feof -# define feof(x) feof_unlocked (x) -# else -# define feof_unlocked(x) feof (x) -# endif -# if HAVE_DECL_FERROR_UNLOCKED -# undef ferror -# define ferror(x) ferror_unlocked (x) -# else -# define ferror_unlocked(x) ferror (x) -# endif -# if HAVE_DECL_FFLUSH_UNLOCKED -# undef fflush -# define fflush(x) fflush_unlocked (x) -# else -# define fflush_unlocked(x) fflush (x) -# endif -# if HAVE_DECL_FGETS_UNLOCKED -# undef fgets -# define fgets(x,y,z) fgets_unlocked (x,y,z) -# else -# define fgets_unlocked(x,y,z) fgets (x,y,z) -# endif -# if HAVE_DECL_FPUTC_UNLOCKED -# undef fputc -# define fputc(x,y) fputc_unlocked (x,y) -# else -# define fputc_unlocked(x,y) fputc (x,y) -# endif -# if HAVE_DECL_FPUTS_UNLOCKED -# undef fputs -# define fputs(x,y) fputs_unlocked (x,y) -# else -# define fputs_unlocked(x,y) fputs (x,y) -# endif -# if HAVE_DECL_FREAD_UNLOCKED -# undef fread -# define fread(w,x,y,z) fread_unlocked (w,x,y,z) -# else -# define fread_unlocked(w,x,y,z) fread (w,x,y,z) -# endif -# if HAVE_DECL_FWRITE_UNLOCKED -# undef fwrite -# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) -# else -# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) -# endif -# if HAVE_DECL_GETC_UNLOCKED -# undef getc -# define getc(x) getc_unlocked (x) -# else -# define getc_unlocked(x) getc (x) -# endif -# if HAVE_DECL_GETCHAR_UNLOCKED -# undef getchar -# define getchar() getchar_unlocked () -# else -# define getchar_unlocked() getchar () -# endif -# if HAVE_DECL_PUTC_UNLOCKED -# undef putc -# define putc(x,y) putc_unlocked (x,y) -# else -# define putc_unlocked(x,y) putc (x,y) -# endif -# if HAVE_DECL_PUTCHAR_UNLOCKED -# undef putchar -# define putchar(x) putchar_unlocked (x) -# else -# define putchar_unlocked(x) putchar (x) -# endif +# if HAVE_DECL_CLEARERR_UNLOCKED +# undef clearerr +# define clearerr(x) clearerr_unlocked (x) +# else +# define clearerr_unlocked(x) clearerr (x) +# endif -# undef flockfile -# define flockfile(x) ((void) 0) +# if HAVE_DECL_FEOF_UNLOCKED +# undef feof +# define feof(x) feof_unlocked (x) +# else +# define feof_unlocked(x) feof (x) +# endif -# undef ftrylockfile -# define ftrylockfile(x) 0 +# if HAVE_DECL_FERROR_UNLOCKED +# undef ferror +# define ferror(x) ferror_unlocked (x) +# else +# define ferror_unlocked(x) ferror (x) +# endif -# undef funlockfile -# define funlockfile(x) ((void) 0) +# if HAVE_DECL_FFLUSH_UNLOCKED +# undef fflush +# define fflush(x) fflush_unlocked (x) +# else +# define fflush_unlocked(x) fflush (x) +# endif + +# if HAVE_DECL_FGETS_UNLOCKED +# undef fgets +# define fgets(x,y,z) fgets_unlocked (x,y,z) +# else +# define fgets_unlocked(x,y,z) fgets (x,y,z) +# endif + +# if HAVE_DECL_FPUTC_UNLOCKED +# undef fputc +# define fputc(x,y) fputc_unlocked (x,y) +# else +# define fputc_unlocked(x,y) fputc (x,y) +# endif + +# if HAVE_DECL_FPUTS_UNLOCKED +# undef fputs +# define fputs(x,y) fputs_unlocked (x,y) +# else +# define fputs_unlocked(x,y) fputs (x,y) +# endif + +# if HAVE_DECL_FREAD_UNLOCKED +# undef fread +# define fread(w,x,y,z) fread_unlocked (w,x,y,z) +# else +# define fread_unlocked(w,x,y,z) fread (w,x,y,z) +# endif + +# if HAVE_DECL_FWRITE_UNLOCKED +# undef fwrite +# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) +# else +# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) +# endif + +# if HAVE_DECL_GETC_UNLOCKED +# undef getc +# define getc(x) getc_unlocked (x) +# else +# define getc_unlocked(x) getc (x) +# endif + +# if HAVE_DECL_GETCHAR_UNLOCKED +# undef getchar +# define getchar() getchar_unlocked () +# else +# define getchar_unlocked() getchar () +# endif + +# if HAVE_DECL_PUTC_UNLOCKED +# undef putc +# define putc(x,y) putc_unlocked (x,y) +# else +# define putc_unlocked(x,y) putc (x,y) +# endif + +# if HAVE_DECL_PUTCHAR_UNLOCKED +# undef putchar +# define putchar(x) putchar_unlocked (x) +# else +# define putchar_unlocked(x) putchar (x) +# endif + +# undef flockfile +# define flockfile(x) ((void) 0) + +# undef ftrylockfile +# define ftrylockfile(x) 0 + +# undef funlockfile +# define funlockfile(x) ((void) 0) -# endif /* USE_UNLOCKED_IO */ #endif /* UNLOCKED_IO_H */ diff --git a/src/bin/bison/lib/vbitset.c b/src/bin/bison/lib/vbitset.c index a7d9bdec07..d0fe30f641 100644 --- a/src/bin/bison/lib/vbitset.c +++ b/src/bin/bison/lib/vbitset.c @@ -1,5 +1,5 @@ /* Variable array bitsets. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -13,12 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include #endif #include "vbitset.h" diff --git a/src/bin/bison/lib/verify.h b/src/bin/bison/lib/verify.h new file mode 100644 index 0000000000..d603b17379 --- /dev/null +++ b/src/bin/bison/lib/verify.h @@ -0,0 +1,141 @@ +/* Compile-time assert-like macros. + + Copyright (C) 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ + +#ifndef VERIFY_H +# define VERIFY_H 1 + +/* Each of these macros verifies that its argument R is nonzero. To + be portable, R should be an integer constant expression. Unlike + assert (R), there is no run-time overhead. + + There are two macros, since no single macro can be used in all + contexts in C. verify_true (R) is for scalar contexts, including + integer constant expression contexts. verify (R) is for declaration + contexts, e.g., the top level. + + Symbols ending in "__" are private to this header. + + The code below uses several ideas. + + * The first step is ((R) ? 1 : -1). Given an expression R, of + integral or boolean or floating-point type, this yields an + expression of integral type, whose value is later verified to be + constant and nonnegative. + + * Next this expression W is wrapped in a type + struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }. + If W is negative, this yields a compile-time error. No compiler can + deal with a bit-field of negative size. + + One might think that an array size check would have the same + effect, that is, that the type struct { unsigned int dummy[W]; } + would work as well. However, inside a function, some compilers + (such as C++ compilers and GNU C) allow local parameters and + variables inside array size expressions. With these compilers, + an array size check would not properly diagnose this misuse of + the verify macro: + + void function (int n) { verify (n < 0); } + + * For the verify macro, the struct verify_type__ will need to + somehow be embedded into a declaration. To be portable, this + declaration must declare an object, a constant, a function, or a + typedef name. If the declared entity uses the type directly, + such as in + + struct dummy {...}; + typedef struct {...} dummy; + extern struct {...} *dummy; + extern void dummy (struct {...} *); + extern struct {...} *dummy (void); + + two uses of the verify macro would yield colliding declarations + if the entity names are not disambiguated. A workaround is to + attach the current line number to the entity name: + + #define GL_CONCAT0(x, y) x##y + #define GL_CONCAT(x, y) GL_CONCAT0 (x, y) + extern struct {...} * GL_CONCAT(dummy,__LINE__); + + But this has the problem that two invocations of verify from + within the same macro would collide, since the __LINE__ value + would be the same for both invocations. + + A solution is to use the sizeof operator. It yields a number, + getting rid of the identity of the type. Declarations like + + extern int dummy [sizeof (struct {...})]; + extern void dummy (int [sizeof (struct {...})]); + extern int (*dummy (void)) [sizeof (struct {...})]; + + can be repeated. + + * Should the implementation use a named struct or an unnamed struct? + Which of the following alternatives can be used? + + extern int dummy [sizeof (struct {...})]; + extern int dummy [sizeof (struct verify_type__ {...})]; + extern void dummy (int [sizeof (struct {...})]); + extern void dummy (int [sizeof (struct verify_type__ {...})]); + extern int (*dummy (void)) [sizeof (struct {...})]; + extern int (*dummy (void)) [sizeof (struct verify_type__ {...})]; + + In the second and sixth case, the struct type is exported to the + outer scope; two such declarations therefore collide. GCC warns + about the first, third, and fourth cases. So the only remaining + possibility is the fifth case: + + extern int (*dummy (void)) [sizeof (struct {...})]; + + * This implementation exploits the fact that GCC does not warn about + the last declaration mentioned above. If a future version of GCC + introduces a warning for this, the problem could be worked around + by using code specialized to GCC, e.g.,: + + #if 4 <= __GNUC__ + # define verify(R) \ + extern int (* verify_function__ (void)) \ + [__builtin_constant_p (R) && (R) ? 1 : -1] + #endif + + * In C++, any struct definition inside sizeof is invalid. + Use a template type to work around the problem. */ + + +/* Verify requirement R at compile-time, as an integer constant expression. + Return 1. */ + +# ifdef __cplusplus +template + struct verify_type__ { unsigned int verify_error_if_negative_size__: w; }; +# define verify_true(R) \ + (!!sizeof (verify_type__<(R) ? 1 : -1>)) +# else +# define verify_true(R) \ + (!!sizeof \ + (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; })) +# endif + +/* Verify requirement R at compile-time, as a declaration without a + trailing ';'. */ + +# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] + +#endif diff --git a/src/bin/bison/lib/xalloc-die.c b/src/bin/bison/lib/xalloc-die.c index 637933e308..9b4a76c6ba 100644 --- a/src/bin/bison/lib/xalloc-die.c +++ b/src/bin/bison/lib/xalloc-die.c @@ -1,6 +1,6 @@ /* Report a memory allocation failure and exit. - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free + Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif @@ -30,7 +30,6 @@ #include "gettext.h" #define _(msgid) gettext (msgid) -#define N_(msgid) msgid void xalloc_die (void) diff --git a/src/bin/bison/lib/xmalloc.c b/src/bin/bison/lib/xmalloc.c index 6977703b80..687633c250 100644 --- a/src/bin/bison/lib/xmalloc.c +++ b/src/bin/bison/lib/xmalloc.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/lib/xstrndup.c b/src/bin/bison/lib/xstrndup.c index edf83cf87f..a62d4bd695 100644 --- a/src/bin/bison/lib/xstrndup.c +++ b/src/bin/bison/lib/xstrndup.c @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif diff --git a/src/bin/bison/src/LR0.c b/src/bin/bison/src/LR0.c index 43030fc5ba..259b8912fa 100644 --- a/src/bin/bison/src/LR0.c +++ b/src/bin/bison/src/LR0.c @@ -1,6 +1,6 @@ /* Generate the nondeterministic finite state machine for Bison. - Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004 Free + Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -24,6 +24,7 @@ /* See comments in state.h for the data structures that represent it. The entry point is generate_states. */ +#include #include "system.h" #include @@ -66,11 +67,6 @@ state_list_append (symbol_number sym, size_t core_size, item_number *core) fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n", nstates, sym, symbols[sym]->tag); - /* If this is the endtoken, and this is not the initial state, then - this is the final state. */ - if (sym == 0 && first_state) - final_state = s; - node->next = NULL; node->state = s; @@ -213,20 +209,20 @@ new_itemsets (state *s) static state * get_state (symbol_number sym, size_t core_size, item_number *core) { - state *sp; + state *s; if (trace_flag & trace_automaton) fprintf (stderr, "Entering get_state, symbol = %d (%s)\n", sym, symbols[sym]->tag); - sp = state_hash_lookup (core_size, core); - if (!sp) - sp = state_list_append (sym, core_size, core); + s = state_hash_lookup (core_size, core); + if (!s) + s = state_list_append (sym, core_size, core); if (trace_flag & trace_automaton) - fprintf (stderr, "Exiting get_state => %d\n", sp->number); + fprintf (stderr, "Exiting get_state => %d\n", s->number); - return sp; + return s; } /*---------------------------------------------------------------. @@ -278,9 +274,18 @@ save_reductions (state *s) /* Find and count the active items that represent ends of rules. */ for (i = 0; i < nritemset; ++i) { - int item = ritem[itemset[i]]; - if (item < 0) - redset[count++] = &rules[item_number_as_rule_number (item)]; + item_number item = ritem[itemset[i]]; + if (item_number_is_rule_number (item)) + { + rule_number r = item_number_as_rule_number (item); + redset[count++] = &rules[r]; + if (r == 0) + { + /* This is "reduce 0", i.e., accept. */ + assert (!final_state); + final_state = s; + } + } } /* Make a reductions structure and copy the data into it. */ @@ -338,9 +343,8 @@ generate_states (void) item of this initial rule. */ state_list_append (0, 1, &initial_core); - list = first_state; - - while (list) + /* States are queued when they are created; process them all. */ + for (list = first_state; list; list = list->next) { state *s = list->state; if (trace_flag & trace_automaton) @@ -362,10 +366,6 @@ generate_states (void) /* Create the shifts structures for the shifts to those states, now that the state numbers transitioning to are known. */ state_transitions_set (s, nshifts, shiftset); - - /* states are queued when they are created; process them all. - */ - list = list->next; } /* discard various storage */ diff --git a/src/bin/bison/src/Makefile.am b/src/bin/bison/src/Makefile.am index 4fc07a29a1..c973e9e75c 100644 --- a/src/bin/bison/src/Makefile.am +++ b/src/bin/bison/src/Makefile.am @@ -53,8 +53,8 @@ bison_SOURCES = \ reader.c reader.h \ reduce.c reduce.h \ relation.c relation.h \ - scan-gram.l \ - scan-skel.h scan-skel.l \ + scan-gram-c.c \ + scan-skel-c.c scan-skel.h \ state.c state.h \ symlist.c symlist.h \ symtab.c symtab.h \ @@ -64,6 +64,8 @@ bison_SOURCES = \ vcg.c vcg.h \ vcg_defaults.h +EXTRA_bison_SOURCES = scan-skel.l scan-gram.l + BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h MOSTLYCLEANFILES = yacc diff --git a/src/bin/bison/src/Makefile.in b/src/bin/bison/src/Makefile.in index be41e91bdb..7de908128a 100644 --- a/src/bin/bison/src/Makefile.in +++ b/src/bin/bison/src/Makefile.in @@ -42,8 +42,8 @@ subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in parse-gram.c \ scan-gram.c scan-skel.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ - $(top_srcdir)/m4/bison-i18n.m4 $(top_srcdir)/m4/cxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \ + $(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \ $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \ $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \ @@ -60,11 +60,14 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \ $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strndup.m4 \ - $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/subpipe.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ + $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \ + $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \ $(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \ $(top_srcdir)/m4/ulonglong_gl.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/warning.m4 \ + $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ + $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \ $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -82,7 +85,7 @@ am_bison_OBJECTS = LR0.$(OBJEXT) assoc.$(OBJEXT) closure.$(OBJEXT) \ muscle_tab.$(OBJEXT) nullable.$(OBJEXT) output.$(OBJEXT) \ parse-gram.$(OBJEXT) print.$(OBJEXT) print_graph.$(OBJEXT) \ reader.$(OBJEXT) reduce.$(OBJEXT) relation.$(OBJEXT) \ - scan-gram.$(OBJEXT) scan-skel.$(OBJEXT) state.$(OBJEXT) \ + scan-gram-c.$(OBJEXT) scan-skel-c.$(OBJEXT) state.$(OBJEXT) \ symlist.$(OBJEXT) symtab.$(OBJEXT) tables.$(OBJEXT) \ uniqstr.$(OBJEXT) vcg.$(OBJEXT) bison_OBJECTS = $(am_bison_OBJECTS) @@ -101,14 +104,12 @@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) YLWRAP = $(top_srcdir)/build-aux/ylwrap YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) -SOURCES = $(bison_SOURCES) -DIST_SOURCES = $(bison_SOURCES) +SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES) +DIST_SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALLOCA_H = @ALLOCA_H@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ @@ -118,6 +119,8 @@ AUTOM4TE = @AUTOM4TE@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BISON_CXX_WORKS = @BISON_CXX_WORKS@ +BISON_CXX_WORKS_FALSE = @BISON_CXX_WORKS_FALSE@ +BISON_CXX_WORKS_TRUE = @BISON_CXX_WORKS_TRUE@ BISON_LOCALEDIR = @BISON_LOCALEDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -178,6 +181,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STDBOOL_H = @STDBOOL_H@ STRIP = @STRIP@ +UNISTD_H = @UNISTD_H@ USE_NLS = @USE_NLS@ VALGRIND = @VALGRIND@ VERSION = @VERSION@ @@ -261,8 +265,8 @@ bison_SOURCES = \ reader.c reader.h \ reduce.c reduce.h \ relation.c relation.h \ - scan-gram.l \ - scan-skel.h scan-skel.l \ + scan-gram-c.c \ + scan-skel-c.c scan-skel.h \ state.c state.h \ symlist.c symlist.h \ symtab.c symtab.h \ @@ -272,6 +276,7 @@ bison_SOURCES = \ vcg.c vcg.h \ vcg_defaults.h +EXTRA_bison_SOURCES = scan-skel.l scan-gram.l BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h MOSTLYCLEANFILES = yacc all: $(BUILT_SOURCES) @@ -381,7 +386,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reduce.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-gram-c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-gram.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-skel-c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-skel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlist.Po@am__quote@ diff --git a/src/bin/bison/src/assoc.c b/src/bin/bison/src/assoc.c index b816499c85..6f9a3b5612 100644 --- a/src/bin/bison/src/assoc.c +++ b/src/bin/bison/src/assoc.c @@ -1,5 +1,5 @@ /* Associativity information. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -18,6 +18,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include "assoc.h" @@ -28,6 +29,9 @@ assoc_to_string (assoc a) { switch (a) { + default: + abort (); + case undef_assoc: return "undefined associativity"; @@ -40,5 +44,4 @@ assoc_to_string (assoc a) case non_assoc: return "%nonassoc"; } - return NULL; } diff --git a/src/bin/bison/src/assoc.h b/src/bin/bison/src/assoc.h index b31c55e2bc..778a451c90 100644 --- a/src/bin/bison/src/assoc.h +++ b/src/bin/bison/src/assoc.h @@ -1,5 +1,5 @@ /* Associativity information. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -30,6 +30,6 @@ typedef enum non_assoc } assoc; -char const *assoc_to_string (assoc); +char const *assoc_to_string (assoc a); #endif /* !ASSOC_H_ */ diff --git a/src/bin/bison/src/closure.c b/src/bin/bison/src/closure.c index eb53ee0562..001b8316a7 100644 --- a/src/bin/bison/src/closure.c +++ b/src/bin/bison/src/closure.c @@ -1,7 +1,7 @@ /* Closures for Bison - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,6 +20,7 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include diff --git a/src/bin/bison/src/complain.c b/src/bin/bison/src/complain.c index 4769df5c27..927dbb6305 100644 --- a/src/bin/bison/src/complain.c +++ b/src/bin/bison/src/complain.c @@ -1,5 +1,6 @@ /* Declaration for error-reporting function for Bison. - Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc. + + Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -19,6 +20,7 @@ /* Based on error.c and error.h, written by David MacKenzie . */ +#include #include "system.h" #include diff --git a/src/bin/bison/src/conflicts.c b/src/bin/bison/src/conflicts.c index ede39690c3..13121f6e29 100644 --- a/src/bin/bison/src/conflicts.c +++ b/src/bin/bison/src/conflicts.c @@ -1,6 +1,6 @@ /* Find and resolve or report look-ahead conflicts for bison, - Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004 + Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,6 +20,7 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include @@ -39,7 +40,7 @@ int expected_sr_conflicts = -1; int expected_rr_conflicts = -1; static char *conflicts; -struct obstack solved_conflicts_obstack; +static struct obstack solved_conflicts_obstack; static bitset shift_set; static bitset look_ahead_set; @@ -215,6 +216,9 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) switch (symbols[i]->assoc) { + default: + abort (); + case right_assoc: log_resolution (redrule, i, right_resolution); flush_reduce (look_ahead_tokens, i); @@ -232,9 +236,6 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) /* Record an explicit error for this token. */ errors[nerrs++] = symbols[i]; break; - - case undef_assoc: - abort (); } } @@ -464,11 +465,13 @@ conflicts_print (void) /* Is the number of SR conflicts OK? Either EXPECTED_CONFLICTS is not set, and then we want 0 SR, or else it is specified, in which case we want equality. */ - bool src_ok = false; - bool rrc_ok = false; + bool src_ok; + bool rrc_ok; int src_total = 0; int rrc_total = 0; + int src_expected; + int rrc_expected; /* Conflicts by state. */ { @@ -488,33 +491,36 @@ conflicts_print (void) expected_rr_conflicts = -1; } - src_ok = - src_total == (expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts); - rrc_ok = - rrc_total == (expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts); + src_expected = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts; + rrc_expected = expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts; + src_ok = src_total == src_expected; + rrc_ok = rrc_total == rrc_expected; /* If there are as many RR conflicts and SR conflicts as expected, then there is nothing to report. */ - if (rrc_ok && src_ok) + if (rrc_ok & src_ok) return; /* Report the total number of conflicts on STDERR. */ - if (! yacc_flag) - fprintf (stderr, "%s: ", current_file); - conflict_report (stderr, src_total, rrc_total); + if (src_total | rrc_total) + { + if (! yacc_flag) + fprintf (stderr, "%s: ", current_file); + conflict_report (stderr, src_total, rrc_total); + } if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1) { - int sr = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts; - int rr = expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts; if (! src_ok) - warn (ngettext ("expected %d shift/reduce conflict", - "expected %d shift/reduce conflicts", - sr), sr); + complain (ngettext ("expected %d shift/reduce conflict", + "expected %d shift/reduce conflicts", + src_expected), + src_expected); if (! rrc_ok) - warn (ngettext ("expected %d reduce/reduce conflict", - "expected %d reduce/reduce conflicts", - rr), rr); + complain (ngettext ("expected %d reduce/reduce conflict", + "expected %d reduce/reduce conflicts", + rrc_expected), + rrc_expected); } } diff --git a/src/bin/bison/src/derives.c b/src/bin/bison/src/derives.c index 24fde5d2d6..2e4ff31ba6 100644 --- a/src/bin/bison/src/derives.c +++ b/src/bin/bison/src/derives.c @@ -1,7 +1,7 @@ /* Match rules with nonterminals for bison, - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2005 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include "getargs.h" diff --git a/src/bin/bison/src/files.c b/src/bin/bison/src/files.c index f2092b273a..f3bb0f9c5a 100644 --- a/src/bin/bison/src/files.c +++ b/src/bin/bison/src/files.c @@ -20,7 +20,7 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -29,16 +29,12 @@ #include #include "complain.h" +#include "dirname.h" #include "files.h" #include "getargs.h" #include "gram.h" #include "stdio-safer.h" -/* From basename.c. Almost a lie, as it returns a char *. */ -const char *base_name (char const *name); - -FILE *finput = NULL; - struct obstack pre_prologue_obstack; struct obstack post_prologue_obstack; @@ -49,21 +45,36 @@ struct obstack post_prologue_obstack; NULL), then the %directive is ignored. As a result, %name-prefix, for instance, will not be honored. */ -char *spec_outfile = NULL; /* for -o. */ -char *spec_file_prefix = NULL; /* for -b. */ -const char *spec_name_prefix = NULL; /* for -p. */ -char *spec_verbose_file = NULL; /* for --verbose. */ -char *spec_graph_file = NULL; /* for -g. */ -char *spec_defines_file = NULL; /* for --defines. */ -char *parser_file_name = NULL; +char const *spec_outfile = NULL; /* for -o. */ +char const *spec_file_prefix = NULL; /* for -b. */ +char const *spec_name_prefix = NULL; /* for -p. */ +char const *spec_verbose_file = NULL; /* for --verbose. */ +char const *spec_graph_file = NULL; /* for -g. */ +char const *spec_defines_file = NULL; /* for --defines. */ +char const *parser_file_name; uniqstr grammar_file = NULL; uniqstr current_file = NULL; -static char *full_base_name = NULL; +/* If --output=dir/foo.c was specified, + DIR_PREFIX is `dir/' and ALL_BUT_EXT and ALL_BUT_TAB_EXT are `dir/foo'. -/* Prefix used to generate output file names. */ -char *short_base_name = NULL; + If --output=dir/foo.tab.c was specified, DIR_PREFIX is `dir/', + ALL_BUT_EXT is `dir/foo.tab', and ALL_BUT_TAB_EXT is `dir/foo'. + + If --output was not specified but --file-prefix=dir/foo was specified, + ALL_BUT_EXT = `foo.tab' and ALL_BUT_TAB_EXT = `foo'. + + If neither --output nor --file was specified but the input grammar + is name dir/foo.y, ALL_BUT_EXT and ALL_BUT_TAB_EXT are `foo'. + + If neither --output nor --file was specified, DIR_PREFIX is the + empty string (meaning the current directory); otherwise it is + `dir/'. */ + +static char const *all_but_ext; +static char const *all_but_tab_ext; +char const *dir_prefix; /* C source file extension (the parser source). */ static char const *src_extension = NULL; @@ -121,9 +132,9 @@ xfclose (FILE *ptr) } -/*---------------------------------------------------------------------. -| Compute FULL_BASE_NAME, SHORT_BASE_NAME and output files extensions. | -`---------------------------------------------------------------------*/ +/*------------------------------------------------------------------. +| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. | +`------------------------------------------------------------------*/ /* Replace all characters FROM by TO in the string IN. and returns a new allocated string. */ @@ -218,29 +229,27 @@ file_name_split (const char *file_name, static void -compute_base_names (void) +compute_file_name_parts (void) { const char *base, *tab, *ext; - /* If --output=foo.c was specified (SPEC_OUTFILE == foo.c), - FULL_BASE_NAME and SHORT_BASE_NAME are `foo'. - - If --output=foo.tab.c was specified, FULL_BASE_NAME is `foo.tab' - and SHORT_BASE_NAME is `foo'. + /* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE + or GRAMMAR_FILE. The precise -o name will be used for FTABLE. For other output files, remove the ".c" or ".tab.c" suffix. */ if (spec_outfile) { file_name_split (spec_outfile, &base, &tab, &ext); + dir_prefix = xstrndup (spec_outfile, base - spec_outfile); - /* The full base name goes up the EXT, excluding it. */ - full_base_name = + /* ALL_BUT_EXT goes up the EXT, excluding it. */ + all_but_ext = xstrndup (spec_outfile, (strlen (spec_outfile) - (ext ? strlen (ext) : 0))); - /* The short base name goes up to TAB, excluding it. */ - short_base_name = + /* ALL_BUT_TAB_EXT goes up to TAB, excluding it. */ + all_but_tab_ext = xstrndup (spec_outfile, (strlen (spec_outfile) - (tab ? strlen (tab) : (ext ? strlen (ext) : 0)))); @@ -248,40 +257,34 @@ compute_base_names (void) if (ext) compute_exts_from_src (ext); } - - /* If --file-prefix=foo was specified, FULL_BASE_NAME = `foo.tab' - and SHORT_BASE_NAME = `foo'. - - Construct names from it. */ else { + file_name_split (grammar_file, &base, &tab, &ext); + if (spec_file_prefix) { - /* If --file-prefix=foo was specified, SHORT_BASE_NAME = - `foo'. */ - short_base_name = xstrdup (spec_file_prefix); + /* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */ + dir_prefix = xstrndup (grammar_file, base - grammar_file); + all_but_tab_ext = xstrdup (spec_file_prefix); } else if (yacc_flag) { - /* If --yacc, then the output is `y.tab.c'. */ - short_base_name = xstrdup ("y"); + /* If --yacc, then the output is `y.tab.c'. */ + dir_prefix = ""; + all_but_tab_ext = "y"; } else { - /* Otherwise, the short base name is computed from the input + /* Otherwise, ALL_BUT_TAB_EXT is computed from the input grammar: `foo/bar.yy' => `bar'. */ - file_name_split (grammar_file, &base, &tab, &ext); - short_base_name = - xstrndup (base, - (strlen (base) - (ext ? strlen (ext) : 0))); + dir_prefix = ""; + all_but_tab_ext = + xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0))); } - full_base_name = xmalloc (strlen (short_base_name) - + strlen (TAB_EXT) + 1); - stpcpy (stpcpy (full_base_name, short_base_name), TAB_EXT); + all_but_ext = concat2 (all_but_tab_ext, TAB_EXT); /* Compute the extensions from the grammar file name. */ - file_name_split (grammar_file, &base, &tab, &ext); if (ext && !yacc_flag) compute_exts_from_gf (ext); } @@ -299,7 +302,7 @@ compute_output_file_names (void) int j; int names = 0; - compute_base_names (); + compute_file_name_parts (); /* If not yet done. */ if (!src_extension) @@ -308,25 +311,25 @@ compute_output_file_names (void) header_extension = ".h"; name[names++] = parser_file_name = - spec_outfile ? spec_outfile : concat2 (full_base_name, src_extension); + spec_outfile ? spec_outfile : concat2 (all_but_ext, src_extension); if (defines_flag) { if (! spec_defines_file) - spec_defines_file = concat2 (full_base_name, header_extension); + spec_defines_file = concat2 (all_but_ext, header_extension); name[names++] = spec_defines_file; } if (graph_flag) { if (! spec_graph_file) - spec_graph_file = concat2 (short_base_name, ".vcg"); + spec_graph_file = concat2 (all_but_tab_ext, ".vcg"); name[names++] = spec_graph_file; } if (report_flag) { - spec_verbose_file = concat2 (short_base_name, OUTPUT_EXT); + spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT); name[names++] = spec_verbose_file; } diff --git a/src/bin/bison/src/files.h b/src/bin/bison/src/files.h index 3269c40d41..ba9fec2f2e 100644 --- a/src/bin/bison/src/files.h +++ b/src/bin/bison/src/files.h @@ -24,28 +24,28 @@ # include "uniqstr.h" /* File name specified with -o for the output file, or 0 if no -o. */ -extern char *spec_outfile; +extern char const *spec_outfile; /* File name for the parser (i.e., the one above, or its default.) */ -extern char *parser_file_name; +extern char const *parser_file_name; /* Symbol prefix specified with -p, or 0 if no -p. */ extern const char *spec_name_prefix; /* File name prefix specified with -b, or 0 if no -b. */ -extern char *spec_file_prefix; +extern char const *spec_file_prefix; /* --verbose. */ -extern char *spec_verbose_file; +extern char const *spec_verbose_file; /* File name specified for the output VCG graph. */ -extern char *spec_graph_file; +extern char const *spec_graph_file; /* File name specified with --defines. */ -extern char *spec_defines_file; +extern char const *spec_defines_file; -/* Read grammar specifications. */ -extern FILE *finput; +/* Directory prefix of output file names. */ +extern char const *dir_prefix; /* If semantic parser, output a .h file that defines YYSTYPE... */ @@ -65,7 +65,4 @@ void compute_output_file_names (void); FILE *xfopen (const char *name, const char *mode); void xfclose (FILE *ptr); -/* Prefix used to generate output file names. */ -extern char *short_base_name; - #endif /* !FILES_H_ */ diff --git a/src/bin/bison/src/getargs.c b/src/bin/bison/src/getargs.c index 0170f8e34f..13b0d3215c 100644 --- a/src/bin/bison/src/getargs.c +++ b/src/bin/bison/src/getargs.c @@ -1,7 +1,7 @@ /* Parse command line arguments for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, + 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,6 +20,7 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include @@ -45,19 +46,22 @@ bool debug_flag; bool defines_flag; +bool graph_flag; bool locations_flag; bool no_lines_flag; bool no_parser_flag; -int report_flag = report_none; bool token_table_flag; bool yacc_flag; /* for -y */ -bool graph_flag; -int trace_flag = trace_none; + +bool error_verbose = false; bool nondeterministic_parser = false; bool glr_parser = false; bool pure_parser = false; +int report_flag = report_none; +int trace_flag = trace_none; + const char *skeleton = NULL; const char *include = NULL; @@ -80,7 +84,8 @@ static const char * const trace_args[] = "grammar - reading, reducing of the grammar", "resource - memory consumption (where available)", "sets - grammar sets: firsts, nullable etc.", - "tools - m4 invocation and preserve the temporary file", + "tools - m4 invocation", + "m4 - m4 traces", "skeleton - skeleton postprocessing", "time - time consumption", "all - all of the above", @@ -98,16 +103,17 @@ static const int trace_types[] = trace_resource, trace_sets, trace_tools, + trace_m4, trace_skeleton, trace_time, trace_all }; +ARGMATCH_VERIFY (trace_args, trace_types); static void trace_argmatch (char *args) { - verify (trace_constraint, ARGMATCH_CONSTRAINT (trace_args, trace_types)); if (args) { args = strtok (args, ","); @@ -156,11 +162,11 @@ static const int report_types[] = report_all }; +ARGMATCH_VERIFY (report_args, report_types); static void report_argmatch (char *args) { - verify (report_constraint, ARGMATCH_CONSTRAINT (report_args, report_types)); args = strtok (args, ","); do { @@ -270,7 +276,7 @@ version (void) putc ('\n', stdout); fprintf (stdout, - _("Copyright (C) %d Free Software Foundation, Inc.\n"), 2005); + _("Copyright (C) %d Free Software Foundation, Inc.\n"), 2006); fputs (_("\ This is free software; see the source for copying conditions. There is NO\n\ diff --git a/src/bin/bison/src/getargs.h b/src/bin/bison/src/getargs.h index 2e02a76ae9..816eb95659 100644 --- a/src/bin/bison/src/getargs.h +++ b/src/bin/bison/src/getargs.h @@ -1,5 +1,5 @@ /* Parse command line arguments for bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -32,13 +32,16 @@ extern char const *include; extern bool debug_flag; /* for -t */ extern bool defines_flag; /* for -d */ +extern bool graph_flag; /* for -g */ extern bool locations_flag; extern bool no_lines_flag; /* for -l */ extern bool no_parser_flag; /* for -n */ extern bool token_table_flag; /* for -k */ -extern bool graph_flag; /* for -g */ extern bool yacc_flag; /* for -y */ +extern bool error_verbose; + + /* GLR_PARSER is true if the input file says to use the GLR (Generalized LR) parser, and to output some additional information used by the GLR algorithm. */ @@ -70,6 +73,7 @@ enum trace trace_grammar = 1 << 7, trace_time = 1 << 8, trace_skeleton = 1 << 9, + trace_m4 = 1 << 10, trace_all = ~0 }; extern int trace_flag; diff --git a/src/bin/bison/src/gram.c b/src/bin/bison/src/gram.c index 4636f4e14c..28666b0c8c 100644 --- a/src/bin/bison/src/gram.c +++ b/src/bin/bison/src/gram.c @@ -1,7 +1,7 @@ /* Allocate input grammar variables for Bison. - Copyright (C) 1984, 1986, 1989, 2001, 2002, 2003 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2001, 2002, 2003, 2005, 2006 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -65,7 +65,7 @@ rule_useful_p (rule *r) bool rule_useless_p (rule *r) { - return r->number >= nrules; + return !rule_useful_p (r); } @@ -77,7 +77,7 @@ rule_useless_p (rule *r) bool rule_never_reduced_p (rule *r) { - return !r->useful && r->number < nrules; + return !r->useful && rule_useful_p (r); } @@ -317,8 +317,7 @@ grammar_rules_never_reduced_report (const char *message) if (!rules[r].useful) { location_print (stderr, rules[r].location); - fprintf (stderr, ": %s: %s: ", - _("warning"), message); + fprintf (stderr, ": %s: %s: ", _("warning"), message); rule_print (&rules[r], stderr); } } @@ -326,7 +325,8 @@ grammar_rules_never_reduced_report (const char *message) void grammar_free (void) { - free (ritem); + if (ritem) + free (ritem - 1); free (rules); free (token_translations); /* Free the symbol table data structure. */ diff --git a/src/bin/bison/src/gram.h b/src/bin/bison/src/gram.h index a5dfc1e93b..b8f316a039 100644 --- a/src/bin/bison/src/gram.h +++ b/src/bin/bison/src/gram.h @@ -1,6 +1,6 @@ /* Data definitions for internal representation of Bison's input. - Copyright (C) 1984, 1986, 1989, 1992, 2001, 2002, 2003, 2004 + Copyright (C) 1984, 1986, 1989, 1992, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -138,6 +138,12 @@ item_number_as_symbol_number (item_number i) return i; } +static inline bool +item_number_is_symbol_number (item_number i) +{ + return i >= 0; +} + /* Rule numbers. */ typedef int rule_number; extern rule_number nrules; @@ -154,6 +160,11 @@ item_number_as_rule_number (item_number i) return -1 - i; } +static inline bool +item_number_is_rule_number (item_number i) +{ + return i < 0; +} /*--------. | Rules. | diff --git a/src/bin/bison/src/lalr.c b/src/bin/bison/src/lalr.c index 8627f1cbc3..65c55ab7c8 100644 --- a/src/bin/bison/src/lalr.c +++ b/src/bin/bison/src/lalr.c @@ -1,7 +1,7 @@ /* Compute look-ahead criteria for Bison. - Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -25,6 +25,7 @@ which rules need look-ahead in each state, and which look-ahead tokens they accept. */ +#include #include "system.h" #include @@ -93,8 +94,7 @@ set_goto_map (void) ngotos++; /* Abort if (ngotos + 1) would overflow. */ - if (ngotos == GOTO_NUMBER_MAXIMUM) - abort (); + assert (ngotos != GOTO_NUMBER_MAXIMUM); goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++; } @@ -153,8 +153,7 @@ map_goto (state_number s0, symbol_number sym) for (;;) { - if (high < low) - abort (); + assert (low <= high); middle = (low + high) / 2; s = from_state[middle]; if (s == s0) @@ -246,11 +245,11 @@ build_relations (void) { bool done; int length = 1; - item_number *rp; + item_number const *rp; state *s = states[from_state[i]]; states1[0] = s->number; - for (rp = (*rulep)->rhs; *rp >= 0; rp++) + for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++) { s = transitions_to (s->transitions, item_number_as_symbol_number (*rp)); @@ -265,9 +264,11 @@ build_relations (void) while (!done) { done = true; + /* Each rhs ends in an item number, and there is a + sentinel before the first rhs, so it is safe to + decrement RP here. */ rp--; - /* JF added rp>=ritem && I hope to god its right! */ - if (rp >= ritem && ISVAR (*rp)) + if (ISVAR (*rp)) { /* Downcasting from item_number to symbol_number. */ edge[nedges++] = map_goto (states1[--length], diff --git a/src/bin/bison/src/location.c b/src/bin/bison/src/location.c index 8c235bbbf9..ecd3658b14 100644 --- a/src/bin/bison/src/location.c +++ b/src/bin/bison/src/location.c @@ -1,5 +1,6 @@ /* Locations for Bison - Copyright (C) 2002 Free Software Foundation, Inc. + + Copyright (C) 2002, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -18,6 +19,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include diff --git a/src/bin/bison/src/location.h b/src/bin/bison/src/location.h index b03f6d0e69..49d2a2edfa 100644 --- a/src/bin/bison/src/location.h +++ b/src/bin/bison/src/location.h @@ -1,5 +1,5 @@ /* Locations for Bison - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -29,11 +29,13 @@ typedef struct /* The name of the file that contains the boundary. */ uniqstr file; - /* The (origin-1) line that contains the boundary. */ + /* The (origin-1) line that contains the boundary. + If this is INT_MAX, the line number has overflowed. */ int line; /* The (origin-1) column just after the boundary. This is neither a - byte count, nor a character count; it is a column count. */ + byte count, nor a character count; it is a column count. + If this is INT_MAX, the column number has overflowed. */ int column; } boundary; @@ -62,6 +64,6 @@ typedef struct extern location const empty_location; -void location_print (FILE *, location); +void location_print (FILE *out, location loc); #endif /* ! defined LOCATION_H_ */ diff --git a/src/bin/bison/src/main.c b/src/bin/bison/src/main.c index 08de721692..8769fef8aa 100644 --- a/src/bin/bison/src/main.c +++ b/src/bin/bison/src/main.c @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -172,14 +172,6 @@ main (int argc, char *argv[]) scanner_free (); muscle_free (); uniqstrs_free (); - /* If using alloca.c, flush the alloca'ed memory for the benefit of - people running Bison as a library in IDEs. */ -#if C_ALLOCA - { - extern void *alloca (size_t); - alloca (0); - } -#endif timevar_pop (TV_FREE); if (trace_flag & trace_bitsets) diff --git a/src/bin/bison/src/muscle_tab.c b/src/bin/bison/src/muscle_tab.c index 3e0fb289de..2d71085ebe 100644 --- a/src/bin/bison/src/muscle_tab.c +++ b/src/bin/bison/src/muscle_tab.c @@ -20,6 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include @@ -117,9 +118,9 @@ muscle_insert (const char *key, char *value) /*-------------------------------------------------------------------. -| Insert (KEY, VALUE). If KEY already existed, overwrite the | -| previous value. Uses MUSCLE_OBSTACK. De-allocates the previously | -| associated value. VALUE and SEPARATOR are copied. | +| Append VALUE to the current value of KEY. If KEY did not already | +| exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously | +| associated value. Copy VALUE and SEPARATOR. | `-------------------------------------------------------------------*/ void @@ -197,7 +198,7 @@ void muscle_pair_list_grow (const char *muscle, | Find the value of muscle KEY. | `-------------------------------*/ -char* +char * muscle_find (const char *key) { muscle_entry probe; diff --git a/src/bin/bison/src/nullable.c b/src/bin/bison/src/nullable.c index e73344f828..83a90e9556 100644 --- a/src/bin/bison/src/nullable.c +++ b/src/bin/bison/src/nullable.c @@ -1,7 +1,7 @@ /* Calculate which nonterminals can expand into the null string for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2004 Free - Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -25,6 +25,7 @@ the null string. NULLABLE[I - NTOKENS] is nonzero if symbol I can do so. */ +#include #include "system.h" #include "getargs.h" @@ -103,8 +104,8 @@ nullable_compute (void) else { /* This rule has an empty RHS. */ - if (item_number_as_rule_number (rules_ruleno->rhs[0]) != ruleno) - abort (); + assert (item_number_as_rule_number (rules_ruleno->rhs[0]) + == ruleno); if (rules_ruleno->useful && ! nullable[rules_ruleno->lhs->number - ntokens]) { diff --git a/src/bin/bison/src/output.c b/src/bin/bison/src/output.c index 5b12f72806..6a02bb3306 100644 --- a/src/bin/bison/src/output.c +++ b/src/bin/bison/src/output.c @@ -1,7 +1,7 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, + 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,7 +20,7 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -43,9 +43,6 @@ static struct obstack format_obstack; -bool error_verbose = false; - - /*-------------------------------------------------------------------. | Create a function NAME which associates to the muscle NAME the | @@ -239,8 +236,7 @@ prepare_rules (void) /* Merger-function index (GLR). */ merger[r] = rules[r].merger; } - if (i != nritems) - abort (); + assert (i == nritems); muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems); muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules); @@ -351,8 +347,7 @@ token_definitions_output (FILE *out) /* At this stage, if there are literal aliases, they are part of SYMBOLS, so we should not find symbols which are the aliases here. */ - if (number == USER_NUMBER_ALIAS) - abort (); + assert (number != USER_NUMBER_ALIAS); /* Skip error token. */ if (sym == errtoken) @@ -515,7 +510,6 @@ output_skeleton (void) cheap sanity check is worthwhile. */ char const m4sugar[] = "m4sugar/m4sugar.m4"; char *full_m4sugar; - char *full_cm4; char *full_skeleton; char const *p; char const *m4 = (p = getenv ("M4")) ? p : M4; @@ -531,28 +525,25 @@ output_skeleton (void) full_skeleton[pkgdatadirlen] = '/'; strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar); full_m4sugar = xstrdup (full_skeleton); - strcpy (full_skeleton + pkgdatadirlen + 1, "c.m4"); - full_cm4 = xstrdup (full_skeleton); strcpy (full_skeleton + pkgdatadirlen + 1, skeleton); xfclose (xfopen (full_m4sugar, "r")); /* Create an m4 subprocess connected to us via two pipes. */ if (trace_flag & trace_tools) - fprintf (stderr, "running: %s %s - %s %s\n", - m4, full_m4sugar, full_cm4, full_skeleton); + fprintf (stderr, "running: %s %s - %s\n", + m4, full_m4sugar, full_skeleton); argv[0] = m4; argv[1] = full_m4sugar; argv[2] = "-"; - argv[3] = full_cm4; - argv[4] = full_skeleton; + argv[3] = full_skeleton; + argv[4] = trace_flag & trace_m4 ? "-dV" : NULL; argv[5] = NULL; init_subpipe (); pid = create_subpipe (argv, filter_fd); free (full_m4sugar); - free (full_cm4); free (full_skeleton); out = fdopen (filter_fd[0], "w"); @@ -577,6 +568,7 @@ output_skeleton (void) /* Read and process m4's output. */ timevar_push (TV_M4); + end_of_output_subpipe (pid, filter_fd); in = fdopen (filter_fd[1], "r"); if (! in) error (EXIT_FAILURE, get_errno (), @@ -591,15 +583,25 @@ static void prepare (void) { /* Flags. */ - MUSCLE_INSERT_BOOL ("debug", debug_flag); + MUSCLE_INSERT_BOOL ("debug_flag", debug_flag); MUSCLE_INSERT_BOOL ("defines_flag", defines_flag); - MUSCLE_INSERT_BOOL ("error_verbose", error_verbose); + MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose); MUSCLE_INSERT_BOOL ("locations_flag", locations_flag); - MUSCLE_INSERT_BOOL ("pure", pure_parser); + MUSCLE_INSERT_BOOL ("pure_flag", pure_parser); MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag); /* File names. */ MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy"); +#define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "") + DEFINE (dir_prefix); + DEFINE (parser_file_name); + DEFINE (spec_defines_file); + DEFINE (spec_file_prefix); + DEFINE (spec_graph_file); + DEFINE (spec_name_prefix); + DEFINE (spec_outfile); + DEFINE (spec_verbose_file); +#undef DEFINE /* User Code. */ obstack_1grow (&pre_prologue_obstack, 0); diff --git a/src/bin/bison/src/output.h b/src/bin/bison/src/output.h index 0f16e874d9..784f227cd2 100644 --- a/src/bin/bison/src/output.h +++ b/src/bin/bison/src/output.h @@ -1,5 +1,5 @@ /* Output the generated parsing program for bison, - Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -21,8 +21,6 @@ #ifndef OUTPUT_H_ # define OUTPUT_H_ -extern bool error_verbose; - /* Output the parsing tables and the parser code to FTABLE. */ void output (void); diff --git a/src/bin/bison/src/parse-gram.c b/src/bin/bison/src/parse-gram.c index 35492f567b..2b77f3eafa 100644 --- a/src/bin/bison/src/parse-gram.c +++ b/src/bin/bison/src/parse-gram.c @@ -1,7 +1,9 @@ -/* A Bison parser, made by GNU Bison 2.1. */ +/* A Bison parser, made by GNU Bison 2.2a. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +20,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -37,7 +47,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.1" +#define YYBISON_VERSION "2.2a" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -98,21 +108,22 @@ PERCENT_OUTPUT = 288, PERCENT_PARSE_PARAM = 289, PERCENT_PURE_PARSER = 290, - PERCENT_SKELETON = 291, - PERCENT_START = 292, - PERCENT_TOKEN_TABLE = 293, - PERCENT_VERBOSE = 294, - PERCENT_YACC = 295, - TYPE = 296, - EQUAL = 297, - SEMICOLON = 298, - PIPE = 299, - ID = 300, - ID_COLON = 301, - PERCENT_PERCENT = 302, - PROLOGUE = 303, - EPILOGUE = 304, - BRACED_CODE = 305 + PERCENT_REQUIRE = 291, + PERCENT_SKELETON = 292, + PERCENT_START = 293, + PERCENT_TOKEN_TABLE = 294, + PERCENT_VERBOSE = 295, + PERCENT_YACC = 296, + TYPE = 297, + EQUAL = 298, + SEMICOLON = 299, + PIPE = 300, + ID = 301, + ID_COLON = 302, + PERCENT_PERCENT = 303, + PROLOGUE = 304, + EPILOGUE = 305, + BRACED_CODE = 306 }; #endif /* Tokens. */ @@ -150,21 +161,22 @@ #define PERCENT_OUTPUT 288 #define PERCENT_PARSE_PARAM 289 #define PERCENT_PURE_PARSER 290 -#define PERCENT_SKELETON 291 -#define PERCENT_START 292 -#define PERCENT_TOKEN_TABLE 293 -#define PERCENT_VERBOSE 294 -#define PERCENT_YACC 295 -#define TYPE 296 -#define EQUAL 297 -#define SEMICOLON 298 -#define PIPE 299 -#define ID 300 -#define ID_COLON 301 -#define PERCENT_PERCENT 302 -#define PROLOGUE 303 -#define EPILOGUE 304 -#define BRACED_CODE 305 +#define PERCENT_REQUIRE 291 +#define PERCENT_SKELETON 292 +#define PERCENT_START 293 +#define PERCENT_TOKEN_TABLE 294 +#define PERCENT_VERBOSE 295 +#define PERCENT_YACC 296 +#define TYPE 297 +#define EQUAL 298 +#define SEMICOLON 299 +#define PIPE 300 +#define ID 301 +#define ID_COLON 302 +#define PERCENT_PERCENT 303 +#define PROLOGUE 304 +#define EPILOGUE 305 +#define BRACED_CODE 306 @@ -173,7 +185,7 @@ #line 1 "parse-gram.y" /* Bison Grammar Parser -*- C -*- - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -193,6 +205,7 @@ 02110-1301 USA */ +#include #include "system.h" #include "complain.h" @@ -201,33 +214,47 @@ #include "getargs.h" #include "gram.h" #include "muscle_tab.h" -#include "output.h" #include "quotearg.h" #include "reader.h" #include "symlist.h" +#include "strverscmp.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); #define YY_LOCATION_PRINT(File, Loc) \ - location_print (File, Loc) + location_print (File, Loc) + +static void version_check (location const *loc, char const *version); /* Request detailed syntax error messages, and pass them to GRAM_ERROR. FIXME: depends on the undocumented availability of YYLLOC. */ #undef yyerror #define yyerror(Msg) \ - gram_error (&yylloc, Msg) + gram_error (&yylloc, Msg) static void gram_error (location const *, char const *); static void add_param (char const *, char *, location); static symbol_class current_class = unknown_sym; static uniqstr current_type = 0; -symbol *current_lhs; -location current_lhs_location; -assoc current_assoc; +static symbol *current_lhs; +static location current_lhs_location; static int current_prec = 0; +#ifdef UINT_FAST8_MAX +# define YYTYPE_UINT8 uint_fast8_t +#endif +#ifdef INT_FAST8_MAX +# define YYTYPE_INT8 int_fast8_t +#endif +#ifdef UINT_FAST16_MAX +# define YYTYPE_UINT16 uint_fast16_t +#endif +#ifdef INT_FAST16_MAX +# define YYTYPE_INT16 int_fast16_t +#endif + /* Enabling traces. */ #ifndef YYDEBUG @@ -247,24 +274,26 @@ static int current_prec = 0; # define YYTOKEN_TABLE 0 #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 79 "parse-gram.y" -typedef union YYSTYPE { +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 94 "parse-gram.y" +{ symbol *symbol; symbol_list *list; int integer; char *chars; assoc assoc; uniqstr uniqstr; -} YYSTYPE; -/* Line 196 of yacc.c. */ -#line 262 "parse-gram.c" +} +/* Line 193 of yacc.c. */ +#line 290 "parse-gram.c" + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif -#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; @@ -281,23 +310,56 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 219 of yacc.c. */ -#line 286 "parse-gram.c" +/* Line 216 of yacc.c. */ +#line 315 "parse-gram.c" -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ +#ifdef short +# undef short #endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; #endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; #endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; #endif +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS @@ -310,7 +372,32 @@ typedef struct YYLTYPE # endif #endif -#if ! defined (yyoverflow) || YYERROR_VERBOSE +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -318,65 +405,77 @@ typedef struct YYLTYPE # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# ifdef __cplusplus -extern "C" { +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif -# ifdef __cplusplus -} -# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \ - && defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short int yyss; + yytype_int16 yyss; YYSTYPE yyvs; YYLTYPE yyls; }; @@ -387,13 +486,13 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ +# if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else @@ -404,7 +503,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif @@ -422,39 +521,33 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (YYID (0)) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 158 +#define YYLAST 161 -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 51 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 25 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 79 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 108 +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 52 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 26 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 82 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 111 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 305 +#define YYMAXUTOK 306 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -486,67 +579,69 @@ static const unsigned char yytranslate[] = 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50 + 45, 46, 47, 48, 49, 50, 51 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const unsigned char yyprhs[] = +static const yytype_uint8 yyprhs[] = { - 0, 0, 3, 8, 9, 12, 14, 16, 18, 22, - 24, 26, 29, 32, 36, 38, 40, 42, 44, 48, - 50, 52, 56, 58, 60, 63, 65, 67, 69, 71, - 73, 75, 78, 80, 83, 86, 88, 90, 91, 95, - 96, 100, 104, 108, 110, 112, 114, 115, 117, 119, - 122, 124, 126, 129, 132, 136, 138, 141, 143, 146, - 148, 151, 154, 155, 159, 161, 165, 168, 169, 172, - 175, 179, 183, 187, 189, 191, 193, 195, 197, 198 + 0, 0, 3, 8, 9, 12, 14, 16, 18, 21, + 25, 27, 29, 32, 35, 39, 41, 43, 45, 47, + 51, 53, 55, 59, 61, 63, 66, 69, 71, 73, + 75, 77, 79, 81, 84, 86, 89, 92, 94, 96, + 97, 101, 102, 106, 110, 114, 116, 118, 120, 121, + 123, 125, 128, 130, 132, 135, 138, 142, 144, 147, + 149, 152, 154, 157, 160, 161, 165, 167, 171, 174, + 175, 178, 181, 185, 189, 193, 195, 197, 198, 201, + 203, 205, 206 }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = { - 52, 0, -1, 53, 47, 65, 75, -1, -1, 53, - 54, -1, 55, -1, 48, -1, 17, -1, 19, 74, - 74, -1, 20, -1, 21, -1, 22, 4, -1, 23, - 4, -1, 24, 42, 74, -1, 25, -1, 26, -1, - 27, -1, 28, -1, 29, 42, 74, -1, 31, -1, - 32, -1, 33, 42, 74, -1, 34, -1, 35, -1, - 36, 74, -1, 38, -1, 39, -1, 40, -1, 43, - -1, 59, -1, 56, -1, 37, 71, -1, 10, -1, - 8, 62, -1, 9, 62, -1, 18, -1, 30, -1, - -1, 6, 57, 64, -1, -1, 5, 58, 64, -1, - 7, 41, 62, -1, 60, 61, 62, -1, 11, -1, - 12, -1, 13, -1, -1, 41, -1, 71, -1, 62, - 71, -1, 41, -1, 45, -1, 45, 4, -1, 45, - 73, -1, 45, 4, 73, -1, 63, -1, 64, 63, - -1, 66, -1, 65, 66, -1, 67, -1, 55, 43, - -1, 1, 43, -1, -1, 46, 68, 69, -1, 70, - -1, 69, 44, 70, -1, 69, 43, -1, -1, 70, - 71, -1, 70, 72, -1, 70, 14, 71, -1, 70, - 15, 4, -1, 70, 16, 41, -1, 45, -1, 73, - -1, 50, -1, 3, -1, 3, -1, -1, 47, 49, - -1 + 53, 0, -1, 54, 48, 66, 77, -1, -1, 54, + 55, -1, 56, -1, 49, -1, 17, -1, 19, 76, + -1, 19, 76, 76, -1, 20, -1, 21, -1, 22, + 4, -1, 23, 4, -1, 24, 43, 76, -1, 25, + -1, 26, -1, 27, -1, 28, -1, 29, 43, 76, + -1, 31, -1, 32, -1, 33, 43, 76, -1, 34, + -1, 35, -1, 36, 76, -1, 37, 76, -1, 39, + -1, 40, -1, 41, -1, 44, -1, 60, -1, 57, + -1, 38, 72, -1, 10, -1, 8, 63, -1, 9, + 63, -1, 18, -1, 30, -1, -1, 6, 58, 65, + -1, -1, 5, 59, 65, -1, 7, 42, 63, -1, + 61, 62, 63, -1, 11, -1, 12, -1, 13, -1, + -1, 42, -1, 72, -1, 63, 72, -1, 42, -1, + 46, -1, 46, 4, -1, 46, 75, -1, 46, 4, + 75, -1, 64, -1, 65, 64, -1, 67, -1, 66, + 67, -1, 68, -1, 56, 44, -1, 1, 44, -1, + -1, 47, 69, 70, -1, 71, -1, 70, 45, 71, + -1, 70, 44, -1, -1, 71, 72, -1, 71, 73, + -1, 71, 14, 72, -1, 71, 15, 4, -1, 71, + 16, 42, -1, 46, -1, 75, -1, -1, 74, 51, + -1, 3, -1, 3, -1, -1, 48, 50, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = +static const yytype_uint16 yyrline[] = { - 0, 188, 188, 196, 198, 202, 203, 204, 205, 206, - 207, 208, 209, 210, 211, 216, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 236, - 237, 238, 242, 248, 255, 262, 266, 273, 273, 278, - 278, 283, 293, 308, 309, 310, 314, 315, 321, 322, - 327, 331, 336, 342, 348, 359, 360, 369, 370, 376, - 377, 382, 389, 389, 393, 394, 395, 400, 401, 403, - 405, 407, 409, 414, 415, 419, 425, 434, 439, 441 + 0, 202, 202, 210, 212, 216, 217, 218, 219, 224, + 225, 226, 227, 228, 229, 230, 235, 239, 240, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, + 252, 256, 257, 258, 262, 278, 285, 292, 296, 303, + 303, 308, 308, 313, 323, 338, 339, 340, 344, 345, + 351, 352, 357, 361, 366, 372, 378, 389, 390, 399, + 400, 406, 407, 408, 415, 415, 419, 420, 421, 426, + 427, 429, 430, 432, 434, 439, 440, 456, 456, 462, + 471, 476, 478 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "\"end of file\"", "error", "$undefined", "\"string\"", "\"integer\"", @@ -558,170 +653,178 @@ static const char *const yytname[] = "\"%initial-action {...}\"", "\"%lex-param {...}\"", "\"%locations\"", "\"%name-prefix\"", "\"%no-default-prec\"", "\"%no-lines\"", "\"%nondeterministic-parser\"", "\"%output\"", "\"%parse-param {...}\"", - "\"%pure-parser\"", "\"%skeleton\"", "\"%start\"", "\"%token-table\"", - "\"%verbose\"", "\"%yacc\"", "\"type\"", "\"=\"", "\";\"", "\"|\"", - "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"%{...%}\"", - "\"epilogue\"", "\"{...}\"", "$accept", "input", "declarations", - "declaration", "grammar_declaration", "symbol_declaration", "@1", "@2", - "precedence_declaration", "precedence_declarator", "type.opt", - "symbols.1", "symbol_def", "symbol_defs.1", "grammar", - "rules_or_grammar_declaration", "rules", "@3", "rhses.1", "rhs", - "symbol", "action", "string_as_id", "string_content", "epilogue.opt", 0 + "\"%pure-parser\"", "\"%require\"", "\"%skeleton\"", "\"%start\"", + "\"%token-table\"", "\"%verbose\"", "\"%yacc\"", "\"type\"", "\"=\"", + "\";\"", "\"|\"", "\"identifier\"", "\"identifier:\"", "\"%%\"", + "\"%{...%}\"", "\"epilogue\"", "\"{...}\"", "$accept", "input", + "declarations", "declaration", "grammar_declaration", + "symbol_declaration", "@1", "@2", "precedence_declaration", + "precedence_declarator", "type.opt", "symbols.1", "symbol_def", + "symbol_defs.1", "grammar", "rules_or_grammar_declaration", "rules", + "@3", "rhses.1", "rhs", "symbol", "action", "@4", "string_as_id", + "string_content", "epilogue.opt", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305 + 305, 306 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = +static const yytype_uint8 yyr1[] = { - 0, 51, 52, 53, 53, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, - 55, 55, 55, 55, 55, 55, 55, 57, 56, 58, - 56, 56, 59, 60, 60, 60, 61, 61, 62, 62, - 63, 63, 63, 63, 63, 64, 64, 65, 65, 66, - 66, 66, 68, 67, 69, 69, 69, 70, 70, 70, - 70, 70, 70, 71, 71, 72, 73, 74, 75, 75 + 0, 52, 53, 54, 54, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 56, 56, 56, 56, 56, 56, 56, 56, 58, + 57, 59, 57, 57, 60, 61, 61, 61, 62, 62, + 63, 63, 64, 64, 64, 64, 64, 65, 65, 66, + 66, 67, 67, 67, 69, 68, 70, 70, 70, 71, + 71, 71, 71, 71, 71, 72, 72, 74, 73, 75, + 76, 77, 77 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = +static const yytype_uint8 yyr2[] = { - 0, 2, 4, 0, 2, 1, 1, 1, 3, 1, - 1, 2, 2, 3, 1, 1, 1, 1, 3, 1, - 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, - 1, 2, 1, 2, 2, 1, 1, 0, 3, 0, - 3, 3, 3, 1, 1, 1, 0, 1, 1, 2, - 1, 1, 2, 2, 3, 1, 2, 1, 2, 1, - 2, 2, 0, 3, 1, 3, 2, 0, 2, 2, - 3, 3, 3, 1, 1, 1, 1, 1, 0, 2 + 0, 2, 4, 0, 2, 1, 1, 1, 2, 3, + 1, 1, 2, 2, 3, 1, 1, 1, 1, 3, + 1, 1, 3, 1, 1, 2, 2, 1, 1, 1, + 1, 1, 1, 2, 1, 2, 2, 1, 1, 0, + 3, 0, 3, 3, 3, 1, 1, 1, 0, 1, + 1, 2, 1, 1, 2, 2, 3, 1, 2, 1, + 2, 1, 2, 2, 0, 3, 1, 3, 2, 0, + 2, 2, 3, 3, 3, 1, 1, 0, 2, 1, + 1, 0, 2 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const unsigned char yydefact[] = +static const yytype_uint8 yydefact[] = { - 3, 0, 0, 1, 39, 37, 0, 0, 0, 32, - 43, 44, 45, 7, 35, 0, 9, 10, 0, 0, - 0, 14, 15, 16, 17, 0, 36, 19, 20, 0, - 22, 23, 0, 0, 25, 26, 27, 28, 0, 6, - 4, 5, 30, 29, 46, 0, 0, 0, 76, 73, - 33, 48, 74, 34, 77, 0, 11, 12, 0, 0, - 0, 24, 31, 0, 62, 0, 0, 57, 59, 47, - 0, 50, 51, 55, 40, 38, 41, 49, 8, 13, - 18, 21, 61, 67, 60, 0, 58, 2, 42, 52, - 53, 56, 63, 64, 79, 54, 66, 67, 0, 0, - 0, 75, 68, 69, 65, 70, 71, 72 + 3, 0, 0, 1, 41, 39, 0, 0, 0, 34, + 45, 46, 47, 7, 37, 0, 10, 11, 0, 0, + 0, 15, 16, 17, 18, 0, 38, 20, 21, 0, + 23, 24, 0, 0, 0, 27, 28, 29, 30, 0, + 6, 4, 5, 32, 31, 48, 0, 0, 0, 79, + 75, 35, 50, 76, 36, 80, 8, 12, 13, 0, + 0, 0, 25, 26, 33, 0, 64, 0, 0, 59, + 61, 49, 0, 52, 53, 57, 42, 40, 43, 51, + 9, 14, 19, 22, 63, 69, 62, 0, 60, 2, + 44, 54, 55, 58, 65, 66, 82, 56, 68, 69, + 0, 0, 0, 70, 71, 0, 67, 72, 73, 74, + 78 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = { - -1, 1, 2, 40, 65, 42, 46, 45, 43, 44, - 70, 50, 73, 74, 66, 67, 68, 83, 92, 93, - 51, 103, 52, 55, 87 + -1, 1, 2, 41, 67, 43, 47, 46, 44, 45, + 72, 51, 75, 76, 68, 69, 70, 85, 94, 95, + 52, 104, 105, 53, 56, 89 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -67 -static const yysigned_char yypact[] = +#define YYPACT_NINF -69 +static const yytype_int8 yypact[] = { - -67, 5, 110, -67, -67, -67, -34, 0, 0, -67, - -67, -67, -67, -67, -67, 13, -67, -67, 20, 31, - -17, -67, -67, -67, -67, -6, -67, -67, -67, -5, - -67, -67, 13, 0, -67, -67, -67, -67, 68, -67, - -67, -67, -67, -67, -3, -37, -37, 0, -67, -67, - 0, -67, -67, 0, -67, 13, -67, -67, 13, 13, - 13, -67, -67, -2, -67, 3, 21, -67, -67, -67, - 0, -67, 6, -67, -37, -37, 0, -67, -67, -67, - -67, -67, -67, -67, -67, 1, -67, -67, 0, 39, - -67, -67, -32, -1, -67, -67, -67, -67, 0, 43, - 7, -67, -67, -67, -1, -67, -67, -67 + -69, 5, 112, -69, -69, -69, -35, 0, 0, -69, + -69, -69, -69, -69, -69, 13, -69, -69, 20, 31, + -18, -69, -69, -69, -69, -6, -69, -69, -69, -5, + -69, -69, 13, 13, 0, -69, -69, -69, -69, 69, + -69, -69, -69, -69, -69, -2, -38, -38, 0, -69, + -69, 0, -69, -69, 0, -69, 13, -69, -69, 13, + 13, 13, -69, -69, -69, -8, -69, 3, 21, -69, + -69, -69, 0, -69, 6, -69, -38, -38, 0, -69, + -69, -69, -69, -69, -69, -69, -69, 2, -69, -69, + 0, 39, -69, -69, -33, -1, -69, -69, -69, -69, + 0, 44, 1, -69, -69, 4, -1, -69, -69, -69, + -69 }; /* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = +static const yytype_int8 yypgoto[] = { - -67, -67, -67, -67, 50, -67, -67, -67, -67, -67, - -67, -7, -56, 8, -67, -13, -67, -67, -67, -41, - -33, -67, -66, 29, -67 + -69, -69, -69, -69, 47, -69, -69, -69, -69, -69, + -69, -7, -58, 7, -69, -15, -69, -69, -69, -42, + -34, -69, -69, -68, 30, -69 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -79 -static const yysigned_char yytable[] = +#define YYTABLE_NINF -82 +static const yytype_int8 yytable[] = { - 62, 53, 48, 48, 71, 3, 90, 47, 72, 48, - 89, 96, 97, 98, 99, 100, 54, 77, 91, 91, - 77, -78, 63, 95, 56, 58, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 57, 59, 60, 69, 14, - 76, 82, 48, 77, 49, 49, 84, 106, 107, 101, - 94, 26, 41, 86, 75, 77, 104, 0, 33, 0, - 102, 61, 0, 88, 0, 105, 0, 64, 85, 63, - 0, 102, 0, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 0, 0, 78, 0, 14, 79, 80, 81, - 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 0, 0, 0, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 0, 0, 37, 0, 0, 0, 38, 39 + 64, 54, 49, 49, 73, 3, 92, 48, 74, 49, + 91, 98, 99, 100, 101, 102, 55, 79, 93, 93, + 79, -81, 65, 97, 57, 59, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 58, 84, 60, 61, 14, + 71, 78, 49, 109, 79, 50, 50, 86, 108, 42, + -77, 26, 96, 88, 77, 110, 79, 106, 0, 34, + 0, 103, 62, 63, 0, 90, 107, 0, 66, 87, + 65, 0, 103, 0, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 0, 0, 0, 80, 14, 0, 81, + 82, 83, 0, 0, 0, 0, 0, 0, 0, 26, + 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 66, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 0, 0, 0, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 0, 0, 38, 0, 0, 0, + 39, 40 }; -static const yysigned_char yycheck[] = +static const yytype_int8 yycheck[] = { - 33, 8, 3, 3, 41, 0, 72, 41, 45, 3, - 4, 43, 44, 14, 15, 16, 3, 50, 74, 75, - 53, 0, 1, 89, 4, 42, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 4, 42, 42, 41, 18, - 47, 43, 3, 76, 45, 45, 43, 4, 41, 50, - 49, 30, 2, 66, 46, 88, 97, -1, 37, -1, - 93, 32, -1, 70, -1, 98, -1, 46, 47, 1, - -1, 104, -1, 5, 6, 7, 8, 9, 10, 11, - 12, 13, -1, -1, 55, -1, 18, 58, 59, 60, - -1, -1, -1, -1, -1, -1, -1, -1, 30, -1, - -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, - -1, -1, -1, -1, 46, 5, 6, 7, 8, 9, - 10, 11, 12, 13, -1, -1, -1, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, -1, -1, 43, -1, -1, -1, 47, 48 + 34, 8, 3, 3, 42, 0, 74, 42, 46, 3, + 4, 44, 45, 14, 15, 16, 3, 51, 76, 77, + 54, 0, 1, 91, 4, 43, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 4, 44, 43, 43, 18, + 42, 48, 3, 42, 78, 46, 46, 44, 4, 2, + 51, 30, 50, 68, 47, 51, 90, 99, -1, 38, + -1, 95, 32, 33, -1, 72, 100, -1, 47, 48, + 1, -1, 106, -1, 5, 6, 7, 8, 9, 10, + 11, 12, 13, -1, -1, -1, 56, 18, -1, 59, + 60, 61, -1, -1, -1, -1, -1, -1, -1, 30, + -1, -1, -1, -1, -1, -1, -1, 38, -1, -1, + -1, -1, -1, -1, -1, -1, 47, 5, 6, 7, + 8, 9, 10, 11, 12, 13, -1, -1, -1, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, -1, -1, 44, -1, -1, -1, + 48, 49 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const unsigned char yystos[] = +static const yytype_uint8 yystos[] = { - 0, 52, 53, 0, 5, 6, 7, 8, 9, 10, + 0, 53, 54, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 43, 47, 48, - 54, 55, 56, 59, 60, 58, 57, 41, 3, 45, - 62, 71, 73, 62, 3, 74, 4, 4, 42, 42, - 42, 74, 71, 1, 46, 55, 65, 66, 67, 41, - 61, 41, 45, 63, 64, 64, 62, 71, 74, 74, - 74, 74, 43, 68, 43, 47, 66, 75, 62, 4, - 73, 63, 69, 70, 49, 73, 43, 44, 14, 15, - 16, 50, 71, 72, 70, 71, 4, 41 + 34, 35, 36, 37, 38, 39, 40, 41, 44, 48, + 49, 55, 56, 57, 60, 61, 59, 58, 42, 3, + 46, 63, 72, 75, 63, 3, 76, 4, 4, 43, + 43, 43, 76, 76, 72, 1, 47, 56, 66, 67, + 68, 42, 62, 42, 46, 64, 65, 65, 63, 72, + 76, 76, 76, 76, 44, 69, 44, 48, 67, 77, + 63, 4, 75, 64, 70, 71, 50, 75, 44, 45, + 14, 15, 16, 72, 73, 74, 71, 72, 4, 42, + 51 }; #define yyerrok (yyerrstatus = 0) @@ -749,7 +852,7 @@ do \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ + YYPOPSTACK (1); \ goto yybackup; \ } \ else \ @@ -757,7 +860,7 @@ do \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (YYID (0)) #define YYTERROR 1 @@ -772,7 +875,7 @@ while (0) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ - if (N) \ + if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ @@ -786,7 +889,7 @@ while (0) (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (YYID (0)) #endif @@ -798,8 +901,8 @@ while (0) # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -826,36 +929,181 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value, Location); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + case 3: /* "\"string\"" */ +#line 179 "parse-gram.y" + { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); }; +#line 979 "parse-gram.c" + break; + case 4: /* "\"integer\"" */ +#line 192 "parse-gram.y" + { fprintf (stderr, "%d", (yyvaluep->integer)); }; +#line 984 "parse-gram.c" + break; + case 8: /* "\"%destructor {...}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 989 "parse-gram.c" + break; + case 9: /* "\"%printer {...}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 994 "parse-gram.c" + break; + case 10: /* "\"%union {...}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 999 "parse-gram.c" + break; + case 26: /* "\"%initial-action {...}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 1004 "parse-gram.c" + break; + case 27: /* "\"%lex-param {...}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 1009 "parse-gram.c" + break; + case 34: /* "\"%parse-param {...}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 1014 "parse-gram.c" + break; + case 42: /* "\"type\"" */ +#line 190 "parse-gram.y" + { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; +#line 1019 "parse-gram.c" + break; + case 46: /* "\"identifier\"" */ +#line 194 "parse-gram.y" + { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; +#line 1024 "parse-gram.c" + break; + case 47: /* "\"identifier:\"" */ +#line 196 "parse-gram.y" + { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; +#line 1029 "parse-gram.c" + break; + case 49: /* "\"%{...%}\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 1034 "parse-gram.c" + break; + case 50: /* "\"epilogue\"" */ +#line 181 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; +#line 1039 "parse-gram.c" + break; + case 72: /* "symbol" */ +#line 194 "parse-gram.y" + { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; +#line 1044 "parse-gram.c" + break; + case 75: /* "string_as_id" */ +#line 194 "parse-gram.y" + { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; +#line 1049 "parse-gram.c" + break; + case 76: /* "string_content" */ +#line 179 "parse-gram.y" + { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); }; +#line 1054 "parse-gram.c" + break; + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); + YYFPRINTF (yyoutput, ")"); +} /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (short int *bottom, short int *top) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void yy_stack_print (bottom, top) - short int *bottom; - short int *top; + yytype_int16 *bottom; + yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) + for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -864,37 +1112,46 @@ yy_stack_print (bottom, top) do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) #else static void -yy_reduce_print (yyrule) +yy_reduce_print (yyvsp, yylsp, yyrule) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; int yyrule; #endif { + int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) ); + fprintf (stderr, "\n"); + } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) + yy_reduce_print (yyvsp, yylsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -928,42 +1185,44 @@ int yydebug; #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) -# else +#else +static YYSIZE_T yystrlen (yystr) - const char *yystr; -# endif + const char *yystr; +#endif { - const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * -# if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) -# else +#else +static char * yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif + char *yydest; + const char *yysrc; +#endif { char *yyd = yydest; const char *yys = yysrc; @@ -989,7 +1248,7 @@ yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - size_t yyn = 0; + YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) @@ -1024,147 +1283,123 @@ yytnamerr (char *yyres, const char *yystr) } # endif -#endif /* YYERROR_VERBOSE */ +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep, yylocationp) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; - YYLTYPE *yylocationp; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - (void) yylocationp; - - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - YY_LOCATION_PRINT (yyoutput, *yylocationp); - YYFPRINTF (yyoutput, ": "); - -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - switch (yytype) - { - case 3: /* "\"string\"" */ -#line 165 "parse-gram.y" - { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); }; -#line 1070 "parse-gram.c" - break; - case 4: /* "\"integer\"" */ -#line 178 "parse-gram.y" - { fprintf (stderr, "%d", (yyvaluep->integer)); }; -#line 1075 "parse-gram.c" - break; - case 8: /* "\"%destructor {...}\"" */ -#line 167 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1080 "parse-gram.c" - break; - case 9: /* "\"%printer {...}\"" */ -#line 171 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1085 "parse-gram.c" - break; - case 10: /* "\"%union {...}\"" */ -#line 172 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1090 "parse-gram.c" - break; - case 26: /* "\"%initial-action {...}\"" */ -#line 168 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1095 "parse-gram.c" - break; - case 27: /* "\"%lex-param {...}\"" */ -#line 169 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1100 "parse-gram.c" - break; - case 34: /* "\"%parse-param {...}\"" */ -#line 170 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1105 "parse-gram.c" - break; - case 41: /* "\"type\"" */ -#line 176 "parse-gram.y" - { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; -#line 1110 "parse-gram.c" - break; - case 45: /* "\"identifier\"" */ -#line 180 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -#line 1115 "parse-gram.c" - break; - case 46: /* "\"identifier:\"" */ -#line 182 "parse-gram.y" - { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; -#line 1120 "parse-gram.c" - break; - case 48: /* "\"%{...%}\"" */ -#line 174 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1125 "parse-gram.c" - break; - case 49: /* "\"epilogue\"" */ -#line 174 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1130 "parse-gram.c" - break; - case 50: /* "\"{...}\"" */ -#line 173 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1135 "parse-gram.c" - break; - case 71: /* "symbol" */ -#line 180 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -#line 1140 "parse-gram.c" - break; - case 72: /* "action" */ -#line 173 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1145 "parse-gram.c" - break; - case 73: /* "string_as_id" */ -#line 180 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -#line 1150 "parse-gram.c" - break; - case 74: /* "string_content" */ -#line 165 "parse-gram.y" - { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); }; -#line 1155 "parse-gram.c" - break; - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) #else @@ -1176,9 +1411,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) YYLTYPE *yylocationp; #endif { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - (void) yylocationp; + YYUSE (yyvaluep); + YYUSE (yylocationp); if (!yymsg) yymsg = "Deleting"; @@ -1188,7 +1422,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) { default: - break; + break; } } @@ -1196,13 +1430,13 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); -# else +#else int yyparse (); -# endif +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); @@ -1219,20 +1453,24 @@ int yyparse (); `----------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () - ; + #endif #endif { @@ -1254,6 +1492,12 @@ YYLTYPE yylloc; int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif /* Three stacks and their tools: `yyss': related to states, @@ -1264,9 +1508,9 @@ YYLTYPE yylloc; to reallocate them elsewhere. */ /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; @@ -1277,10 +1521,10 @@ YYLTYPE yylloc; YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; - /* The locations where the error started and ended. */ + /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2]; -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; @@ -1289,9 +1533,9 @@ YYLTYPE yylloc; YYSTYPE yyval; YYLTYPE yyloc; - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1315,8 +1559,8 @@ YYLTYPE yylloc; #endif - /* User initialization code. */ -#line 69 "parse-gram.y" + /* User initialization code. */ +#line 84 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default location is needed. */ @@ -1324,8 +1568,8 @@ YYLTYPE yylloc; yylloc.start.line = yylloc.end.line = 1; yylloc.start.column = yylloc.end.column = 0; } -/* Line 930 of yacc.c. */ -#line 1329 "parse-gram.c" +/* Line 1078 of yacc.c. */ +#line 1573 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -1334,8 +1578,7 @@ YYLTYPE yylloc; `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -1348,11 +1591,11 @@ YYLTYPE yylloc; #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the @@ -1380,7 +1623,7 @@ YYLTYPE yylloc; yystacksize = YYMAXDEPTH; { - short int *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) @@ -1415,12 +1658,10 @@ YYLTYPE yylloc; `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ -/* yyresume: */ + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; @@ -1462,22 +1703,21 @@ yybackup: if (yyn == YYFINAL) YYACCEPT; - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - *++yylsp = yylloc; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; goto yynewstate; @@ -1508,196 +1748,206 @@ yyreduce: GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; - /* Default location. */ - YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen); + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 6: -#line 203 "parse-gram.y" - { prologue_augment ((yyvsp[0].chars), (yylsp[0])); } +#line 217 "parse-gram.y" + { prologue_augment ((yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); } break; case 7: -#line 204 "parse-gram.y" +#line 218 "parse-gram.y" { debug_flag = true; } break; case 8: -#line 205 "parse-gram.y" - { muscle_insert ((yyvsp[-1].chars), (yyvsp[0].chars)); } +#line 220 "parse-gram.y" + { + static char one[] = "1"; + muscle_insert ((yyvsp[(2) - (2)].chars), one); + } break; case 9: -#line 206 "parse-gram.y" - { defines_flag = true; } +#line 224 "parse-gram.y" + { muscle_insert ((yyvsp[(2) - (3)].chars), (yyvsp[(3) - (3)].chars)); } break; case 10: -#line 207 "parse-gram.y" - { error_verbose = true; } +#line 225 "parse-gram.y" + { defines_flag = true; } break; case 11: -#line 208 "parse-gram.y" - { expected_sr_conflicts = (yyvsp[0].integer); } +#line 226 "parse-gram.y" + { error_verbose = true; } break; case 12: -#line 209 "parse-gram.y" - { expected_rr_conflicts = (yyvsp[0].integer); } +#line 227 "parse-gram.y" + { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: -#line 210 "parse-gram.y" - { spec_file_prefix = (yyvsp[0].chars); } +#line 228 "parse-gram.y" + { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: -#line 212 "parse-gram.y" - { - nondeterministic_parser = true; - glr_parser = true; - } +#line 229 "parse-gram.y" + { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 15: -#line 217 "parse-gram.y" +#line 231 "parse-gram.y" { - muscle_code_grow ("initial_action", (yyvsp[0].chars), (yylsp[0])); - } + nondeterministic_parser = true; + glr_parser = true; + } break; case 16: -#line 220 "parse-gram.y" - { add_param ("lex_param", (yyvsp[0].chars), (yylsp[0])); } +#line 236 "parse-gram.y" + { + muscle_code_grow ("initial_action", (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); + } break; case 17: -#line 221 "parse-gram.y" - { locations_flag = true; } +#line 239 "parse-gram.y" + { add_param ("lex_param", (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); } break; case 18: -#line 222 "parse-gram.y" - { spec_name_prefix = (yyvsp[0].chars); } +#line 240 "parse-gram.y" + { locations_flag = true; } break; case 19: -#line 223 "parse-gram.y" - { no_lines_flag = true; } +#line 241 "parse-gram.y" + { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 20: -#line 224 "parse-gram.y" - { nondeterministic_parser = true; } +#line 242 "parse-gram.y" + { no_lines_flag = true; } break; case 21: -#line 225 "parse-gram.y" - { spec_outfile = (yyvsp[0].chars); } +#line 243 "parse-gram.y" + { nondeterministic_parser = true; } break; case 22: -#line 226 "parse-gram.y" - { add_param ("parse_param", (yyvsp[0].chars), (yylsp[0])); } +#line 244 "parse-gram.y" + { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 23: -#line 227 "parse-gram.y" - { pure_parser = true; } +#line 245 "parse-gram.y" + { add_param ("parse_param", (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); } break; case 24: -#line 228 "parse-gram.y" - { skeleton = (yyvsp[0].chars); } +#line 246 "parse-gram.y" + { pure_parser = true; } break; case 25: -#line 229 "parse-gram.y" - { token_table_flag = true; } +#line 247 "parse-gram.y" + { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 26: -#line 230 "parse-gram.y" - { report_flag = report_states; } +#line 248 "parse-gram.y" + { skeleton = (yyvsp[(2) - (2)].chars); } break; case 27: -#line 231 "parse-gram.y" +#line 249 "parse-gram.y" + { token_table_flag = true; } + break; + + case 28: +#line 250 "parse-gram.y" + { report_flag = report_states; } + break; + + case 29: +#line 251 "parse-gram.y" { yacc_flag = true; } break; - case 31: -#line 239 "parse-gram.y" - { - grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0])); - } - break; - - case 32: -#line 243 "parse-gram.y" - { - typed = true; - MUSCLE_INSERT_INT ("stype_line", (yylsp[0]).start.line); - muscle_insert ("stype", (yyvsp[0].chars)); - } - break; - case 33: -#line 249 "parse-gram.y" +#line 259 "parse-gram.y" { - symbol_list *list; - for (list = (yyvsp[0].list); list; list = list->next) - symbol_destructor_set (list->sym, (yyvsp[-1].chars), (yylsp[-1])); - symbol_list_free ((yyvsp[0].list)); + grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } break; case 34: -#line 256 "parse-gram.y" +#line 263 "parse-gram.y" { - symbol_list *list; - for (list = (yyvsp[0].list); list; list = list->next) - symbol_printer_set (list->sym, (yyvsp[-1].chars), list->location); - symbol_list_free ((yyvsp[0].list)); + char const *body = (yyvsp[(1) - (1)].chars); + + if (typed) + { + /* Concatenate the union bodies, turning the first one's + trailing '}' into '\n', and omitting the second one's '{'. */ + char *code = muscle_find ("stype"); + code[strlen (code) - 1] = '\n'; + body++; + } + + typed = true; + muscle_code_grow ("stype", body, (yylsp[(1) - (1)])); } break; case 35: -#line 263 "parse-gram.y" +#line 279 "parse-gram.y" + { + symbol_list *list; + for (list = (yyvsp[(2) - (2)].list); list; list = list->next) + symbol_destructor_set (list->sym, (yyvsp[(1) - (2)].chars), (yylsp[(1) - (2)])); + symbol_list_free ((yyvsp[(2) - (2)].list)); + } + break; + + case 36: +#line 286 "parse-gram.y" + { + symbol_list *list; + for (list = (yyvsp[(2) - (2)].list); list; list = list->next) + symbol_printer_set (list->sym, (yyvsp[(1) - (2)].chars), (yylsp[(1) - (2)])); + symbol_list_free ((yyvsp[(2) - (2)].list)); + } + break; + + case 37: +#line 293 "parse-gram.y" { default_prec = true; } break; - case 36: -#line 267 "parse-gram.y" + case 38: +#line 297 "parse-gram.y" { default_prec = false; } break; - case 37: -#line 273 "parse-gram.y" + case 39: +#line 303 "parse-gram.y" { current_class = nterm_sym; } break; - case 38: -#line 274 "parse-gram.y" - { - current_class = unknown_sym; - current_type = NULL; - } - break; - - case 39: -#line 278 "parse-gram.y" - { current_class = token_sym; } - break; - case 40: -#line 279 "parse-gram.y" +#line 304 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -1705,215 +1955,213 @@ yyreduce: break; case 41: -#line 284 "parse-gram.y" - { - symbol_list *list; - for (list = (yyvsp[0].list); list; list = list->next) - symbol_type_set (list->sym, (yyvsp[-1].uniqstr), (yylsp[-1])); - symbol_list_free ((yyvsp[0].list)); - } +#line 308 "parse-gram.y" + { current_class = token_sym; } break; case 42: -#line 294 "parse-gram.y" +#line 309 "parse-gram.y" { - symbol_list *list; - ++current_prec; - for (list = (yyvsp[0].list); list; list = list->next) - { - symbol_type_set (list->sym, current_type, (yylsp[-1])); - symbol_precedence_set (list->sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2])); - } - symbol_list_free ((yyvsp[0].list)); + current_class = unknown_sym; current_type = NULL; } break; case 43: -#line 308 "parse-gram.y" - { (yyval.assoc) = left_assoc; } +#line 314 "parse-gram.y" + { + symbol_list *list; + for (list = (yyvsp[(3) - (3)].list); list; list = list->next) + symbol_type_set (list->sym, (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)])); + symbol_list_free ((yyvsp[(3) - (3)].list)); + } break; case 44: -#line 309 "parse-gram.y" - { (yyval.assoc) = right_assoc; } +#line 324 "parse-gram.y" + { + symbol_list *list; + ++current_prec; + for (list = (yyvsp[(3) - (3)].list); list; list = list->next) + { + symbol_type_set (list->sym, current_type, (yylsp[(2) - (3)])); + symbol_precedence_set (list->sym, current_prec, (yyvsp[(1) - (3)].assoc), (yylsp[(1) - (3)])); + } + symbol_list_free ((yyvsp[(3) - (3)].list)); + current_type = NULL; + } break; case 45: -#line 310 "parse-gram.y" - { (yyval.assoc) = non_assoc; } +#line 338 "parse-gram.y" + { (yyval.assoc) = left_assoc; } break; case 46: -#line 314 "parse-gram.y" - { current_type = NULL; } +#line 339 "parse-gram.y" + { (yyval.assoc) = right_assoc; } break; case 47: -#line 315 "parse-gram.y" - { current_type = (yyvsp[0].uniqstr); } +#line 340 "parse-gram.y" + { (yyval.assoc) = non_assoc; } break; case 48: -#line 321 "parse-gram.y" - { (yyval.list) = symbol_list_new ((yyvsp[0].symbol), (yylsp[0])); } +#line 344 "parse-gram.y" + { current_type = NULL; } break; case 49: -#line 322 "parse-gram.y" - { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), (yyvsp[0].symbol), (yylsp[0])); } +#line 345 "parse-gram.y" + { current_type = (yyvsp[(1) - (1)].uniqstr); } break; case 50: -#line 328 "parse-gram.y" - { - current_type = (yyvsp[0].uniqstr); - } +#line 351 "parse-gram.y" + { (yyval.list) = symbol_list_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 51: -#line 332 "parse-gram.y" - { - symbol_class_set ((yyvsp[0].symbol), current_class, (yylsp[0])); - symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0])); - } +#line 352 "parse-gram.y" + { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } break; case 52: -#line 337 "parse-gram.y" +#line 358 "parse-gram.y" { - symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1])); - symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1])); - symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); - } + current_type = (yyvsp[(1) - (1)].uniqstr); + } break; case 53: -#line 343 "parse-gram.y" +#line 362 "parse-gram.y" { - symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1])); - symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1])); - symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc)); - } + symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); + symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)])); + } break; case 54: -#line 349 "parse-gram.y" +#line 367 "parse-gram.y" { - symbol_class_set ((yyvsp[-2].symbol), current_class, (yylsp[-2])); - symbol_type_set ((yyvsp[-2].symbol), current_type, (yylsp[-2])); - symbol_user_token_number_set ((yyvsp[-2].symbol), (yyvsp[-1].integer), (yylsp[-1])); - symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc)); + symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); + symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); + symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); } break; - case 60: -#line 378 "parse-gram.y" + case 55: +#line 373 "parse-gram.y" { - if (yacc_flag) - complain_at ((yyloc), _("POSIX forbids declarations in the grammar")); + symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); + symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); + symbol_make_alias ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].symbol), (yyloc)); } break; - case 61: -#line 383 "parse-gram.y" + case 56: +#line 379 "parse-gram.y" + { + symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); + symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)])); + symbol_user_token_number_set ((yyvsp[(1) - (3)].symbol), (yyvsp[(2) - (3)].integer), (yylsp[(2) - (3)])); + symbol_make_alias ((yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol), (yyloc)); + } + break; + + case 63: +#line 409 "parse-gram.y" { yyerrok; } break; - case 62: -#line 389 "parse-gram.y" - { current_lhs = (yyvsp[0].symbol); current_lhs_location = (yylsp[0]); } - break; - case 64: -#line 393 "parse-gram.y" - { grammar_rule_end ((yylsp[0])); } +#line 415 "parse-gram.y" + { current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); } break; - case 65: -#line 394 "parse-gram.y" - { grammar_rule_end ((yylsp[0])); } + case 66: +#line 419 "parse-gram.y" + { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 67: -#line 400 "parse-gram.y" - { grammar_rule_begin (current_lhs, current_lhs_location); } - break; - - case 68: -#line 402 "parse-gram.y" - { grammar_current_rule_symbol_append ((yyvsp[0].symbol), (yylsp[0])); } +#line 420 "parse-gram.y" + { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 69: -#line 404 "parse-gram.y" - { grammar_current_rule_action_append ((yyvsp[0].chars), (yylsp[0])); } +#line 426 "parse-gram.y" + { grammar_current_rule_begin (current_lhs, current_lhs_location); } break; case 70: -#line 406 "parse-gram.y" - { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); } - break; - - case 71: -#line 408 "parse-gram.y" - { grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); } +#line 428 "parse-gram.y" + { grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } break; case 72: -#line 410 "parse-gram.y" - { grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); } +#line 431 "parse-gram.y" + { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 73: -#line 414 "parse-gram.y" - { (yyval.symbol) = (yyvsp[0].symbol); } +#line 433 "parse-gram.y" + { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 74: -#line 415 "parse-gram.y" - { (yyval.symbol) = (yyvsp[0].symbol); } +#line 435 "parse-gram.y" + { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 75: -#line 420 "parse-gram.y" - { (yyval.chars) = (yyvsp[0].chars); } +#line 439 "parse-gram.y" + { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 76: -#line 426 "parse-gram.y" - { - (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].chars)), (yylsp[0])); - symbol_class_set ((yyval.symbol), token_sym, (yylsp[0])); - } +#line 440 "parse-gram.y" + { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 77: -#line 435 "parse-gram.y" - { (yyval.chars) = (yyvsp[0].chars); } +#line 456 "parse-gram.y" + { grammar_current_rule_action_append (last_string, last_braced_code_loc); } break; case 79: -#line 442 "parse-gram.y" +#line 463 "parse-gram.y" { - muscle_code_grow ("epilogue", (yyvsp[0].chars), (yylsp[0])); + (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); + symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); + } + break; + + case 80: +#line 472 "parse-gram.y" + { (yyval.chars) = (yyvsp[(1) - (1)].chars); } + break; + + case 82: +#line 479 "parse-gram.y" + { + muscle_code_grow ("epilogue", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); scanner_last_string_free (); } break; +/* Line 1267 of yacc.c. */ +#line 2159 "parse-gram.c" default: break; } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); -/* Line 1126 of yacc.c. */ -#line 1912 "parse-gram.c" - - yyvsp -= yylen; - yyssp -= yylen; - yylsp -= yylen; - + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; @@ -1942,110 +2190,41 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - char *yymsg = 0; -# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - - if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yymsg; - int yyi = 0; - while ((*yyp = *yyf)) - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - yyerror (yymsg); +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - } - else - { - yyerror (YY_("syntax error")); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) goto yyexhaustedlab; - } - } - else -#endif /* YYERROR_VERBOSE */ - yyerror (YY_("syntax error")); + } + } +#endif } yyerror_range[0] = yylloc; @@ -2056,14 +2235,15 @@ yyerrlab: error, discard it. */ if (yychar <= YYEOF) - { + { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; - } + } else { - yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc); yychar = YYEMPTY; } } @@ -2081,13 +2261,15 @@ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (0) + if (/*CONSTCOND*/ 0) goto yyerrorlab; yyerror_range[0] = yylsp[1-yylen]; - yylsp -= yylen; - yyvsp -= yylen; - yyssp -= yylen; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -2117,8 +2299,9 @@ yyerrlab1: YYABORT; yyerror_range[0] = *yylsp; - yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); - YYPOPSTACK; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } @@ -2130,11 +2313,11 @@ yyerrlab1: yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); + the look-ahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; - /* Shift the error token. */ + /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; @@ -2169,21 +2352,30 @@ yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp); - YYPOPSTACK; + YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif - return yyresult; +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 448 "parse-gram.y" +#line 485 "parse-gram.y" @@ -2268,6 +2460,17 @@ add_param (char const *type, char *decl, location loc) scanner_last_string_free (); } +static void +version_check (location const *loc, char const *version) +{ + if (strverscmp (version, PACKAGE_VERSION) > 0) + { + complain_at (*loc, "require bison %s, but have %s", + version, PACKAGE_VERSION); + exit (63); + } +} + static void gram_error (location const *loc, char const *msg) { diff --git a/src/bin/bison/src/parse-gram.h b/src/bin/bison/src/parse-gram.h index 876e749067..2d37fc10f0 100644 --- a/src/bin/bison/src/parse-gram.h +++ b/src/bin/bison/src/parse-gram.h @@ -1,7 +1,9 @@ -/* A Bison parser, made by GNU Bison 2.1. */ +/* A Bison parser, made by GNU Bison 2.2a. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,10 +20,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE @@ -63,21 +73,22 @@ PERCENT_OUTPUT = 288, PERCENT_PARSE_PARAM = 289, PERCENT_PURE_PARSER = 290, - PERCENT_SKELETON = 291, - PERCENT_START = 292, - PERCENT_TOKEN_TABLE = 293, - PERCENT_VERBOSE = 294, - PERCENT_YACC = 295, - TYPE = 296, - EQUAL = 297, - SEMICOLON = 298, - PIPE = 299, - ID = 300, - ID_COLON = 301, - PERCENT_PERCENT = 302, - PROLOGUE = 303, - EPILOGUE = 304, - BRACED_CODE = 305 + PERCENT_REQUIRE = 291, + PERCENT_SKELETON = 292, + PERCENT_START = 293, + PERCENT_TOKEN_TABLE = 294, + PERCENT_VERBOSE = 295, + PERCENT_YACC = 296, + TYPE = 297, + EQUAL = 298, + SEMICOLON = 299, + PIPE = 300, + ID = 301, + ID_COLON = 302, + PERCENT_PERCENT = 303, + PROLOGUE = 304, + EPILOGUE = 305, + BRACED_CODE = 306 }; #endif /* Tokens. */ @@ -115,37 +126,40 @@ #define PERCENT_OUTPUT 288 #define PERCENT_PARSE_PARAM 289 #define PERCENT_PURE_PARSER 290 -#define PERCENT_SKELETON 291 -#define PERCENT_START 292 -#define PERCENT_TOKEN_TABLE 293 -#define PERCENT_VERBOSE 294 -#define PERCENT_YACC 295 -#define TYPE 296 -#define EQUAL 297 -#define SEMICOLON 298 -#define PIPE 299 -#define ID 300 -#define ID_COLON 301 -#define PERCENT_PERCENT 302 -#define PROLOGUE 303 -#define EPILOGUE 304 -#define BRACED_CODE 305 +#define PERCENT_REQUIRE 291 +#define PERCENT_SKELETON 292 +#define PERCENT_START 293 +#define PERCENT_TOKEN_TABLE 294 +#define PERCENT_VERBOSE 295 +#define PERCENT_YACC 296 +#define TYPE 297 +#define EQUAL 298 +#define SEMICOLON 299 +#define PIPE 300 +#define ID 301 +#define ID_COLON 302 +#define PERCENT_PERCENT 303 +#define PROLOGUE 304 +#define EPILOGUE 305 +#define BRACED_CODE 306 -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 79 "parse-gram.y" -typedef union YYSTYPE { +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 94 "parse-gram.y" +{ symbol *symbol; symbol_list *list; int integer; char *chars; assoc assoc; uniqstr uniqstr; -} YYSTYPE; -/* Line 1447 of yacc.c. */ -#line 149 "parse-gram.h" +} +/* Line 1529 of yacc.c. */ +#line 162 "parse-gram.h" + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -153,7 +167,7 @@ typedef union YYSTYPE { -#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; @@ -167,5 +181,3 @@ typedef struct YYLTYPE #endif - - diff --git a/src/bin/bison/src/parse-gram.y b/src/bin/bison/src/parse-gram.y index db15562dff..e189e14346 100644 --- a/src/bin/bison/src/parse-gram.y +++ b/src/bin/bison/src/parse-gram.y @@ -1,6 +1,6 @@ %{/* Bison Grammar Parser -*- C -*- - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,6 +20,7 @@ 02110-1301 USA */ +#include #include "system.h" #include "complain.h" @@ -28,32 +29,46 @@ #include "getargs.h" #include "gram.h" #include "muscle_tab.h" -#include "output.h" #include "quotearg.h" #include "reader.h" #include "symlist.h" +#include "strverscmp.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); #define YY_LOCATION_PRINT(File, Loc) \ - location_print (File, Loc) + location_print (File, Loc) + +static void version_check (location const *loc, char const *version); /* Request detailed syntax error messages, and pass them to GRAM_ERROR. FIXME: depends on the undocumented availability of YYLLOC. */ #undef yyerror #define yyerror(Msg) \ - gram_error (&yylloc, Msg) + gram_error (&yylloc, Msg) static void gram_error (location const *, char const *); static void add_param (char const *, char *, location); static symbol_class current_class = unknown_sym; static uniqstr current_type = 0; -symbol *current_lhs; -location current_lhs_location; -assoc current_assoc; +static symbol *current_lhs; +static location current_lhs_location; static int current_prec = 0; + +#ifdef UINT_FAST8_MAX +# define YYTYPE_UINT8 uint_fast8_t +#endif +#ifdef INT_FAST8_MAX +# define YYTYPE_INT8 int_fast8_t +#endif +#ifdef UINT_FAST16_MAX +# define YYTYPE_UINT16 uint_fast16_t +#endif +#ifdef INT_FAST16_MAX +# define YYTYPE_INT16 int_fast16_t +#endif %} %debug @@ -129,10 +144,11 @@ static int current_prec = 0; PERCENT_NO_DEFAULT_PREC "%no-default-prec" PERCENT_NO_LINES "%no-lines" PERCENT_NONDETERMINISTIC_PARSER - "%nondeterministic-parser" + "%nondeterministic-parser" PERCENT_OUTPUT "%output" PERCENT_PARSE_PARAM "%parse-param {...}" PERCENT_PURE_PARSER "%pure-parser" + PERCENT_REQUIRE "%require" PERCENT_SKELETON "%skeleton" PERCENT_START "%start" PERCENT_TOKEN_TABLE "%token-table" @@ -159,10 +175,9 @@ static int current_prec = 0; "%parse-param {...}" "%printer {...}" "%union {...}" - BRACED_CODE action PROLOGUE EPILOGUE %printer { fprintf (stderr, "\"%s\"", $$); } - STRING string_content + STRING string_content %printer { fprintf (stderr, "{\n%s\n}", $$); } "%destructor {...}" "%initial-action {...}" @@ -170,7 +185,6 @@ static int current_prec = 0; "%parse-param {...}" "%printer {...}" "%union {...}" - BRACED_CODE action PROLOGUE EPILOGUE %type TYPE %printer { fprintf (stderr, "<%s>", $$); } TYPE @@ -202,6 +216,11 @@ declaration: grammar_declaration | PROLOGUE { prologue_augment ($1, @1); } | "%debug" { debug_flag = true; } +| "%define" string_content + { + static char one[] = "1"; + muscle_insert ($2, one); + } | "%define" string_content string_content { muscle_insert ($2, $3); } | "%defines" { defines_flag = true; } | "%error-verbose" { error_verbose = true; } @@ -209,14 +228,14 @@ declaration: | "%expect-rr" INT { expected_rr_conflicts = $2; } | "%file-prefix" "=" string_content { spec_file_prefix = $3; } | "%glr-parser" - { - nondeterministic_parser = true; - glr_parser = true; - } + { + nondeterministic_parser = true; + glr_parser = true; + } | "%initial-action {...}" - { - muscle_code_grow ("initial_action", $1, @1); - } + { + muscle_code_grow ("initial_action", $1, @1); + } | "%lex-param {...}" { add_param ("lex_param", $1, @1); } | "%locations" { locations_flag = true; } | "%name-prefix" "=" string_content { spec_name_prefix = $3; } @@ -225,6 +244,7 @@ declaration: | "%output" "=" string_content { spec_outfile = $3; } | "%parse-param {...}" { add_param ("parse_param", $1, @1); } | "%pure-parser" { pure_parser = true; } +| "%require" string_content { version_check (&@2, $2); } | "%skeleton" string_content { skeleton = $2; } | "%token-table" { token_table_flag = true; } | "%verbose" { report_flag = report_states; } @@ -241,9 +261,19 @@ grammar_declaration: } | "%union {...}" { + char const *body = $1; + + if (typed) + { + /* Concatenate the union bodies, turning the first one's + trailing '}' into '\n', and omitting the second one's '{'. */ + char *code = muscle_find ("stype"); + code[strlen (code) - 1] = '\n'; + body++; + } + typed = true; - MUSCLE_INSERT_INT ("stype_line", @1.start.line); - muscle_insert ("stype", $1); + muscle_code_grow ("stype", body, @1); } | "%destructor {...}" symbols.1 { @@ -256,7 +286,7 @@ grammar_declaration: { symbol_list *list; for (list = $2; list; list = list->next) - symbol_printer_set (list->sym, $1, list->location); + symbol_printer_set (list->sym, $1, @1); symbol_list_free ($2); } | "%default-prec" @@ -330,24 +360,24 @@ symbol_def: } | ID { - symbol_class_set ($1, current_class, @1); + symbol_class_set ($1, current_class, @1, true); symbol_type_set ($1, current_type, @1); } | ID INT { - symbol_class_set ($1, current_class, @1); + symbol_class_set ($1, current_class, @1, true); symbol_type_set ($1, current_type, @1); symbol_user_token_number_set ($1, $2, @2); } | ID string_as_id { - symbol_class_set ($1, current_class, @1); + symbol_class_set ($1, current_class, @1, true); symbol_type_set ($1, current_type, @1); symbol_make_alias ($1, $2, @$); } | ID INT string_as_id { - symbol_class_set ($1, current_class, @1); + symbol_class_set ($1, current_class, @1, true); symbol_type_set ($1, current_type, @1); symbol_user_token_number_set ($1, $2, @2); symbol_make_alias ($1, $3, @$); @@ -375,10 +405,6 @@ grammar: rules_or_grammar_declaration: rules | grammar_declaration ";" - { - if (yacc_flag) - complain_at (@$, _("POSIX forbids declarations in the grammar")); - } | error ";" { yyerrok; @@ -390,18 +416,17 @@ rules: ; rhses.1: - rhs { grammar_rule_end (@1); } -| rhses.1 "|" rhs { grammar_rule_end (@3); } + rhs { grammar_current_rule_end (@1); } +| rhses.1 "|" rhs { grammar_current_rule_end (@3); } | rhses.1 ";" ; rhs: /* Nothing. */ - { grammar_rule_begin (current_lhs, current_lhs_location); } + { grammar_current_rule_begin (current_lhs, current_lhs_location); } | rhs symbol { grammar_current_rule_symbol_append ($2, @2); } | rhs action - { grammar_current_rule_action_append ($2, @2); } | rhs "%prec" symbol { grammar_current_rule_prec_set ($3, @3); } | rhs "%dprec" INT @@ -415,9 +440,21 @@ symbol: | string_as_id { $$ = $1; } ; +/* Handle the semantics of an action specially, with a mid-rule + action, so that grammar_current_rule_action_append is invoked + immediately after the braced code is read by the scanner. + + This implementation relies on the LALR(1) parsing algorithm. + If grammar_current_rule_action_append were executed in a normal + action for this rule, then when the input grammar contains two + successive actions, the scanner would have to read both actions + before reducing this rule. That wouldn't work, since the scanner + relies on all preceding input actions being processed by + grammar_current_rule_action_append before it scans the next + action. */ action: + { grammar_current_rule_action_append (last_string, last_braced_code_loc); } BRACED_CODE - { $$ = $1; } ; /* A string used as an ID: quote it. */ @@ -425,7 +462,7 @@ string_as_id: STRING { $$ = symbol_get (quotearg_style (c_quoting_style, $1), @1); - symbol_class_set ($$, token_sym, @1); + symbol_class_set ($$, token_sym, @1, false); } ; @@ -529,6 +566,17 @@ add_param (char const *type, char *decl, location loc) scanner_last_string_free (); } +static void +version_check (location const *loc, char const *version) +{ + if (strverscmp (version, PACKAGE_VERSION) > 0) + { + complain_at (*loc, "require bison %s, but have %s", + version, PACKAGE_VERSION); + exit (63); + } +} + static void gram_error (location const *loc, char const *msg) { diff --git a/src/bin/bison/src/print.c b/src/bin/bison/src/print.c index 533e3ca1d7..cb1600c9fa 100644 --- a/src/bin/bison/src/print.c +++ b/src/bin/bison/src/print.c @@ -1,6 +1,6 @@ /* Print information on generated parser, for bison, - Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004 + Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include diff --git a/src/bin/bison/src/print_graph.c b/src/bin/bison/src/print_graph.c index dc0f8306c7..9580f3f145 100644 --- a/src/bin/bison/src/print_graph.c +++ b/src/bin/bison/src/print_graph.c @@ -19,6 +19,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include diff --git a/src/bin/bison/src/reader.c b/src/bin/bison/src/reader.c index 6b247b7f2d..d07ce5caa9 100644 --- a/src/bin/bison/src/reader.c +++ b/src/bin/bison/src/reader.c @@ -1,7 +1,7 @@ /* Input parser for Bison Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003, - 2005 Free Software Foundation, Inc. + 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,6 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include @@ -30,16 +31,17 @@ #include "getargs.h" #include "gram.h" #include "muscle_tab.h" -#include "output.h" #include "reader.h" #include "symlist.h" #include "symtab.h" +static void check_and_convert_grammar (void); + static symbol_list *grammar = NULL; static bool start_flag = false; merger_list *merge_functions; -/* Has %union been seen? */ +/* Was %union seen? */ bool typed = false; /* Should rules have a default precedence? */ @@ -103,7 +105,7 @@ get_merge_function (uniqstr name, uniqstr type, location loc) type = uniqstr_new (""); head.next = merge_functions; - for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1) + for (syms = &head, n = 1; syms->next; syms = syms->next, n += 1) if (UNIQSTR_EQ (name, syms->next->name)) break; if (syms->next == NULL) @@ -127,11 +129,8 @@ get_merge_function (uniqstr name, uniqstr type, location loc) void free_merger_functions (void) { - merger_list *L0; - if (! glr_parser) - return; - L0 = merge_functions; - while (L0 != NULL) + merger_list *L0 = merge_functions; + while (L0) { merger_list *L1 = L0->next; free (L0); @@ -149,20 +148,13 @@ free_merger_functions (void) | | | All actions are copied out, labelled by the rule number they apply | | to. | -| | -| Bison used to allow some %directives in the rules sections, but | -| this is no longer consider appropriate: (i) the documented grammar | -| doesn't claim it, (ii), it would promote bad style, (iii), error | -| recovery for %directives consists in skipping the junk until a `%' | -| is seen and helrp synchronizing. This scheme is definitely wrong | -| in the rules section. | `-------------------------------------------------------------------*/ /* The (currently) last symbol of GRAMMAR. */ static symbol_list *grammar_end = NULL; /* Append SYM to the grammar. */ -void +static void grammar_symbol_append (symbol *sym, location loc) { symbol_list *p = symbol_list_new (sym, loc); @@ -173,6 +165,11 @@ grammar_symbol_append (symbol *sym, location loc) grammar = p; grammar_end = p; + + /* A null SYM stands for an end of rule; it is not an actual + part of it. */ + if (sym) + ++nritems; } /* The rule currently being defined, and the previous rule. @@ -187,7 +184,7 @@ static symbol_list *previous_rule_end = NULL; `----------------------------------------------*/ void -grammar_rule_begin (symbol *lhs, location loc) +grammar_current_rule_begin (symbol *lhs, location loc) { if (!start_flag) { @@ -198,14 +195,11 @@ grammar_rule_begin (symbol *lhs, location loc) /* Start a new rule and record its lhs. */ ++nrules; - ++nritems; - previous_rule_end = grammar_end; grammar_symbol_append (lhs, loc); current_rule = grammar_end; /* Mark the rule's lhs as a nonterminal if not already so. */ - if (lhs->class == unknown_sym) { lhs->class = nterm_sym; @@ -216,39 +210,71 @@ grammar_rule_begin (symbol *lhs, location loc) complain_at (loc, _("rule given for %s, which is a token"), lhs->tag); } -/* Check that the last rule (CURRENT_RULE) is properly defined. For - instance, there should be no type clash on the default action. */ + +/*----------------------------------------------------------------------. +| A symbol should be used if it has a destructor, or if it is a | +| mid-rule symbol (i.e., the generated LHS replacing a mid-rule | +| action) that was assigned to, as in "exp: { $$ = 1; } { $$ = $1; }". | +`----------------------------------------------------------------------*/ + +static bool +symbol_should_be_used (symbol_list const *s) +{ + return (s->sym->destructor + || (s->midrule && s->midrule->used)); +} + +/*----------------------------------------------------------------. +| Check that the rule R is properly defined. For instance, there | +| should be no type clash on the default action. | +`----------------------------------------------------------------*/ static void -grammar_current_rule_check (void) +grammar_rule_check (const symbol_list *r) { - symbol *lhs = current_rule->sym; - char const *lhs_type = lhs->type_name; - symbol *first_rhs = current_rule->next->sym; + /* Type check. - /* If there is an action, then there is nothing we can do: the user - is allowed to shoot herself in the foot. */ - if (current_rule->action) - return; + If there is an action, then there is nothing we can do: the user + is allowed to shoot herself in the foot. - /* Don't worry about the default action if $$ is untyped, since $$'s + Don't worry about the default action if $$ is untyped, since $$'s value can't be used. */ - if (! lhs_type) - return; - - /* If $$ is being set in default way, report if any type mismatch. */ - if (first_rhs) + if (!r->action && r->sym->type_name) { - const char *rhs_type = first_rhs->type_name ? first_rhs->type_name : ""; - if (!UNIQSTR_EQ (lhs_type, rhs_type)) - warn_at (current_rule->location, - _("type clash on default action: <%s> != <%s>"), - lhs_type, rhs_type); + symbol *first_rhs = r->next->sym; + /* If $$ is being set in default way, report if any type mismatch. */ + if (first_rhs) + { + char const *lhs_type = r->sym->type_name; + const char *rhs_type = + first_rhs->type_name ? first_rhs->type_name : ""; + if (!UNIQSTR_EQ (lhs_type, rhs_type)) + warn_at (r->location, + _("type clash on default action: <%s> != <%s>"), + lhs_type, rhs_type); + } + /* Warn if there is no default for $$ but we need one. */ + else + warn_at (r->location, + _("empty rule for typed nonterminal, and no action")); } - /* Warn if there is no default for $$ but we need one. */ - else - warn_at (current_rule->location, - _("empty rule for typed nonterminal, and no action")); + + /* Check that symbol values that should be used are in fact used. */ + { + symbol_list const *l = r; + int n = 0; + for (; l && l->sym; l = l->next, ++n) + if (! (l->used + || !symbol_should_be_used (l) + /* The default action, $$ = $1, `uses' both. */ + || (!r->action && (n == 0 || n == 1)))) + { + if (n) + warn_at (r->location, _("unused value: $%d"), n); + else + warn_at (r->location, _("unset value: $$")); + } + } } @@ -257,12 +283,12 @@ grammar_current_rule_check (void) `-------------------------------------*/ void -grammar_rule_end (location loc) +grammar_current_rule_end (location loc) { /* Put an empty link in the list to mark the end of this rule */ grammar_symbol_append (NULL, grammar_end->location); current_rule->location = loc; - grammar_current_rule_check (); + grammar_rule_check (current_rule); } @@ -295,6 +321,10 @@ grammar_midrule_action (void) midrule->action = current_rule->action; midrule->action_location = dummy_location; current_rule->action = NULL; + /* If $$ was used in the action, the LHS of the enclosing rule was + incorrectly flagged as used. */ + midrule->used = current_rule->used; + current_rule->used = false; if (previous_rule_end) previous_rule_end->next = midrule; @@ -302,14 +332,16 @@ grammar_midrule_action (void) grammar = midrule; /* End the dummy's rule. */ - previous_rule_end = symbol_list_new (NULL, dummy_location); - previous_rule_end->next = current_rule; + midrule->next = symbol_list_new (NULL, dummy_location); + grammar_rule_check (midrule); + midrule->next->next = current_rule; - midrule->next = previous_rule_end; + previous_rule_end = midrule->next; /* Insert the dummy nonterminal replacing the midrule action into - the current rule. */ + the current rule. Bind it to its dedicated rule. */ grammar_current_rule_symbol_append (dummy, dummy_location); + grammar_end->midrule = midrule; } /* Set the precedence symbol of the current rule to PRECSYM. */ @@ -358,18 +390,16 @@ grammar_current_rule_symbol_append (symbol *sym, location loc) { if (current_rule->action) grammar_midrule_action (); - ++nritems; grammar_symbol_append (sym, loc); } -/* Attach an ACTION to the current rule. If needed, move the previous - action as a mid-rule action. */ +/* Attach an ACTION to the current rule. */ void grammar_current_rule_action_append (const char *action, location loc) { - if (current_rule->action) - grammar_midrule_action (); + /* There's no need to invoke grammar_midrule_action here, since the + scanner already did it if necessary. */ current_rule->action = action; current_rule->action_location = loc; } @@ -387,7 +417,11 @@ packgram (void) rule_number ruleno = 0; symbol_list *p = grammar; - ritem = xnmalloc (nritems, sizeof *ritem); + ritem = xnmalloc (nritems + 1, sizeof *ritem); + + /* This sentinel is used by build_relations in gram.c. */ + *ritem++ = 0; + rules = xnmalloc (nrules, sizeof *rules); while (p) @@ -434,8 +468,7 @@ packgram (void) p = p->next; } - if (itemno != nritems) - abort (); + assert (itemno == nritems); if (trace_flag & trace_sets) ritem_print (stderr); @@ -474,20 +507,29 @@ reader (void) obstack_init (&pre_prologue_obstack); obstack_init (&post_prologue_obstack); - finput = xfopen (grammar_file, "r"); - gram_in = finput; + gram_in = xfopen (grammar_file, "r"); gram__flex_debug = trace_flag & trace_scan; gram_debug = trace_flag & trace_parse; scanner_initialize (); gram_parse (); - /* If something went wrong during the parsing, don't try to - continue. */ - if (complaint_issued) - return; + if (! complaint_issued) + check_and_convert_grammar (); - /* Grammar has been read. Do some checking */ + xfclose (gram_in); +} + + +/*-------------------------------------------------------------. +| Check the grammar that has just been read, and convert it to | +| internal form. | +`-------------------------------------------------------------*/ + +static void +check_and_convert_grammar (void) +{ + /* Grammar has been read. Do some checking. */ if (nrules == 0) fatal (_("no rules in the input grammar")); @@ -504,7 +546,7 @@ reader (void) endtoken->user_token_number = 0; } - /* Insert the initial rule, which line is that of the first rule + /* Insert the initial rule, whose line is that of the first rule (not that of the start symbol): accept: %start EOF. */ @@ -520,10 +562,7 @@ reader (void) grammar = p; } - if (! (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars)) - abort (); - - xfclose (finput); + assert (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars); /* Assign the symbols their symbol numbers. Write #defines for the token symbols into FDEFINES if requested. */ diff --git a/src/bin/bison/src/reader.h b/src/bin/bison/src/reader.h index c47a16ebfc..f110f70e70 100644 --- a/src/bin/bison/src/reader.h +++ b/src/bin/bison/src/reader.h @@ -1,6 +1,7 @@ /* Input parser for Bison - Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -38,6 +39,8 @@ typedef struct merger_list extern FILE *gram_in; extern int gram__flex_debug; extern boundary scanner_cursor; +extern char *last_string; +extern location last_braced_code_loc; extern int max_left_semantic_context; void scanner_initialize (void); void scanner_free (void); @@ -55,20 +58,18 @@ YY_DECL; /* From the parser. */ extern int gram_debug; int gram_parse (void); -char const *token_name (int); +char const *token_name (int type); /* From reader.c. */ void grammar_start_symbol_set (symbol *sym, location loc); void prologue_augment (const char *prologue, location loc); -void grammar_symbol_append (symbol *sym, location loc); -void grammar_rule_begin (symbol *lhs, location loc); -void grammar_rule_end (location loc); +void grammar_current_rule_begin (symbol *lhs, location loc); +void grammar_current_rule_end (location loc); void grammar_midrule_action (void); void grammar_current_rule_prec_set (symbol *precsym, location loc); void grammar_current_rule_dprec_set (int dprec, location loc); void grammar_current_rule_merge_set (uniqstr name, location loc); - void grammar_current_rule_symbol_append (symbol *sym, location loc); void grammar_current_rule_action_append (const char *action, location loc); extern symbol_list *current_rule; @@ -77,7 +78,10 @@ void free_merger_functions (void); extern merger_list *merge_functions; +/* Was %union seen? */ extern bool typed; + +/* Should rules have a default precedence? */ extern bool default_prec; #endif /* !READER_H_ */ diff --git a/src/bin/bison/src/reduce.c b/src/bin/bison/src/reduce.c index a6b9e62908..1bb40f01bf 100644 --- a/src/bin/bison/src/reduce.c +++ b/src/bin/bison/src/reduce.c @@ -1,7 +1,7 @@ /* Grammar reduction for Bison. - Copyright (C) 1988, 1989, 2000, 2001, 2002, 2003 Free Software - Foundation, Inc. + Copyright (C) 1988, 1989, 2000, 2001, 2002, 2003, 2005, 2006 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -27,6 +27,7 @@ /* Don't eliminate unreachable terminals: They may be used by the user's parser. */ +#include #include "system.h" #include @@ -425,7 +426,7 @@ reduce_grammar (void) useless_nonterminals (); inaccessable_symbols (); - reduced = (bool) (nuseless_nonterminals + nuseless_productions > 0); + reduced = (nuseless_nonterminals + nuseless_productions > 0); if (!reduced) return; diff --git a/src/bin/bison/src/relation.c b/src/bin/bison/src/relation.c index da62af8fb0..1d2b42dd9f 100644 --- a/src/bin/bison/src/relation.c +++ b/src/bin/bison/src/relation.c @@ -18,6 +18,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include diff --git a/src/bin/bison/src/scan-gram.c b/src/bin/bison/src/scan-gram.c index f15f19f036..04cf539de8 100644 --- a/src/bin/bison/src/scan-gram.c +++ b/src/bin/bison/src/scan-gram.c @@ -429,8 +429,8 @@ static void yy_fatal_error (yyconst char msg[] ); (yy_c_buf_p) = yy_cp; /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ -#define YY_NUM_RULES 106 -#define YY_END_OF_BUFFER 107 +#define YY_NUM_RULES 109 +#define YY_END_OF_BUFFER 110 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -438,58 +438,58 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[455] = +static yyconst flex_int16_t yy_accept[461] = { 0, - 0, 0, 0, 0, 65, 65, 0, 0, 83, 83, - 83, 83, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 107, 58, 2, 2, - 53, 58, 52, 1, 49, 58, 50, 50, 48, 58, - 46, 55, 47, 58, 104, 105, 100, 104, 101, 102, - 103, 64, 104, 62, 62, 87, 86, 104, 85, 84, - 60, 2, 1, 60, 59, 60, 67, 66, 104, 70, - 69, 68, 92, 2, 1, 92, 92, 89, 100, 104, - 88, 104, 104, 101, 93, 95, 104, 57, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 0, 0, 0, 0, 66, 66, 0, 0, 84, 84, + 84, 84, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 110, 59, 2, 2, + 54, 59, 53, 1, 50, 59, 51, 51, 49, 59, + 47, 56, 48, 59, 107, 108, 103, 107, 104, 105, + 106, 65, 107, 63, 63, 88, 87, 107, 86, 85, + 61, 2, 1, 61, 60, 61, 68, 67, 107, 71, + 70, 69, 93, 2, 1, 93, 93, 90, 100, 107, + 89, 107, 107, 101, 94, 96, 107, 58, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 45, 45, 45, 45, 45, 45, 54, 49, 4, 3, - 50, 0, 0, 0, 63, 0, 0, 65, 61, 83, - 83, 83, 83, 82, 80, 71, 82, 73, 74, 75, - 76, 77, 78, 82, 79, 82, 97, 0, 97, 0, - 94, 0, 90, 91, 0, 93, 96, 0, 98, 0, - 98, 99, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 3, 51, 56, 0, 0, 0, 0, 0, 0, 0, - 0, 71, 0, 0, 72, 0, 0, 0, 0, 0, + 46, 46, 46, 46, 46, 46, 55, 50, 4, 3, + 51, 0, 0, 0, 64, 0, 0, 66, 62, 84, + 84, 84, 84, 83, 81, 72, 83, 74, 75, 76, + 77, 78, 79, 83, 80, 83, 98, 0, 98, 0, + 95, 0, 91, 92, 0, 94, 97, 0, 99, 0, + 99, 102, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 3, 52, 57, 0, 0, 0, 0, 0, 0, + 0, 0, 72, 0, 0, 73, 0, 0, 0, 0, - 0, 0, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 0, 71, 0, 0, 0, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 20, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 32, 45, 45, 45, 45, 45, - 38, 45, 41, 45, 45, 44, 0, 0, 0, 45, - 7, 45, 45, 45, 12, 45, 45, 45, 45, 45, - 45, 45, 45, 23, 45, 45, 45, 45, 45, 29, + 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 0, 72, 0, + 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 20, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 32, 46, 46, 46, + 46, 46, 46, 39, 46, 42, 46, 46, 45, 0, + 0, 0, 46, 7, 46, 46, 46, 12, 46, 46, + 46, 46, 46, 46, 46, 46, 23, 46, 46, 46, - 45, 45, 45, 45, 35, 45, 37, 39, 42, 45, - 0, 0, 81, 6, 45, 9, 45, 45, 14, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 30, 45, 45, 45, 45, 45, 45, 0, 45, 10, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 33, 45, 45, 45, 43, - 0, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 26, 27, 45, 45, 45, 36, 45, - 0, 45, 45, 45, 15, 45, 45, 45, 45, 21, - 22, 45, 45, 45, 45, 45, 45, 0, 0, 45, + 46, 46, 29, 46, 46, 46, 46, 46, 36, 46, + 38, 40, 43, 46, 0, 0, 82, 6, 46, 9, + 46, 46, 14, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 30, 46, 46, 46, 46, 46, + 46, 46, 0, 46, 10, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 33, 46, 35, 46, 46, 44, 0, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 26, + 27, 46, 46, 46, 37, 46, 0, 46, 46, 46, + 15, 46, 46, 46, 46, 21, 22, 46, 46, 46, - 11, 45, 45, 45, 19, 45, 45, 45, 45, 45, - 45, 45, 5, 45, 45, 16, 45, 45, 24, 45, - 45, 31, 34, 40, 8, 45, 45, 45, 45, 45, - 13, 45, 45, 45, 45, 45, 18, 45, 45, 45, - 25, 45, 45, 45, 45, 45, 17, 45, 45, 45, - 45, 45, 28, 0 + 46, 46, 46, 0, 0, 46, 11, 46, 46, 46, + 19, 46, 46, 46, 46, 46, 46, 46, 5, 46, + 46, 16, 46, 46, 24, 46, 46, 31, 34, 41, + 8, 46, 46, 46, 46, 46, 13, 46, 46, 46, + 46, 46, 18, 46, 46, 46, 25, 46, 46, 46, + 46, 46, 17, 46, 46, 46, 46, 46, 28, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -506,8 +506,8 @@ static yyconst flex_int32_t yy_ec[256] = 28, 29, 30, 1, 31, 1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 13, 41, 42, 43, 44, - 45, 46, 13, 47, 48, 49, 50, 51, 13, 52, - 53, 13, 54, 55, 56, 1, 1, 1, 1, 1, + 45, 46, 47, 48, 49, 50, 51, 52, 13, 53, + 54, 13, 55, 56, 57, 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, @@ -524,306 +524,312 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[58] = +static yyconst flex_int32_t yy_meta[59] = { 0, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 4, 5, 1, 6, 6, 6, 1, 1, 1, 1, 7, 1, 3, 6, 5, 5, 3, 1, 3, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 1, 1, 1, 7 + 5, 5, 5, 5, 1, 1, 1, 7 } ; -static yyconst flex_int16_t yy_base[477] = +static yyconst flex_int16_t yy_base[483] = { 0, - 0, 725, 55, 56, 64, 67, 720, 719, 95, 98, - 105, 108, 137, 143, 101, 113, 147, 150, 160, 178, - 205, 0, 53, 170, 178, 198, 728, 732, 732, 732, - 732, 254, 732, 732, 0, 54, 184, 150, 732, 0, - 732, 732, 732, 685, 732, 732, 732, 58, 732, 732, - 732, 732, 193, 732, 712, 732, 732, 213, 732, 732, - 732, 732, 732, 68, 732, 683, 732, 732, 304, 732, - 732, 732, 732, 732, 732, 158, 682, 732, 231, 47, - 732, 159, 123, 248, 732, 732, 667, 732, 0, 682, - 53, 176, 681, 678, 675, 45, 682, 195, 667, 221, + 0, 733, 56, 57, 65, 68, 728, 727, 96, 99, + 106, 109, 138, 144, 85, 102, 142, 150, 161, 174, + 206, 0, 162, 182, 220, 225, 736, 740, 740, 740, + 740, 275, 740, 740, 0, 51, 176, 61, 740, 0, + 740, 740, 740, 693, 740, 740, 740, 103, 740, 740, + 740, 740, 164, 740, 720, 740, 740, 192, 740, 740, + 740, 740, 740, 59, 740, 691, 740, 740, 326, 740, + 740, 740, 740, 740, 740, 60, 690, 740, 231, 132, + 740, 187, 71, 243, 740, 740, 674, 740, 0, 690, + 75, 151, 689, 686, 683, 74, 690, 173, 674, 220, - 676, 72, 205, 671, 678, 681, 732, 0, 732, 0, - 257, 0, 690, 671, 732, 273, 280, 681, 732, 732, - 308, 680, 312, 732, 732, 205, 0, 732, 732, 732, - 732, 732, 732, 0, 732, 0, 732, 306, 309, 0, - 732, 336, 732, 732, 340, 732, 732, 343, 732, 342, - 345, 732, 0, 664, 330, 660, 659, 659, 68, 657, - 663, 123, 668, 654, 657, 225, 663, 649, 650, 147, - 649, 657, 658, 661, 645, 650, 644, 649, 641, 653, - 0, 0, 732, 642, 362, 216, 366, 369, 372, 377, - 228, 302, 0, 0, 0, 663, 380, 306, 383, 378, + 147, 157, 220, 680, 687, 690, 740, 0, 740, 0, + 269, 0, 699, 680, 740, 287, 290, 690, 740, 740, + 293, 689, 301, 740, 740, 67, 0, 740, 740, 740, + 740, 740, 740, 0, 740, 0, 740, 317, 321, 0, + 740, 341, 740, 740, 344, 740, 740, 358, 740, 349, + 352, 740, 0, 673, 220, 668, 667, 668, 131, 665, + 672, 188, 677, 662, 666, 223, 672, 657, 658, 226, + 657, 657, 665, 666, 669, 652, 658, 652, 657, 648, + 661, 0, 0, 740, 650, 369, 250, 378, 381, 384, + 387, 269, 324, 0, 0, 0, 671, 390, 152, 393, - 387, 385, 652, 633, 238, 633, 645, 635, 643, 642, - 641, 664, 626, 625, 661, 640, 633, 634, 359, 297, - 622, 622, 619, 632, 621, 628, 624, 620, 614, 617, - 623, 622, 612, 623, 621, 618, 732, 0, 0, 396, - 606, 614, 601, 606, 602, 614, 600, 612, 633, 609, - 597, 602, 0, 595, 591, 603, 319, 602, 597, 588, - 599, 591, 583, 596, 0, 582, 365, 581, 593, 579, - 0, 583, 0, 582, 580, 0, 620, 0, 0, 570, - 0, 580, 585, 570, 0, 385, 570, 572, 386, 585, - 584, 583, 574, 0, 567, 575, 567, 562, 560, 0, + 388, 397, 202, 660, 640, 238, 640, 653, 643, 651, + 650, 649, 672, 633, 632, 669, 648, 641, 642, 315, + 241, 629, 630, 626, 640, 629, 636, 620, 631, 627, + 620, 624, 630, 629, 619, 630, 628, 625, 740, 0, + 0, 396, 612, 621, 607, 613, 608, 621, 606, 619, + 640, 616, 604, 609, 0, 602, 597, 610, 344, 609, + 604, 594, 606, 598, 589, 603, 0, 588, 392, 597, + 586, 599, 584, 0, 589, 0, 588, 586, 0, 626, + 0, 0, 575, 0, 586, 591, 575, 0, 393, 575, + 578, 394, 591, 590, 589, 580, 0, 573, 581, 573, - 559, 595, 570, 559, 0, 555, 0, 387, 0, 555, - 404, 0, 732, 0, 553, 553, 566, 548, 392, 551, - 552, 549, 553, 547, 548, 545, 559, 554, 544, 552, - 0, 541, 539, 553, 539, 534, 546, 411, 394, 0, - 532, 544, 532, 542, 527, 528, 563, 542, 529, 536, - 521, 522, 535, 521, 535, 0, 519, 521, 532, 0, - 558, 516, 516, 513, 512, 521, 508, 520, 523, 511, - 505, 515, 509, 0, 0, 507, 502, 500, 0, 514, - 541, 498, 497, 510, 0, 502, 495, 493, 505, 0, - 0, 498, 488, 496, 503, 498, 491, 527, 188, 495, + 567, 565, 0, 564, 601, 576, 565, 562, 0, 559, + 0, 395, 0, 559, 399, 0, 740, 0, 557, 557, + 571, 552, 397, 555, 557, 553, 558, 551, 553, 549, + 564, 559, 549, 557, 0, 546, 543, 558, 553, 543, + 537, 550, 414, 407, 0, 535, 548, 535, 546, 530, + 531, 567, 546, 533, 540, 524, 525, 539, 524, 539, + 0, 522, 0, 525, 536, 0, 562, 520, 520, 516, + 515, 525, 511, 524, 527, 515, 508, 519, 513, 0, + 0, 511, 505, 503, 0, 518, 545, 501, 500, 514, + 0, 506, 499, 496, 509, 0, 0, 502, 491, 500, - 0, 485, 477, 478, 0, 478, 474, 398, 481, 481, - 476, 486, 732, 487, 472, 0, 470, 478, 0, 471, - 476, 0, 0, 0, 0, 479, 410, 464, 456, 448, - 0, 443, 429, 404, 390, 398, 0, 403, 396, 393, - 0, 400, 397, 420, 383, 384, 0, 392, 362, 354, - 364, 348, 0, 732, 441, 448, 455, 462, 465, 471, - 477, 484, 488, 494, 346, 343, 328, 260, 501, 243, - 233, 203, 197, 138, 69, 507 + 507, 502, 495, 531, 348, 499, 0, 489, 480, 481, + 0, 481, 477, 408, 485, 485, 479, 490, 740, 491, + 475, 0, 473, 482, 0, 475, 480, 0, 0, 0, + 0, 483, 409, 473, 469, 467, 0, 478, 470, 472, + 452, 455, 0, 445, 432, 395, 0, 402, 399, 422, + 384, 386, 0, 395, 374, 361, 318, 251, 0, 740, + 440, 447, 454, 461, 464, 470, 476, 483, 487, 493, + 281, 275, 236, 218, 500, 206, 151, 138, 116, 102, + 56, 506 } ; -static yyconst flex_int16_t yy_def[477] = +static yyconst flex_int16_t yy_def[483] = { 0, - 454, 1, 455, 455, 455, 455, 456, 456, 455, 455, - 455, 455, 457, 457, 455, 455, 455, 455, 458, 458, - 455, 21, 21, 21, 21, 21, 454, 454, 454, 454, - 454, 454, 454, 454, 459, 454, 454, 454, 454, 460, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 461, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 462, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, + 460, 1, 461, 461, 461, 461, 462, 462, 461, 461, + 461, 461, 463, 463, 461, 461, 461, 461, 464, 464, + 461, 21, 21, 21, 21, 21, 460, 460, 460, 460, + 460, 460, 460, 460, 465, 460, 460, 460, 460, 466, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 467, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 468, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 463, 463, 463, 463, 463, 463, 454, 459, 454, 464, - 454, 465, 460, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 466, 454, 454, 454, - 454, 454, 454, 467, 454, 468, 454, 454, 454, 469, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 464, 465, 454, 454, 454, 454, 454, 454, 454, 454, - 461, 454, 470, 471, 468, 469, 454, 454, 454, 454, + 469, 469, 469, 469, 469, 469, 460, 465, 460, 470, + 460, 471, 466, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 472, 460, 460, 460, + 460, 460, 460, 473, 460, 474, 460, 460, 460, 475, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 470, 471, 460, 460, 460, 460, 460, 460, 460, + 460, 467, 460, 476, 477, 474, 475, 460, 460, 460, - 454, 454, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 454, 454, 472, 473, 454, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 454, 474, 475, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, + 460, 460, 460, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 460, 460, 478, + 479, 460, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 460, + 480, 481, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 454, 467, 454, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 454, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 454, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 476, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 476, 476, 463, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 460, 473, 460, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 460, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 460, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 482, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 454, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 0, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454 + 469, 469, 469, 482, 482, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 460, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 469, 469, 469, 469, 469, 469, 469, 0, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460 } ; -static yyconst flex_int16_t yy_nxt[790] = +static yyconst flex_int16_t yy_nxt[799] = { 0, 28, 29, 30, 29, 31, 28, 28, 32, 33, 28, 34, 28, 35, 36, 37, 38, 38, 28, 39, 40, 41, 28, 28, 28, 35, 35, 35, 28, 28, 28, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 42, 43, 28, 28, 46, 46, 47, - 87, 47, 47, 109, 48, 48, 52, 110, 141, 52, - 47, 115, 45, 47, 313, 142, 49, 109, 49, 49, - 162, 110, 50, 50, 51, 51, 116, 49, 155, 163, - 49, 50, 53, 51, 50, 53, 51, 56, 156, 57, + 35, 35, 35, 35, 42, 43, 28, 28, 46, 46, + 109, 317, 47, 47, 110, 48, 48, 52, 109, 109, + 52, 47, 110, 110, 47, 111, 111, 111, 146, 49, + 49, 193, 193, 50, 50, 51, 51, 67, 49, 68, + 147, 49, 50, 53, 51, 50, 53, 51, 56, 148, - 56, 47, 57, 67, 47, 68, 45, 59, 45, 210, - 59, 47, 173, 60, 47, 67, 60, 68, 49, 211, - 174, 49, 50, 58, 51, 50, 58, 51, 49, 69, - 146, 49, 50, 58, 51, 50, 58, 51, 62, 30, - 62, 69, 147, 312, 62, 30, 62, 63, 66, 71, - 64, 148, 71, 63, 65, 72, 64, 70, 72, 214, - 65, 74, 30, 74, 111, 111, 111, 109, 143, 70, - 75, 110, 144, 76, 215, 69, 47, 87, 69, 74, - 30, 74, 224, 77, 47, 45, 225, 145, 75, 45, - 413, 76, 399, 49, 117, 118, 117, 45, 111, 111, + 57, 56, 47, 57, 67, 47, 68, 316, 59, 162, + 155, 59, 47, 69, 60, 47, 115, 60, 163, 49, + 156, 282, 49, 50, 58, 51, 50, 58, 51, 49, + 69, 116, 49, 50, 58, 51, 50, 58, 51, 62, + 30, 62, 70, 281, 71, 62, 30, 62, 63, 66, + 72, 64, 71, 141, 63, 65, 241, 64, 72, 70, + 142, 65, 74, 30, 74, 117, 118, 117, 47, 87, + 69, 75, 211, 141, 76, 74, 30, 74, 69, 77, + 142, 45, 172, 212, 75, 49, 173, 76, 47, 87, + 111, 111, 111, 121, 122, 121, 143, 174, 157, 70, - 111, 49, 279, 70, 47, 45, 70, 46, 278, 78, - 112, 79, 80, 81, 121, 122, 121, 45, 82, 192, - 192, 49, 157, 45, 83, 45, 165, 158, 84, 115, - 454, 45, 50, 45, 51, 112, 219, 137, 239, 166, - 175, 123, 138, 167, 116, 139, 139, 139, 238, 176, - 140, 45, 169, 45, 149, 219, 123, 177, 85, 150, - 86, 88, 151, 151, 151, 195, 89, 170, 220, 243, - 171, 111, 111, 111, 185, 186, 185, 244, 89, 89, - 89, 117, 118, 117, 89, 89, 90, 89, 91, 92, - 93, 94, 89, 95, 89, 96, 97, 98, 99, 100, + 144, 45, 112, 158, 165, 49, 175, 70, 46, 146, + 78, 240, 79, 80, 81, 145, 45, 166, 45, 82, + 123, 147, 167, 196, 215, 83, 47, 45, 112, 84, + 148, 47, 45, 50, 220, 51, 45, 137, 45, 45, + 216, 195, 138, 49, 45, 139, 139, 139, 49, 149, + 140, 169, 205, 220, 150, 176, 206, 151, 151, 151, + 85, 225, 86, 115, 177, 226, 221, 170, 207, 245, + 171, 460, 262, 178, 45, 263, 45, 246, 116, 45, + 194, 45, 88, 111, 111, 111, 183, 89, 186, 187, + 186, 117, 118, 117, 189, 122, 189, 123, 459, 89, - 101, 102, 103, 104, 105, 89, 106, 107, 125, 188, - 122, 188, 125, 190, 191, 190, 237, 237, 126, 126, - 139, 139, 139, 139, 139, 139, 125, 141, 260, 127, - 295, 261, 125, 194, 142, 128, 129, 197, 198, 197, - 130, 199, 200, 199, 201, 202, 201, 131, 193, 295, - 132, 182, 133, 134, 135, 136, 151, 151, 151, 151, - 151, 151, 204, 185, 186, 185, 205, 117, 118, 117, - 188, 122, 188, 188, 122, 188, 304, 206, 190, 191, - 190, 197, 198, 197, 199, 200, 199, 143, 201, 202, - 201, 144, 146, 258, 453, 304, 318, 321, 336, 452, + 89, 89, 191, 192, 191, 89, 89, 90, 89, 91, + 92, 93, 94, 89, 95, 89, 96, 97, 98, 99, + 100, 89, 101, 102, 103, 104, 105, 89, 106, 107, + 125, 139, 139, 139, 125, 139, 139, 139, 239, 239, + 126, 126, 198, 199, 198, 200, 201, 200, 125, 260, + 419, 127, 405, 458, 125, 298, 261, 128, 129, 202, + 203, 202, 130, 151, 151, 151, 151, 151, 151, 131, + 186, 187, 186, 132, 298, 133, 134, 135, 136, 117, + 118, 117, 189, 122, 189, 189, 122, 189, 191, 192, + 191, 198, 199, 198, 200, 201, 200, 143, 202, 203, - 259, 451, 137, 343, 147, 362, 145, 138, 450, 420, - 139, 139, 139, 148, 361, 318, 321, 336, 338, 338, - 338, 432, 343, 449, 362, 338, 338, 338, 420, 448, - 447, 446, 445, 444, 443, 442, 441, 440, 439, 438, - 432, 45, 45, 45, 45, 45, 45, 45, 54, 54, - 54, 54, 54, 54, 54, 61, 61, 61, 61, 61, - 61, 61, 73, 73, 73, 73, 73, 73, 73, 108, - 108, 113, 437, 113, 113, 113, 113, 120, 120, 436, - 120, 120, 120, 120, 124, 124, 124, 124, 124, 124, - 124, 153, 153, 153, 181, 435, 181, 181, 181, 181, + 202, 144, 137, 307, 322, 325, 341, 138, 348, 457, + 139, 139, 139, 343, 343, 343, 145, 367, 368, 426, + 438, 456, 307, 322, 325, 341, 455, 348, 343, 343, + 343, 454, 453, 452, 451, 450, 449, 368, 426, 438, + 45, 45, 45, 45, 45, 45, 45, 54, 54, 54, + 54, 54, 54, 54, 61, 61, 61, 61, 61, 61, + 61, 73, 73, 73, 73, 73, 73, 73, 108, 108, + 113, 448, 113, 113, 113, 113, 120, 120, 447, 120, + 120, 120, 120, 124, 124, 124, 124, 124, 124, 124, + 153, 153, 153, 182, 446, 182, 182, 182, 182, 182, - 181, 196, 434, 196, 196, 196, 196, 398, 433, 398, - 398, 398, 398, 398, 431, 430, 429, 428, 427, 426, - 425, 424, 423, 422, 421, 419, 418, 417, 416, 415, - 414, 399, 412, 411, 410, 409, 408, 407, 406, 405, - 404, 403, 402, 401, 400, 399, 397, 396, 395, 394, + 197, 445, 197, 197, 197, 197, 404, 444, 404, 404, + 404, 404, 404, 443, 442, 441, 440, 439, 437, 436, + 435, 434, 433, 432, 431, 430, 429, 428, 427, 425, + 424, 423, 422, 421, 420, 405, 418, 417, 416, 415, + 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, + 403, 402, 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, 387, 386, 385, 384, 383, 382, 381, 380, 379, 378, 377, 376, 375, 374, - 373, 372, 371, 370, 369, 368, 367, 366, 365, 364, - 363, 360, 359, 358, 357, 356, 355, 354, 353, 352, - 351, 350, 349, 348, 347, 346, 345, 344, 342, 341, + 373, 372, 371, 370, 369, 366, 365, 364, 363, 362, + 361, 360, 359, 358, 357, 356, 355, 354, 353, 352, - 340, 339, 337, 335, 334, 333, 332, 331, 330, 329, - 328, 327, 326, 325, 324, 323, 322, 320, 319, 317, - 316, 315, 314, 311, 310, 309, 308, 307, 306, 305, - 303, 302, 301, 300, 299, 298, 297, 296, 294, 293, + 351, 350, 349, 347, 346, 345, 344, 342, 340, 339, + 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, + 328, 327, 326, 324, 323, 321, 320, 319, 318, 315, + 314, 313, 312, 311, 310, 309, 308, 306, 305, 304, + 303, 302, 301, 300, 299, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, - 282, 281, 280, 277, 276, 275, 274, 273, 272, 271, - 270, 269, 268, 267, 266, 265, 264, 263, 262, 257, + 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, + 270, 269, 268, 267, 266, 265, 264, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, - 246, 245, 242, 241, 240, 236, 235, 234, 233, 232, - 231, 230, 229, 228, 227, 226, 223, 222, 221, 218, + 244, 243, 242, 238, 237, 236, 235, 234, 233, 232, + + 231, 230, 229, 228, 227, 224, 223, 222, 219, 218, + 217, 214, 213, 210, 209, 208, 204, 190, 188, 185, + 184, 181, 180, 179, 168, 164, 161, 160, 159, 154, + 152, 114, 114, 119, 114, 460, 55, 55, 44, 27, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460 - 217, 216, 213, 212, 209, 208, 207, 203, 189, 187, - 184, 183, 180, 179, 178, 172, 168, 164, 161, 160, - 159, 154, 152, 114, 114, 119, 114, 454, 55, 55, - 44, 27, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454 } ; -static yyconst flex_int16_t yy_chk[790] = +static yyconst flex_int16_t yy_chk[799] = { 0, 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, 3, 4, 23, - 23, 3, 4, 36, 3, 4, 5, 36, 80, 6, - 5, 48, 23, 6, 475, 80, 23, 64, 3, 4, - 96, 64, 3, 4, 3, 4, 48, 5, 91, 96, - 6, 5, 5, 5, 6, 6, 6, 9, 91, 9, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, + 36, 481, 3, 4, 36, 3, 4, 5, 64, 76, + 6, 5, 64, 76, 6, 38, 38, 38, 83, 3, + 4, 126, 126, 3, 4, 3, 4, 15, 5, 15, + 83, 6, 5, 5, 5, 6, 6, 6, 9, 83, - 10, 9, 10, 15, 10, 15, 23, 11, 23, 159, - 12, 11, 102, 11, 12, 16, 12, 16, 9, 159, - 102, 10, 9, 9, 9, 10, 10, 10, 11, 15, - 83, 12, 11, 11, 11, 12, 12, 12, 13, 13, - 13, 16, 83, 474, 14, 14, 14, 13, 14, 17, - 13, 83, 18, 14, 13, 17, 14, 15, 18, 162, - 14, 19, 19, 19, 38, 38, 38, 76, 82, 16, - 19, 76, 82, 19, 162, 17, 24, 24, 18, 20, - 20, 20, 170, 20, 25, 25, 170, 82, 20, 24, - 399, 20, 399, 24, 53, 53, 53, 25, 37, 37, + 9, 10, 9, 10, 16, 10, 16, 480, 11, 96, + 91, 12, 11, 15, 11, 12, 48, 12, 96, 9, + 91, 479, 10, 9, 9, 9, 10, 10, 10, 11, + 16, 48, 12, 11, 11, 11, 12, 12, 12, 13, + 13, 13, 15, 478, 17, 14, 14, 14, 13, 14, + 17, 13, 18, 80, 14, 13, 477, 14, 18, 16, + 80, 14, 19, 19, 19, 53, 53, 53, 23, 23, + 17, 19, 159, 199, 19, 20, 20, 20, 18, 20, + 199, 23, 101, 159, 20, 23, 101, 20, 24, 24, + 37, 37, 37, 58, 58, 58, 82, 102, 92, 17, - 37, 25, 473, 17, 26, 26, 18, 21, 472, 21, - 37, 21, 21, 21, 58, 58, 58, 26, 21, 126, - 126, 26, 92, 24, 21, 24, 98, 92, 21, 186, - 191, 25, 21, 25, 21, 37, 166, 79, 471, 98, - 103, 58, 79, 98, 186, 79, 79, 79, 470, 103, - 79, 26, 100, 26, 84, 166, 191, 103, 21, 84, - 21, 32, 84, 84, 84, 468, 32, 100, 166, 205, - 100, 111, 111, 111, 116, 116, 116, 205, 32, 32, - 32, 117, 117, 117, 32, 32, 32, 32, 32, 32, + 82, 24, 37, 92, 98, 24, 102, 18, 21, 203, + 21, 476, 21, 21, 21, 82, 23, 98, 23, 21, + 58, 203, 98, 474, 162, 21, 25, 25, 37, 21, + 203, 26, 26, 21, 166, 21, 24, 79, 24, 25, + 162, 473, 79, 25, 26, 79, 79, 79, 26, 84, + 79, 100, 155, 166, 84, 103, 155, 84, 84, 84, + 21, 170, 21, 187, 103, 170, 166, 100, 155, 206, + 100, 192, 221, 103, 25, 221, 25, 206, 187, 26, + 472, 26, 32, 111, 111, 111, 471, 32, 116, 116, + 116, 117, 117, 117, 121, 121, 121, 192, 458, 32, + + 32, 32, 123, 123, 123, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 69, 138, 138, 138, 69, 139, 139, 139, 193, 193, + 69, 69, 142, 142, 142, 145, 145, 145, 69, 220, + 405, 69, 405, 457, 69, 259, 220, 69, 69, 148, + 148, 148, 69, 150, 150, 150, 151, 151, 151, 69, + 186, 186, 186, 69, 259, 69, 69, 69, 69, 188, + 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, + 191, 198, 198, 198, 200, 200, 200, 201, 202, 202, - 32, 32, 32, 32, 32, 32, 32, 32, 69, 121, - 121, 121, 69, 123, 123, 123, 192, 192, 69, 69, - 138, 138, 138, 139, 139, 139, 69, 198, 220, 69, - 257, 220, 69, 467, 198, 69, 69, 142, 142, 142, - 69, 145, 145, 145, 148, 148, 148, 69, 466, 257, - 69, 465, 69, 69, 69, 69, 150, 150, 150, 151, - 151, 151, 155, 185, 185, 185, 155, 187, 187, 187, - 188, 188, 188, 189, 189, 189, 267, 155, 190, 190, - 190, 197, 197, 197, 199, 199, 199, 200, 201, 201, - 201, 200, 202, 219, 452, 267, 286, 289, 308, 451, + 202, 201, 242, 269, 289, 292, 312, 242, 323, 456, + 242, 242, 242, 315, 315, 315, 201, 343, 344, 414, + 433, 455, 269, 289, 292, 312, 454, 323, 343, 343, + 343, 452, 451, 450, 449, 448, 446, 344, 414, 433, + 461, 461, 461, 461, 461, 461, 461, 462, 462, 462, + 462, 462, 462, 462, 463, 463, 463, 463, 463, 463, + 463, 464, 464, 464, 464, 464, 464, 464, 465, 465, + 466, 445, 466, 466, 466, 466, 467, 467, 444, 467, + 467, 467, 467, 468, 468, 468, 468, 468, 468, 468, + 469, 469, 469, 470, 442, 470, 470, 470, 470, 470, - 219, 450, 240, 319, 202, 339, 200, 240, 449, 408, - 240, 240, 240, 202, 338, 286, 289, 308, 311, 311, - 311, 427, 319, 448, 339, 338, 338, 338, 408, 446, - 445, 444, 443, 442, 440, 439, 438, 436, 435, 434, - 427, 455, 455, 455, 455, 455, 455, 455, 456, 456, - 456, 456, 456, 456, 456, 457, 457, 457, 457, 457, - 457, 457, 458, 458, 458, 458, 458, 458, 458, 459, - 459, 460, 433, 460, 460, 460, 460, 461, 461, 432, - 461, 461, 461, 461, 462, 462, 462, 462, 462, 462, - 462, 463, 463, 463, 464, 430, 464, 464, 464, 464, + 475, 441, 475, 475, 475, 475, 482, 440, 482, 482, + 482, 482, 482, 439, 438, 436, 435, 434, 432, 427, + 426, 424, 423, 421, 420, 418, 417, 416, 415, 413, + 412, 410, 409, 408, 406, 404, 403, 402, 401, 400, + 399, 398, 395, 394, 393, 392, 390, 389, 388, 387, + 386, 384, 383, 382, 379, 378, 377, 376, 375, 374, + 373, 372, 371, 370, 369, 368, 367, 365, 364, 362, + 360, 359, 358, 357, 356, 355, 354, 353, 352, 351, + 350, 349, 348, 347, 346, 342, 341, 340, 339, 338, + 337, 336, 334, 333, 332, 331, 330, 329, 328, 327, - 464, 469, 429, 469, 469, 469, 469, 476, 428, 476, - 476, 476, 476, 476, 426, 421, 420, 418, 417, 415, - 414, 412, 411, 410, 409, 407, 406, 404, 403, 402, - 400, 398, 397, 396, 395, 394, 393, 392, 389, 388, - 387, 386, 384, 383, 382, 381, 380, 378, 377, 376, - 373, 372, 371, 370, 369, 368, 367, 366, 365, 364, - 363, 362, 361, 359, 358, 357, 355, 354, 353, 352, - 351, 350, 349, 348, 347, 346, 345, 344, 343, 342, - 341, 337, 336, 335, 334, 333, 332, 330, 329, 328, - 327, 326, 325, 324, 323, 322, 321, 320, 318, 317, + 326, 325, 324, 322, 321, 320, 319, 314, 310, 308, + 307, 306, 305, 304, 302, 301, 300, 299, 298, 296, + 295, 294, 293, 291, 290, 287, 286, 285, 283, 280, + 278, 277, 275, 273, 272, 271, 270, 268, 266, 265, + 264, 263, 262, 261, 260, 258, 257, 256, 254, 253, + 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, + 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, + 228, 227, 226, 225, 224, 223, 222, 219, 218, 217, + 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, + 205, 204, 197, 185, 181, 180, 179, 178, 177, 176, - 316, 315, 310, 306, 304, 303, 302, 301, 299, 298, - 297, 296, 295, 293, 292, 291, 290, 288, 287, 284, - 283, 282, 280, 277, 275, 274, 272, 270, 269, 268, - 266, 264, 263, 262, 261, 260, 259, 258, 256, 255, - 254, 252, 251, 250, 249, 248, 247, 246, 245, 244, - 243, 242, 241, 236, 235, 234, 233, 232, 231, 230, - 229, 228, 227, 226, 225, 224, 223, 222, 221, 218, - 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, - 207, 206, 204, 203, 196, 184, 180, 179, 178, 177, - 176, 175, 174, 173, 172, 171, 169, 168, 167, 165, + 175, 174, 173, 172, 171, 169, 168, 167, 165, 164, + 163, 161, 160, 158, 157, 156, 154, 122, 118, 114, + 113, 106, 105, 104, 99, 97, 95, 94, 93, 90, + 87, 77, 66, 55, 44, 27, 8, 7, 2, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, + 460, 460, 460, 460, 460, 460, 460, 460 - 164, 163, 161, 160, 158, 157, 156, 154, 122, 118, - 114, 113, 106, 105, 104, 101, 99, 97, 95, 94, - 93, 90, 87, 77, 66, 55, 44, 27, 8, 7, - 2, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 454, 454, 454 } ; static yy_state_type yy_last_accepting_state; @@ -832,20 +838,20 @@ static char *yy_last_accepting_cpos; extern int gram__flex_debug; int gram__flex_debug = 1; -static yyconst flex_int16_t yy_rule_linenum[106] = +static yyconst flex_int16_t yy_rule_linenum[109] = { 0, - 176, 177, 178, 179, 187, 198, 199, 200, 201, 202, - 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - 233, 234, 235, 236, 238, 242, 243, 244, 246, 253, - 257, 263, 266, 269, 272, 281, 289, 296, 313, 319, - 340, 341, 352, 363, 364, 376, 384, 395, 411, 417, - 427, 437, 449, 450, 451, 452, 453, 454, 455, 458, - 460, 469, 481, 486, 487, 493, 494, 505, 511, 517, - 523, 539, 573, 574, 575, 610, 612, 613, 625, 660, + 197, 198, 199, 200, 208, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, + 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, + 254, 255, 256, 257, 258, 260, 264, 265, 266, 268, + 275, 279, 285, 288, 291, 294, 305, 313, 320, 337, + 343, 364, 365, 376, 387, 388, 400, 408, 419, 435, + 441, 451, 461, 472, 473, 474, 475, 476, 477, 478, + 481, 483, 492, 504, 509, 510, 516, 517, 528, 534, + 540, 546, 562, 596, 597, 598, 634, 636, 637, 639, - 661, 662, 663, 671, 672 + 643, 658, 693, 694, 695, 696, 704, 705 } ; /* The intent behind this definition is that it'll catch @@ -859,7 +865,7 @@ char *gram_text; #line 1 "scan-gram.l" /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -879,10 +885,14 @@ char *gram_text; 02110-1301 USA */ #line 27 "scan-gram.l" +/* Work around a bug in flex 2.5.31. See Debian bug 333231 + . */ +#undef gram_wrap +#define gram_wrap() 1 + #include "system.h" #include -#include #include #include "complain.h" @@ -938,8 +948,11 @@ static size_t no_cr_read (FILE *, char *, size_t); static struct obstack obstack_for_string; /* A string representing the most recently saved token. */ -static char *last_string; +char *last_string; +/* The location of the most recently saved token, if it was a + BRACED_CODE token; otherwise, this has an unspecified value. */ +location last_braced_code_loc; #define STRING_GROW \ obstack_grow (&obstack_for_string, gram_text, gram_leng) @@ -967,9 +980,23 @@ scanner_last_string_free (void) Outside of well-formed rules, RULE_LENGTH has an undefined value. */ static int rule_length; +static void rule_length_overflow (location) __attribute__ ((__noreturn__)); + +/* Increment the rule length by one, checking for overflow. */ +static inline void +increment_rule_length (location loc) +{ + rule_length++; + + /* Don't allow rule_length == INT_MAX, since that might cause + confusion with strtol if INT_MAX == LONG_MAX. */ + if (rule_length == INT_MAX) + rule_length_overflow (loc); +} + static void handle_dollar (int token_type, char *cp, location loc); static void handle_at (int token_type, char *cp, location loc); -static void handle_syncline (char *args); +static void handle_syncline (char *, location); static unsigned long int scan_integer (char const *p, int base, location loc); static int convert_ucn_to_byte (char const *hex_text); static void unexpected_eof (boundary, char const *); @@ -985,7 +1012,7 @@ static void unexpected_newline (boundary, char const *); NUL and newline, as this simplifies our implementation. */ /* Zero or more instances of backslash-newline. Following GCC, allow white space between the backslash and the newline. */ -#line 989 "scan-gram.c" +#line 1016 "scan-gram.c" #define INITIAL 0 #define SC_COMMENT 1 @@ -1205,7 +1232,7 @@ YY_DECL register int yy_act; /* %% [7.0] user's declarations go here */ -#line 144 "scan-gram.l" +#line 165 "scan-gram.l" /* Nesting level of the current code in braces. */ @@ -1235,7 +1262,7 @@ YY_DECL | Scanning white space. | `-----------------------*/ -#line 1239 "scan-gram.c" +#line 1266 "scan-gram.c" if ( (yy_init) ) { @@ -1299,13 +1326,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 455 ) + if ( yy_current_state >= 461 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 454 ); + while ( yy_current_state != 460 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1324,13 +1351,13 @@ do_action: /* This label is used only to access EOF actions. */ { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 106 ) + else if ( yy_act < 109 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], gram_text ); - else if ( yy_act == 106 ) + else if ( yy_act == 109 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", gram_text ); - else if ( yy_act == 107 ) + else if ( yy_act == 110 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); @@ -1349,21 +1376,21 @@ do_action: /* This label is used only to access EOF actions. */ /* Comments and white space. */ case 1: YY_RULE_SETUP -#line 176 "scan-gram.l" +#line 197 "scan-gram.l" warn_at (*loc, _("stray `,' treated as white space")); YY_BREAK case 2: /* rule 2 can match eol */ -#line 178 "scan-gram.l" +#line 199 "scan-gram.l" case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 178 "scan-gram.l" +#line 199 "scan-gram.l" ; YY_BREAK case 4: YY_RULE_SETUP -#line 179 "scan-gram.l" +#line 200 "scan-gram.l" { token_start = loc->start; context_state = YY_START; @@ -1375,9 +1402,9 @@ YY_RULE_SETUP case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 187 "scan-gram.l" +#line 208 "scan-gram.l" { - handle_syncline (gram_text + sizeof "#line " - 1); + handle_syncline (gram_text + sizeof "#line " - 1, *loc); } YY_BREAK @@ -1388,270 +1415,277 @@ YY_RULE_SETUP case 6: YY_RULE_SETUP -#line 198 "scan-gram.l" +#line 219 "scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 7: YY_RULE_SETUP -#line 199 "scan-gram.l" +#line 220 "scan-gram.l" return PERCENT_DEBUG; YY_BREAK case 8: YY_RULE_SETUP -#line 200 "scan-gram.l" +#line 221 "scan-gram.l" return PERCENT_DEFAULT_PREC; YY_BREAK case 9: YY_RULE_SETUP -#line 201 "scan-gram.l" +#line 222 "scan-gram.l" return PERCENT_DEFINE; YY_BREAK case 10: YY_RULE_SETUP -#line 202 "scan-gram.l" +#line 223 "scan-gram.l" return PERCENT_DEFINES; YY_BREAK case 11: YY_RULE_SETUP -#line 203 "scan-gram.l" +#line 224 "scan-gram.l" token_type = PERCENT_DESTRUCTOR; BEGIN SC_PRE_CODE; YY_BREAK case 12: YY_RULE_SETUP -#line 204 "scan-gram.l" +#line 225 "scan-gram.l" return PERCENT_DPREC; YY_BREAK case 13: YY_RULE_SETUP -#line 205 "scan-gram.l" +#line 226 "scan-gram.l" return PERCENT_ERROR_VERBOSE; YY_BREAK case 14: YY_RULE_SETUP -#line 206 "scan-gram.l" +#line 227 "scan-gram.l" return PERCENT_EXPECT; YY_BREAK case 15: YY_RULE_SETUP -#line 207 "scan-gram.l" +#line 228 "scan-gram.l" return PERCENT_EXPECT_RR; YY_BREAK case 16: YY_RULE_SETUP -#line 208 "scan-gram.l" +#line 229 "scan-gram.l" return PERCENT_FILE_PREFIX; YY_BREAK case 17: YY_RULE_SETUP -#line 209 "scan-gram.l" +#line 230 "scan-gram.l" return PERCENT_YACC; YY_BREAK case 18: YY_RULE_SETUP -#line 210 "scan-gram.l" +#line 231 "scan-gram.l" token_type = PERCENT_INITIAL_ACTION; BEGIN SC_PRE_CODE; YY_BREAK case 19: YY_RULE_SETUP -#line 211 "scan-gram.l" +#line 232 "scan-gram.l" return PERCENT_GLR_PARSER; YY_BREAK case 20: YY_RULE_SETUP -#line 212 "scan-gram.l" +#line 233 "scan-gram.l" return PERCENT_LEFT; YY_BREAK case 21: YY_RULE_SETUP -#line 213 "scan-gram.l" +#line 234 "scan-gram.l" token_type = PERCENT_LEX_PARAM; BEGIN SC_PRE_CODE; YY_BREAK case 22: YY_RULE_SETUP -#line 214 "scan-gram.l" +#line 235 "scan-gram.l" return PERCENT_LOCATIONS; YY_BREAK case 23: YY_RULE_SETUP -#line 215 "scan-gram.l" +#line 236 "scan-gram.l" return PERCENT_MERGE; YY_BREAK case 24: YY_RULE_SETUP -#line 216 "scan-gram.l" +#line 237 "scan-gram.l" return PERCENT_NAME_PREFIX; YY_BREAK case 25: YY_RULE_SETUP -#line 217 "scan-gram.l" +#line 238 "scan-gram.l" return PERCENT_NO_DEFAULT_PREC; YY_BREAK case 26: YY_RULE_SETUP -#line 218 "scan-gram.l" +#line 239 "scan-gram.l" return PERCENT_NO_LINES; YY_BREAK case 27: YY_RULE_SETUP -#line 219 "scan-gram.l" +#line 240 "scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 28: YY_RULE_SETUP -#line 220 "scan-gram.l" +#line 241 "scan-gram.l" return PERCENT_NONDETERMINISTIC_PARSER; YY_BREAK case 29: YY_RULE_SETUP -#line 221 "scan-gram.l" +#line 242 "scan-gram.l" return PERCENT_NTERM; YY_BREAK case 30: YY_RULE_SETUP -#line 222 "scan-gram.l" +#line 243 "scan-gram.l" return PERCENT_OUTPUT; YY_BREAK case 31: YY_RULE_SETUP -#line 223 "scan-gram.l" +#line 244 "scan-gram.l" token_type = PERCENT_PARSE_PARAM; BEGIN SC_PRE_CODE; YY_BREAK case 32: YY_RULE_SETUP -#line 224 "scan-gram.l" +#line 245 "scan-gram.l" rule_length--; return PERCENT_PREC; YY_BREAK case 33: YY_RULE_SETUP -#line 225 "scan-gram.l" +#line 246 "scan-gram.l" token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE; YY_BREAK case 34: YY_RULE_SETUP -#line 226 "scan-gram.l" +#line 247 "scan-gram.l" return PERCENT_PURE_PARSER; YY_BREAK case 35: YY_RULE_SETUP -#line 227 "scan-gram.l" -return PERCENT_RIGHT; +#line 248 "scan-gram.l" +return PERCENT_REQUIRE; YY_BREAK case 36: YY_RULE_SETUP -#line 228 "scan-gram.l" -return PERCENT_SKELETON; +#line 249 "scan-gram.l" +return PERCENT_RIGHT; YY_BREAK case 37: YY_RULE_SETUP -#line 229 "scan-gram.l" -return PERCENT_START; +#line 250 "scan-gram.l" +return PERCENT_SKELETON; YY_BREAK case 38: YY_RULE_SETUP -#line 230 "scan-gram.l" -return PERCENT_TOKEN; +#line 251 "scan-gram.l" +return PERCENT_START; YY_BREAK case 39: YY_RULE_SETUP -#line 231 "scan-gram.l" +#line 252 "scan-gram.l" return PERCENT_TOKEN; YY_BREAK case 40: YY_RULE_SETUP -#line 232 "scan-gram.l" -return PERCENT_TOKEN_TABLE; +#line 253 "scan-gram.l" +return PERCENT_TOKEN; YY_BREAK case 41: YY_RULE_SETUP -#line 233 "scan-gram.l" -return PERCENT_TYPE; +#line 254 "scan-gram.l" +return PERCENT_TOKEN_TABLE; YY_BREAK case 42: YY_RULE_SETUP -#line 234 "scan-gram.l" -token_type = PERCENT_UNION; BEGIN SC_PRE_CODE; +#line 255 "scan-gram.l" +return PERCENT_TYPE; YY_BREAK case 43: YY_RULE_SETUP -#line 235 "scan-gram.l" -return PERCENT_VERBOSE; +#line 256 "scan-gram.l" +token_type = PERCENT_UNION; BEGIN SC_PRE_CODE; YY_BREAK case 44: YY_RULE_SETUP -#line 236 "scan-gram.l" -return PERCENT_YACC; +#line 257 "scan-gram.l" +return PERCENT_VERBOSE; YY_BREAK case 45: YY_RULE_SETUP -#line 238 "scan-gram.l" +#line 258 "scan-gram.l" +return PERCENT_YACC; + YY_BREAK +case 46: +YY_RULE_SETUP +#line 260 "scan-gram.l" { complain_at (*loc, _("invalid directive: %s"), quote (gram_text)); } YY_BREAK -case 46: -YY_RULE_SETUP -#line 242 "scan-gram.l" -return EQUAL; - YY_BREAK case 47: YY_RULE_SETUP -#line 243 "scan-gram.l" -rule_length = 0; return PIPE; +#line 264 "scan-gram.l" +return EQUAL; YY_BREAK case 48: YY_RULE_SETUP -#line 244 "scan-gram.l" -return SEMICOLON; +#line 265 "scan-gram.l" +rule_length = 0; return PIPE; YY_BREAK case 49: YY_RULE_SETUP -#line 246 "scan-gram.l" -{ - val->symbol = symbol_get (gram_text, *loc); - id_loc = *loc; - rule_length++; - BEGIN SC_AFTER_IDENTIFIER; - } +#line 266 "scan-gram.l" +return SEMICOLON; YY_BREAK case 50: YY_RULE_SETUP -#line 253 "scan-gram.l" +#line 268 "scan-gram.l" +{ + val->symbol = symbol_get (gram_text, *loc); + id_loc = *loc; + increment_rule_length (*loc); + BEGIN SC_AFTER_IDENTIFIER; + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 275 "scan-gram.l" { val->integer = scan_integer (gram_text, 10, *loc); return INT; } YY_BREAK -case 51: +case 52: YY_RULE_SETUP -#line 257 "scan-gram.l" +#line 279 "scan-gram.l" { val->integer = scan_integer (gram_text, 16, *loc); return INT; } YY_BREAK /* Characters. We don't check there is only one. */ -case 52: +case 53: YY_RULE_SETUP -#line 263 "scan-gram.l" +#line 285 "scan-gram.l" STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER; YY_BREAK /* Strings. */ -case 53: +case 54: YY_RULE_SETUP -#line 266 "scan-gram.l" +#line 288 "scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_STRING; YY_BREAK /* Prologue. */ -case 54: +case 55: YY_RULE_SETUP -#line 269 "scan-gram.l" +#line 291 "scan-gram.l" code_start = loc->start; BEGIN SC_PROLOGUE; YY_BREAK /* Code in between braces. */ -case 55: +case 56: YY_RULE_SETUP -#line 272 "scan-gram.l" +#line 294 "scan-gram.l" { + if (current_rule && current_rule->action) + grammar_midrule_action (); STRING_GROW; token_type = BRACED_CODE; braces_level = 0; @@ -1660,9 +1694,9 @@ YY_RULE_SETUP } YY_BREAK /* A type. */ -case 56: +case 57: YY_RULE_SETUP -#line 281 "scan-gram.l" +#line 305 "scan-gram.l" { obstack_grow (&obstack_for_string, gram_text + 1, gram_leng - 2); STRING_FINISH; @@ -1671,9 +1705,9 @@ YY_RULE_SETUP return TYPE; } YY_BREAK -case 57: +case 58: YY_RULE_SETUP -#line 289 "scan-gram.l" +#line 313 "scan-gram.l" { static int percent_percent_count; if (++percent_percent_count == 2) @@ -1681,15 +1715,15 @@ YY_RULE_SETUP return PERCENT_PERCENT; } YY_BREAK -case 58: +case 59: YY_RULE_SETUP -#line 296 "scan-gram.l" +#line 320 "scan-gram.l" { complain_at (*loc, _("invalid character: %s"), quote (gram_text)); } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 300 "scan-gram.l" +#line 324 "scan-gram.l" { loc->start = loc->end = scanner_cursor; yyterminate (); @@ -1701,9 +1735,9 @@ case YY_STATE_EOF(INITIAL): `-----------------------------------------------------------------*/ -case 59: +case 60: YY_RULE_SETUP -#line 313 "scan-gram.l" +#line 337 "scan-gram.l" { rule_length = 0; *loc = id_loc; @@ -1711,9 +1745,9 @@ YY_RULE_SETUP return ID_COLON; } YY_BREAK -case 60: +case 61: YY_RULE_SETUP -#line 319 "scan-gram.l" +#line 343 "scan-gram.l" { scanner_cursor.column -= mbsnwidth (gram_text, gram_leng, 0); yyless (0); @@ -1723,7 +1757,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_AFTER_IDENTIFIER): -#line 326 "scan-gram.l" +#line 350 "scan-gram.l" { *loc = id_loc; BEGIN INITIAL; @@ -1736,19 +1770,19 @@ case YY_STATE_EOF(SC_AFTER_IDENTIFIER): `---------------------------------------------------------------*/ -case 61: +case 62: YY_RULE_SETUP -#line 340 "scan-gram.l" +#line 364 "scan-gram.l" BEGIN context_state; YY_BREAK -case 62: -/* rule 62 can match eol */ +case 63: +/* rule 63 can match eol */ YY_RULE_SETUP -#line 341 "scan-gram.l" +#line 365 "scan-gram.l" ; YY_BREAK case YY_STATE_EOF(SC_YACC_COMMENT): -#line 342 "scan-gram.l" +#line 366 "scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -1757,14 +1791,14 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; `------------------------------------------------------------*/ -case 63: -/* rule 63 can match eol */ +case 64: +/* rule 64 can match eol */ YY_RULE_SETUP -#line 352 "scan-gram.l" +#line 376 "scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case YY_STATE_EOF(SC_COMMENT): -#line 353 "scan-gram.l" +#line 377 "scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -1773,20 +1807,20 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; `--------------------------------------------------------------*/ -case 64: -/* rule 64 can match eol */ -YY_RULE_SETUP -#line 363 "scan-gram.l" -STRING_GROW; BEGIN context_state; - YY_BREAK case 65: /* rule 65 can match eol */ YY_RULE_SETUP -#line 364 "scan-gram.l" +#line 387 "scan-gram.l" +STRING_GROW; BEGIN context_state; + YY_BREAK +case 66: +/* rule 66 can match eol */ +YY_RULE_SETUP +#line 388 "scan-gram.l" STRING_GROW; YY_BREAK case YY_STATE_EOF(SC_LINE_COMMENT): -#line 365 "scan-gram.l" +#line 389 "scan-gram.l" BEGIN context_state; YY_BREAK @@ -1796,26 +1830,26 @@ BEGIN context_state; `------------------------------------------------*/ -case 66: +case 67: YY_RULE_SETUP -#line 376 "scan-gram.l" +#line 400 "scan-gram.l" { STRING_FINISH; loc->start = token_start; val->chars = last_string; - rule_length++; + increment_rule_length (*loc); BEGIN INITIAL; return STRING; } YY_BREAK -case 67: -/* rule 67 can match eol */ +case 68: +/* rule 68 can match eol */ YY_RULE_SETUP -#line 384 "scan-gram.l" +#line 408 "scan-gram.l" unexpected_newline (token_start, "\""); BEGIN INITIAL; YY_BREAK case YY_STATE_EOF(SC_ESCAPED_STRING): -#line 385 "scan-gram.l" +#line 409 "scan-gram.l" unexpected_eof (token_start, "\""); BEGIN INITIAL; YY_BREAK @@ -1825,9 +1859,9 @@ unexpected_eof (token_start, "\""); BEGIN INITIAL; `----------------------------------------------------------*/ -case 68: +case 69: YY_RULE_SETUP -#line 395 "scan-gram.l" +#line 419 "scan-gram.l" { unsigned char last_string_1; STRING_GROW; @@ -1836,31 +1870,31 @@ YY_RULE_SETUP val->symbol = symbol_get (quotearg_style (escape_quoting_style, last_string), *loc); - symbol_class_set (val->symbol, token_sym, *loc); + symbol_class_set (val->symbol, token_sym, *loc, false); last_string_1 = last_string[1]; symbol_user_token_number_set (val->symbol, last_string_1, *loc); STRING_FREE; - rule_length++; + increment_rule_length (*loc); BEGIN INITIAL; return ID; } YY_BREAK -case 69: -/* rule 69 can match eol */ +case 70: +/* rule 70 can match eol */ YY_RULE_SETUP -#line 411 "scan-gram.l" +#line 435 "scan-gram.l" unexpected_newline (token_start, "'"); BEGIN INITIAL; YY_BREAK case YY_STATE_EOF(SC_ESCAPED_CHARACTER): -#line 412 "scan-gram.l" +#line 436 "scan-gram.l" unexpected_eof (token_start, "'"); BEGIN INITIAL; YY_BREAK -case 70: +case 71: YY_RULE_SETUP -#line 417 "scan-gram.l" +#line 441 "scan-gram.l" complain_at (*loc, _("invalid null character")); YY_BREAK @@ -1869,27 +1903,12 @@ complain_at (*loc, _("invalid null character")); `----------------------------*/ -case 71: -YY_RULE_SETUP -#line 427 "scan-gram.l" -{ - unsigned long int c = strtoul (gram_text + 1, 0, 8); - if (UCHAR_MAX < c) - complain_at (*loc, _("invalid escape sequence: %s"), quote (gram_text)); - else if (! c) - complain_at (*loc, _("invalid null character: %s"), quote (gram_text)); - else - obstack_1grow (&obstack_for_string, c); - } - YY_BREAK case 72: YY_RULE_SETUP -#line 437 "scan-gram.l" +#line 451 "scan-gram.l" { - unsigned long int c; - set_errno (0); - c = strtoul (gram_text + 2, 0, 16); - if (UCHAR_MAX < c || get_errno ()) + unsigned long int c = strtoul (gram_text + 1, NULL, 8); + if (UCHAR_MAX < c) complain_at (*loc, _("invalid escape sequence: %s"), quote (gram_text)); else if (! c) complain_at (*loc, _("invalid null character: %s"), quote (gram_text)); @@ -1899,48 +1918,62 @@ YY_RULE_SETUP YY_BREAK case 73: YY_RULE_SETUP -#line 449 "scan-gram.l" -obstack_1grow (&obstack_for_string, '\a'); +#line 461 "scan-gram.l" +{ + verify (UCHAR_MAX < ULONG_MAX); + unsigned long int c = strtoul (gram_text + 2, NULL, 16); + if (UCHAR_MAX < c) + complain_at (*loc, _("invalid escape sequence: %s"), quote (gram_text)); + else if (! c) + complain_at (*loc, _("invalid null character: %s"), quote (gram_text)); + else + obstack_1grow (&obstack_for_string, c); + } YY_BREAK case 74: YY_RULE_SETUP -#line 450 "scan-gram.l" -obstack_1grow (&obstack_for_string, '\b'); +#line 472 "scan-gram.l" +obstack_1grow (&obstack_for_string, '\a'); YY_BREAK case 75: YY_RULE_SETUP -#line 451 "scan-gram.l" -obstack_1grow (&obstack_for_string, '\f'); +#line 473 "scan-gram.l" +obstack_1grow (&obstack_for_string, '\b'); YY_BREAK case 76: YY_RULE_SETUP -#line 452 "scan-gram.l" -obstack_1grow (&obstack_for_string, '\n'); +#line 474 "scan-gram.l" +obstack_1grow (&obstack_for_string, '\f'); YY_BREAK case 77: YY_RULE_SETUP -#line 453 "scan-gram.l" -obstack_1grow (&obstack_for_string, '\r'); +#line 475 "scan-gram.l" +obstack_1grow (&obstack_for_string, '\n'); YY_BREAK case 78: YY_RULE_SETUP -#line 454 "scan-gram.l" -obstack_1grow (&obstack_for_string, '\t'); +#line 476 "scan-gram.l" +obstack_1grow (&obstack_for_string, '\r'); YY_BREAK case 79: YY_RULE_SETUP -#line 455 "scan-gram.l" +#line 477 "scan-gram.l" +obstack_1grow (&obstack_for_string, '\t'); + YY_BREAK +case 80: +YY_RULE_SETUP +#line 478 "scan-gram.l" obstack_1grow (&obstack_for_string, '\v'); YY_BREAK /* \\[\"\'?\\] would be shorter, but it confuses xgettext. */ -case 80: -YY_RULE_SETUP -#line 458 "scan-gram.l" -obstack_1grow (&obstack_for_string, gram_text[1]); - YY_BREAK case 81: YY_RULE_SETUP -#line 460 "scan-gram.l" +#line 481 "scan-gram.l" +obstack_1grow (&obstack_for_string, gram_text[1]); + YY_BREAK +case 82: +YY_RULE_SETUP +#line 483 "scan-gram.l" { int c = convert_ucn_to_byte (gram_text); if (c < 0) @@ -1951,10 +1984,10 @@ YY_RULE_SETUP obstack_1grow (&obstack_for_string, c); } YY_BREAK -case 82: -/* rule 82 can match eol */ +case 83: +/* rule 83 can match eol */ YY_RULE_SETUP -#line 469 "scan-gram.l" +#line 492 "scan-gram.l" { complain_at (*loc, _("unrecognized escape sequence: %s"), quote (gram_text)); STRING_GROW; @@ -1966,46 +1999,46 @@ YY_RULE_SETUP `--------------------------------------------*/ -case 83: -/* rule 83 can match eol */ +case 84: +/* rule 84 can match eol */ YY_RULE_SETUP -#line 481 "scan-gram.l" +#line 504 "scan-gram.l" STRING_GROW; YY_BREAK -case 84: +case 85: YY_RULE_SETUP -#line 486 "scan-gram.l" +#line 509 "scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 85: -/* rule 85 can match eol */ +case 86: +/* rule 86 can match eol */ YY_RULE_SETUP -#line 487 "scan-gram.l" +#line 510 "scan-gram.l" unexpected_newline (token_start, "'"); BEGIN context_state; YY_BREAK case YY_STATE_EOF(SC_CHARACTER): -#line 488 "scan-gram.l" +#line 511 "scan-gram.l" unexpected_eof (token_start, "'"); BEGIN context_state; YY_BREAK -case 86: +case 87: YY_RULE_SETUP -#line 493 "scan-gram.l" +#line 516 "scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 87: -/* rule 87 can match eol */ +case 88: +/* rule 88 can match eol */ YY_RULE_SETUP -#line 494 "scan-gram.l" +#line 517 "scan-gram.l" unexpected_newline (token_start, "\""); BEGIN context_state; YY_BREAK case YY_STATE_EOF(SC_STRING): -#line 495 "scan-gram.l" +#line 518 "scan-gram.l" unexpected_eof (token_start, "\""); BEGIN context_state; YY_BREAK @@ -2014,9 +2047,9 @@ unexpected_eof (token_start, "\""); BEGIN context_state; `---------------------------------------------------*/ -case 88: +case 89: YY_RULE_SETUP -#line 505 "scan-gram.l" +#line 528 "scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2024,9 +2057,9 @@ YY_RULE_SETUP BEGIN SC_CHARACTER; } YY_BREAK -case 89: +case 90: YY_RULE_SETUP -#line 511 "scan-gram.l" +#line 534 "scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2034,10 +2067,10 @@ YY_RULE_SETUP BEGIN SC_STRING; } YY_BREAK -case 90: -/* rule 90 can match eol */ +case 91: +/* rule 91 can match eol */ YY_RULE_SETUP -#line 517 "scan-gram.l" +#line 540 "scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2045,10 +2078,10 @@ YY_RULE_SETUP BEGIN SC_COMMENT; } YY_BREAK -case 91: -/* rule 91 can match eol */ +case 92: +/* rule 92 can match eol */ YY_RULE_SETUP -#line 523 "scan-gram.l" +#line 546 "scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2063,9 +2096,9 @@ YY_RULE_SETUP `---------------------------------------------------------------*/ -case 92: +case 93: YY_RULE_SETUP -#line 539 "scan-gram.l" +#line 562 "scan-gram.l" { bool valid = gram_text[0] == '{' || token_type == PERCENT_UNION; scanner_cursor.column -= mbsnwidth (gram_text, gram_leng, 0); @@ -2090,7 +2123,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_PRE_CODE): -#line 562 "scan-gram.l" +#line 585 "scan-gram.l" unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL; YY_BREAK @@ -2100,21 +2133,21 @@ unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL; `---------------------------------------------------------------*/ -case 93: -/* rule 93 can match eol */ -YY_RULE_SETUP -#line 573 "scan-gram.l" -STRING_GROW; braces_level++; - YY_BREAK case 94: /* rule 94 can match eol */ YY_RULE_SETUP -#line 574 "scan-gram.l" -STRING_GROW; braces_level--; +#line 596 "scan-gram.l" +STRING_GROW; braces_level++; YY_BREAK case 95: +/* rule 95 can match eol */ YY_RULE_SETUP -#line 575 "scan-gram.l" +#line 597 "scan-gram.l" +STRING_GROW; braces_level--; + YY_BREAK +case 96: +YY_RULE_SETUP +#line 598 "scan-gram.l" { bool outer_brace = --braces_level < 0; @@ -2140,9 +2173,10 @@ YY_RULE_SETUP if (outer_brace) { STRING_FINISH; - rule_length++; loc->start = code_start; val->chars = last_string; + increment_rule_length (*loc); + last_braced_code_loc = *loc; BEGIN INITIAL; return token_type; } @@ -2150,24 +2184,40 @@ YY_RULE_SETUP YY_BREAK /* Tokenize `<<%' correctly (as `<<' `%') rather than incorrrectly (as `<' `<%'). */ -case 96: -/* rule 96 can match eol */ -YY_RULE_SETUP -#line 610 "scan-gram.l" -STRING_GROW; - YY_BREAK case 97: +/* rule 97 can match eol */ YY_RULE_SETUP -#line 612 "scan-gram.l" -handle_dollar (token_type, gram_text, *loc); +#line 634 "scan-gram.l" +STRING_GROW; YY_BREAK case 98: YY_RULE_SETUP -#line 613 "scan-gram.l" +#line 636 "scan-gram.l" +handle_dollar (token_type, gram_text, *loc); + YY_BREAK +case 99: +YY_RULE_SETUP +#line 637 "scan-gram.l" handle_at (token_type, gram_text, *loc); YY_BREAK +case 100: +YY_RULE_SETUP +#line 639 "scan-gram.l" +{ + warn_at (*loc, _("stray `$'")); + obstack_sgrow (&obstack_for_string, "$]["); + } + YY_BREAK +case 101: +YY_RULE_SETUP +#line 643 "scan-gram.l" +{ + warn_at (*loc, _("stray `@'")); + obstack_sgrow (&obstack_for_string, "@@"); + } + YY_BREAK case YY_STATE_EOF(SC_BRACED_CODE): -#line 615 "scan-gram.l" +#line 648 "scan-gram.l" unexpected_eof (code_start, "}"); BEGIN INITIAL; YY_BREAK @@ -2176,9 +2226,9 @@ unexpected_eof (code_start, "}"); BEGIN INITIAL; `--------------------------------------------------------------*/ -case 99: +case 102: YY_RULE_SETUP -#line 625 "scan-gram.l" +#line 658 "scan-gram.l" { STRING_FINISH; loc->start = code_start; @@ -2188,7 +2238,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_PROLOGUE): -#line 633 "scan-gram.l" +#line 666 "scan-gram.l" unexpected_eof (code_start, "%}"); BEGIN INITIAL; YY_BREAK @@ -2199,7 +2249,7 @@ unexpected_eof (code_start, "%}"); BEGIN INITIAL; case YY_STATE_EOF(SC_EPILOGUE): -#line 644 "scan-gram.l" +#line 677 "scan-gram.l" { STRING_FINISH; loc->start = code_start; @@ -2214,44 +2264,44 @@ case YY_STATE_EOF(SC_EPILOGUE): `-----------------------------------------*/ -case 100: -YY_RULE_SETUP -#line 660 "scan-gram.l" -obstack_sgrow (&obstack_for_string, "$]["); - YY_BREAK -case 101: -YY_RULE_SETUP -#line 661 "scan-gram.l" -obstack_sgrow (&obstack_for_string, "@@"); - YY_BREAK -case 102: -YY_RULE_SETUP -#line 662 "scan-gram.l" -obstack_sgrow (&obstack_for_string, "@{"); - YY_BREAK case 103: YY_RULE_SETUP -#line 663 "scan-gram.l" +#line 693 "scan-gram.l" +obstack_sgrow (&obstack_for_string, "$]["); + YY_BREAK +case 104: +YY_RULE_SETUP +#line 694 "scan-gram.l" +obstack_sgrow (&obstack_for_string, "@@"); + YY_BREAK +case 105: +YY_RULE_SETUP +#line 695 "scan-gram.l" +obstack_sgrow (&obstack_for_string, "@{"); + YY_BREAK +case 106: +YY_RULE_SETUP +#line 696 "scan-gram.l" obstack_sgrow (&obstack_for_string, "@}"); YY_BREAK /*-----------------------------------------------------. | By default, grow the string obstack with the input. | `-----------------------------------------------------*/ -case 104: -#line 672 "scan-gram.l" -case 105: -/* rule 105 can match eol */ +case 107: +#line 705 "scan-gram.l" +case 108: +/* rule 108 can match eol */ YY_RULE_SETUP -#line 672 "scan-gram.l" +#line 705 "scan-gram.l" STRING_GROW; YY_BREAK -case 106: +case 109: YY_RULE_SETUP -#line 674 "scan-gram.l" +#line 707 "scan-gram.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2255 "scan-gram.c" +#line 2305 "scan-gram.c" case YY_END_OF_BUFFER: { @@ -2547,7 +2597,7 @@ static int yy_get_next_buffer (void) for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { /* %% [16.0] code to find the next state goes here */ - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 57); + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 58); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2556,7 +2606,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 455 ) + if ( yy_current_state >= 461 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2580,7 +2630,7 @@ static int yy_get_next_buffer (void) /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ register char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 57; + register YY_CHAR yy_c = 58; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2589,11 +2639,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 455 ) + if ( yy_current_state >= 461 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 454); + yy_is_jam = (yy_current_state == 460); return yy_is_jam ? 0 : yy_current_state; } @@ -3306,7 +3356,7 @@ void gram_free (void * ptr ) #undef YY_DECL_IS_OURS #undef YY_DECL #endif -#line 674 "scan-gram.l" +#line 707 "scan-gram.l" @@ -3315,6 +3365,29 @@ void gram_free (void * ptr ) semantic actions of this grammar. */ int max_left_semantic_context = 0; +/* If BUF is null, add BUFSIZE (which in this case must be less than + INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to + COLUMN. If an overflow occurs, or might occur but is undetectable, + return INT_MAX. Assume COLUMN is nonnegative. */ + +static inline int +add_column_width (int column, char const *buf, size_t bufsize) +{ + size_t width; + unsigned int remaining_columns = INT_MAX - column; + + if (buf) + { + if (INT_MAX / 2 <= bufsize) + return INT_MAX; + width = mbsnwidth (buf, bufsize, 0); + } + else + width = bufsize; + + return width <= remaining_columns ? column + width : INT_MAX; +} + /* Set *LOC and adjust scanner cursor to account for token TOKEN of size SIZE. */ @@ -3333,22 +3406,30 @@ adjust_location (location *loc, char const *token, size_t size) switch (*p) { case '\n': - line++; + line += line < INT_MAX; column = 1; p0 = p + 1; break; case '\t': - column += mbsnwidth (p0, p - p0, 0); - column += 8 - ((column - 1) & 7); + column = add_column_width (column, p0, p - p0); + column = add_column_width (column, NULL, 8 - ((column - 1) & 7)); p0 = p + 1; break; + + default: + break; } scanner_cursor.line = line; - scanner_cursor.column = column + mbsnwidth (p0, p - p0, 0); + scanner_cursor.column = column = add_column_width (column, p0, p - p0); loc->end = scanner_cursor; + + if (line == INT_MAX && loc->start.line != INT_MAX) + warn_at (*loc, _("line number overflow")); + if (column == INT_MAX && loc->start.column != INT_MAX) + warn_at (*loc, _("column number overflow")); } @@ -3437,19 +3518,18 @@ handle_action_dollar (char *text, location loc) type_name = ""; obstack_fgrow1 (&obstack_for_string, "]b4_lhs_value([%s])[", type_name); + current_rule->used = true; } else { - long int num; - set_errno (0); - num = strtol (cp, 0, 10); + long int num = strtol (cp, NULL, 10); - if (INT_MIN <= num && num <= rule_length && ! get_errno ()) + if (1 - INT_MAX + rule_length <= num && num <= rule_length) { int n = num; - if (1-n > max_left_semantic_context) - max_left_semantic_context = 1-n; - if (!type_name && n > 0) + if (max_left_semantic_context < 1 - n) + max_left_semantic_context = 1 - n; + if (!type_name && 0 < n) type_name = symbol_list_n_type_name_get (current_rule, loc, n); if (!type_name && typed) complain_at (loc, _("$%d of `%s' has no declared type"), @@ -3459,6 +3539,7 @@ handle_action_dollar (char *text, location loc) obstack_fgrow3 (&obstack_for_string, "]b4_rhs_value(%d, %d, [%s])[", rule_length, n, type_name); + symbol_list_n_used_set (current_rule, n, true); } else complain_at (loc, _("integer out of range: %s"), quote (text)); @@ -3519,11 +3600,9 @@ handle_action_at (char *text, location loc) obstack_sgrow (&obstack_for_string, "]b4_lhs_location["); else { - long int num; - set_errno (0); - num = strtol (cp, 0, 10); + long int num = strtol (cp, NULL, 10); - if (INT_MIN <= num && num <= rule_length && ! get_errno ()) + if (1 - INT_MAX + rule_length <= num && num <= rule_length) { int n = num; obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[", @@ -3576,14 +3655,15 @@ handle_at (int token_type, char *text, location loc) static unsigned long int scan_integer (char const *number, int base, location loc) { - unsigned long int num; - set_errno (0); - num = strtoul (number, 0, base); - if (INT_MAX < num || get_errno ()) + verify (INT_MAX < ULONG_MAX); + unsigned long int num = strtoul (number, NULL, base); + + if (INT_MAX < num) { complain_at (loc, _("integer out of range: %s"), quote (number)); num = INT_MAX; } + return num; } @@ -3597,7 +3677,8 @@ scan_integer (char const *number, int base, location loc) static int convert_ucn_to_byte (char const *ucn) { - unsigned long int code = strtoul (ucn + 2, 0, 16); + verify (UCHAR_MAX <= INT_MAX); + unsigned long int code = strtoul (ucn + 2, NULL, 16); /* FIXME: Currently we assume Unicode-compatible unibyte characters on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes). On @@ -3649,18 +3730,34 @@ convert_ucn_to_byte (char const *ucn) `----------------------------------------------------------------*/ static void -handle_syncline (char *args) +handle_syncline (char *args, location loc) { - int lineno = strtol (args, &args, 10); - const char *file = NULL; - file = strchr (args, '"') + 1; - *strchr (file, '"') = 0; + char *after_num; + unsigned long int lineno = strtoul (args, &after_num, 10); + char *file = strchr (after_num, '"') + 1; + *strchr (file, '"') = '\0'; + if (INT_MAX <= lineno) + { + warn_at (loc, _("line number overflow")); + lineno = INT_MAX; + } scanner_cursor.file = current_file = uniqstr_new (file); scanner_cursor.line = lineno; scanner_cursor.column = 1; } +/*---------------------------------. +| Report a rule that is too long. | +`---------------------------------*/ + +static void +rule_length_overflow (location loc) +{ + fatal_at (loc, _("rule is too long")); +} + + /*----------------------------------------------------------------. | For a token or comment starting at START, report message MSGID, | | which should say that an end marker was found before | diff --git a/src/bin/bison/src/scan-gram.l b/src/bin/bison/src/scan-gram.l index 268df5efbd..1622a35bcd 100644 --- a/src/bin/bison/src/scan-gram.l +++ b/src/bin/bison/src/scan-gram.l @@ -1,6 +1,6 @@ /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -24,10 +24,14 @@ %option prefix="gram_" %{ +/* Work around a bug in flex 2.5.31. See Debian bug 333231 + . */ +#undef gram_wrap +#define gram_wrap() 1 + #include "system.h" #include -#include #include #include "complain.h" @@ -83,8 +87,11 @@ static size_t no_cr_read (FILE *, char *, size_t); static struct obstack obstack_for_string; /* A string representing the most recently saved token. */ -static char *last_string; +char *last_string; +/* The location of the most recently saved token, if it was a + BRACED_CODE token; otherwise, this has an unspecified value. */ +location last_braced_code_loc; #define STRING_GROW \ obstack_grow (&obstack_for_string, yytext, yyleng) @@ -112,9 +119,23 @@ scanner_last_string_free (void) Outside of well-formed rules, RULE_LENGTH has an undefined value. */ static int rule_length; +static void rule_length_overflow (location) __attribute__ ((__noreturn__)); + +/* Increment the rule length by one, checking for overflow. */ +static inline void +increment_rule_length (location loc) +{ + rule_length++; + + /* Don't allow rule_length == INT_MAX, since that might cause + confusion with strtol if INT_MAX == LONG_MAX. */ + if (rule_length == INT_MAX) + rule_length_overflow (loc); +} + static void handle_dollar (int token_type, char *cp, location loc); static void handle_at (int token_type, char *cp, location loc); -static void handle_syncline (char *args); +static void handle_syncline (char *, location); static unsigned long int scan_integer (char const *p, int base, location loc); static int convert_ucn_to_byte (char const *hex_text); static void unexpected_eof (boundary, char const *); @@ -185,7 +206,7 @@ splice (\\[ \f\t\v]*\n)* /* #line directives are not documented, and may be withdrawn or modified in future versions of Bison. */ ^"#line "{int}" \"".*"\"\n" { - handle_syncline (yytext + sizeof "#line " - 1); + handle_syncline (yytext + sizeof "#line " - 1, *loc); } } @@ -224,6 +245,7 @@ splice (\\[ \f\t\v]*\n)* "%prec" rule_length--; return PERCENT_PREC; "%printer" token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE; "%pure"[-_]"parser" return PERCENT_PURE_PARSER; + "%require" return PERCENT_REQUIRE; "%right" return PERCENT_RIGHT; "%skeleton" return PERCENT_SKELETON; "%start" return PERCENT_START; @@ -246,7 +268,7 @@ splice (\\[ \f\t\v]*\n)* {id} { val->symbol = symbol_get (yytext, *loc); id_loc = *loc; - rule_length++; + increment_rule_length (*loc); BEGIN SC_AFTER_IDENTIFIER; } @@ -270,6 +292,8 @@ splice (\\[ \f\t\v]*\n)* /* Code in between braces. */ "{" { + if (current_rule && current_rule->action) + grammar_midrule_action (); STRING_GROW; token_type = BRACED_CODE; braces_level = 0; @@ -377,7 +401,7 @@ splice (\\[ \f\t\v]*\n)* STRING_FINISH; loc->start = token_start; val->chars = last_string; - rule_length++; + increment_rule_length (*loc); BEGIN INITIAL; return STRING; } @@ -400,11 +424,11 @@ splice (\\[ \f\t\v]*\n)* val->symbol = symbol_get (quotearg_style (escape_quoting_style, last_string), *loc); - symbol_class_set (val->symbol, token_sym, *loc); + symbol_class_set (val->symbol, token_sym, *loc, false); last_string_1 = last_string[1]; symbol_user_token_number_set (val->symbol, last_string_1, *loc); STRING_FREE; - rule_length++; + increment_rule_length (*loc); BEGIN INITIAL; return ID; } @@ -425,7 +449,7 @@ splice (\\[ \f\t\v]*\n)* { \\[0-7]{1,3} { - unsigned long int c = strtoul (yytext + 1, 0, 8); + unsigned long int c = strtoul (yytext + 1, NULL, 8); if (UCHAR_MAX < c) complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext)); else if (! c) @@ -435,10 +459,9 @@ splice (\\[ \f\t\v]*\n)* } \\x[0-9abcdefABCDEF]+ { - unsigned long int c; - set_errno (0); - c = strtoul (yytext + 2, 0, 16); - if (UCHAR_MAX < c || get_errno ()) + verify (UCHAR_MAX < ULONG_MAX); + unsigned long int c = strtoul (yytext + 2, NULL, 16); + if (UCHAR_MAX < c) complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext)); else if (! c) complain_at (*loc, _("invalid null character: %s"), quote (yytext)); @@ -597,9 +620,10 @@ splice (\\[ \f\t\v]*\n)* if (outer_brace) { STRING_FINISH; - rule_length++; loc->start = code_start; val->chars = last_string; + increment_rule_length (*loc); + last_braced_code_loc = *loc; BEGIN INITIAL; return token_type; } @@ -612,6 +636,15 @@ splice (\\[ \f\t\v]*\n)* "$"("<"{tag}">")?(-?[0-9]+|"$") handle_dollar (token_type, yytext, *loc); "@"(-?[0-9]+|"$") handle_at (token_type, yytext, *loc); + "$" { + warn_at (*loc, _("stray `$'")); + obstack_sgrow (&obstack_for_string, "$]["); + } + "@" { + warn_at (*loc, _("stray `@'")); + obstack_sgrow (&obstack_for_string, "@@"); + } + <> unexpected_eof (code_start, "}"); BEGIN INITIAL; } @@ -678,6 +711,29 @@ splice (\\[ \f\t\v]*\n)* semantic actions of this grammar. */ int max_left_semantic_context = 0; +/* If BUF is null, add BUFSIZE (which in this case must be less than + INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to + COLUMN. If an overflow occurs, or might occur but is undetectable, + return INT_MAX. Assume COLUMN is nonnegative. */ + +static inline int +add_column_width (int column, char const *buf, size_t bufsize) +{ + size_t width; + unsigned int remaining_columns = INT_MAX - column; + + if (buf) + { + if (INT_MAX / 2 <= bufsize) + return INT_MAX; + width = mbsnwidth (buf, bufsize, 0); + } + else + width = bufsize; + + return width <= remaining_columns ? column + width : INT_MAX; +} + /* Set *LOC and adjust scanner cursor to account for token TOKEN of size SIZE. */ @@ -696,22 +752,30 @@ adjust_location (location *loc, char const *token, size_t size) switch (*p) { case '\n': - line++; + line += line < INT_MAX; column = 1; p0 = p + 1; break; case '\t': - column += mbsnwidth (p0, p - p0, 0); - column += 8 - ((column - 1) & 7); + column = add_column_width (column, p0, p - p0); + column = add_column_width (column, NULL, 8 - ((column - 1) & 7)); p0 = p + 1; break; + + default: + break; } scanner_cursor.line = line; - scanner_cursor.column = column + mbsnwidth (p0, p - p0, 0); + scanner_cursor.column = column = add_column_width (column, p0, p - p0); loc->end = scanner_cursor; + + if (line == INT_MAX && loc->start.line != INT_MAX) + warn_at (*loc, _("line number overflow")); + if (column == INT_MAX && loc->start.column != INT_MAX) + warn_at (*loc, _("column number overflow")); } @@ -800,19 +864,18 @@ handle_action_dollar (char *text, location loc) type_name = ""; obstack_fgrow1 (&obstack_for_string, "]b4_lhs_value([%s])[", type_name); + current_rule->used = true; } else { - long int num; - set_errno (0); - num = strtol (cp, 0, 10); + long int num = strtol (cp, NULL, 10); - if (INT_MIN <= num && num <= rule_length && ! get_errno ()) + if (1 - INT_MAX + rule_length <= num && num <= rule_length) { int n = num; - if (1-n > max_left_semantic_context) - max_left_semantic_context = 1-n; - if (!type_name && n > 0) + if (max_left_semantic_context < 1 - n) + max_left_semantic_context = 1 - n; + if (!type_name && 0 < n) type_name = symbol_list_n_type_name_get (current_rule, loc, n); if (!type_name && typed) complain_at (loc, _("$%d of `%s' has no declared type"), @@ -822,6 +885,7 @@ handle_action_dollar (char *text, location loc) obstack_fgrow3 (&obstack_for_string, "]b4_rhs_value(%d, %d, [%s])[", rule_length, n, type_name); + symbol_list_n_used_set (current_rule, n, true); } else complain_at (loc, _("integer out of range: %s"), quote (text)); @@ -882,11 +946,9 @@ handle_action_at (char *text, location loc) obstack_sgrow (&obstack_for_string, "]b4_lhs_location["); else { - long int num; - set_errno (0); - num = strtol (cp, 0, 10); + long int num = strtol (cp, NULL, 10); - if (INT_MIN <= num && num <= rule_length && ! get_errno ()) + if (1 - INT_MAX + rule_length <= num && num <= rule_length) { int n = num; obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[", @@ -939,14 +1001,15 @@ handle_at (int token_type, char *text, location loc) static unsigned long int scan_integer (char const *number, int base, location loc) { - unsigned long int num; - set_errno (0); - num = strtoul (number, 0, base); - if (INT_MAX < num || get_errno ()) + verify (INT_MAX < ULONG_MAX); + unsigned long int num = strtoul (number, NULL, base); + + if (INT_MAX < num) { complain_at (loc, _("integer out of range: %s"), quote (number)); num = INT_MAX; } + return num; } @@ -960,7 +1023,8 @@ scan_integer (char const *number, int base, location loc) static int convert_ucn_to_byte (char const *ucn) { - unsigned long int code = strtoul (ucn + 2, 0, 16); + verify (UCHAR_MAX <= INT_MAX); + unsigned long int code = strtoul (ucn + 2, NULL, 16); /* FIXME: Currently we assume Unicode-compatible unibyte characters on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes). On @@ -1012,18 +1076,34 @@ convert_ucn_to_byte (char const *ucn) `----------------------------------------------------------------*/ static void -handle_syncline (char *args) +handle_syncline (char *args, location loc) { - int lineno = strtol (args, &args, 10); - const char *file = NULL; - file = strchr (args, '"') + 1; - *strchr (file, '"') = 0; + char *after_num; + unsigned long int lineno = strtoul (args, &after_num, 10); + char *file = strchr (after_num, '"') + 1; + *strchr (file, '"') = '\0'; + if (INT_MAX <= lineno) + { + warn_at (loc, _("line number overflow")); + lineno = INT_MAX; + } scanner_cursor.file = current_file = uniqstr_new (file); scanner_cursor.line = lineno; scanner_cursor.column = 1; } +/*---------------------------------. +| Report a rule that is too long. | +`---------------------------------*/ + +static void +rule_length_overflow (location loc) +{ + fatal_at (loc, _("rule is too long")); +} + + /*----------------------------------------------------------------. | For a token or comment starting at START, report message MSGID, | | which should say that an end marker was found before | diff --git a/src/bin/bison/src/scan-skel.c b/src/bin/bison/src/scan-skel.c index 303b7a9008..f2dd18c980 100644 --- a/src/bin/bison/src/scan-skel.c +++ b/src/bin/bison/src/scan-skel.c @@ -429,8 +429,8 @@ static void yy_fatal_error (yyconst char msg[] ); (yy_c_buf_p) = yy_cp; /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ -#define YY_NUM_RULES 12 -#define YY_END_OF_BUFFER 13 +#define YY_NUM_RULES 13 +#define YY_END_OF_BUFFER 14 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -438,14 +438,15 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[58] = +static yyconst flex_int16_t yy_accept[69] = { 0, - 0, 0, 13, 11, 10, 9, 11, 9, 2, 9, - 3, 4, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 6, 5, 9, 9, 9, 9, - 1, 0, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 8, 7, 0 + 0, 0, 14, 12, 11, 10, 12, 10, 2, 10, + 10, 3, 4, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 6, 5, 10, 10, 10, 10, 10, 10, 1, 0, + 10, 10, 10, 10, 10, 10, 10, 10, 7, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 9, 8, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -462,8 +463,8 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 5, 1, 6, 1, 1, 7, 8, 9, 1, 10, 11, 1, 1, 12, 13, 14, - 15, 16, 1, 17, 18, 19, 20, 1, 1, 1, - 1, 1, 21, 1, 22, 1, 1, 1, 1, 1, + 15, 16, 1, 17, 18, 19, 20, 1, 1, 21, + 1, 1, 22, 1, 23, 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, @@ -480,73 +481,79 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[23] = +static yyconst flex_int32_t yy_meta[24] = { 0, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1 + 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[63] = +static yyconst flex_int16_t yy_base[74] = { 0, - 0, 1, 37, 0, 123, 2, 0, 4, 123, 23, - 123, 123, 42, 11, 0, 1, 4, 5, 20, 22, - 9, 3, 30, 28, 123, 123, 37, 63, 39, 84, - 123, 7, 43, 46, 50, 49, 51, 57, 61, 62, - 60, 63, 71, 76, 78, 79, 72, 85, 25, 84, - 90, 91, 96, 99, 123, 123, 123, 110, 0, 113, - 116, 119 + 0, 1, 107, 0, 138, 2, 0, 4, 138, 24, + 39, 138, 138, 1, 63, 45, 0, 2, 3, 9, + 5, 18, 22, 28, 11, 21, 33, 38, 34, 32, + 138, 138, 49, 46, 59, 54, 30, 81, 138, 8, + 58, 56, 47, 65, 61, 69, 68, 66, 138, 78, + 79, 77, 80, 87, 88, 91, 95, 89, 90, 97, + 100, 104, 106, 112, 114, 138, 138, 138, 125, 0, + 128, 131, 134 } ; -static yyconst flex_int16_t yy_def[63] = +static yyconst flex_int16_t yy_def[74] = { 0, - 58, 58, 57, 59, 57, 60, 59, 60, 57, 60, - 57, 57, 60, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 57, 57, 13, 61, 13, 61, - 57, 62, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 57, 57, 0, 57, 57, 57, - 57, 57 + 69, 69, 68, 70, 68, 71, 70, 71, 68, 71, + 10, 68, 68, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 68, 68, 10, 10, 72, 10, 10, 72, 68, 73, + 10, 10, 10, 10, 10, 10, 10, 10, 68, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 68, 68, 0, 68, 68, + 68, 68, 68 } ; -static yyconst flex_int16_t yy_nxt[146] = +static yyconst flex_int16_t yy_nxt[162] = { 0, - 7, 5, 5, 6, 6, 9, 25, 57, 31, 57, - 8, 8, 19, 8, 8, 8, 10, 20, 18, 8, - 21, 17, 11, 12, 57, 57, 57, 22, 24, 23, - 8, 13, 8, 26, 14, 8, 57, 51, 8, 28, - 8, 29, 15, 57, 57, 57, 27, 8, 33, 8, - 35, 36, 16, 8, 34, 37, 8, 39, 57, 8, - 8, 8, 57, 57, 31, 38, 32, 8, 41, 42, - 8, 8, 8, 8, 40, 45, 43, 49, 57, 44, - 46, 8, 8, 32, 32, 31, 8, 32, 8, 8, - 50, 47, 48, 57, 8, 8, 52, 53, 54, 55, + 7, 5, 5, 6, 6, 9, 22, 68, 10, 39, + 8, 8, 8, 8, 23, 8, 11, 18, 21, 8, + 25, 8, 24, 12, 13, 68, 68, 68, 8, 27, + 29, 8, 8, 26, 14, 28, 31, 30, 8, 34, + 43, 32, 8, 8, 8, 68, 68, 15, 8, 8, + 16, 35, 33, 36, 37, 20, 8, 8, 17, 8, + 39, 45, 40, 41, 8, 44, 8, 46, 8, 42, + 47, 8, 49, 19, 50, 8, 8, 48, 8, 8, + 40, 40, 39, 51, 40, 52, 53, 8, 8, 8, + 8, 56, 57, 54, 60, 61, 55, 8, 8, 8, - 8, 8, 56, 57, 32, 32, 8, 57, 57, 8, - 4, 4, 4, 8, 57, 8, 30, 30, 30, 32, - 32, 32, 3, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57 + 8, 8, 40, 40, 58, 8, 68, 8, 59, 62, + 8, 64, 63, 65, 8, 66, 8, 67, 68, 68, + 68, 68, 8, 68, 8, 4, 4, 4, 8, 68, + 8, 38, 38, 38, 40, 40, 40, 3, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68 } ; -static yyconst flex_int16_t yy_chk[146] = +static yyconst flex_int16_t yy_chk[162] = { 0, - 59, 1, 2, 1, 2, 6, 22, 8, 32, 0, - 15, 16, 16, 22, 17, 18, 6, 17, 15, 21, - 18, 14, 6, 6, 8, 8, 10, 19, 21, 20, - 19, 10, 20, 23, 10, 49, 3, 49, 24, 27, - 23, 27, 10, 10, 10, 13, 24, 27, 29, 29, - 33, 34, 13, 33, 29, 35, 34, 37, 0, 36, - 35, 37, 13, 13, 28, 36, 28, 38, 39, 40, - 41, 39, 40, 42, 38, 43, 41, 47, 0, 42, - 44, 43, 47, 28, 28, 30, 44, 30, 45, 46, - 48, 45, 46, 0, 50, 48, 50, 51, 52, 53, + 70, 1, 2, 1, 2, 6, 18, 8, 6, 40, + 17, 14, 18, 19, 19, 21, 6, 14, 17, 20, + 21, 25, 20, 6, 6, 8, 8, 10, 22, 23, + 25, 26, 23, 22, 10, 24, 27, 26, 24, 30, + 37, 28, 30, 27, 29, 10, 10, 11, 28, 11, + 11, 33, 29, 33, 34, 16, 34, 43, 11, 33, + 35, 42, 35, 36, 36, 41, 42, 43, 41, 36, + 44, 45, 46, 15, 47, 44, 48, 45, 47, 46, + 35, 35, 38, 48, 38, 50, 51, 52, 50, 51, + 53, 54, 55, 52, 58, 59, 53, 54, 55, 58, - 51, 52, 54, 0, 30, 30, 53, 0, 0, 54, - 58, 58, 58, 60, 0, 60, 61, 61, 61, 62, - 62, 62, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57 + 59, 56, 38, 38, 56, 57, 3, 60, 57, 60, + 61, 62, 61, 63, 62, 64, 63, 65, 0, 0, + 0, 0, 64, 0, 65, 69, 69, 69, 71, 0, + 71, 72, 72, 72, 73, 73, 73, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68 } ; static yy_state_type yy_last_accepting_state; @@ -555,10 +562,10 @@ static char *yy_last_accepting_cpos; extern int skel__flex_debug; int skel__flex_debug = 1; -static yyconst flex_int16_t yy_rule_linenum[12] = +static yyconst flex_int16_t yy_rule_linenum[13] = { 0, - 47, 71, 72, 73, 75, 76, 77, 78, 81, 82, - 83 + 70, 97, 98, 99, 101, 102, 103, 104, 105, 108, + 109, 110 } ; /* The intent behind this definition is that it'll catch @@ -572,7 +579,8 @@ char *skel_text; #line 1 "scan-skel.l" /* Scan Bison Skeletons. -*- C -*- - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -590,7 +598,12 @@ char *skel_text; along with Bison; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#line 26 "scan-skel.l" +#line 27 "scan-skel.l" +/* Work around a bug in flex 2.5.31. See Debian bug 333231 + . */ +#undef skel_wrap +#define skel_wrap() 1 + #include "system.h" #include @@ -601,10 +614,27 @@ char *skel_text; #include "files.h" #include "scan-skel.h" -#define QPUTS(String) \ - fputs (quotearg_style (c_quoting_style, (String)), skel_out) +/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ +int skel_lex (void); +int skel_get_lineno (void); +FILE *skel_get_in (void); +FILE *skel_get_out (void); +int skel_get_leng (void); +char *skel_get_text (void); +void skel_set_lineno (int); +void skel_set_in (FILE *); +void skel_set_out (FILE *); +int skel_get_debug (void); +void skel_set_debug (int); +int skel_lex_destroy (void); -#line 608 "scan-skel.c" +#define QPUTS(String) \ + fputs (quotearg_style (c_quoting_style, String), skel_out) + +#define BASE_QPUTS(File) \ + QPUTS (base_name (File)) + +#line 638 "scan-skel.c" #define INITIAL 0 @@ -809,7 +839,7 @@ YY_DECL register int yy_act; /* %% [7.0] user's declarations go here */ -#line 40 "scan-skel.l" +#line 63 "scan-skel.l" @@ -817,7 +847,7 @@ YY_DECL char *outname = NULL; -#line 821 "scan-skel.c" +#line 851 "scan-skel.c" if ( (yy_init) ) { @@ -880,13 +910,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 58 ) + if ( yy_current_state >= 69 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 57 ); + while ( yy_current_state != 68 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -905,13 +935,13 @@ do_action: /* This label is used only to access EOF actions. */ { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 12 ) + else if ( yy_act < 13 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], skel_text ); - else if ( yy_act == 12 ) + else if ( yy_act == 13 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", skel_text ); - else if ( yy_act == 13 ) + else if ( yy_act == 14 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); @@ -930,11 +960,15 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 47 "scan-skel.l" +#line 70 "scan-skel.l" { char const *file_name = skel_text + sizeof "@output " - 1; skel_text[skel_leng - 1] = '\0'; + /* Decode special file names. They include the directory part, + contrary to their "free" occurrences, used for issuing #includes, + which must not include the directory part. */ + if (*file_name == '@') { if (strcmp (file_name, "@output_header_name@") == 0) @@ -944,7 +978,6 @@ YY_RULE_SETUP else fatal ("invalid token in skeleton: %s", skel_text); } - if (outname) { free (outname); @@ -957,58 +990,63 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 71 "scan-skel.l" +#line 97 "scan-skel.l" fputc ('@', skel_out); YY_BREAK case 3: YY_RULE_SETUP -#line 72 "scan-skel.l" +#line 98 "scan-skel.l" fputc ('[', skel_out); YY_BREAK case 4: YY_RULE_SETUP -#line 73 "scan-skel.l" +#line 99 "scan-skel.l" fputc (']', skel_out); YY_BREAK case 5: YY_RULE_SETUP -#line 75 "scan-skel.l" +#line 101 "scan-skel.l" fprintf (skel_out, "%d", lineno + 1); YY_BREAK case 6: YY_RULE_SETUP -#line 76 "scan-skel.l" +#line 102 "scan-skel.l" QPUTS (outname); YY_BREAK case 7: YY_RULE_SETUP -#line 77 "scan-skel.l" -QPUTS (parser_file_name); +#line 103 "scan-skel.l" +QPUTS (dir_prefix); YY_BREAK case 8: YY_RULE_SETUP -#line 78 "scan-skel.l" -QPUTS (spec_defines_file); +#line 104 "scan-skel.l" +BASE_QPUTS (parser_file_name); YY_BREAK -/* This pattern must not match more than the previous @ patterns. */ case 9: YY_RULE_SETUP -#line 81 "scan-skel.l" +#line 105 "scan-skel.l" +BASE_QPUTS (spec_defines_file); + YY_BREAK +/* This pattern must not match more than the previous @ patterns. */ +case 10: +YY_RULE_SETUP +#line 108 "scan-skel.l" fatal ("invalid @ in skeleton: %s", skel_text); YY_BREAK -case 10: -/* rule 10 can match eol */ +case 11: +/* rule 11 can match eol */ YY_RULE_SETUP -#line 82 "scan-skel.l" +#line 109 "scan-skel.l" lineno++; ECHO; YY_BREAK -case 11: +case 12: YY_RULE_SETUP -#line 83 "scan-skel.l" +#line 110 "scan-skel.l" ECHO; YY_BREAK case YY_STATE_EOF(INITIAL): -#line 85 "scan-skel.l" +#line 112 "scan-skel.l" { if (outname) { @@ -1018,12 +1056,12 @@ case YY_STATE_EOF(INITIAL): return EOF; } YY_BREAK -case 12: +case 13: YY_RULE_SETUP -#line 93 "scan-skel.l" +#line 120 "scan-skel.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1027 "scan-skel.c" +#line 1065 "scan-skel.c" case YY_END_OF_BUFFER: { @@ -1327,7 +1365,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 58 ) + if ( yy_current_state >= 69 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1360,11 +1398,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 58 ) + if ( yy_current_state >= 69 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 57); + yy_is_jam = (yy_current_state == 68); return yy_is_jam ? 0 : yy_current_state; } @@ -2076,7 +2114,7 @@ void skel_free (void * ptr ) #undef YY_DECL_IS_OURS #undef YY_DECL #endif -#line 93 "scan-skel.l" +#line 120 "scan-skel.l" diff --git a/src/bin/bison/src/scan-skel.h b/src/bin/bison/src/scan-skel.h index c5b19eaced..a7e14c38d1 100644 --- a/src/bin/bison/src/scan-skel.h +++ b/src/bin/bison/src/scan-skel.h @@ -1,6 +1,6 @@ /* Scan Bison Skeletons. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -26,16 +26,3 @@ extern FILE *skel_in; extern FILE *skel_out; extern int skel__flex_debug; extern int skel_lineno; - -/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ -int skel_get_lineno (void); -FILE *skel_get_in (void); -FILE *skel_get_out (void); -int skel_get_leng (void); -char *skel_get_text (void); -void skel_set_lineno (int); -void skel_set_in (FILE *); -void skel_set_out (FILE *); -int skel_get_debug (void); -void skel_set_debug (int); -int skel_lex_destroy (void); diff --git a/src/bin/bison/src/scan-skel.l b/src/bin/bison/src/scan-skel.l index 7474c7f1b1..edccceca54 100644 --- a/src/bin/bison/src/scan-skel.l +++ b/src/bin/bison/src/scan-skel.l @@ -1,6 +1,7 @@ /* Scan Bison Skeletons. -*- C -*- - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -23,6 +24,11 @@ %option prefix="skel_" %{ +/* Work around a bug in flex 2.5.31. See Debian bug 333231 + . */ +#undef skel_wrap +#define skel_wrap() 1 + #include "system.h" #include @@ -33,8 +39,25 @@ #include "files.h" #include "scan-skel.h" +/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ +int skel_lex (void); +int skel_get_lineno (void); +FILE *skel_get_in (void); +FILE *skel_get_out (void); +int skel_get_leng (void); +char *skel_get_text (void); +void skel_set_lineno (int); +void skel_set_in (FILE *); +void skel_set_out (FILE *); +int skel_get_debug (void); +void skel_set_debug (int); +int skel_lex_destroy (void); + #define QPUTS(String) \ - fputs (quotearg_style (c_quoting_style, (String)), yyout) + fputs (quotearg_style (c_quoting_style, String), yyout) + +#define BASE_QPUTS(File) \ + QPUTS (base_name (File)) %} %% @@ -48,6 +71,10 @@ char const *file_name = yytext + sizeof "@output " - 1; yytext[yyleng - 1] = '\0'; + /* Decode special file names. They include the directory part, + contrary to their "free" occurrences, used for issuing #includes, + which must not include the directory part. */ + if (*file_name == '@') { if (strcmp (file_name, "@output_header_name@") == 0) @@ -57,7 +84,6 @@ else fatal ("invalid token in skeleton: %s", yytext); } - if (outname) { free (outname); @@ -74,8 +100,9 @@ "@oline@" fprintf (yyout, "%d", lineno + 1); "@ofile@" QPUTS (outname); -"@output_parser_name@" QPUTS (parser_file_name); -"@output_header_name@" QPUTS (spec_defines_file); +"@dir_prefix@" QPUTS (dir_prefix); +"@output_parser_name@" BASE_QPUTS (parser_file_name); +"@output_header_name@" BASE_QPUTS (spec_defines_file); /* This pattern must not match more than the previous @ patterns. */ @[^{}@\n]* fatal ("invalid @ in skeleton: %s", yytext); diff --git a/src/bin/bison/src/state.c b/src/bin/bison/src/state.c index 89d0c870b5..4eb39f9f6c 100644 --- a/src/bin/bison/src/state.c +++ b/src/bin/bison/src/state.c @@ -1,6 +1,7 @@ /* Type definitions for nondeterministic finite state machine for Bison. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -19,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -58,10 +59,12 @@ state * transitions_to (transitions *shifts, symbol_number sym) { int j; - for (j = 0; j < shifts->num; j++) - if (TRANSITION_SYMBOL (shifts, j) == sym) - return shifts->states[j]; - abort (); + for (j = 0; ; j++) + { + assert (j < shifts->num); + if (TRANSITION_SYMBOL (shifts, j) == sym) + return shifts->states[j]; + } } @@ -132,8 +135,7 @@ state_new (symbol_number accessing_symbol, state *res; size_t items_size = nitems * sizeof *core; - if (STATE_NUMBER_MAXIMUM <= nstates) - abort (); + assert (nstates < STATE_NUMBER_MAXIMUM); res = xmalloc (offsetof (state, items) + items_size); res->number = nstates++; @@ -174,8 +176,7 @@ state_free (state *s) void state_transitions_set (state *s, int num, state **trans) { - if (s->transitions) - abort (); + assert (!s->transitions); s->transitions = transitions_new (num, trans); } @@ -187,8 +188,7 @@ state_transitions_set (state *s, int num, state **trans) void state_reductions_set (state *s, int num, rule **reds) { - if (s->reductions) - abort (); + assert (!s->reductions); s->reductions = reductions_new (num, reds); } @@ -212,8 +212,7 @@ state_reduction_find (state *s, rule *r) void state_errs_set (state *s, int num, symbol **tokens) { - if (s->errs) - abort (); + assert (!s->errs); s->errs = errs_new (num, tokens); } @@ -248,9 +247,9 @@ state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out) } -/*----------------------. +/*---------------------. | A state hash table. | -`----------------------*/ +`---------------------*/ /* Initial capacity of states hash table. */ #define HT_INITIAL_CAPACITY 257 diff --git a/src/bin/bison/src/symlist.c b/src/bin/bison/src/symlist.c index 106db46cb2..70db82f07c 100644 --- a/src/bin/bison/src/symlist.c +++ b/src/bin/bison/src/symlist.c @@ -1,6 +1,6 @@ /* Lists of symbols for Bison - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -19,6 +19,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include "complain.h" @@ -33,13 +34,21 @@ symbol_list * symbol_list_new (symbol *sym, location loc) { symbol_list *res = xmalloc (sizeof *res); - res->next = NULL; + res->sym = sym; res->location = loc; + + res->midrule = NULL; + res->action = NULL; + res->used = false; + res->ruleprec = NULL; res->dprec = 0; res->merger = 0; + + res->next = NULL; + return res; } @@ -49,13 +58,14 @@ symbol_list_new (symbol *sym, location loc) `------------------*/ void -symbol_list_print (symbol_list *l, FILE *f) +symbol_list_print (const symbol_list *l, FILE *f) { for (/* Nothing. */; l && l->sym; l = l->next) { symbol_print (l->sym, f); + fprintf (stderr, l->used ? " used" : " unused"); if (l && l->sym) - fputc (' ', f); + fprintf (f, ", "); } } @@ -89,43 +99,64 @@ symbol_list_free (symbol_list *list) `--------------------*/ unsigned int -symbol_list_length (symbol_list *list) +symbol_list_length (const symbol_list *l) { int res = 0; - for (/* Nothing. */; list; list = list->next) + for (/* Nothing. */; l; l = l->next) ++res; return res; } -/*--------------------------------------------------------------. -| Get the data type (alternative in the union) of the value for | -| symbol N in symbol list RP. | -`--------------------------------------------------------------*/ +/*--------------------------------. +| Get symbol N in symbol list L. | +`--------------------------------*/ -uniqstr -symbol_list_n_type_name_get (symbol_list *rp, location loc, int n) +symbol_list * +symbol_list_n_get (symbol_list *l, int n) { int i; if (n < 0) + return NULL; + + for (i = 0; i < n; ++i) + { + l = l->next; + if (l == NULL || l->sym == NULL) + return NULL; + } + + return l; +} + + +/*--------------------------------------------------------------. +| Get the data type (alternative in the union) of the value for | +| symbol N in symbol list L. | +`--------------------------------------------------------------*/ + +uniqstr +symbol_list_n_type_name_get (symbol_list *l, location loc, int n) +{ + l = symbol_list_n_get (l, n); + if (!l) { complain_at (loc, _("invalid $ value: $%d"), n); return NULL; } - - i = 0; - - while (i < n) - { - rp = rp->next; - if (rp == NULL || rp->sym == NULL) - { - complain_at (loc, _("invalid $ value: $%d"), n); - return NULL; - } - ++i; - } - - return rp->sym->type_name; + return l->sym->type_name; +} + + +/*----------------------------------------. +| The symbol N in symbol list L is USED. | +`----------------------------------------*/ + +void +symbol_list_n_used_set (symbol_list *l, int n, bool used) +{ + l = symbol_list_n_get (l, n); + if (l) + l->used = used; } diff --git a/src/bin/bison/src/symlist.h b/src/bin/bison/src/symlist.h index e4714f6cdc..0423d016d1 100644 --- a/src/bin/bison/src/symlist.h +++ b/src/bin/bison/src/symlist.h @@ -25,19 +25,31 @@ # include "location.h" # include "symtab.h" +/* A list of symbols, used during the parsing to store the rules. */ typedef struct symbol_list { - struct symbol_list *next; + /* The symbol. */ symbol *sym; location location; + /* If this symbol is the generated lhs for a mid-rule, a pointer to + that mid-rule. */ + struct symbol_list *midrule; + /* The action is attached to the LHS of a rule. */ const char *action; location action_location; + /* Whether this symbol's value is used in the current action. */ + bool used; + + /* Precedence/associativity. */ symbol *ruleprec; int dprec; int merger; + + /* The list. */ + struct symbol_list *next; } symbol_list; @@ -45,21 +57,27 @@ typedef struct symbol_list symbol_list *symbol_list_new (symbol *sym, location loc); /* Print it. */ -void symbol_list_print (symbol_list *l, FILE *f); +void symbol_list_print (const symbol_list *l, FILE *f); /* Prepend SYM at LOC to the LIST. */ -symbol_list *symbol_list_prepend (symbol_list *list, +symbol_list *symbol_list_prepend (symbol_list *l, symbol *sym, location loc); /* Free the LIST, but not the symbols it contains. */ -void symbol_list_free (symbol_list *list); +void symbol_list_free (symbol_list *l); /* Return its length. */ -unsigned int symbol_list_length (symbol_list *list); +unsigned int symbol_list_length (const symbol_list *l); + +/* Get symbol N in symbol list L. */ +symbol_list *symbol_list_n_get (symbol_list *l, int n); /* Get the data type (alternative in the union) of the value for symbol N in rule RULE. */ -uniqstr symbol_list_n_type_name_get (symbol_list *rp, location loc, int n); +uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n); + +/* The symbol N in symbol list L is USED. */ +void symbol_list_n_used_set (symbol_list *l, int n, bool used); #endif /* !SYMLIST_H_ */ diff --git a/src/bin/bison/src/symtab.c b/src/bin/bison/src/symtab.c index 8cbfc54f6c..ef59c6eef7 100644 --- a/src/bin/bison/src/symtab.c +++ b/src/bin/bison/src/symtab.c @@ -1,7 +1,7 @@ /* Symbol table manager for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -65,6 +65,7 @@ symbol_new (uniqstr tag, location loc) res->alias = NULL; res->class = unknown_sym; + res->declared = false; if (nsyms == SYMBOL_NUMBER_MAXIMUM) fatal (_("too many symbols in input grammar (limit is %d)"), @@ -85,10 +86,15 @@ symbol_new (uniqstr tag, location loc) void symbol_print (symbol *s, FILE *f) { - fprintf (f, "\"%s\"", s->tag); - SYMBOL_ATTR_PRINT (type_name); - SYMBOL_ATTR_PRINT (destructor); - SYMBOL_ATTR_PRINT (printer); + if (s) + { + fprintf (f, "\"%s\"", s->tag); + SYMBOL_ATTR_PRINT (type_name); + SYMBOL_ATTR_PRINT (destructor); + SYMBOL_ATTR_PRINT (printer); + } + else + fprintf (f, ""); } #undef SYMBOL_ATTR_PRINT @@ -177,7 +183,7 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc) } /* Only terminals have a precedence. */ - symbol_class_set (sym, token_sym, loc); + symbol_class_set (sym, token_sym, loc, false); } @@ -186,10 +192,13 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc) `------------------------------------*/ void -symbol_class_set (symbol *sym, symbol_class class, location loc) +symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) { if (sym->class != unknown_sym && sym->class != class) - complain_at (loc, _("symbol %s redefined"), sym->tag); + { + complain_at (loc, _("symbol %s redefined"), sym->tag); + sym->declared = false; + } if (class == nterm_sym && sym->class != nterm_sym) sym->number = nvars++; @@ -197,6 +206,13 @@ symbol_class_set (symbol *sym, symbol_class class, location loc) sym->number = ntokens++; sym->class = class; + + if (declaring) + { + if (sym->declared) + warn_at (loc, _("symbol %s redeclared"), sym->tag); + sym->declared = true; + } } @@ -207,8 +223,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc) void symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) { - if (sym->class != token_sym) - abort (); + assert (sym->class == token_sym); if (sym->user_token_number != USER_NUMBER_UNDEFINED && sym->user_token_number != user_token_number) @@ -279,8 +294,7 @@ symbol_make_alias (symbol *sym, symbol *symval, location loc) /* sym and symval combined are only one symbol. */ nsyms--; ntokens--; - if (ntokens != sym->number && ntokens != symval->number) - abort (); + assert (ntokens == sym->number || ntokens == symval->number); sym->number = symval->number = (symval->number < sym->number) ? symval->number : sym->number; symbol_type_set (symval, sym->type_name, loc); @@ -373,8 +387,7 @@ symbol_pack (symbol *this) this->number = this->alias->number = 0; else { - if (this->alias->number == NUMBER_UNDEFINED) - abort (); + assert (this->alias->number != NUMBER_UNDEFINED); this->number = this->alias->number; } } @@ -383,10 +396,7 @@ symbol_pack (symbol *this) return true; } else /* this->class == token_sym */ - { - if (this->number == NUMBER_UNDEFINED) - abort (); - } + assert (this->number != NUMBER_UNDEFINED); symbols[this->number] = this; return true; diff --git a/src/bin/bison/src/symtab.h b/src/bin/bison/src/symtab.h index 0f87c224fc..0f852b7aa7 100644 --- a/src/bin/bison/src/symtab.h +++ b/src/bin/bison/src/symtab.h @@ -1,6 +1,6 @@ /* Definitions for symtab.c and callers, part of Bison. - Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2004, 2005 + Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -79,6 +79,7 @@ struct symbol identifier-symbol pair for an alias. */ symbol *alias; symbol_class class; + bool declared; }; /* Undefined user number. */ @@ -121,7 +122,8 @@ void symbol_printer_set (symbol *sym, const char *printer, location loc); void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc); /* Set the CLASS associated with SYM. */ -void symbol_class_set (symbol *sym, symbol_class class, location loc); +void symbol_class_set (symbol *sym, symbol_class class, location loc, + bool declaring); /* Set the USER_TOKEN_NUMBER associated with SYM. */ void symbol_user_token_number_set (symbol *sym, int user_number, location loc); diff --git a/src/bin/bison/src/system.h b/src/bin/bison/src/system.h index 755a75cb39..63157904fb 100644 --- a/src/bin/bison/src/system.h +++ b/src/bin/bison/src/system.h @@ -1,7 +1,7 @@ /* System-dependent definitions for Bison. - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software - Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free + Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,18 +20,28 @@ #ifndef BISON_SYSTEM_H #define BISON_SYSTEM_H -#if HAVE_CONFIG_H -# include +/* flex 2.5.31 gratutiously defines macros like INT8_MIN. But this + runs afoul of pre-C99 compilers that have or + , which are included below if available. It also runs + afoul of pre-C99 compilers that define these macros in . */ +#if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901 +# undef INT8_MIN +# undef INT16_MIN +# undef INT32_MIN +# undef INT8_MAX +# undef INT16_MAX +# undef UINT8_MAX +# undef INT32_MAX +# undef UINT16_MAX +# undef UINT32_MAX #endif #include #include -#include #include #include -/* Verify a requirement at compile-time (unlike assert, which is runtime). */ -#define verify(name, assertion) struct name {char name[(assertion) ? 1 : -1];} +#include "unlocked-io.h" #if HAVE_SYS_TYPES_H # include @@ -54,6 +64,7 @@ typedef size_t uintptr_t; #endif +#include #include @@ -63,6 +74,9 @@ typedef size_t uintptr_t; #include +/* From lib/basename.c. */ +char *base_name (char const *name); + /*-----------------. | GCC extensions. | @@ -78,8 +92,8 @@ typedef size_t uintptr_t; #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ -# if !defined (__GNUC__) || __GNUC__ < 2 || \ -(__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +# if (! defined __GNUC__ || __GNUC__ < 2 \ + || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__) # define __attribute__(Spec) /* empty */ # endif #endif @@ -200,6 +214,11 @@ do { \ } while (0) +/* Assertions. 's assertions are too heavyweight, and can + be disabled too easily, so implement it separately here. */ +#define assert(x) ((void) ((x) || (abort (), 0))) + + /*---------------------------------------------. | Debugging memory allocation (must be last). | `---------------------------------------------*/ diff --git a/src/bin/bison/src/tables.c b/src/bin/bison/src/tables.c index 4e99f4add9..c938139b2b 100644 --- a/src/bin/bison/src/tables.c +++ b/src/bin/bison/src/tables.c @@ -20,7 +20,7 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "system.h" #include @@ -202,16 +202,14 @@ conflict_row (state *s) && (actrow[j] != rule_number_as_item_number (reds->rules[i]->number))) { - if (conflict_list_free <= 0) - abort (); + assert (0 < conflict_list_free); conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1; conflict_list_cnt += 1; conflict_list_free -= 1; } /* Leave a 0 at the end. */ - if (conflict_list_free <= 0) - abort (); + assert (0 < conflict_list_free); conflict_list[conflict_list_cnt] = 0; conflict_list_cnt += 1; conflict_list_free -= 1; @@ -675,16 +673,14 @@ pack_vector (vector_number vector) base_number *to = tos[i]; unsigned int *conflict_to = conflict_tos[i]; - if (!t) - abort (); + assert (t); for (j = lowzero - from[0]; ; j++) { int k; bool ok = true; - if (table_size <= j) - abort (); + assert (j < table_size); for (k = 0; ok && k < t; k++) { @@ -717,8 +713,7 @@ pack_vector (vector_number vector) if (loc > high) high = loc; - if (! (BASE_MINIMUM <= j && j <= BASE_MAXIMUM)) - abort (); + assert (BASE_MINIMUM <= j && j <= BASE_MAXIMUM); return j; } } @@ -810,9 +805,8 @@ tables_generate (void) /* This is a poor way to make sure the sizes are properly correlated. In particular the signedness is not taken into account. But it's not useless. */ - verify (sizes_are_properly_correlated, - (sizeof nstates <= sizeof nvectors - && sizeof nvars <= sizeof nvectors)); + verify (sizeof nstates <= sizeof nvectors + && sizeof nvars <= sizeof nvectors); nvectors = state_number_as_int (nstates) + nvars; diff --git a/src/bin/bison/src/uniqstr.c b/src/bin/bison/src/uniqstr.c index f082f338b2..8804a80e0e 100644 --- a/src/bin/bison/src/uniqstr.c +++ b/src/bin/bison/src/uniqstr.c @@ -19,6 +19,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include diff --git a/src/bin/bison/src/vcg.c b/src/bin/bison/src/vcg.c index fa5133888b..25fbb64ec8 100644 --- a/src/bin/bison/src/vcg.c +++ b/src/bin/bison/src/vcg.c @@ -1,6 +1,7 @@ /* VCG description handler for Bison. - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -19,6 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include @@ -212,6 +214,7 @@ get_color_str (enum color color) { switch (color) { + default: abort (); case white: return "white"; case blue: return "blue"; case red: return "red"; @@ -244,7 +247,6 @@ get_color_str (enum color color) case orange: return "orange"; case orchid: return "orchid"; case black: return "black"; - default: abort (); return NULL; } } @@ -253,10 +255,10 @@ get_textmode_str (enum textmode textmode) { switch (textmode) { + default: abort (); case centered: return "center"; case left_justify: return "left_justify"; case right_justify: return "right_justify"; - default: abort (); return NULL; } } @@ -265,11 +267,11 @@ get_shape_str (enum shape shape) { switch (shape) { + default: abort (); case box: return "box"; case rhomb: return "rhomb"; case ellipse: return "ellipse"; case triangle: return "triangle"; - default: abort (); return NULL; } } @@ -278,9 +280,9 @@ get_decision_str (enum decision decision) { switch (decision) { + default: abort (); case no: return "no"; case yes: return "yes"; - default: abort (); return NULL; } } @@ -289,11 +291,11 @@ get_orientation_str (enum orientation orientation) { switch (orientation) { + default: abort (); case top_to_bottom: return "top_to_bottom"; case bottom_to_top: return "bottom_to_top"; case left_to_right: return "left_to_right"; case right_to_left: return "right_to_left"; - default: abort (); return NULL; } } @@ -302,10 +304,10 @@ get_node_alignment_str (enum alignment alignment) { switch (alignment) { + default: abort (); case center: return "center"; case top: return "top"; case bottom: return "bottom"; - default: abort (); return NULL; } } @@ -314,9 +316,9 @@ get_arrow_mode_str (enum arrow_mode arrow_mode) { switch (arrow_mode) { + default: abort (); case fixed: return "fixed"; case free_a: return "free"; - default: abort (); return NULL; } } @@ -325,11 +327,11 @@ get_crossing_type_str (enum crossing_type crossing_type) { switch (crossing_type) { + default: abort (); case bary: return "bary"; case median: return "median"; case barymedian: return "barymedian"; case medianbary: return "medianbary"; - default: abort (); return NULL; } } @@ -340,11 +342,11 @@ get_view_str (enum view view) so it is an error here if view == normal_view. */ switch (view) { + default: abort (); case cfish: return "cfish"; case pfish: return "pfish"; case fcfish: return "fcfish"; case fpfish: return "fpfish"; - default: abort (); return NULL; } } @@ -353,11 +355,11 @@ get_linestyle_str (enum linestyle linestyle) { switch (linestyle) { + default: abort (); case continuous: return "continuous"; case dashed: return "dashed"; case dotted: return "dotted"; case invisible: return "invisible"; - default: abort (); return NULL; } } @@ -366,10 +368,10 @@ get_arrowstyle_str (enum arrowstyle arrowstyle) { switch (arrowstyle) { + default: abort (); case solid: return "solid"; case line: return "line"; case none: return "none"; - default: abort (); return NULL; } }