Compare commits

...
173 Commits
Author SHA1 Message Date
Akim Demaille 6eb8f74f8f version 2.6.3
* NEWS: Record release date.
2012-10-22 15:16:12 +02:00
Akim Demaille cc5a986ce4 gnulib: update 2012-10-22 12:17:37 +02:00
Akim Demaille ae2199381e tests: check %no-lines
* tests/synclines.at: here.
2012-10-22 12:17:37 +02:00
Akim Demaille 7b70847e58 NEWS: warnings with clang
* NEWS: here.
2012-10-22 12:17:35 +02:00
Akim Demaille 19d9b60787 warnings: avoid warnings from clang
Fix the following warning

  parse-gram.c:2078:14: error: equality comparison with extraneous parentheses
                        [-Werror,-Wparentheses-equality]
    if (((yyn) == (-91)))
         ~~~~~~^~~~~~~~
  parse-gram.c:2078:14: note: remove extraneous parentheses around the
                        comparison to silence this warning
    if (((yyn) == (-91)))
        ~      ^       ~
  parse-gram.c:2078:14: note: use '=' to turn this equality comparison into
                        an assignment
    if (((yyn) == (-91)))
               ^~
               =
  1 error generated.

and the following one:

  input.cc:740:1: error: function declared 'noreturn' should not return
                         [-Werror,-Winvalid-noreturn]
  static void yyMemoryExhausted (yyGLRStack* yystackp)
    __attribute__ ((__noreturn__));
  static void
  yyMemoryExhausted (yyGLRStack* yystackp)
  {
    YYLONGJMP (yystackp->yyexception_buffer, 2);
  }
  ^
  1 warning and 1 error generated.

This is Apple clang version 3.1 (tags/Apple/clang-318.0.61).

* data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B)
to avoid this warning.
Any reasonable compiler should generate the same code.
* src/uniqstr.h (UNIQSTR_EQ): Likewise.
* data/glr.c (LONGJMP): abort after longjmp to pacify clang.
2012-10-22 12:17:17 +02:00
Akim Demaille 8f8439cee1 tests: no longer disable -O compiler options
Tests are running without -O since
f377f69fec because some warnings (about
yylval not being initialized) show only when GCC is given -O2.  The
previous patch fixes the warnings. Run the test suite with compiler
options unmodified.

* tests/atlocal.in (O0CFLAGS, O0CXXFLAGS): Remove, use CFLAGS and
CXXFLAGS.
2012-10-22 12:17:14 +02:00
Paul EggertandAkim Demaille fa5303b8ff yacc.c: initialize yylval in pure-parser mode
See http://lists.gnu.org/archive/html/bison-patches/2012-08/msg00024.html
(spreading over September and October).

* data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN)
(YY_IGNORE_MAYBE_UNINITIALIZED_END, YYLVAL_INITIALIZE):
New macros.  Use them to suppress an unwanted GCC diagnostic.
2012-10-22 12:16:33 +02:00
Akim Demaille 39845e8e40 skeletons: style changes
* data/yacc.c, data/glr.c: Prefer Title case for (CPP) macro arguments.
2012-10-22 12:16:33 +02:00
Akim Demaille 5b34bb3110 tests: minor improvements
* tests/c++.at: Space changes.
Use AT_YYERROR_DEFINE.
* tests/local.at (AT_YYERROR_DEFINE): Issue errors on unknown languages.
2012-10-22 12:16:33 +02:00
Akim Demaille c955769a75 tests: use $PERL instead of perl
* tests/atlocal.in (PERL): New.
Sort.
* tests/calc.at, tests/input.at, tests/local.at, tests/regression.at,
* tests/skeletons.at, tests/synclines.at, tests/torture.at: here.
2012-10-22 12:16:33 +02:00
Akim Demaille 82443642d2 build: look for Perl in configure.
Bison uses "/usr/bin/perl" or "perl" in several places, and it does
not appear to be a problem.  But, at least to make it simpler to
change PERL on the make command line, check for perl in configure.

* configure.ac (PERL): New.
* doc/Doxyfile.in, doc/Makefile.am, tests/bison.in: Use it.
2012-10-22 12:16:33 +02:00
Akim Demaille e272d9dc80 tests: fix sed portability issues
Reported by Didier Godefroy,
<http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00005.html>.

* tests/calc.at (AT_CHECK_SPACES): Use Perl.
2012-10-22 12:16:33 +02:00
Akim Demaille 9a50c55af7 tests: diff -u is not portable
Reported by Didier Godefroy
<http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00006.html>.

* tests/existing.at (AT_LALR1_DIFF_CHECK): Skip if diff -u does not
work.
2012-10-22 12:16:33 +02:00
Akim Demaille e28ce5def0 maint: word changes
* README-hacking (Typical errors): Improve wording.
2012-10-22 12:16:32 +02:00
Akim Demaille 7aa15a0026 lalr1.cc: fix test suite portability
Reported by Rob Vermaas' Hydra build farm on x86_64-darwin 10.2.0 with
G++ 4.6.3.

* tests/headers.at (Several parsers): Include AT_DATA_SOURCE_PROLOGUE
in the files to compile.
* data/location.cc: Do not include twice string and iostream (once
by position.hh, and then by location.hh).
* README-hacking (Typical errors): Some hints for other maintainers.
2012-10-22 12:16:32 +02:00
Theophile RanquetandAkim Demaille 90b1335aed maint: fix an erroneous include
This fixes test 130 (Several parsers).

* data/location.cc: Include <iostream> rather than <iosfwd> since
we really need << on strings for instance.
* NEWS: Document this.

Signed-off-by: Akim Demaille <[email protected]>
2012-10-22 12:16:28 +02:00
Akim Demaille ddbd0c40dc tests: check that headers are self contained
Reported by Alexandre Duret-Lutz.

* tests/headers.at (Several parsers): here.
2012-10-22 12:16:08 +02:00
Akim Demaille c473e022d9 doc: add missing documentation for --report
* doc/bison.texi (Bison Options): Document --report's "solved", "all",
and "none".
2012-10-22 12:16:08 +02:00
Akim Demaille 6192d2c6de headers: move CPP guards into YY_*_INCLUDED to avoid collisions
See <http://lists.gnu.org/archive/html/bug-bison/2012-09/msg00016.html>.

* data/c.m4 (b4_cpp_guard): Prepend YY_ and append _INCLUDED.
* tests/headers.at: Adjust.
* NEWS, doc/bison.texi: Document.
2012-10-22 12:16:04 +02:00
Akim Demaille 3746fc33c4 minor changes.
* NEWS: Word changes.
* doc/bison.texi: Spell check.
Fix minor issues.
* tests/headers.at: Comment and formatting changes.
2012-10-22 12:14:57 +02:00
Akim Demaille 36cdaaac53 gnulib: update 2012-10-22 12:14:04 +02:00
Akim Demaille 63fec1eeba regen 2012-09-25 10:29:02 +02:00
Akim Demaille 6b4cb804b5 yacc: fix handling of CPP guards when no header is generated
When no header was to be generated, Bison would issue:

  /* In a future release of Bison, this section will be replaced
     by #include "".  */
  #ifndef YY_
  # define YY_

It now properly generates nothing.

* data/c.m4 (b4_cpp_guard_open, b4_cpp_guard_close): Issue nothing when
the file name is empty.
* data/yacc.c: Do not generate the above comment when there is no header
to generate.
* NEWS: Update.
2012-09-25 10:24:37 +02:00
Akim Demaille 53425dbfaa gnulib: update 2012-09-25 10:24:36 +02:00
Akim Demaille 403ddfb7e0 maint: remove useless file
* externals/bootstrap.cfg: Remove.
This file was used by a specific build system.
It was added to the master repository by accident.
2012-09-04 11:00:11 +02:00
Akim Demaille 76e5017732 update files to ignore
* doc/.gitignore: Don't ignore split info files as we don't split our
info file.
See <http://lists.gnu.org/archive/html/bug-bison/2012-08/msg00006.html>.
2012-09-04 10:50:30 +02:00
Akim Demaille 592bdad15e remove useless include
* src/system.h: Don't include sys/types.h.
Reported by Eric Blake,
<http://lists.gnu.org/archive/html/bug-bison/2012-09/msg00002.html>.
(FUNCTION_PRINT): Remove, unused.
2012-09-04 09:51:12 +02:00
Jim Meyering 457bf91968 use locale-indep. c_is* functions for parsing, not isspace, isprint etc
* src/parse-gram.y: Include "c-ctype.h".
(add_param): Parse with c_isspace, not isspace.
* src/parse-gram.c: Likewise.
* src/scan-gram.l: Include c-ctype.h, not ctype.h.
(SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER): Use c_isspace and c_isprint,
not ctype.h's locale-dependent functions.
2012-09-03 19:45:03 +02:00
Akim Demaille 2e350a617f gnulib: update 2012-09-03 16:40:03 +02:00
Akim Demaille d740d2b541 --help: include a place to report translation issues
http://lists.gnu.org/archive/html/bug-bison/2012-08/msg00007.html
shows that it is useful to help users report translation issues.
While at it, include other informative bits that the coreutils shows.

* src/getargs.c (usage): Report more URLs where the user can
refer to.
Mostly copied/pasted from coreutils' emit_ancillary_info function.
2012-09-03 16:40:03 +02:00
Akim Demaille e411069eee tests: style changes
* tests/torture.at (AT_DATA_STACK_TORTURE): M4 style changes to
improve readability.
Fix an assertion which, because of a <= instead of ==, did not check
new_status as visibly meant.
(get_args): New.
2012-08-31 17:50:43 +02:00
Akim Demaille ae62d0fc4f tests: fix push-pull test
* tests/torture.at: %push-pull-parser is no longer supported.
2012-08-31 17:50:43 +02:00
Akim Demaille e3f8c4ef69 yacc.c: style changes
* data/yacc.c: (yytoken): Define with initial value.
2012-08-31 17:50:31 +02:00
Akim Demaille 933ec5449f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-08-03 09:52:05 +02:00
Akim Demaille e1eeecd384 version 2.6.2
* NEWS: Record release date.
2012-08-03 09:43:02 +02:00
Akim Demaille 43ca804096 NEWS: update.
* NEWS: Catch up with the other changes from 2.6.1.
2012-08-02 13:51:52 +02:00
Akim Demaille dcd5344dcd yacc: remove trailing end of line at end of file
There are still spurious spaces at the end of some lines.  But this is
addressed in the master branch, and I am reluctant to try to backport
this.

* data/yacc.c, data/glr.c, data/lalr1.cc, data/glr.cc: here.
* tests/calc.at (AT_CHECK_SPACES): New.
Use it.
Be sure not to introduce trailing empty lines in the *.y files.
* NEWS: Doc it.
* cfg.mk (syntax-check): Remove the exception.
2012-08-02 13:51:52 +02:00
Akim Demaille 62a58c14bd thanks: fix a contributor name
* THANKS: On his request.
2012-08-02 08:29:18 +02:00
Akim Demaille e39eff37e2 gnulib: update 2012-08-01 15:02:25 +02:00
Akim Demaille 06f2ac78d7 tests: synch line -> syncline, for consistency
* tests/synclines.at: Do it, as "syncline" is used consistently
everywhere else in Bison.
2012-08-01 15:02:25 +02:00
Akim Demaille 1914a78115 tests: synclines: style changes
* tests/synclines.at (AT_TEST_SYNCLINE): Rename as...
(AT_TEST): this.
Use pushdef/popdef.
Formatting changes.
Use '+' instead of '*' where appropriate.
2012-08-01 15:02:25 +02:00
Akim Demaille d6e2a57964 tests: synclines: fix perl invocation
Reported by Summum Bonum.

* tests/synclines.at: Fix Perl invocation: its -f is not like sed's.
2012-08-01 15:02:21 +02:00
Akim Demaille a0c45dd5d2 regen 2012-08-01 09:16:56 +02:00
Akim Demaille c9d546b2a8 c++: trailing end-of-lines in %parse-param
* src/parse-gram.y (add_param): No only skip ' ' and '\t', skip all
leading and trailing spaces.
* tests/regression.at (Lex and parse params): Check it.
* NEWS: Document it.
2012-08-01 09:16:55 +02:00
Akim Demaille d61e59ea0e tests: simplify
* tests/regression.at: Remove useless compilations: AT_FULL_COMPILE
includes the compilation by bison.
2012-08-01 09:16:55 +02:00
Akim Demaille aaf63e45b6 use obstack_printf
This is not just nicer, it is also much safer, since we were
using sprintf...

* bootstrap.conf: Require it.
* src/system.h (obstack_fgrow1, obstack_fgrow2, obstack_fgrow3)
(obstack_fgrow4): Remove.
Adjust dependencies.
2012-07-31 10:50:06 +02:00
Akim Demaille dbfcf7a89f scanner: restore a missing start condition
$ flex src/scan-skel.l
src/scan-skel.l:145: multiple <<EOF>> rules for start condition SC_AT_DIRECTIVE_ARGS
src/scan-skel.l:145: multiple <<EOF>> rules for start condition SC_AT_DIRECTIVE_SKIP_WS
This is warning, and it seems there are no means to make it an error.

* src/scan-skel.l: Restore the start-condition INITIAL for an <<EOF>>
clause.
2012-07-30 14:54:27 +02:00
Akim Demaille 8c707b10e7 gnulib: update 2012-07-30 14:53:58 +02:00
Akim Demaille 9c26b8fc03 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-07-30 11:47:29 +02:00
Akim Demaille 77b214ef48 version 2.6.1
* NEWS: Record release date.
2012-07-30 11:18:23 +02:00
Akim Demaille d35d6dd2cd gnulib: update 2012-07-30 11:17:44 +02:00
Akim Demaille 466a2de317 maint: fix some syntax-check issues
* cfg.mk: Nuke the following warnings which are confused by our
text reports (that state that the error token is number 256).
  prohibit_magic_number_exit
  ../../doc/bison.texi:8170:error (256)
  ../../tests/conflicts.at:570:error (256)
  ../../tests/conflicts.at:673:error (256)
  ../../tests/conflicts.at:811:error (256)
  ../../tests/conflicts.at:1154:error (256)
  ../../tests/regression.at:281:error (256)
  ../../tests/regression.at:582:error (256)
  maint.mk: use EXIT_* values rather than magic number
2012-07-27 17:00:28 +02:00
Akim Demaille 4acc22e5cf tests: do not depend on __cplusplus to decide for C++ or C output
Since we do support compiling C code with a C++ compiler.

* tests/actions.at (Qualified $$ in actions): Use AT_SKEL_CC_IF.
2012-07-27 16:36:07 +02:00
Akim Demaille 7b18c11231 regen 2012-07-27 14:52:55 +02:00
Akim Demaille e6cab382c5 synclines: remove spurious empty line
* data/bison.m4 (b4_syncline): Do not start with an empty line.
2012-07-27 14:52:23 +02:00
Akim Demaille cd735a8c6c also support $<foo>$ in the %initial-action
scan-code.l is already passing argument to b4_dollar_dollar for the
initial acton, but its definition (of b4_dollar_dollar) does not use
this argument.

Generalize this definition, and use it for the %initial-action too.

* data/c.m4 (b4_dollar_dollar_, b4_dollar_pushdef, b4_dollar_popdef):
Instead of expecting a pointer, require a value, and use ".".
Since they are now generic enough, move to...
* data/c-like.m4: this new file.
* data/c.m4, data/java.m4: Load it.
* data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Use
b4_dollar_pushdef for the %initial-action.
* tests/actions.at: Check that.
* data/Makefile.am: Adjust.
* NEWS, doc/bison.texi: Document.
2012-07-27 14:47:20 +02:00
Akim Demaille d6a44ffd00 skeletons: b4_dollar_pushdef and popdef to simpify complex definitions
M4 is really making it uselessly hard to define macros that define
macros.
* data/c.m4 (b4_dollar_pushdef, b4_dollar_popdef): New.
Use it.
2012-07-27 13:47:24 +02:00
Akim Demaille 93e3dbab95 regen 2012-07-27 12:54:31 +02:00
Akim Demaille 1c292035e1 printer/destructor: translate only once
Currently "%printer {...} a b c d e f" translates the {...} six times.
Not only is this bad for time and space, it also issues six times the
same warnings.

* src/symlist.h, src/symlist.c (symbol_list_destructor_set)
(symbol_list_printer_set): Take the action as code_props instead of
const char *.
* src/parse-gram.y: Translate these actions here.
* src/scan-code.h: Comment change.
* tests/input.at: Check that warnings are issued only once.
2012-07-27 12:54:31 +02:00
Akim Demaille 263137264f factor the handling of m4 escaping
The conversion from @ to @@ and so forth is coded is too many
different places.  Factor, a bit.

* src/scan-code.l: Instead of duplicating the logic of obstack_escape,
use it.
It sure is less efficient, but the cost is negligible.
This allows to factor rules that are alike.
And to factor some start-condition clauses.
* tests/input.at (Stray $ or @): New.
* NEWS: Document it.
2012-07-27 12:54:31 +02:00
Akim Demaille e20e6a50d5 news: schedule the removal of the ";" hack
scan-code.l is significantly more complex because of this.

* NEWS: Doc it.
2012-07-27 12:54:31 +02:00
Akim Demaille 4d24ffb75e style changes in the scanners
* src/scan-code.l, src/scan-skel.l: Use a more traditional indentation
style for start-conditions.
Prefer "continue" to a comment, for empty actions.
Strip useless {}.
Remove useless start-condition clauses.
2012-07-27 12:13:40 +02:00
Akim Demaille a74a3158d4 regen 2012-07-26 18:30:43 +02:00
Akim Demaille 4982f078bf support $<tag>$ in printers and destructors
* src/scan-code.l (SC_SYMBOL_ACTION): Accept $<tag>$, not just $$.
* data/c.m4 (b4_dollar_dollar_): New.
(b4_symbol_actions): Let b4_dollar_dollar use b4_dollar_dollar_.
* NEWS, doc/bison.texi: Document it.
* tests/actions.at: Check this for C and C++.
2012-07-26 18:30:43 +02:00
Akim Demaille 65a99eca25 scan-code: factor the handling of the type in $<TYPE>$
* src/scan-code.l (fetch_type_name): New.
(handle_action_dollar): Use it.
(gt_ptr): Remove, useless.
2012-07-26 17:03:54 +02:00
Akim Demaille 9a86ee6058 muscles: fix another occurrence of unescaped type name
* src/output.c (quoted_output): Split into...
(quoted_output, string_output): these.
Use the former when outputting a type_name.
* tests/input.at: Check this case.
* src/symtab.h: Comment changes.
2012-07-26 17:03:54 +02:00
Akim Demaille 0e164d43d1 glr.cc: fix the handling of yydebug
* data/glr.cc (yydebug_): Remove, unused.
(set_debug_level, debug_level): Work on yydebug instead.
* doc/bison.texi, NEWS: Document this.
2012-07-26 17:03:52 +02:00
Akim Demaille d511fbd576 gnulib: update 2012-07-26 16:51:26 +02:00
Akim Demaille 9c46ba16e3 formatting changes
* src/symtab.h: here.
2012-07-26 16:51:26 +02:00
Akim Demaille 55e075f229 tests: fix an assertion
* tests/local.at (AT_YYLEX_DEFINE): Be sure to check the array
against its length, not its size in bytes.
2012-07-26 16:51:26 +02:00
Akim Demaille 0bb672d87c tests: adjust to GCC 4.8, which displays caret errors
With GCC 4.8, the tests on synclines are skipped.  Transform

  input.y:1:2: error: #error "1"
   #error "1"
    ^

into

  input.y:1: #error "1"

* tests/synclines.at (AT_SYNCLINES_COMPILE): Do it, using Perl instead of
sed.
2012-07-26 16:51:26 +02:00
Akim Demaille 8617d87e24 be sure to properly escape type names
* src/scan-code.l: Use obstack_quote when passing type_name to m4.
* tests/input.at (Code injection): New.
* NEWS: Document it.
Thanks to Paul Eggert for the wording.
2012-07-26 14:20:47 +02:00
Akim Demaille 0601c3bf0f obstack_quote: escape and quote for M4
* src/system.h (obstack_quote): New.
* src/muscle-tab.c: Use it instead of obstack_escape where applicable.
* src/scan-code.l: Since obstack_quote supports NULL, leave type_name
as NULL instead of defaulting to "".
2012-07-26 14:20:18 +02:00
Akim Demaille eea7239a23 muscles: shuffle responsabilities
* src/muscle-tab.c (muscle_boundary_grow): Be in charge of quotation,
instead of leaving this to the caller.
2012-07-26 12:30:03 +02:00
Akim Demaille e58782294d muscles: make private functions static
* src/muscle-tab.h, src/muscle-tab.c (muscle_boundary_grow)
(muscle_location_grow): Now static.
2012-07-26 12:30:03 +02:00
Akim Demaille c1cc91bdcd muscles: rename private functions/macros
* src/muscle-tab.c (MUSCLE_COMMON_DECODE, muscle_string_decode)
(muscle_location_decode): Not related to muscles, rename as...
(COMMON_DECODE, string_decode, location_decode): these.
2012-07-26 12:30:03 +02:00
Akim Demaille 13b712d7d4 obstack_escape: escape M4 characters
* src/muscle-tab.h (MUSCLE_OBSTACK_SGROW): This is not related to
muscles, so move to, and rename as...
* src/system.h (obstack_escape): this.
Adjust dependencies.
2012-07-26 12:30:02 +02:00
Akim Demaille dba9149595 remove dead macro
* src/system.h (DEFAULT_TMPDIR): Remove, unused.
2012-07-26 12:28:40 +02:00
Akim Demaille 9b8585410a maint: style changes
* src/scan-code.l: Remove useless braces.
Formatting changes.
Prefer NULL to 0.
* src/muscle-tab.c, src/system.h: Formatting changes.
2012-07-26 12:28:17 +02:00
Akim Demaille f9b8635172 doc: avoid problems with case insensitive file systems
makeinfo --html generates index.html, and the node "Index" will result
in Index.html.  On case insensitive file systems, such as on Mac OS X
by default, this results in a single, invalid, file (Texinfo 4.13).
See http://lists.gnu.org/archive/html/bug-texinfo/2012-07/msg00032.html

* doc/bison.texi (Index): Rename as...
(Index of Terms): this.
2012-07-24 13:30:49 +02:00
Stefano LattariniandAkim Demaille 733d4546ce configure: fix botched quoting
* configure.ac: In the AC_SUBST call on 'VALGRIND_PREBISON'.  Without
this change, when running ./configure, I see:

    ...
    checking for valgrind... valgrind
    ./configure: line 35221: -q: command not found
    checking for Java compiler... gcj -C -fsource=1.3 -ftarget=1.4
    ...

Copyright-paperwork-exempt: yes
Signed-off-by: Stefano Lattarini <[email protected]>
2012-07-24 12:22:17 +02:00
Akim Demaille aaf6103699 news: fix typo.
* NEWS: here.
Reported by Ben Pfaff.
2012-07-20 10:01:48 +02:00
Akim Demaille d0d3313d10 maint: update gnu-web-doc-update.
* gnulib: here.
2012-07-19 16:24:33 +02:00
Akim Demaille a4107f24bc maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-07-19 15:38:29 +02:00
Akim Demaille 1505e8bb78 version 2.6
* NEWS: Record release date.
2012-07-19 15:24:23 +02:00
Akim Demaille 58c7e5ee2c maint: prepare for release 2.6
* NEWS: here.
2012-07-19 15:21:32 +02:00
Akim Demaille ad6b775fc5 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-07-18 18:33:25 +02:00
Akim Demaille 5d614dfa8c version 2.5.91
* NEWS: Record release date.
2012-07-18 18:19:32 +02:00
Akim Demaille 858c700fc0 maint: prepare NEWS. 2012-07-18 18:19:12 +02:00
Akim Demaille c30717cafa maint: fix spaces.
* build-aux/Makefile.am: here.
2012-07-18 17:56:30 +02:00
Akim Demaille 0e98a81e00 tests: adjust to case where the C compiler is actually a C++ compiler
* tests/atlocal.in (CC_IS_CXX): New.
* tests/headers.at (Several parsers): Use it.
2012-07-18 09:17:31 +02:00
Akim Demaille d5c20d1a36 tests: fix dependencies
* tests/Makefile.am: we need atconfig and atlocal to be up to date
when calling testsuite.
2012-07-18 09:17:31 +02:00
Akim Demaille e6ae99fe75 doc: fix Texinfo command
* doc/bison.texi: In parens, use @pxref.
2012-07-18 09:17:31 +02:00
Akim Demaille bcbbf65486 maint: Valgrind on OS X.
* configure.ac (VALGRIND_PREBISON): New.
* tests/Makefile.am (maintainer-check-valgrind): Use it.
* etc/darwin11.4.0.supp: New.
* configure.ac, etc/Makefile.am: Use it.
* configure.ac: Disable Valgrind on Mac OS X.
* README-hacking: Explain why.
2012-07-18 09:17:15 +02:00
Akim Demaille 1aa9fa823b tests: be sure that backups are safe.
* tests/local.at (at_save_special_files): here.
2012-07-17 14:47:35 +02:00
Akim Demaille 321b8117a6 maint: dead comment.
* etc/README: here.
2012-07-17 14:47:35 +02:00
Akim Demaille e4828e2384 tests: refactor for legibility.
* tests/local.at (AT_BISON_CHECK_WARNINGS, AT_BISON_CHECK_WARNINGS_):
New.
2012-07-17 14:47:34 +02:00
Akim Demaille a122efad8a tests: refactor the bison invocations.
* tests/local.at (m4_null_if, AT_BISON_CHECK_): New.
2012-07-17 14:47:34 +02:00
Akim Demaille 15ffba51b0 maint: fix syntax-check ignore patterns.
* cfg.mk: here.
2012-07-17 12:14:55 +02:00
Akim Demaille ea6a2d96db gnulib: update 2012-07-17 09:49:57 +02:00
Akim Demaille ae63f0e8e2 gnulib: update.
* gnulib: Update so that gitlog-to-changelog support --srcdir.
* Makefile.am: Use it.
2012-07-16 20:40:18 +02:00
Akim Demaille 41c11ce484 gnulib: update
* bootstrap, build-aux/.gitignore, gnulib, m4/.gitignore: update.
2012-07-10 16:07:32 +02:00
Akim Demaille a59a6ddef4 maint: update release instructions
* README-hacking: here.
2012-07-06 10:21:39 +02:00
Akim Demaille aca4ddc75d maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-07-05 16:29:06 +02:00
Akim Demaille 47977a7e74 version 2.5.90
* NEWS: Record release date.
2012-07-05 16:20:44 +02:00
Akim Demaille 813f7d3482 build: fix gen-ChangeLog call.
* Makefile.am: Be sure to catch errors, and fix option name
2012-07-05 16:16:10 +02:00
Akim Demaille 7a9e6d65ea gnulib: update.
* gnulib/build-aux/do-release-commit-and-tag: Fix.
2012-07-05 15:24:34 +02:00
Akim Demaille 916f26b65a tests: fix SKIP_IF for Java.
* tests/local.at (AT_JAVA_COMPILE): here.
2012-07-05 14:27:09 +02:00
Akim Demaille 32ae07efde api.prefix: incompatible with %name-prefix.
* data/bison.m4: Make it incompatible.
* tests/input.at: Check that it is.
2012-07-05 12:41:16 +02:00
Akim Demaille ad60e80f3d api.prefix: strengthen the tests and fix push-parsers.
* tests/calc.at: Check api.prefix in addition to %name-prefix.
* tests/headers.at: Check push parsers and pure interface.
* tests/local.at: Use YYLTYPE renamed.
* data/yacc.c (b4_declare_yyparse_push_): Handle api.prefix.
* doc/bison.texi: Style changes.
2012-07-05 12:41:15 +02:00
Akim Demaille 2a824fae30 skeletons: style changes.
* data/bison.m4: Define default values after having defined
the support macros.
Kill a dead comment.
2012-07-05 12:41:09 +02:00
Akim Demaille c242519127 NEWS: minor changes.
* NEWS: style changes.
2012-07-05 12:41:09 +02:00
Akim Demaille e358222ba8 api.prefix: improve the documentation for YYDEBUG.
* doc/bison.texi: Explain how api.prefix is applied to YYDEBUG.
2012-07-05 12:41:08 +02:00
Akim Demaille 9dcb193aeb gnulib: update.
* bootstrap, gnulib: Update.
* cfg.mk (syntax-check): Don't check "error" usage in bison.texi.
2012-07-05 11:13:47 +02:00
Akim Demaille faff3bef5b tests: headers.at: strengthen.
* tests/headers.at (Several headers): Be stricter when checking
the exported macros.
2012-07-04 12:24:13 +02:00
Akim Demaille 53ab797db7 glr.cc: do not override C++ definitions by C macros.
* data/glr.c: here.
* data/glr.cc: Fix overquotation.
* tests/headers.at: Comment changes.
2012-07-04 12:24:13 +02:00
Akim Demaille 426903aa75 YYLLOC_DEFAULT: factor, and don't export it in headers.
* data/c++.m4, data/c.m4 (b4_yylloc_default_define): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* data/glr.cc: Do not define YYLLOC_DEFAULT in the header file,
but in the implementation one.
2012-07-04 12:24:13 +02:00
Akim Demaille 9104636b03 api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc.
The following mixture is insane:

  #define YYSTYPE_IS_TRIVIAL PREFIX_STYPE_IS_TRIVIAL
  #if (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)

since, of course YYSTYPE_IS_TRIVIAL is defined.  Instead we could
define YYSTYPE_IS_TRIVIAL as PREFIX_STYPE_IS_TRIVIAL only when the
later is defined, but let's avoid stacking CPP on top of M4: rather, use

  #if (defined PREFIX_STYPE_IS_TRIVIAL && PREFIX_STYPE_IS_TRIVIAL)

* data/glr.c, data/yacc.c: Use YYSTYPE_IS_TRIVIAL, YYSTYPE_IS_DECLARED,
YYLTYPE_IS_TRIVIAL and YYLTYPE_IS_DECLARED under their api.prefix-renamed
name.
2012-07-04 12:24:13 +02:00
Akim Demaille 1168b32295 tests: portability fixes.
Reported by Hydra.

* tests/headers.at (Several headers): Be sure to include config.h
in the files to compile.
2012-07-04 12:24:13 +02:00
Akim Demaille 771dc64324 c++: fewer #includes in the headers.
* data/lalr1.cc: Define YY_NULL in the *.cc file, it is not needed
in the header.
* data/location.cc: iosfwd suffices.
2012-07-04 12:24:13 +02:00
Akim Demaille a7385a21ce glr.cc: formatting changes.
* data/glr.cc: here.
2012-07-04 12:24:13 +02:00
Akim Demaille b142cfd128 tests: more logs.
* tests/headers.at (Several parsers): Here.
2012-07-04 12:24:13 +02:00
Akim Demaille 5f108727a1 api.prefix: also rename YYDEBUG.
The testsuite in master has shown weird errors for the "Mulitple
Parsers" tests: the caller of p5.parse() received some apparently
random value, while tracing p5.parse() showed that the function was
consistently returning 0.

It happens when mixing several parser headers, some generated without
%debug, others with.  In particular the C++ parser was generated with
%debug, i.e., with:

  #ifndef YYDEBUG
  # define YYDEBUG 1
  #endif

and compiled separatedly.  Yet, its header was included after the one
of another parser, this time without %debug, i.e., with

  #ifndef YYDEBUG
  # define YYDEBUG 0
  #endif

in its header.  As a result, the parser was compiled with YYDEBUG set,
but its header was used without.  Since the layout of the objects are
then completely different, boom.

Therefore, do not change the value of YYDEBUG.  Rather, use it as a
default value for <API.PREFIX>DEBUG.

* data/c.m4 (b4_YYDEBUG_define): New.
(b4_declare_yydebug): Rename as...
(b4_yydebug_declare): this, for consistency.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* NEWS: Document it.
2012-07-04 12:24:12 +02:00
Akim Demaille 242cc08e8d NEWS: spell check.
* NEWS: here.
2012-07-02 09:26:22 +02:00
Akim Demaille 4b3847c3c0 api.prefix.
* data/c.m4 (b4_api_prefix, b4_api_PREFIX): New.
(b4_prefix, b4_union_name, b4_token_enums, b4_declare_yylstype): Use them.
* data/glr.c, data/yacc.c, data/glr.cc, data/lalr1.cc: Use them to change
the prefix of exported preprocessor symbols.
* src/getargs.c (usage): Ditto.
* tests/headers.at (Several parsers): New.
* tests/local.at (AT_API_PREFIX): New.
AT_YYSTYPE, AT_YYLTYPE): Adjust.
* doc/bison.texi (Multiple Parsers): Move documentation of %name-prefix to...
(Table of Symbols): here.
(Multiple Parsers): Document api.prefix.
(%define Summary): Point to it.
Use @code for variable names.
(Bison Options): -p/--name-prefix are obsoleted.
* NEWS: Announce api.prefix.
2012-06-29 17:40:42 +02:00
Akim Demaille 087dcd7868 tests: use the generalized default yylex.
* tests/actions.at, tests/glr-regression.at, tests/regression.at: here.
2012-06-28 15:01:36 +02:00
Akim Demaille 95361618de tests: AT_YYERROR_DEFINE: prepare for list of ints.
* tests/local.at (AT_YYERROR_DEFINE): Don't add quotes, check their
presence to detect char/int types.
* tests/actions.at, tests/conflicts.at, tests/glr-regression.at,
* tests/push.at, tests/regression.at: Adjust.
2012-06-28 15:01:36 +02:00
Akim Demaille 694af10cb7 skeletons: no longer define YYLSP_NEEDED.
* data/c.m4, data/glr.cc: here.
* NEWS, TODO: Adjust.
2012-06-27 10:03:23 +02:00
Akim Demaille 258cddbc36 c++: do not export YYTOKEN_TABLE and YYERROR_VERBOSE.
* src/output.c (prepare_symbols): Do not define b4_token_table.
(prepare): Define b4_token_table_flag.
* data/bison.m4 (b4_token_table_if): New.
Arm it when error-verbose.
* data/glr.c, data/yacc.c (YYTOKEN_TABLE): Remove.
Use m4.
* data/lalr1.cc: Likewise.
(YYERROR_VERBOSE): Remove.
* NEWS, doc/bison.texi: Document this.
2012-06-27 10:03:21 +02:00
Akim Demaille 9bcffa0c13 maint: use *.texi.
This is more consistent with the other packages, and Automake-NG
supports only *.texi.

* doc/bison.texinfo: Rename as...
* doc/bison.texi: this.
* doc/Makefile.am, examples/calc++/Makefile.am: Adjust.
2012-06-26 16:55:23 +02:00
Akim Demaille a32a2d57a5 tests: do not output m4 set up.
* tests/local.at (AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS):
Use a diversion to avoid outputting comments etc.
Removes 17k lines from testsuite (10% of the number of lines).
2012-06-26 14:07:34 +02:00
Akim Demaille 8d6c1b5e85 tests: use the generic yyerror function.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Factor.
Use AT_YYERROR_DEFINE.
Therefore, instead of using stdout, use and check stderr.
* tests/glr-regression.at (Uninitialized location when reporting ambiguity):
Use AT_YYERROR_DEFINE.
2012-06-26 13:55:50 +02:00
Akim Demaille 77519a7d18 tests: use assert instead of plain abort.
* tests/actions.at, tests/calc.at, tests/conflicts.at,
* tests/cxx-type.at, tests/glr-regression.at, tests/input.at,
* tests/named-refs.at, tests/regression.at, tests/torture.at,
* tests/local.at:
Prefer assert to abort.
2012-06-26 13:55:50 +02:00
Akim Demaille 0e16927b48 tests: improve the generic yylex implementation.
* tests/local.at (AT_YYSTYPE, AT_YYLTYPE): New.
(AT_YYLEX_FORMALS): Use them.
(AT_YYLEX_DEFINE): Be independent of the location implementation.
2012-06-26 13:55:49 +02:00
Akim Demaille 91ce0b3a66 tests: generalize the compilation macros.
* tests/local.at (AT_COMPILE, AT_COMPILE_CXX): If OUTPUT ends with ".o",
then append the "natural" extension for the input file (.c or .cc).
If there is no source, pass -c.
* tests/headers.at, tests/input.at, tests/regression.at: Adjust.
2012-06-26 13:55:49 +02:00
Akim Demaille 837b769659 tests: fix confusion between api.prefix and name-prefix.
* tests/local.at (AT_NAME_PREFIX): Take api.prefix into account.
(AT_API_PREFIX): Rename as...
(AT_API_prefix): this.
Do not take %name-prefix into account.
Fix misuses.
2012-06-26 13:55:49 +02:00
Akim Demaille 5e01579ec0 maint: gitignores. 2012-06-26 13:55:49 +02:00
Akim Demaille 55d1006fce yacc: work around the ylwrap limitation.
* data/yacc.c (b4_shared_declarations): Include the header guards.
Do not include the header in the *.c file, duplicate it.
* NEWS (Future Changes): Extend, and announce the forthcoming change
about the use of the parser header.
2012-06-25 10:20:56 +02:00
Akim Demaille 230a3db428 tests: more uniformity.
* tests/local.at (AT_LEX_FORMALS, AT_LEX_ARGS, AT_LEX_PRE_FORMALS)
(AT_LEX_PRE_ARGS): Rename as...
(AT_YYLEX_FORMALS, AT_YYLEX_ARGS, AT_YYLEX_PRE_FORMALS)
(AT_YYLEX_PRE_ARGS): these, for consistency.
(AT_API_PREFIX): Take %name-prefix into account.
(AT_YYLEX_PROTOTYPE): New.
Use it.
* tests/actions.at, tests/calc.at, tests/cxx-type.at: Adjust to
use them.
2012-06-22 12:08:02 +02:00
Akim Demaille 6d55954743 tests: handle locations in a more generic way.
* tests/local.at (AT_YYERROR_PROTOTYPE): New.
Use it.
* tests/cxx-type.at: Extensive revamp to use a more traditional
quotation scheme, and to use the generic yyerror implementation.
Prefer Autotest macros to CPP macros.
* tests/java.at: .
2012-06-22 11:34:37 +02:00
Akim Demaille 7490994123 tests: handle locations in the generic yyerror functions.
* tests/local.at (AT_YYERROR_DECLARE_EXTERN, AT_YYERROR_DECLARE)
(AT_YYERROR_DEFINE): Handle locations for C and C++.
* tests/calc.at: Use it for C++ (as C has extra arguments which
are not yet handled by AT_BISON_OPTION_PUSHDEFS).
* tests/actions.at: Adjust.
2012-06-22 10:20:28 +02:00
Akim Demaille eb46d61f4d tests: fix AT_CHECK_CALC.
* tests/calc.at (AT_CHECK_CALC): Contrary to its documentation,
the test was skipped if given a second argument.
Unused feature, remove it.
2012-06-22 09:41:36 +02:00
Akim Demaille 05a7b6ec80 tests: improve infrastructure
* tests/local.at (AT_LANG): Use c++ instead of cxx for C++.
Adjust dependencies.
(AT_YYERROR_DECLARE_EXTERN, AT_YYERROR_DECLARE): Issue nothing
for C++/Java.
(AT_YYERROR_DEFINE): Use m4_case.
(AT_JAVA_COMPILE): Use AT_SKIP_IF.
2012-06-22 09:30:07 +02:00
Akim Demaille 290a8ff2c0 tests: factor.
* tests/glr-regression.at, tests/output.at, tests/push.at,
* tests/regression.at, tests/torture.at, tests/actions.at:
Use AT_YYLEX_* and AT_YYERROR_*.
2012-06-21 22:54:40 +02:00
Akim Demaille 6e2d7b0974 skeletons: minor style changes
* data/glr.c, data/yacc.c: here.
2012-06-21 17:08:11 +02:00
Akim Demaille 2d40532bf5 tests: AT_LANG.
* tests/local.at (AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS):
Define/undefine AT_LANGE
(AT_LANG_COMPILE): New.
(AT_FULL_COMPILE): Use AT_LANG.
2012-06-21 17:08:11 +02:00
Akim Demaille 756257ee86 c skeletons: factor the declaration of yylloc and yylval.
There is one difference: now, even without --defines, we generate
extern declarations for these variables.  The factoring is worth it.
* data/c.m4 (b4_declare_yylstype): Declare them.
* data/glr.c, data/yacc.c: Adjust.
2012-06-21 15:19:43 +02:00
Akim Demaille 18ad57b384 news: condemn YYPARSE_PARAM and YYLEX_PARAM.
* NEWS: here.
(Bison 1.875): Add %parse-param and %lex-param.
* doc/bison.texinfo: Spello.
2012-06-21 15:19:43 +02:00
Akim Demaille da402d1cae maint: regen.
* Makefile.am (regen): New target.
(cherry picked from commit 71bff31edd)
2012-06-20 10:17:14 +02:00
Akim Demaille e29f0771d7 maint: formatting changes.
* NEWS: Fix indentation of code snippets.
Untabify.
2012-06-19 17:01:35 +02:00
Akim Demaille 71c7e24f2e tests: support api.prefix.
* tests/local.at (AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS):
Define AT_API_PREFIX.
(AT_YYERROR_DEFINE, AT_YYERROR_DECLARE_EXTERN, AT_YYLEX_DECLARE_EXTERN)
(AT_YYLEX_DEFINE): Use it.
* tests/input.at, tests/regression.at, tests/torture.at: Add
AT_BISON_OPTION_PUSHDEFS/POPDEFS.
2012-06-17 19:37:07 +02:00
Akim Demaille 5f7f1e210b tests: pacify font-lock-mode.
* tests/local.at: here.
2012-06-17 19:37:07 +02:00
Akim Demaille eb83259dc1 tests: remove test covered elsewhere.
* tests/headers.at (%union and --defines): Remove, pretty useless and
insignificant.
2012-06-17 19:37:07 +02:00
Akim Demaille 55f48c4831 tests: factor the declaration/definition of yyerror and yylex.
* tests/local.at (AT_YYERROR_DECLARE, AT_YYERROR_DECLARE_EXTERN)
(AT_YYERROR_DEFINE, AT_YYLEX_DECLARE, AT_YYLEX_DECLARE_EXTERN)
(AT_YYLEX_DEFINE): New.
Must be used inside AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
* tests/actions.at, tests/conflicts.at, tests/glr-regression.at,
* tests/headers.at, tests/input.at, tests/named-refs.at,
* tests/regression.at, tests/skeletons.at, tests/synclines.at,
* tests/torture.at: Use them.
2012-06-17 19:37:07 +02:00
Akim Demaille 34d867d7d2 regen. 2012-06-17 12:13:20 +02:00
Akim Demaille 363bf73276 tests: portability issues.
* tests/calc.at (AT_CALC_MAIN): Missing include reported by Hydra.
2012-06-17 11:20:21 +02:00
Akim Demaille c8c220d19a tests: call the parser from another compilation unit.
In order to improve the testing of %defines, which exports the
interface of the generated parser, change the calc.at tests so that
when %defines is passed, main will be in another compilation unit.  It
loads the generated header.

* tests/calc.at (AT_CALC_MAIN): New.
Includes the definition of the global variables.
Therefore, now declare them from the %requires section of the parser.
Adjust to yydebug and yyparse being renamed by %name-prefix.
2012-06-15 15:39:19 +02:00
Akim Demaille 56ca3d8fce glr.c, yacc.c: declare yydebug in the header.
* data/c.m4 (b4_declare_yydebug): New.
* data/glr.c, data/yacc.c (b4_shared_declarations): Use it.
Remove the corresponding code from the parser body.
* NEWS: Doc this.
2012-06-15 15:33:14 +02:00
Akim Demaille c3e9f08f93 skeletons: use header guards.
* data/glr.c, data/glr.cc, data/yacc.c: here.
* NEWS: Document it.
2012-06-15 15:33:14 +02:00
Akim Demaille 6aef2e01a4 tests: improve AT_FULL_COMPILE.
* tests/local.at: Accept a third argument.
Simplify quotation pattern.
Calls for better refactoring, but will suffice for a while.
2012-06-15 15:20:53 +02:00
Akim Demaille 3d8082ad27 tests: reorder.
* tests/calc.at (power): Move its definition, as a preparation for
forthcoming changes.
And space changes.
2012-06-15 13:36:01 +02:00
Akim Demaille 9d67a52ad6 tests: strengthen the test on generated headers inclusion
* tests/headers.at (AT_TEST_CPP_GUARD_H): Accept Bison directives.
(Invalid CPP headers): Check glr.
2012-06-15 13:31:59 +02:00
Akim Demaille 0f11eec272 yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it.
This is already what glr.c and lalr1.cc do.

* data/yacc.c: here.
2012-06-15 13:31:34 +02:00
Akim Demaille ae6bdabbf6 yacc.c: factor.
yacc.c used to include two almost identical sections: one for the *.h
file, and another for the *.c file.  The main difference is that in
the *.c file we used the yy* names (as %name-prefix is handled by
"#define yy* <prefix>*" before), while the *.hh used <prefix>* names.
Keep only the later.  If this is troublesome, b4_shared_declarations
can easily take the desired prefix as argument.

* data/yacc.c (b4_shared_declarations): New.
Use it to factor duplicated declarations.
2012-06-13 21:52:38 +02:00
Akim Demaille c0828abf9d skeletons: factor yacc.c and glr.c.
yacc.c and glr.c share common declarations.  Their YYLTYPE are exactly
equal, and their YYSTYPE are sufficiently alike to be fused (its
declaration was protected by YYSTYPE_IS_DECLARED in yacc.c, but not in
glr.c).  Besides, yacc.c duplicated the definitions of YYLTYPE and
YYSTYPE (*.h/*.c).

* data/c.m4 (b4_declare_yylstype): New.
* data/yacc.c, data/glr.c: Use it.
2012-06-12 14:49:48 +02:00
Akim Demaille e9807a7934 glr.c: minor refactoring.
* data/glr.c (b4_shared_declarations): Move from the generated file
section, to the M4 prologue.
2012-06-12 14:49:48 +02:00
Akim Demaille 02287ec650 tests: remove all the -On flags.
* tests/atlocal.in: Here.
Reported by Gilles Espinasse.
2012-06-12 14:49:48 +02:00
Akim Demaille 6537c71fcc maint: fix spello.
* README-hacking: Here.
* THANKS: Reported by Gilles Espinasse.
2012-06-12 14:49:48 +02:00
Akim Demaille 6733d02476 maint: improve release procedure instructions.
* gnulib: Update, in particular (README-release).
* bootstrap.conf: don't require gendocs, provided by gnu-web-doc-update,
provided by readme-release.
* README-hacking: Update accordingly.
2012-06-12 14:49:15 +02:00
Akim Demaille cc9fb4f6b6 gnulib: update readme-release.
* gnulib (readme-release): Now includes the modules it promotes.
* bootstrap.conf: Simplify accordingly.
2012-06-07 11:15:04 +02:00
Akim Demaille f763e6ef67 maint: cfg.mk: manual title.
* cfg.mk (manuel_title): New.
2012-06-07 11:15:04 +02:00
Akim Demaille c4576b484a maint: cfg.mk: simplify
* cfg.mk: Remove bits provided by maint.mk.
2012-06-07 11:15:04 +02:00
Akim Demaille 91aadcc7a9 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-06-07 11:15:04 +02:00
77 changed files with 3915 additions and 3112 deletions
+1 -1
View File
@@ -11,6 +11,7 @@
/INSTALL
/Makefile
/Makefile.in
/README-release
/_*
/a.exe
/a.out
@@ -31,4 +32,3 @@
/patches
/releases
/stamp-h*
/README-release
+1 -1
View File
@@ -1 +1 @@
2.5
2.6.2
+11 -9
View File
@@ -66,13 +66,15 @@ update-package-copyright-year:
gen_start_date = 2012-01-16
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
$(top_srcdir)/build-aux/gitlog-to-changelog \
--strip-tab \
--strip-cherry-picked \
--no-cluster \
--amend=$(srcdir)/build-aux/git-log-fix \
--since=$(gen_start_date) > $(distdir)/cl-t; \
rm -f $(distdir)/ChangeLog; \
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
cl=$(distdir)/ChangeLog && \
rm -f $$cl.tmp && \
$(top_srcdir)/build-aux/gitlog-to-changelog \
--strip-tab \
--strip-cherry-pick \
--no-cluster \
--amend=$(srcdir)/build-aux/git-log-fix \
--srcdir=$(srcdir) \
--since=$(gen_start_date) > $$cl.tmp && \
mv -f $$cl.tmp $$cl; \
fi
+314 -54
View File
@@ -1,5 +1,236 @@
GNU Bison NEWS
* Noteworthy changes in release 2.6.3 (2012-10-22) [stable]
** Bug fixes
Bugs and portability issues in the test suite have been fixed.
Some errors in translations have been addressed, and --help now directs
users to the appropriate place to report them.
Stray Info files shipped by accident are removed.
Incorrect definitions of YY_, issued by yacc.c when no parser header is
generated, are removed.
All the generated headers are self-contained.
** Header guards (yacc.c, glr.c, glr.cc)
In order to avoid collisions, the header guards are now
YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
For instance the header generated from
%define api.prefix "calc"
%defines "lib/parse.h"
will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.
** Fix compiler warnings in the generated parser (yacc.c, glr.c)
The compilation of pure parsers (%define api.pure) can trigger GCC
warnings such as:
input.c: In function 'yyparse':
input.c:1503:12: warning: 'yylval' may be used uninitialized in this
function [-Wmaybe-uninitialized]
*++yyvsp = yylval;
^
This is now fixed; pragmas to avoid these warnings are no longer needed.
Warnings from clang ("equality comparison with extraneous parentheses" and
"function declared 'noreturn' should not return") have also been
addressed.
* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
** Bug fixes
Buffer overruns, complaints from Flex, and portability issues in the test
suite have been fixed.
** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
Trailing end-of-lines in %parse-param or %lex-param would result in
invalid C++. This is fixed.
** Spurious spaces and end-of-lines
The generated files no longer end (nor start) with empty lines.
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
Bison no longer executes user-specified M4 code when processing a grammar.
** Future Changes
In addition to the removal of the features announced in Bison 2.6, the
next major release will remove the "Temporary hack for adding a semicolon
to the user action", as announced in the release 2.5. Instead of:
exp: exp "+" exp { $$ = $1 + $3 };
write:
exp: exp "+" exp { $$ = $1 + $3; };
** Bug fixes
*** Type names are now properly escaped.
*** glr.cc: set_debug_level and debug_level work as expected.
*** Stray @ or $ in actions
While Bison used to warn about stray $ or @ in action rules, it did not
for other actions such as printers, destructors, or initial actions. It
now does.
** Type names in actions
For consistency with rule actions, it is now possible to qualify $$ by a
type-name in destructors, printers, and initial actions. For instance:
%printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
will display two values for each typed and untyped symbol (provided
that YYSTYPE has both "ival" and "fval" fields).
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
** Future Changes
The next major release of Bison will drop support for the following
deprecated features. Please report disagreements to [email protected].
*** K&R C parsers
Support for generating parsers in K&R C will be removed. Parsers
generated for C support ISO C90, and are tested with ISO C99 and ISO C11
compilers.
*** Features deprecated since Bison 1.875
The definitions of yystype and yyltype will be removed; use YYSTYPE and
YYLTYPE.
YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
%lex-param, will no longer be supported.
Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
%error-verbose.
*** The generated header will be included (yacc.c)
Instead of duplicating the content of the generated header (definition of
YYSTYPE, yyparse declaration etc.), the generated parser will include it,
as is already the case for GLR or C++ parsers. This change is deferred
because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
it.
** Generated Parser Headers
*** Guards (yacc.c, glr.c, glr.cc)
The generated headers are now guarded, as is already the case for C++
parsers (lalr1.cc). For instance, with --defines=foo.h:
#ifndef YY_FOO_H
# define YY_FOO_H
...
#endif /* !YY_FOO_H */
*** New declarations (yacc.c, glr.c)
The generated header now declares yydebug and yyparse. Both honor
--name-prefix=bar_, and yield
int bar_parse (void);
rather than
#define yyparse bar_parse
int yyparse (void);
in order to facilitate the inclusion of several parser headers inside a
single compilation unit.
*** Exported symbols in C++
The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
header, are removed, as they prevent the possibility of including several
generated headers from a single compilation unit.
*** YYLSP_NEEDED
For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
longer defined.
** New %define variable: api.prefix
Now that the generated headers are more complete and properly protected
against multiple inclusions, constant names, such as YYSTYPE are a
problem. While yyparse and others are properly renamed by %name-prefix,
YYSTYPE, YYDEBUG and others have never been affected by it. Because it
would introduce backward compatibility issues in projects not expecting
YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
it is deprecated in favor of a new %define variable: api.prefix.
The following examples compares both:
%name-prefix "bar_" | %define api.prefix "bar_"
%token <ival> FOO %token <ival> FOO
%union { int ival; } %union { int ival; }
%% %%
exp: 'a'; exp: 'a';
bison generates:
#ifndef BAR_FOO_H #ifndef BAR_FOO_H
# define BAR_FOO_H # define BAR_FOO_H
/* Enabling traces. */ /* Enabling traces. */
# ifndef YYDEBUG | # ifndef BAR_DEBUG
> # if defined YYDEBUG
> # if YYDEBUG
> # define BAR_DEBUG 1
> # else
> # define BAR_DEBUG 0
> # endif
> # else
# define YYDEBUG 0 | # define BAR_DEBUG 0
> # endif
# endif | # endif
# if YYDEBUG | # if BAR_DEBUG
extern int bar_debug; extern int bar_debug;
# endif # endif
/* Tokens. */ /* Tokens. */
# ifndef YYTOKENTYPE | # ifndef BAR_TOKENTYPE
# define YYTOKENTYPE | # define BAR_TOKENTYPE
enum yytokentype { | enum bar_tokentype {
FOO = 258 FOO = 258
}; };
# endif # endif
#if ! defined YYSTYPE \ | #if ! defined BAR_STYPE \
&& ! defined YYSTYPE_IS_DECLARED | && ! defined BAR_STYPE_IS_DECLARED
typedef union YYSTYPE | typedef union BAR_STYPE
{ {
int ival; int ival;
} YYSTYPE; | } BAR_STYPE;
# define YYSTYPE_IS_DECLARED 1 | # define BAR_STYPE_IS_DECLARED 1
#endif #endif
extern YYSTYPE bar_lval; | extern BAR_STYPE bar_lval;
int bar_parse (void); int bar_parse (void);
#endif /* !BAR_FOO_H */ #endif /* !BAR_FOO_H */
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
** Future changes:
@@ -37,10 +268,10 @@ GNU Bison NEWS
The header files such as "parser.hh", "location.hh", etc. used a constant
name for preprocessor guards, for instance:
#ifndef BISON_LOCATION_HH
# define BISON_LOCATION_HH
...
#endif // !BISON_LOCATION_HH
#ifndef BISON_LOCATION_HH
# define BISON_LOCATION_HH
...
#endif // !BISON_LOCATION_HH
The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
case characters are converted to upper case, and series of
@@ -48,10 +279,10 @@ GNU Bison NEWS
With "bison -o lang++/parser.cc", "location.hh" would now include:
#ifndef YY_LANG_LOCATION_HH
# define YY_LANG_LOCATION_HH
...
#endif // !YY_LANG_LOCATION_HH
#ifndef YY_LANG_LOCATION_HH
# define YY_LANG_LOCATION_HH
...
#endif // !YY_LANG_LOCATION_HH
*** C++ locations:
@@ -92,7 +323,7 @@ GNU Bison NEWS
This includes warnings with some compilers, unexpected behavior of tools
such as diff, warning messages from the test suite itself, etc.
*** The install-pdf target work properly:
*** The install-pdf target works properly:
Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
halts in the middle of its course.
@@ -282,33 +513,33 @@ GNU Bison NEWS
to use it. If, for instance, your location structure has "first"
and "last" members, instead of
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first = (Rhs)[1].location.first; \
(Current).last = (Rhs)[N].location.last; \
} \
else \
{ \
(Current).first = (Current).last = (Rhs)[0].location.last; \
} \
while (false)
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first = (Rhs)[1].location.first; \
(Current).last = (Rhs)[N].location.last; \
} \
else \
{ \
(Current).first = (Current).last = (Rhs)[0].location.last; \
} \
while (false)
use:
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first = YYRHSLOC (Rhs, 1).first; \
(Current).last = YYRHSLOC (Rhs, N).last; \
} \
else \
{ \
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
} \
while (false)
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first = YYRHSLOC (Rhs, 1).first; \
(Current).last = YYRHSLOC (Rhs, N).last; \
} \
else \
{ \
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
} \
while (false)
** YYLLOC_DEFAULT in C++:
@@ -927,26 +1158,26 @@ GNU Bison NEWS
if the symbols have destructors. For instance:
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
| exp "+" exp
;
| 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); }
;
{ $$ = $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; }
;
| 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.
@@ -1161,6 +1392,33 @@ GNU Bison NEWS
- "parsing stack overflow..." -> "parser stack overflow"
GLR parsers now report "parser stack overflow" as per the Bison manual.
** %parse-param and %lex-param
The macros YYPARSE_PARAM and YYLEX_PARAM provide a means to pass
additional context to yyparse and yylex. They suffer from several
shortcomings:
- a single argument only can be added,
- their types are weak (void *),
- this context is not passed to ancillary functions such as yyerror,
- only yacc.c parsers support them.
The new %parse-param/%lex-param directives provide a more precise control.
For instance:
%parse-param {int *nastiness}
%lex-param {int *nastiness}
%parse-param {int *randomness}
results in the following signatures:
int yylex (int *nastiness);
int yyparse (int *nastiness, int *randomness);
or, if both %pure-parser and %locations are used:
int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
int yyparse (int *nastiness, int *randomness);
** Bison now warns if it detects conflicting outputs to the same file,
e.g., it generates a warning for "bison -d -o foo.h foo.y" since
that command outputs both code and header to foo.h.
@@ -1190,16 +1448,16 @@ GNU Bison NEWS
In agreement with POSIX and with other Yaccs, leaving a default
action is valid when $$ is untyped, and $1 typed:
untyped: ... typed;
untyped: ... typed;
but the converse remains an error:
typed: ... untyped;
typed: ... untyped;
** Values of mid-rule actions
The following code:
foo: { ... } { $$ = $1; } ...
foo: { ... } { $$ = $1; } ...
was incorrectly rejected: $1 is defined in the second mid-rule
action, and is equal to the $$ of the first mid-rule action.
@@ -1281,9 +1539,9 @@ GNU Bison NEWS
** Incorrect "Token not used"
On a grammar such as
%token useless useful
%%
exp: '0' %prec useful;
%token useless useful
%%
exp: '0' %prec useful;
where a token was used to set the precedence of the last rule,
bison reported both "useful" and "useless" as useless tokens.
@@ -1302,9 +1560,9 @@ GNU Bison NEWS
the user symbol is used in the reports, the graphs, and the verbose
error messages instead of "$end", which remains being the default.
For instance
%token MYEOF 0
%token MYEOF 0
or
%token MYEOF 0 "end of file"
%token MYEOF 0 "end of file"
** Semantic parser
This old option, which has been broken for ages, is removed.
@@ -1340,9 +1598,9 @@ GNU Bison NEWS
Previous versions don't complain when there is a type clash on
the default action if the rule has a mid-rule action, such as in:
%type <foo> bar
%%
bar: '0' {} '0';
%type <foo> bar
%%
bar: '0' {} '0';
This is fixed.
@@ -1639,9 +1897,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG
LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG YY
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
LocalWords: Automake TMPDIR LESSEQ
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval
Local Variables:
mode: outline
+60 -32
View File
@@ -1,5 +1,3 @@
-*- outline -*-
This file attempts to describe the rules to use when hacking Bison.
Don't put this file into the distribution.
@@ -60,8 +58,8 @@ tools we depend upon, including:
- Rsync <http://samba.anu.edu.au/rsync/>
- Tar <http://www.gnu.org/software/tar/>
Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture.
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
your architecture.
Bison is written using Bison grammars, so there are bootstrapping
issues. The bootstrap script attempts to discover when the C code
@@ -124,7 +122,7 @@ import requests for updated submodules. A simple "git diff" will
reveal if the current version of the submodule (i.e., the actual
contents of the gnulib directory) and the current request from the
subscriber (i.e., the reference of the version of gnulib that the
Bison reporitory requests) differ. To upgrade the submodules (i.e.,
Bison repository requests) differ. To upgrade the submodules (i.e.,
to check out the version that is actually requested by the subscriber,
run "git submodule update".
@@ -155,7 +153,7 @@ formal release, see the ChangeLog in the latest gnulib snapshot at:
http://erislabs.net/ianb/projects/gnulib/
The autoconf files we use are currently:
The Autoconf files we use are currently:
m4/m4.m4
lib/m4sugar/m4sugar.m4
@@ -170,6 +168,36 @@ decide whether to update.
** make check
Use liberally.
** Typical errors
If the test suite shows failures such as the following one
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
it probably means that some file was compiled without
AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
pick up gnulib's replacement headers, such as getopt.h, and this will go
wrong if config.h was not included first.
See tests/local.at for details.
** make maintainer-check-valgrind
This target uses valgrind both to check bison, and the generated parsers.
This is not mature on Mac OS X. First, Valgrind does support the way bison
calls m4, so Valgrind cannot be used to check bison on Mac OS X.
Second, there are many errors that come from the platform itself, not from
bison. build-aux/darwin11.4.0.valgrind addresses some of them.
Third, valgrind issues warnings such as:
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
which cause the test to fail uselessly. It is hard to ignore these errors
with a major overhaul of the way instrumentation is performed in the test
suite. So currently, do not try to run valgrind on Mac OS X.
** Release checks
Try to run the test suite with more severe conditions before a
release:
@@ -248,25 +276,13 @@ copyright statement for each Bison file, check the copyright statements
that the skeletons insert into generated parsers, and check all
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
** Update NEWS
The version number, *and* the date of the release (including for
betas).
** Update NEWS, commit and tag.
See do-release-commit-and-tag in README-release. For a while, we used
beta names such as "2.6_rc1". Now that we use gnulib in the release
procedure, we must use "2.5.90", which has the additional benefit of
being properly sorted in "git tag -l".
** Mention the release name in a commit message
Should have an entry similar to "Version 2.3b.".
** Tag the release
Before Bison will build with the right version number, you must tag
the release in git. Do this after all other changes. The command is
similar to:
git tag -a v2.3b -m "Bison 2.3b."
** Push
Once "make distcheck" passes, push your changes and the tag.
"git push" without arguments will not push the tag.
** make alpha, beta, or release
** make alpha, beta, or stable
See README-release.
** Upload
@@ -287,8 +303,8 @@ where F125BDF3 should be replaced with your key ID.
*** Using gnupload
You need "ncftp".
At the end "make release" (or alpha/beta) will display the prodecure
to run. Just copy and paste it in your shell.
At the end "make stable" (or alpha/beta) will display the procedure to
run. Just copy and paste it in your shell.
*** By hand
@@ -359,7 +375,8 @@ function 'index', once for the table of contents); you can ignore this
issue.
** Announce
To generate a template announcement file:
The "make stable" (or alpha/beta) command just created a template,
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
@@ -379,15 +396,15 @@ newsgroup by sending email to [email protected]. Do not make any Cc as
the moderator will throw away anything cross-posted or Cc'ed. It really
needs to be a separate message.
** Bump the version number
In configure.ac. Run "make". So that developers don't accidentally add new
items to the old NEWS entry, create a new empty NEWS entry something like:
** Prepare NEWS
So that developers don't accidentally add new items to the old NEWS
entry, create a new empty entry in line 3 (without the two leading
spaces):
Changes in version ?.? (????-??-??):
* Noteworthy changes in release ?.? (????-??-??) [?]
Push these changes.
-----
Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
@@ -406,3 +423,14 @@ 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, see <http://www.gnu.org/licenses/>.
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
LocalWords: symlinks vti html lt POSIX Cc'ed
Local Variables:
mode: outline
fill-column: 76
End:
+5 -2
View File
@@ -5,7 +5,7 @@ Airy Andre [email protected]
Akim Demaille [email protected]
Albert Chin-A-Young [email protected]
Alexander Belopolsky [email protected]
Alexandre Duret-Lutz adl@src.lip6.fr
Alexandre Duret-Lutz adl@lrde.epita.fr
Andreas Schwab [email protected]
Andrew Suffield [email protected]
Angelo Borsotti [email protected]
@@ -13,6 +13,7 @@ Anthony Heading [email protected]
Arnold Robbins [email protected]
Art Haas [email protected]
Baron Schwartz [email protected]
Ben Pfaff [email protected]
Benoit Perrot [email protected]
Bernd Kiefer [email protected]
Bert Deknuydt [email protected]
@@ -43,6 +44,7 @@ Frank Heckenbach [email protected]
Frans Englich [email protected]
Georg Sauthoff [email protected]
George Neuner [email protected]
Gilles Espinasse [email protected]
Goran Uddeborg [email protected]
Guido Trentalancia [email protected]
H. Merijn Brand [email protected]
@@ -91,6 +93,7 @@ R Blake [email protected]
Raja R Harinath [email protected]
Ralf Wildenhues [email protected]
Richard Stallman [email protected]
Rob Vermaas [email protected]
Robert Anisko [email protected]
Satya Kiran Popuri [email protected]
Sebastian Setzer [email protected]
@@ -99,7 +102,7 @@ Sergei Steshenko [email protected]
Shura [email protected]
Stefano Lattarini [email protected]
Steve Murphy [email protected]
Summum Bonum [email protected]
Sum Wu [email protected]
Thiru Ramakrishnan [email protected]
Tim Josling [email protected]
Tim Landscheidt [email protected]
-6
View File
@@ -126,12 +126,6 @@ The code bw glr.c and yacc.c is really alike, we can certainly factor
some parts.
* Yacc.c: CPP Macros
Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
They should not: it is not documented. But if they need to, let's
find something clean (not like YYLSP_NEEDED...).
* Report
** Figures
+69 -49
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2012-05-15.06; # UTC
scriptversion=2012-07-19.14; # UTC
# Bootstrap this package from checked-out sources.
@@ -77,6 +77,33 @@ Running without arguments will suffice in most cases.
EOF
}
# warnf_ FORMAT-STRING ARG1...
warnf_ ()
{
warnf_format_=$1
shift
nl='
'
case $* in
*$nl*) me_=$(printf "$me"|tr "$nl|" '??')
printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
*) printf "$me: $warnf_format_" "$@" ;;
esac >&2
}
# warn_ WORD1...
warn_ ()
{
# If IFS does not start with ' ', set it and emit the warning in a subshell.
case $IFS in
' '*) warnf_ '%s\n' "$*";;
*) (IFS=' '; warn_ "$@");;
esac
}
# die WORD1...
die() { warn_ "$@"; exit 1; }
# Configuration.
# Name of the Makefile.am
@@ -130,7 +157,8 @@ extract_package_name='
p
}
'
package=$(sed -n "$extract_package_name" configure.ac) || exit
package=$(sed -n "$extract_package_name" configure.ac) \
|| die 'cannot find package name in configure.ac'
gnulib_name=lib$package
build_aux=build-aux
@@ -186,6 +214,8 @@ use_git=true
# otherwise find the first of the NAMES that can be run (i.e.,
# supports --version). If found, set ENVVAR to the program name,
# die otherwise.
#
# FIXME: code duplication, see also gnu-web-doc-update.
find_tool ()
{
find_tool_envvar=$1
@@ -203,19 +233,15 @@ find_tool ()
else
find_tool_error_prefix="\$$find_tool_envvar: "
fi
if test x"$find_tool_res" = x; then
echo >&2 "$me: one of these is required: $find_tool_names"
exit 1
fi
($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
echo >&2 "$me: ${find_tool_error_prefix}cannot run $find_tool_res --version"
exit 1
}
test x"$find_tool_res" != x \
|| die "one of these is required: $find_tool_names"
($find_tool_res --version </dev/null) >/dev/null 2>&1 \
|| die "${find_tool_error_prefix}cannot run $find_tool_res --version"
eval "$find_tool_envvar=\$find_tool_res"
eval "export $find_tool_envvar"
}
# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6.
find_tool SHA1SUM sha1sum gsha1sum shasum
# Override the default configuration, if necessary.
@@ -230,7 +256,6 @@ esac
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
$build_aux/install-sh
$build_aux/missing
$build_aux/mdate-sh
$build_aux/texinfo.tex
$build_aux/depcomp
@@ -270,21 +295,15 @@ do
--no-git)
use_git=false;;
*)
echo >&2 "$0: $option: unknown option"
exit 1;;
die "$option: unknown option";;
esac
done
if $use_git || test -d "$GNULIB_SRCDIR"; then
:
else
echo "$0: Error: --no-git requires --gnulib-srcdir" >&2
exit 1
fi
$use_git || test -d "$GNULIB_SRCDIR" \
|| die "Error: --no-git requires --gnulib-srcdir"
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
exit 1
die "Bootstrapping from a non-checked-out distribution is risky."
fi
# Ensure that lines starting with ! sort last, per gitignore conventions
@@ -310,7 +329,7 @@ insert_sorted_if_absent() {
echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|| { echo "$str" | sort_patterns - $file > $file.bak \
&& mv $file.bak $file; } \
|| exit 1
|| die "insert_sorted_if_absent $file $str: failed"
}
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
@@ -334,11 +353,8 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
>/dev/null && found_aux_dir=yes
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
>/dev/null && found_aux_dir=yes
if test $found_aux_dir = no; then
echo "$0: expected line not found in configure.ac. Add the following:" >&2
echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
exit 1
fi
test $found_aux_dir = yes \
|| die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
# If $build_aux doesn't exist, create it now, otherwise some bits
# below will malfunction. If creating it, also mark it as ignored.
@@ -444,7 +460,7 @@ check_versions() {
automake-ng|aclocal-ng)
app=${app%-ng}
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
echo "$me: Error: '$app' not found or not from Automake-NG" >&2
warn_ "Error: '$app' not found or not from Automake-NG"
ret=1
continue
} ;;
@@ -454,20 +470,21 @@ check_versions() {
# so we have to rely on $? rather than get_version.
$app --version >/dev/null 2>&1
if [ 126 -le $? ]; then
echo "$me: Error: '$app' not found" >&2
warn_ "Error: '$app' not found"
ret=1
fi
else
# Require app to produce a new enough version string.
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
echo "$me: Error: '$app' not found" >&2
warn_ "Error: '$app' not found"
ret=1
else
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
echo " '$app' version >= $req_ver is required" >&2
warnf_ '%s\n' \
"Error: '$app' version == $inst_ver is too old" \
" '$app' version >= $req_ver is required"
ret=1
fi
fi
@@ -524,11 +541,10 @@ fi
if ! printf "$buildreq" | check_versions; then
echo >&2
if test -f README-prereq; then
echo "$0: See README-prereq for how to get the prerequisite programs" >&2
die "See README-prereq for how to get the prerequisite programs"
else
echo "$0: Please install the prerequisite programs" >&2
die "Please install the prerequisite programs"
fi
exit 1
fi
echo "$0: Bootstrapping from checked-out $package sources..."
@@ -739,11 +755,10 @@ symlink_to_dir()
*)
case /$dst/ in
*//* | */../* | */./* | /*/*/*/*/*/)
echo >&2 "$me: invalid symlink calculation: $src -> $dst"
exit 1;;
/*/*/*/*/) dot_dots=../../../;;
/*/*/*/) dot_dots=../../;;
/*/*/) dot_dots=../;;
die "invalid symlink calculation: $src -> $dst";;
/*/*/*/*/) dot_dots=../../../;;
/*/*/*/) dot_dots=../../;;
/*/*/) dot_dots=../;;
esac;;
esac
@@ -765,7 +780,7 @@ version_controlled_file() {
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
grep '^/[^/]*/[0-9]' > /dev/null
else
echo "$me: no version control for $file?" >&2
warn_ "no version control for $file?"
false
fi
}
@@ -855,11 +870,12 @@ echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file || exit
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
bootstrap_post_import_hook \
|| { echo >&2 "$me: bootstrap_post_import_hook failed"; exit 1; }
|| die "bootstrap_post_import_hook failed"
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
@@ -887,7 +903,7 @@ echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
AUTOPOINT=true LIBTOOLIZE=true \
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
|| exit 1
|| die "autoreconf failed"
# Get some extra files from gnulib, overriding existing files.
for file in $gnulib_extra_files; do
@@ -896,7 +912,8 @@ for file in $gnulib_extra_files; do
build-aux/*) dst=$build_aux/${file#build-aux/};;
*) dst=$file;;
esac
symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
|| die "failed to symlink $file"
done
if test $with_gettext = yes; then
@@ -912,7 +929,8 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
}
' po/Makevars.template >po/Makevars || exit 1
' po/Makevars.template >po/Makevars \
|| die 'cannot generate po/Makevars'
# If the 'gettext' module is in use, grab the latest Makefile.in.in.
# If only the 'gettext-h' module is in use, assume autopoint already
@@ -920,7 +938,8 @@ if test $with_gettext = yes; then
case $gnulib_modules in
*gettext-h*) ;;
*gettext*)
cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1
cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
|| die "cannot create po/Makefile.in.in"
;;
esac
@@ -936,7 +955,8 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
}
' po/Makevars.template >runtime-po/Makevars || exit 1
' po/Makevars.template >runtime-po/Makevars \
|| die 'cannot generate runtime-po/Makevars'
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
+7 -5
View File
@@ -17,15 +17,17 @@
# gnulib modules used by this package.
gnulib_modules='
announce-gen argmatch assert calloc-posix close closeout config-h c-strcase
argmatch assert calloc-posix close closeout config-h c-strcase
configmake
dirname
do-release-commit-and-tag
error extensions fdl fopen-safer gendocs getopt-gnu
error extensions fdl fopen-safer getopt-gnu
gettext git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script
javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr
mbswidth obstack perror progname
javaexec-script ldexpl malloc-gnu mbschr mbsrchr
mbswidth
obstack
obstack-printf
perror progname
quote quotearg
readme-release
realloc-posix
+3 -1
View File
@@ -8,9 +8,12 @@
/config.rpath
/config.sub
/depcomp
/do-release-commit-and-tag
/gendocs.sh
/git-version-gen
/gitlog-to-changelog
/gnu-web-doc-update
/gnupload
/install-sh
/javacomp.sh.in
/javaexec.sh.in
@@ -23,4 +26,3 @@
/vc-list-files
/warn-on-use.h
/ylwrap
/do-release-commit-and-tag
+20 -2
View File
@@ -1,2 +1,20 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
EXTRA_DIST = prev-version.txt cross-options.pl update-b4-copyright
## Copyright (C) 2006, 2009-2012 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 3 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, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = \
cross-options.pl \
darwin11.4.0.valgrind \
prev-version.txt \
update-b4-copyright
+64
View File
@@ -0,0 +1,64 @@
# Copyright (C) 2012 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 3 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, see <http://www.gnu.org/licenses/>.
# Valgrind suppression file for Bison.
{
Mac OS X initialization
Memcheck:Leak
fun:?alloc*
...
fun:*ImageLoader*
}
{
Mac OS X initialization
Memcheck:Leak
fun:?alloc*
...
fun:*dyld*
}
{
Mac OS X initialization
Memcheck:Leak
fun:?alloc*
...
fun:__CFInitialize
}
{
Mac OS X I/O buffer
Memcheck:Leak
fun:malloc
fun:__smakebuf
fun:__swsetup
fun:__sfvwrite
fun:fwrite
}
{
Mac OS X I/O buffer
Memcheck:Leak
fun:malloc
fun:__smakebuf
fun:__swsetup
fun:__swbuf
fun:putchar
}
# Local Variables:
# mode: shell-script
# End:
+4
View File
@@ -0,0 +1,4 @@
/_Noreturn.h
/arg-nonnull.h
/c++defs.h
/warn-on-use.h
+18 -12
View File
@@ -1,5 +1,4 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -15,6 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Update version, then recompile so that tests/bison --version be
# up-to-date, then compile our parser again with our up-to-date bison.
.PHONY: regen
regen: _version
$(MAKE) $(AM_MAKEFLAGS)
touch $(srcdir)/src/parse-gram.y
$(MAKE) $(AM_MAKEFLAGS)
# Used in maint.mk's web-manual rule
manual_title = The Yacc-compatible Parser Generator
# It's useful to run maintainer-*check* targets during development, but we
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
@@ -22,13 +32,6 @@
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
# Use alpha.gnu.org for alpha and beta releases.
# Use ftp.gnu.org for major releases.
gnu_ftp_host-alpha = alpha.gnu.org
gnu_ftp_host-beta = alpha.gnu.org
gnu_ftp_host-major = ftp.gnu.org
gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
url_dir_list = \
ftp://$(gnu_rel_host)/gnu/bison
@@ -57,17 +60,20 @@ update-copyright: update-b4-copyright update-package-copyright-year
update-copyright-env = \
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
exclude = $(foreach a,$(1),$(eval exclude_file_name_regexp--sc_$(a)))
exclude = \
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
prohibit_magic_number_exit=^doc/bison.texi$$ \
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
space_tab=^tests/(input|c\+\+)\.at$$ \
trailing_blank=^src/parse-gram.[ch]$$ \
unmarked_diagnostics=^djgpp/ \
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$) \
)
+14
View File
@@ -123,6 +123,10 @@ AC_PROG_GNU_M4
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
supports -g, otherwise to "".])
AC_PATH_PROG([PERL], [perl])
if test -z "$PERL"; then
AC_MSG_ERROR([perl not found])
fi
AM_MISSING_PROG([HELP2MAN], [help2man])
AC_PATH_PROG([XSLTPROC], [xsltproc])
AC_SUBST([XSLTPROC])
@@ -163,6 +167,16 @@ AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
AC_CHECK_PROGS([VALGRIND], [valgrind])
case $VALGRIND:$host_os in
'':*) ;;
*:darwin*)
# See README-hacking.
# VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
VALGRIND=;;
*:*)
AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"]);;
esac
AM_MISSING_PROG([AUTOM4TE], [autom4te])
# Needed by tests/atlocal.in.
AC_SUBST([GCC])
+1
View File
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
dist_pkgdata_DATA = README bison.m4 \
c-like.m4 \
c-skel.m4 c.m4 yacc.c glr.c \
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
java-skel.m4 java.m4 lalr1.java
+37 -29
View File
@@ -183,21 +183,6 @@ m4_define([b4_fatal_at],
m4_exit(1)])
## ---------------- ##
## Default values. ##
## ---------------- ##
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
m4_define_default([b4_pre_prologue], [])
m4_define_default([b4_post_prologue], [])
m4_define_default([b4_epilogue], [])
m4_define_default([b4_parse_param], [])
# The initial column and line.
m4_define_default([b4_location_initial_column], [1])
m4_define_default([b4_location_initial_line], [1])
## ------------ ##
## Data Types. ##
## ------------ ##
@@ -233,9 +218,9 @@ m4_define([b4_define_flag_if],
# _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.
# Work around the impossibility to define macros inside macros,
# because issuing `[$1]' is not possible in M4. GNU M4 should provide
# $$1 a la M5/TeX.
m4_define([_b4_define_flag_if],
[m4_if([$1$2], $[1]$[2], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl
@@ -246,17 +231,17 @@ m4_define([b4_$3_if],
# b4_FLAG_if(IF-TRUE, IF-FALSE)
# -----------------------------
# 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]) # Whether error are verbose.
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([locations]) # Whether locations are tracked.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
b4_define_flag_if([defines]) # Whether headers are requested.
b4_define_flag_if([error_verbose]) # Whether error are verbose.
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([locations]) # Whether locations are tracked.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
# yytoken_table is needed to support verbose errors.
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
## ------------------------- ##
## Assigning token numbers. ##
## ------------------------- ##
## ----------- ##
@@ -274,8 +259,8 @@ m4_define([b4_basename],
# b4_syncline(LINE, FILE)
# -----------------------
m4_define([b4_syncline],
[b4_flag_if([synclines], [
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
[b4_flag_if([synclines],
[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
b4_sync_start([$1], [$2])])])
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
@@ -576,3 +561,26 @@ m4_wrap_lifo([
b4_check_user_names_wrap([[define]], [[variable]])
b4_check_user_names_wrap([[code]], [[qualifier]])
])
## ---------------- ##
## Default values. ##
## ---------------- ##
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
m4_define_default([b4_pre_prologue], [])
m4_define_default([b4_post_prologue], [])
m4_define_default([b4_epilogue], [])
m4_define_default([b4_parse_param], [])
# The initial column and line.
m4_define_default([b4_location_initial_column], [1])
m4_define_default([b4_location_initial_line], [1])
# Sanity checks.
b4_percent_define_ifdef([api.prefix],
[m4_ifdef([b4_prefix],
[b4_complain_at(b4_percent_define_get_loc([api.prefix]),
[['%s' and '%s' cannot be used together]],
[%name-prefix],
[%define api.prefix])])])
+29
View File
@@ -174,3 +174,32 @@ m4_define([b4_cc_var_decls],
], [$@])])
m4_define([b4_cc_var_decl],
[ $1;])
## ---------##
## Values. ##
## ---------##
# b4_yylloc_default_define
# ------------------------
# Define YYLLOC_DEFAULT.
m4_define([b4_yylloc_default_define],
[[/* 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*/ false)
# endif
]])
+44
View File
@@ -0,0 +1,44 @@
-*- Autoconf -*-
# Common code for C-like languages (C, C++, Java, etc.)
# Copyright (C) 2012 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 3 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, see <http://www.gnu.org/licenses/>.
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
# ----------------------------------------------
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
# pointer.
m4_define([b4_dollar_dollar_],
[m4_if([$2], [[]],
[m4_ifval([$3], [($1.$3)],
[$1])],
[($1.$2)])])
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
# b4_dollar_popdef
# ---------------------------------------------------------
# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,
# and b4_at_dollar for LOCATION.
m4_define([b4_dollar_pushdef],
[m4_pushdef([b4_dollar_dollar],
[b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
m4_pushdef([b4_at_dollar], [$3])dnl
])
m4_define([b4_dollar_popdef],
[m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl
])
+137 -24
View File
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[c-like.m4])
# b4_tocpp(STRING)
# ----------------
@@ -29,19 +30,21 @@ m4_define([b4_tocpp],
# ------------------
# A valid C macro name to use as a CPP header guard for FILE.
m4_define([b4_cpp_guard],
[b4_tocpp(m4_defn([b4_prefix])/[$1])])
[[YY_]b4_tocpp(m4_defn([b4_prefix])/[$1])[_INCLUDED]])
# b4_cpp_guard_open(FILE)
# b4_cpp_guard_close(FILE)
# ------------------------
# Open/close CPP inclusion guards for FILE.
# If FILE does not expand to nothing, open/close CPP inclusion guards for FILE.
m4_define([b4_cpp_guard_open],
[m4_ifval(m4_quote($1),
[#ifndef b4_cpp_guard([$1])
# define b4_cpp_guard([$1])])
# define b4_cpp_guard([$1])])])
m4_define([b4_cpp_guard_close],
[#endif b4_comment([!b4_cpp_guard([$1])])])
[m4_ifval(m4_quote($1),
[#endif b4_comment([!b4_cpp_guard([$1])])])])
## ---------------- ##
@@ -77,9 +80,6 @@ m4_define([b4_identification],
/* Pull parsers. */
#define YYPULL ]b4_pull_flag])[
/* Using locations. */
#define YYLSP_NEEDED ]b4_locations_flag[
]])
@@ -87,11 +87,24 @@ m4_define([b4_identification],
## Default values. ##
## ---------------- ##
# If the %union is not named, its name is YYSTYPE.
m4_define_default([b4_union_name], [YYSTYPE])
# b4_api_prefix, b4_api_PREFIX
# ----------------------------
# Corresponds to %define api.prefix
b4_percent_define_default([[api.prefix]], [[yy]])
m4_define([b4_api_prefix],
[b4_percent_define_get([[api.prefix]])])
m4_define([b4_api_PREFIX],
[m4_toupper(b4_api_prefix)])
# b4_prefix
# ---------
# If the %name-prefix is not given, it is api.prefix.
m4_define_default([b4_prefix], [b4_api_prefix])
# If the %union is not named, its name is YYSTYPE.
m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])
# If the %name-prefix is not given, it is yy.
m4_define_default([b4_prefix], [yy])
## ------------------------ ##
## Pure/impure interfaces. ##
@@ -171,7 +184,7 @@ m4_define([b4_table_value_equals],
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|| m4_indir([b4_]$1[_max]) < $3), [1],
[[YYID (0)]],
[[((]$2[) == (]$3[))]])])
[(!!(($2) == ($3)))])])
## ---------##
@@ -235,18 +248,18 @@ m4_define([b4_token_enum],
# Output the definition of the tokens (if there are) as enums.
m4_define([b4_token_enums],
[m4_if([$#$1], [1], [],
[/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
[[/* Tokens. */
#ifndef ]b4_api_PREFIX[TOKENTYPE
# define ]b4_api_PREFIX[TOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
m4_map_sep([ b4_token_enum], [,
enum ]b4_api_prefix[tokentype {
]m4_map_sep([ b4_token_enum], [,
],
[$@])
[$@])[
};
#endif
])])
]])])
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
@@ -411,17 +424,18 @@ $2
# SYMBOL-TAG, SYMBOL-NUM,
# SYMBOL-ACTION, SYMBOL-TYPENAME)
# -------------------------------------------------
# Issue the code for a symbol action (e.g., %printer).
#
# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
m4_define([b4_symbol_actions],
[m4_pushdef([b4_dollar_dollar],
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
case $4: /* $3 */
b4_syncline([$2], [$1])
$5;
b4_syncline([@oline@], [@ofile@])
break;
m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl
b4_dollar_popdef[]dnl
])
@@ -530,3 +544,102 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
YYFPRINTF (yyoutput, ")");
}]dnl
])
## -------------- ##
## Declarations. ##
## -------------- ##
# b4_declare_yylstype
# -------------------
# Declarations that might either go into the header (if --defines) or
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
m4_define([b4_declare_yylstype],
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
]m4_ifdef([b4_stype],
[[typedef union ]b4_union_name[
{
]b4_user_stype[
} ]b4_api_PREFIX[STYPE;
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]],
[m4_if(b4_tag_seen_flag, 0,
[[typedef int ]b4_api_PREFIX[STYPE;
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]])])[
# define ]b4_api_prefix[stype ]b4_api_PREFIX[STYPE /* obsolescent; will be withdrawn */
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
#endif]b4_locations_if([[
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
typedef struct ]b4_api_PREFIX[LTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} ]b4_api_PREFIX[LTYPE;
# define ]b4_api_prefix[ltype ]b4_api_PREFIX[LTYPE /* obsolescent; will be withdrawn */
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
#endif]])
b4_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval;
]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl
])
# b4_YYDEBUG_define
# ------------------
m4_define([b4_YYDEBUG_define],
[[/* Enabling traces. */
]m4_if(b4_api_prefix, [yy],
[[#ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[
#endif]],
[[#ifndef ]b4_api_PREFIX[DEBUG
# if defined YYDEBUG
# if YYDEBUG
# define ]b4_api_PREFIX[DEBUG 1
# else
# define ]b4_api_PREFIX[DEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
# endif /* ! defined ]b4_api_PREFIX[DEBUG */
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
])
# b4_declare_yydebug
# ------------------
m4_define([b4_declare_yydebug],
[b4_YYDEBUG_define[
#if ]b4_api_PREFIX[DEBUG
extern int ]b4_prefix[debug;
#endif][]dnl
])
# b4_yylloc_default_define
# ------------------------
# Define YYLLOC_DEFAULT.
m4_define([b4_yylloc_default_define],
[[/* 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 (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif
]])
+79 -134
View File
@@ -18,7 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[c.m4])
# If we are loaded by glr.cc, do not override c++.m4 definitions by
# those of c.m4.
m4_if(b4_skeleton, ["glr.c"],
[m4_include(b4_pkgdatadir/[c.m4])])
## ---------------- ##
## Default values. ##
@@ -154,6 +157,23 @@ m4_define([b4_rhs_location],
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
## -------------- ##
## Declarations. ##
## -------------- ##
# b4_shared_declarations
# ----------------------
# Declaration that might either go into the header (if --defines)
# or open coded in the parser body.
m4_define([b4_shared_declarations],
[b4_declare_yydebug[
]b4_percent_code_get([[requires]])[
]b4_token_enums(b4_tokens)[
]b4_declare_yylstype[
]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
]b4_percent_code_get([[provides]])[]dnl
])
## -------------- ##
## Output files. ##
@@ -170,66 +190,29 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
]b4_identification
b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [],
[/* Substitute the variable and function names. */
#define yyparse b4_prefix[]parse
#define yylex b4_prefix[]lex
#define yyerror b4_prefix[]error
#define yylval b4_prefix[]lval
#define yychar b4_prefix[]char
#define yydebug b4_prefix[]debug
#define yynerrs b4_prefix[]nerrs
#define yylloc b4_prefix[]lloc])[
b4_percent_code_get([[top]])[
]m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
]m4_if(b4_prefix, [yy], [],
[[/* Substitute the variable and function names. */
#define yyparse ]b4_prefix[parse
#define yylex ]b4_prefix[lex
#define yyerror ]b4_prefix[error
#define yylval ]b4_prefix[lval
#define yychar ]b4_prefix[char
#define yydebug ]b4_prefix[debug
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])])[
/* Copy the first part of user declarations. */
]b4_user_pre_prologue
]b4_user_pre_prologue[
b4_null_define
]b4_null_define[
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_percent_code_get([[requires]])[]dnl
b4_token_enums(b4_tokens)
[#ifndef YYSTYPE
]m4_ifdef([b4_stype],
[[typedef union ]b4_union_name[
{
]b4_user_stype[
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1]],
[m4_if(b4_tag_seen_flag, 0,
[[typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1]])])[
#endif
]b4_locations_if([[
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
]])[
]b4_percent_code_get([[provides]])[]dnl
])
b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
[b4_shared_declarations])[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[
#endif
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
[b4_shared_declarations])[
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
@@ -239,11 +222,6 @@ b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
# 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.
@@ -263,24 +241,24 @@ b4_percent_code_get[]dnl
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
]b4_c_function_def([YYID], [static int], [[int i], [i]])[
{
@@ -311,8 +289,9 @@ b4_percent_code_get[]dnl
#ifndef YYSETJMP
# include <setjmp.h>
# define YYJMP_BUF jmp_buf
# define YYSETJMP(env) setjmp (env)
# define YYLONGJMP(env, val) longjmp (env, val)
# define YYSETJMP(Env) setjmp (Env)
// Pacify clang.
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
#endif
/*-----------------.
@@ -335,7 +314,7 @@ b4_percent_code_get[]dnl
#endif])[
#ifndef YYASSERT
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
#endif
/* YYFINAL -- State number of the termination state. */
@@ -370,7 +349,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
]b4_translate[
};
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
@@ -391,7 +370,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@@ -492,37 +471,13 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
]b4_stos[
};
/* Prevent warning if -Wmissing-prototypes. */
]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
/* Error token number */
#define YYTERROR 1
/* 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). */
]b4_locations_if([[
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
]b4_yylloc_default_define[
# define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
@@ -543,7 +498,6 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
@@ -577,7 +531,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
while (YYID (0))
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
# ifndef YYFPRINTF
# define YYFPRINTF fprintf
@@ -605,12 +559,12 @@ do { \
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
#else /* !]b4_api_PREFIX[DEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
#endif /* !YYDEBUG */
#endif /* !]b4_api_PREFIX[DEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
@@ -637,8 +591,8 @@ int yydebug;
#ifndef YYSTACKEXPANDABLE
# if (! defined __cplusplus \
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))
# define YYSTACKEXPANDABLE 1
# else
# define YYSTACKEXPANDABLE 0
@@ -849,7 +803,7 @@ yyMemoryExhausted (yyGLRStack* yystackp)
YYLONGJMP (yystackp->yyexception_buffer, 2);
}
#if YYDEBUG || YYERROR_VERBOSE
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE
/** A printable representation of TOKEN. */
static inline const char*
yytokenName (yySymbol yytoken)
@@ -986,7 +940,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
&yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[);
else
{
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
if (yydebug)
{
if (yys->yysemantics.yyfirstVal)
@@ -1019,8 +973,8 @@ yylhsNonterm (yyRuleNum yyrule)
return yyr1[yyrule];
}
#define yypact_value_is_default(yystate) \
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
#define yypact_value_is_default(Yystate) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
/** True iff LR state STATE has only a default reduction (regardless
* of token). */
@@ -1037,8 +991,8 @@ yydefaultAction (yyStateNum yystate)
return yydefact[yystate];
}
#define yytable_value_is_error(yytable_value) \
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
* Result R means
@@ -1415,7 +1369,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
}
}
#if !YYDEBUG
#if !]b4_api_PREFIX[DEBUG
# define YY_REDUCE_PRINT(Args)
#else
# define YY_REDUCE_PRINT(Args) \
@@ -1736,7 +1690,7 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
return yyflag;
}
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
static void
yyreportTree (yySemanticOption* yyx, int yyindent)
{
@@ -1791,7 +1745,7 @@ yyreportAmbiguity (yySemanticOption* yyx0,
YYUSE (yyx0);
YYUSE (yyx1);
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
YYFPRINTF (stderr, "Ambiguity detected.\n");
YYFPRINTF (stderr, "Option 1,\n");
yyreportTree (yyx0, 2);
@@ -2343,18 +2297,16 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yychar = YYEMPTY;
yylval = yyval_default;
]b4_locations_if([
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif
])
m4_ifdef([b4_initial_action], [
m4_pushdef([b4_at_dollar], [yylloc])dnl
m4_pushdef([b4_dollar_dollar], [yylval])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
goto yyexhaustedlab;
@@ -2575,7 +2527,7 @@ m4_popdef([b4_at_dollar])])dnl
}
/* DEBUGGING ONLY */
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
static void yypstack (yyGLRStack* yystackp, size_t yyk)
__attribute__ ((__unused__));
static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
@@ -2648,9 +2600,7 @@ yypdumpstack (yyGLRStack* yystackp)
YYFPRINTF (stderr, "\n");
}
#endif
]
b4_epilogue
]b4_epilogue[]dnl
dnl
dnl glr.cc produces its own header.
dnl
@@ -2658,15 +2608,10 @@ m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if(
[@output(b4_spec_defines_file@)@
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2012])
[2002-2012])[
b4_shared_declarations
b4_pure_if([],
[[extern YYSTYPE ]b4_prefix[lval;]])
b4_locations_if([b4_pure_if([],
[extern YYLTYPE ]b4_prefix[lloc;])
])
])])
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]])])dnl
m4_divert_pop(0)
+41 -68
View File
@@ -78,9 +78,9 @@ m4_define([b4_yy_symbol_print_generate],
[static void],
[[FILE *], []],
[[int yytype], [yytype]],
[[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep],
[[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],
[yyvaluep]],
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
[yylocationp]],
b4_parse_param)[
{
@@ -90,19 +90,22 @@ m4_define([b4_yy_symbol_print_generate],
]])
# Declare yyerror.
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
# and declaration of yyerror.
m4_append([b4_post_prologue],
[b4_syncline([@oline@], [@ofile@])
b4_c_ansi_function_decl([yyerror],
[b4_syncline([@oline@], [@ofile@])[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
]b4_c_ansi_function_decl([yyerror],
[static void],
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
[yylocationp]],
b4_parse_param,
[[const char* msg], [msg]])])
# Define yyerror.
# Hijack the epilogue to define implementations (yyerror, parser member
# functions etc.).
m4_append([b4_epilogue],
[b4_syncline([@oline@], [@ofile@])[
/*------------------.
@@ -111,7 +114,7 @@ m4_append([b4_epilogue],
]b4_c_ansi_function_def([yyerror],
[static void],
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
[yylocationp]],
b4_parse_param,
[[const char* msg], [msg]])[
@@ -127,8 +130,8 @@ 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[)]m4_ifset([b4_parse_param], [
:])[
#if YYDEBUG
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
#if ]b4_api_PREFIX[DEBUG
]m4_ifset([b4_parse_param], [ ], [ :])[
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
#endif]b4_parse_param_cons[
{
@@ -144,7 +147,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
return ::yyparse (*this]b4_user_args[);
}
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/*--------------------.
| Print this symbol. |
`--------------------*/
@@ -196,29 +199,28 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
]b4_parser_class_name[::debug_level_type
]b4_parser_class_name[::debug_level () const
{
return yydebug_;
return yydebug;
}
void
]b4_parser_class_name[::set_debug_level (debug_level_type l)
{
yydebug_ = l;
// Actually, it is yydebug which is really used.
yydebug = l;
}
#endif
]m4_popdef([b4_parse_param])dnl
b4_namespace_close[
]])
b4_namespace_close])
# 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_ref::b4_parser_class_name& yyparser], [[yyparser]]],]
m4_defn([b4_parse_param])))],
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
m4_defn([b4_parse_param]))],
[m4_pushdef([b4_parse_param],
[[[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]]]])
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
])
m4_include(b4_pkgdatadir/[glr.c])
m4_popdef([b4_parse_param])
@@ -230,42 +232,16 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
/* C++ GLR parser skeleton written by Akim Demaille. */
#ifndef PARSER_HEADER_H
# define PARSER_HEADER_H
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_percent_code_get([[requires]])[
#include <string>
#include <iostream>
# include <string>
# include <iostream>
]b4_percent_define_ifdef([[location_type]], [],
[[#include "location.hh"]])[
[[# include "location.hh"]])[
/* Using locations. */
#define YYLSP_NEEDED ]b4_locations_flag[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[
#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
]b4_YYDEBUG_define[
]b4_namespace_open[
/// A Bison parser.
@@ -273,7 +249,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
{
public:
/// Symbol semantic values.
#ifndef YYSTYPE
# ifndef ]b4_api_PREFIX[STYPE
]m4_ifdef([b4_stype],
[ union semantic_type
{
@@ -281,10 +257,10 @@ b4_user_stype
};],
[m4_if(b4_tag_seen_flag, 0,
[[ typedef int semantic_type;]],
[[ typedef YYSTYPE semantic_type;]])])[
#else
typedef YYSTYPE semantic_type;
#endif
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[
# else
typedef ]b4_api_PREFIX[STYPE semantic_type;
# endif
/// Symbol locations.
typedef ]b4_percent_define_get([[location_type]],
[[location]])[ location_type;
@@ -325,7 +301,7 @@ b4_user_stype
virtual void error (const location_type& loc, const std::string& msg);
private:
#if YYDEBUG
# if ]b4_api_PREFIX[DEBUG
public:
/// \brief Report a symbol value on the debug stream.
/// \param yytype The token type.
@@ -343,9 +319,8 @@ b4_user_stype
const location_type* yylocationp);
private:
/* Debugging. */
int yydebug_;
std::ostream* yycdebug_;
#endif
# endif
]b4_parse_param_vars[
};
@@ -354,16 +329,14 @@ b4_user_stype
b4_percent_define_flag_if([[global_tokens_and_yystype]],
[b4_token_defines(b4_tokens)])
[
#ifndef YYSTYPE
# define YYSTYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
#ifndef ]b4_api_PREFIX[STYPE
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
#endif
#ifndef YYLTYPE
# define YYLTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
#ifndef ]b4_api_PREFIX[LTYPE
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
#endif
]b4_namespace_close[
]b4_percent_code_get([[provides]])[]dnl
[#endif /* ! defined PARSER_HEADER_H */]
m4_divert_pop(0)
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[
]m4_divert_pop(0)
+1
View File
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[c-like.m4])
# b4_comment(TEXT)
# ----------------
+37 -75
View File
@@ -55,25 +55,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
]b4_percent_define_ifdef([[location_type]], [],
[[#include "location.hh"]])[
]b4_null_define[
/* 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
]b4_YYDEBUG_define[
]b4_namespace_open[
@@ -82,7 +64,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
{
public:
/// Symbol semantic values.
#ifndef YYSTYPE
#ifndef ]b4_api_PREFIX[STYPE
]m4_ifdef([b4_stype],
[ union semantic_type
{
@@ -90,9 +72,9 @@ b4_user_stype
};],
[m4_if(b4_tag_seen_flag, 0,
[[ typedef int semantic_type;]],
[[ typedef YYSTYPE semantic_type;]])])[
[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[
#else
typedef YYSTYPE semantic_type;
typedef ]b4_api_PREFIX[STYPE semantic_type;
#endif
/// Symbol locations.
typedef ]b4_percent_define_get([[location_type]],
@@ -113,7 +95,7 @@ b4_user_stype
/// \returns 0 iff parsing succeeded.
virtual int parse ();
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/// The current debugging stream.
std::ostream& debug_stream () const;
/// Set the current debugging stream.
@@ -138,7 +120,7 @@ b4_user_stype
/// \param tok the lookahead token.
virtual std::string yysyntax_error_ (int yystate, int tok);
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/// \brief Report a symbol value on the debug stream.
/// \param yytype The token type.
/// \param yyvaluep Its semantic value.
@@ -211,17 +193,15 @@ b4_user_stype
/// For a rule, its LHS.
static const ]b4_int_type_for([b4_r1])[ yyr1_[];
/// For a rule, its RHS length.
static const ]b4_int_type_for([b4_r2])[ yyr2_[];
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/// For a symbol, its name in clear.
static const char* const yytname_[];
#endif]b4_error_verbose_if([
static const ]b4_int_type_for([b4_r2])[ yyr2_[]; ]b4_error_verbose_if([
/// Convert the symbol name \a n to a form suitable for a diagnostic.
static std::string yytnamerr_ (const char *n);])[
#if YYDEBUG
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
/// For a symbol, its name in clear.
static const char* const yytname_[];
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
/// A type to store symbol numbers and -1.
typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;
/// A `-1'-separated list of the rules' RHS.
@@ -277,9 +257,9 @@ b4_user_stype
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
[b4_token_defines(b4_tokens)
#ifndef YYSTYPE
#ifndef ]b4_api_PREFIX[STYPE
/* Redirection for backward compatibility. */
# define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type
# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class_name::semantic_type
#endif
])[
]b4_percent_code_get([[provides]])[
@@ -295,16 +275,18 @@ m4_if(b4_prefix, [yy], [],
#define yylex b4_prefix[]lex])[
/* First part of user declarations. */
]b4_user_pre_prologue
]b4_user_pre_prologue[
b4_defines_if([[
]b4_defines_if([[
#include "@basename(]b4_spec_defines_file[@)"]])[
/* User implementation prologue. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
]b4_user_post_prologue[
]b4_percent_code_get[
[#ifndef YY_
]b4_null_define[
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
@@ -316,31 +298,14 @@ b4_percent_code_get[]dnl
# endif
#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). */
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#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 (false)
#endif
]b4_yylloc_default_define[
/* Suppress unused-variable warnings by "using" E. */
#define YYUSE(e) ((void) (e))
/* Enable debugging if requested. */
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/* A pseudo ostream that takes yydebug_ into account. */
# define YYCDEBUG if (yydebug_) (*yycdebug_)
@@ -367,14 +332,14 @@ do { \
yystack_print_ (); \
} while (false)
#else /* !YYDEBUG */
#else /* !]b4_api_PREFIX[DEBUG */
# define YYCDEBUG if (false) std::cerr
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_REDUCE_PRINT(Rule)
# define YY_STACK_PRINT()
#endif /* !YYDEBUG */
#endif /* !]b4_api_PREFIX[DEBUG */
#define yyerrok (yyerrstatus_ = 0)
#define yyclearin (yychar = yyempty_)
@@ -427,7 +392,7 @@ do { \
/// Build a parser object.
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
:])[
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
#endif]b4_parse_param_cons[
@@ -438,7 +403,7 @@ do { \
{
}
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
@@ -499,7 +464,7 @@ do { \
yylocation_stack_.pop (n);
}
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
std::ostream&
]b4_parser_class_name[::debug_stream () const
{
@@ -571,12 +536,10 @@ do { \
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_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[ /* Initialize the stacks. The initial state will be pushed in
yynewstate, since the latter expects the semantical and the
@@ -612,7 +575,7 @@ m4_popdef([b4_at_dollar])])dnl
{
YYCDEBUG << "Reading a token: ";
yychar = ]b4_c_function_call([yylex], [int],
[[YYSTYPE*], [&yylval]][]dnl
[b4_api_PREFIX[STYPE*], [&yylval]][]dnl
b4_locations_if([, [[location*], [&yylloc]]])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
}
@@ -1027,7 +990,7 @@ b4_error_verbose_if([int yystate, int yytoken],
]b4_stos[
};
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
to YYLEX-NUM. */
const ]b4_int_type_for([b4_toknum])[
@@ -1051,7 +1014,7 @@ b4_error_verbose_if([int yystate, int yytoken],
]b4_r2[
};
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
const char*
@@ -1059,9 +1022,8 @@ b4_error_verbose_if([int yystate, int yytoken],
{
]b4_tname[
};
#endif
#if YYDEBUG
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
const ]b4_parser_class_name[::rhs_number_type
]b4_parser_class_name[::yyrhs_[] =
@@ -1111,7 +1073,7 @@ b4_error_verbose_if([int yystate, int yytoken],
&]b4_rhs_value(yynrhs, yyi + 1)[,
&]b4_rhs_location(yynrhs, yyi + 1)[);
}
#endif // YYDEBUG
#endif // ]b4_api_PREFIX[DEBUG
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
]b4_parser_class_name[::token_number_type
@@ -1142,5 +1104,5 @@ b4_error_verbose_if([int yystate, int yytoken],
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
]b4_namespace_close[
]b4_epilogue
]b4_epilogue[]dnl
m4_divert_pop(0)
+4 -6
View File
@@ -458,12 +458,10 @@ b4_lexer_if([[
yyerrstatus_ = 0;
]m4_ifdef([b4_initial_action], [
m4_pushdef([b4_at_dollar], [yylloc])dnl
m4_pushdef([b4_dollar_dollar], [yylval])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[ /* Initialize the stack. */
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
+1 -3
View File
@@ -29,9 +29,9 @@ b4_copyright([Positions for Bison parsers in C++],
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
# include <algorithm> // std::max
# include <iostream>
# include <string>
# include <algorithm>
]b4_null_define[
@@ -159,8 +159,6 @@ b4_copyright([Locations for Bison parsers in C++],
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
# include <iostream>
# include <string>
# include "position.hh"
]b4_namespace_open[
+147 -200
View File
@@ -158,9 +158,9 @@ m4_define([b4_rhs_location],
[(yylsp@{($2) - ($1)@})])
## ------------------ ##
## Parser variables. ##
## ------------------ ##
## -------------- ##
## Declarations. ##
## -------------- ##
# b4_declare_scanner_communication_variables
# ------------------------------------------
@@ -170,6 +170,28 @@ m4_define([b4_declare_scanner_communication_variables], [[
/* The lookahead symbol. */
int yychar;
]b4_pure_if([[
#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__))
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YYLVAL_INITIALIZE() (yylval = yyval_default)
#endif]])[
#ifndef YYLVAL_INITIALIZE
# define YYLVAL_INITIALIZE()
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;]b4_locations_if([[
@@ -225,9 +247,73 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
YYSIZE_T yyes_capacity;]])])
## --------------------------------------------------------- ##
## Defining symbol actions, e.g., printers and destructors. ##
## --------------------------------------------------------- ##
# b4_declare_yyparse_push_
# ------------------------
# Declaration of yyparse (and dependencies) when using the push parser
# (including in pull mode).
m4_define([b4_declare_yyparse_push_],
[[#ifndef YYPUSH_MORE_DEFINED
# define YYPUSH_MORE_DEFINED
enum { YYPUSH_MORE = 4 };
#endif
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
[[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
[[[int pushed_char]], [[pushed_char]]],
[[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
[[b4_api_PREFIX[LTYPE const *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
[[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
[[[void]], []])
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *ps]], [[ps]]])dnl
])
# b4_declare_yyparse_
# -------------------
# When not the push parser.
m4_define([b4_declare_yyparse_],
[[#ifdef YYPARSE_PARAM
]b4_c_function_decl(b4_prefix[parse], [int],
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
#else /* ! YYPARSE_PARAM */
]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
#endif /* ! YYPARSE_PARAM */]dnl
])
# b4_declare_yyparse
# ------------------
m4_define([b4_declare_yyparse],
[b4_push_if([b4_declare_yyparse_push_],
[b4_declare_yyparse_])[]dnl
])
# b4_shared_declarations
# ----------------------
# Declaration that might either go into the header (if --defines)
# or open coded in the parser body.
m4_define([b4_shared_declarations],
[b4_cpp_guard_open([b4_spec_defines_file])[
]b4_declare_yydebug[
]b4_percent_code_get([[requires]])[
]b4_token_enums_defines(b4_tokens)[
]b4_declare_yylstype[
]b4_declare_yyparse[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
])
## -------------- ##
## Output files. ##
## -------------- ##
# We do want M4 expansion after # for CPP macros.
m4_changecom()
@@ -248,7 +334,11 @@ b4_copyright([Bison implementation for Yacc-like parsers in C],
]b4_identification
b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [],
m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
]m4_if(b4_prefix, [yy], [],
[[/* Substitute the variable and function names. */]b4_pull_if([[
#define yyparse ]b4_prefix[parse]])b4_push_if([[
#define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
@@ -261,19 +351,14 @@ m4_if(b4_prefix, [yy], [],
#define yylval ]b4_prefix[lval
#define yychar ]b4_prefix[char
#define yydebug ]b4_prefix[debug
#define yynerrs ]b4_prefix[nerrs
]b4_locations_if([[#define yylloc ]b4_prefix[lloc]])])[
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])])[
/* Copy the first part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[
#endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
@@ -282,66 +367,13 @@ m4_if(b4_prefix, [yy], [],
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE ]b4_token_table[
#endif
]m4_ifval(m4_quote(b4_spec_defines_file),
[[/* In a future release of Bison, this section will be replaced
by #include "@basename(]b4_spec_defines_file[@)". */
]])dnl
b4_shared_declarations[
]b4_percent_code_get([[requires]])[]dnl
b4_token_enums_defines(b4_tokens)[
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
]m4_ifdef([b4_stype],
[[typedef union ]b4_union_name[
{
]b4_user_stype[
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1]],
[m4_if(b4_tag_seen_flag, 0,
[[typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1]])])[
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif]b4_locations_if([[
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif]])b4_push_if([[
#ifndef YYPUSH_DECLS
# define YYPUSH_DECLS
struct yypstate;
typedef struct yypstate yypstate;
enum { YYPUSH_MORE = 4 };
]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
])b4_c_function_decl([[yypush_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
b4_c_function_decl([[yypstate_delete]], [[void]],
[[[yypstate *yyps]], [[yyps]]])[
#endif]])
b4_percent_code_get([[provides]])[]dnl
[/* Copy the second part of user declarations. */
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
@@ -394,24 +426,24 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
{
@@ -491,8 +523,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -582,7 +614,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
]b4_translate[
};
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
@@ -603,7 +635,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@@ -670,11 +702,11 @@ static const ]b4_int_type_for([b4_table])[ yytable[] =
]b4_table[
};
#define yypact_value_is_default(yystate) \
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
#define yypact_value_is_default(Yystate) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
#define yytable_value_is_error(yytable_value) \
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
static const ]b4_int_type_for([b4_check])[ yycheck[] =
{
@@ -737,31 +769,9 @@ while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
/* 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). */
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif]b4_locations_if([[
]b4_locations_if([[
/* YY_LOCATION_PRINT -- Print the location on the stream.
@@ -769,7 +779,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -796,7 +806,7 @@ while (YYID (0))
#endif
/* Enable debugging if requested. */
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
@@ -883,12 +893,12 @@ do { \
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
#else /* !]b4_api_PREFIX[DEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
#endif /* !]b4_api_PREFIX[DEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
@@ -919,7 +929,7 @@ int yydebug;
required. Return 1 if memory is exhausted. */
static int
yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
char const *yydebug_prefix,
char const *yydebug_suffix,
#endif
@@ -1025,7 +1035,7 @@ do { \
the parser stacks to try to find a new initial context in which the
current lookahead is syntactically acceptable. If it fails to find
such a context, it discards the lookahead. */
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
# define YY_LAC_DISCARD(Event) \
do { \
if (yy_lac_established) \
@@ -1128,7 +1138,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
else
{
if (yy_lac_stack_realloc (yyes_capacity, 1,
#if YYDEBUG
#if ]b4_api_PREFIX[DEBUG
" (", ")",
#endif
yyes, yyesa, &yyesp, yyes_prev))
@@ -1335,7 +1345,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yysize = yysize1;
}
}]b4_lac_if([[
# if YYDEBUG
# if ]b4_api_PREFIX[DEBUG
else if (yydebug)
YYFPRINTF (stderr, "No expected tokens.\n");
# endif]])[
@@ -1392,20 +1402,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
}
#endif /* YYERROR_VERBOSE */
]b4_yydestruct_generate([b4_c_function_def])b4_push_if([], [[
]b4_yydestruct_generate([b4_c_function_def])[
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
]b4_c_function_decl([yyparse], [int],
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
#else /* ! YYPARSE_PARAM */
]b4_c_function_decl([yyparse], [int], b4_parse_param)[
#endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
]b4_pure_if([], [
b4_declare_scanner_communication_variables])[]b4_push_if([[
struct yypstate
{]b4_declare_parser_state_variables[
/* Used to determine if this is the first time this instance has
@@ -1535,7 +1537,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;]b4_locations_if([[
@@ -1560,7 +1562,6 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
goto yyread_pushed_token;
}]])[
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;]b4_locations_if([[
yyls = yylsa;]])[
@@ -1584,25 +1585,25 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;]b4_locations_if([[
yylsp = yyls;
yylsp = yyls;]])[
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
YYLVAL_INITIALIZE ();]b4_locations_if([[
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif]])
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
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
[m4_define([b4_at_dollar_used])yylloc])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
b4_dollar_popdef[]dnl
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
]])dnl
m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
]])[
goto yysetstate;
]])])dnl
[ goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
@@ -1772,7 +1773,9 @@ yyread_pushed_token:]])[
YY_LAC_DISCARD ("shift");]])[
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([ *++yylsp = yylloc;])[
goto yynewstate;
@@ -1992,7 +1995,9 @@ yyerrlab1:
current lookahead token, the shift below will for sure. */
YY_LAC_DISCARD ("error recovery");]])[
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([[
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
@@ -2068,70 +2073,12 @@ yypushreturn:]])[
}
]b4_epilogue
]b4_epilogue[]dnl
b4_defines_if(
[@output(b4_spec_defines_file@)@
b4_copyright([Bison interface for Yacc-like parsers in C],
[1984, 1989-1990, 2000-2012])
[1984, 1989-1990, 2000-2012])[
b4_percent_code_get([[requires]])[]dnl
b4_token_enums_defines(b4_tokens)
[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
]m4_ifdef([b4_stype],
[[typedef union ]b4_union_name[
{
]b4_user_stype[
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1]],
[m4_if(b4_tag_seen_flag, 0,
[[typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1]])])[
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
b4_locations_if(
[#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
)dnl b4_locations_if
b4_push_if([[
#ifndef YYPUSH_DECLS
# define YYPUSH_DECLS
struct ]b4_prefix[pstate;
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
enum { YYPUSH_MORE = 4 };
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
[[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
[[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
[[[void]], []])
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *yyps]], [[yyps]]])[
#endif
]])
b4_percent_code_get([[provides]])[]dnl
])dnl b4_defines_if
]b4_shared_declarations[
]])dnl b4_defines_if
m4_divert_pop(0)
+1 -1
View File
@@ -1,4 +1,3 @@
/*.info*
/*~
/.dirstamp
/Makefile
@@ -10,6 +9,7 @@
/bison.dvi
/bison.fn
/bison.html
/bison.info
/bison.ky
/bison.log
/bison.pdf
+1 -1
View File
@@ -940,7 +940,7 @@ EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
PERL_PATH = @PERL@
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
+2 -2
View File
@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AM_MAKEINFOFLAGS = --no-split
info_TEXINFOS = bison.texinfo
info_TEXINFOS = bison.texi
bison_TEXINFOS = $(srcdir)/cross-options.texi gpl-3.0.texi fdl.texi
CLEANFILES = bison.fns
@@ -30,7 +30,7 @@ $(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL)
$(AM_V_at)rm -f $@.tmp
$(AM_V_at)cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) bison
$(AM_V_at)$(top_builddir)/src/bison --help \
| perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
| $(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
$(AM_V_at)diff -u $@~ $@.tmp || true
$(AM_V_at)mv $@.tmp $@
MAINTAINERCLEANFILES = $(srcdir)/cross-options.texi
+201 -88
View File
@@ -110,7 +110,7 @@ Reference sections:
* Glossary:: Basic concepts are explained.
* Copying This Manual:: License for copying this manual.
* Bibliography:: Publications cited in this manual.
* Index:: Cross-references to the text.
* Index of Terms:: Cross-references to the text.
@detailmenu
--- The Detailed Node Listing ---
@@ -4552,9 +4552,9 @@ code.
@deffn {Directive} %initial-action @{ @var{code} @}
@findex %initial-action
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 lookahead --- and the
@code{%parse-param}.
@code{yyparse} is called. The @var{code} may use @code{$$} (or
@code{$<@var{tag}>$}) and @code{@@$} --- initial value and location of the
lookahead --- and the @code{%parse-param}.
@end deffn
For instance, if your locations use a file name, you may use
@@ -4592,11 +4592,11 @@ symbol is automatically discarded.
@deffn {Directive} %destructor @{ @var{code} @} @var{symbols}
@findex %destructor
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, and @code{@@$} designates its location.
The additional parser parameters are also available (@pxref{Parser Function, ,
The Parser Function @code{yyparse}}).
@var{symbols}. Within @var{code}, @code{$$} (or @code{$<@var{tag}>$})
designates the semantic value associated with the discarded symbol, and
@code{@@$} designates its location. The additional parser parameters are
also available (@pxref{Parser Function, , The Parser Function
@code{yyparse}}).
When a symbol is listed among @var{symbols}, its @code{%destructor} is called a
per-symbol @code{%destructor}.
@@ -4734,10 +4734,11 @@ Decl, , Freeing Discarded Symbols}).
@c This is the same text as for %destructor.
Invoke the braced @var{code} whenever the parser displays one of the
@var{symbols}. Within @var{code}, @code{yyoutput} denotes the output stream
(a @code{FILE*} in C, and an @code{std::ostream&} in C++),
@code{$$} designates the semantic value associated with the symbol, and
@code{@@$} its location. The additional parser parameters are also
available (@pxref{Parser Function, , The Parser Function @code{yyparse}}).
(a @code{FILE*} in C, and an @code{std::ostream&} in C++), @code{$$} (or
@code{$<@var{tag}>$}) designates the semantic value associated with the
symbol, and @code{@@$} its location. The additional parser parameters are
also available (@pxref{Parser Function, , The Parser Function
@code{yyparse}}).
The @var{symbols} are defined as for @code{%destructor} (@pxref{Destructor
Decl, , Freeing Discarded Symbols}.): they can be per-type (e.g.,
@@ -5074,9 +5075,11 @@ default location or at the location specified by @var{qualifier}.
@end deffn
@deffn {Directive} %debug
In the parser implementation file, define the macro @code{YYDEBUG} to
1 if it is not already defined, so that the debugging facilities are
compiled. @xref{Tracing, ,Tracing Your Parser}.
In the parser implementation file, define the macro @code{YYDEBUG} (or
@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}, see
@ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is
not already defined, so that the debugging facilities are compiled.
@xref{Tracing, ,Tracing Your Parser}.
@end deffn
@deffn {Directive} %define @var{variable}
@@ -5121,6 +5124,23 @@ Values, ,Semantic Values of Tokens}.
If you have declared @code{%code requires} or @code{%code provides}, the output
header also contains their code.
@xref{%code Summary}.
@cindex Header guard
The generated header is protected against multiple inclusions with a C
preprocessor guard: @samp{YY_@var{PREFIX}_@var{FILE}_INCLUDED}, where
@var{PREFIX} and @var{FILE} are the prefix (@pxref{Multiple Parsers,
,Multiple Parsers in the Same Program}) and generated file name turned
uppercase, with each series of non alphanumerical characters converted to a
single underscore.
For instance with @samp{%define api.prefix "calc"} and @samp{%defines
"lib/parse.h"}, the header will be guarded as follows.
@example
#ifndef YY_CALC_LIB_PARSE_H_INCLUDED
# define YY_CALC_LIB_PARSE_H_INCLUDED
...
#endif /* ! YY_CALC_LIB_PARSE_H_INCLUDED */
@end example
@end deffn
@deffn {Directive} %defines @var{defines-file}
@@ -5154,22 +5174,6 @@ grammar does not use it, using @samp{%locations} allows for more
accurate syntax error messages.
@end deffn
@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{yychar}, @code{yydebug}, and
(if locations are used) @code{yylloc}. If you use a push parser,
@code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
@code{yypstate_new} and @code{yypstate_delete} will
also be renamed. For example, if you use @samp{%name-prefix "c_"}, the
names become @code{c_parse}, @code{c_lex}, and so on.
For C++ parsers, see the @code{%define namespace} documentation in this
section.
@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
@end deffn
@ifset defaultprec
@deffn {Directive} %no-default-prec
Do not assign a precedence to rules lacking an explicit @code{%prec}
@@ -5317,8 +5321,25 @@ Unaccepted @var{variable}s produce an error.
Some of the accepted @var{variable}s are:
@itemize @bullet
@c ================================================== api.prefix
@item @code{api.prefix}
@findex %define api.prefix
@itemize @bullet
@item Language(s): All
@item Purpose: Rename exported symbols
@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
@item Accepted Values: String
@item Default Value: @code{yy}
@item History: introduced in Bison 2.6
@end itemize
@c ================================================== api.pure
@item api.pure
@item @code{api.pure}
@findex %define api.pure
@itemize @bullet
@@ -5332,7 +5353,9 @@ Some of the accepted @var{variable}s are:
@item Default Value: @code{false}
@end itemize
@item api.push-pull
@c ================================================== api.push-pull
@item @code{api.push-pull}
@findex %define api.push-pull
@itemize @bullet
@@ -5350,7 +5373,7 @@ More user feedback will help to stabilize it.)
@c ================================================== lr.default-reductions
@item lr.default-reductions
@item @code{lr.default-reductions}
@findex %define lr.default-reductions
@itemize @bullet
@@ -5371,7 +5394,7 @@ feedback will help to stabilize it.)
@c ============================================ lr.keep-unreachable-states
@item lr.keep-unreachable-states
@item @code{lr.keep-unreachable-states}
@findex %define lr.keep-unreachable-states
@itemize @bullet
@@ -5384,7 +5407,7 @@ remain in the parser tables. @xref{Unreachable States}.
@c ================================================== lr.type
@item lr.type
@item @code{lr.type}
@findex %define lr.type
@itemize @bullet
@@ -5399,7 +5422,9 @@ More user feedback will help to stabilize it.)
@item Default Value: @code{lalr}
@end itemize
@item namespace
@c ================================================== namespace
@item @code{namespace}
@findex %define namespace
@itemize
@@ -5452,7 +5477,7 @@ The parser namespace is @code{foo} and @code{yylex} is referenced as
@end itemize
@c ================================================== parse.lac
@item parse.lac
@item @code{parse.lac}
@findex %define parse.lac
@itemize
@@ -5585,34 +5610,88 @@ of the standard Bison skeletons.
@section Multiple Parsers in the Same Program
Most programs that use Bison parse only one language and therefore contain
only one Bison parser. But what if you want to parse more than one
language with the same program? Then you need to avoid a name conflict
between different definitions of @code{yyparse}, @code{yylval}, and so on.
only one Bison parser. But what if you want to parse more than one language
with the same program? Then you need to avoid name conflicts between
different definitions of functions and variables such as @code{yyparse},
@code{yylval}. To use different parsers from the same compilation unit, you
also need to avoid conflicts on types and macros (e.g., @code{YYSTYPE})
exported in the generated header.
The easy way to do this is to use the option @samp{-p @var{prefix}}
(@pxref{Invocation, ,Invoking Bison}). This renames the interface
functions and variables of the Bison parser to start with @var{prefix}
instead of @samp{yy}. You can use this to give each parser distinct
names that do not conflict.
The easy way to do this is to define the @code{%define} variable
@code{api.prefix}. With different @code{api.prefix}s it is guaranteed that
headers do not conflict when included together, and that compiled objects
can be linked together too. Specifying @samp{%define api.prefix
@var{prefix}} (or passing the option @samp{-Dapi.prefix=@var{prefix}}, see
@ref{Invocation, ,Invoking Bison}) renames the interface functions and
variables of the Bison parser to start with @var{prefix} instead of
@samp{yy}, and all the macros to start by @var{PREFIX} (i.e., @var{prefix}
upper-cased) instead of @samp{YY}.
The precise list of symbols renamed is @code{yyparse}, @code{yylex},
@code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yylloc},
@code{yychar} and @code{yydebug}. If you use a push parser,
@code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
@code{yypstate_new} and @code{yypstate_delete} will also be renamed.
For example, if you use @samp{-p c}, the names become @code{cparse},
@code{clex}, and so on.
The renamed symbols include @code{yyparse}, @code{yylex}, @code{yyerror},
@code{yynerrs}, @code{yylval}, @code{yylloc}, @code{yychar} and
@code{yydebug}. If you use a push parser, @code{yypush_parse},
@code{yypull_parse}, @code{yypstate}, @code{yypstate_new} and
@code{yypstate_delete} will also be renamed. The renamed macros include
@code{YYSTYPE}, @code{YYLTYPE}, and @code{YYDEBUG}, which is treated
specifically --- more about this below.
@strong{All the other variables and macros associated with Bison are not
renamed.} These others are not global; there is no conflict if the same
name is used in different parsers. For example, @code{YYSTYPE} is not
renamed, but defining this in different ways in different parsers causes
no trouble (@pxref{Value Type, ,Data Types of Semantic Values}).
For example, if you use @samp{%define api.prefix c}, the names become
@code{cparse}, @code{clex}, @dots{}, @code{CSTYPE}, @code{CLTYPE}, and so
on.
The @samp{-p} option works by adding macro definitions to the
beginning of the parser implementation file, defining @code{yyparse}
as @code{@var{prefix}parse}, and so on. This effectively substitutes
one name for the other in the entire parser implementation file.
The @code{%define} variable @code{api.prefix} works in two different ways.
In the implementation file, it works by adding macro definitions to the
beginning of the parser implementation file, defining @code{yyparse} as
@code{@var{prefix}parse}, and so on:
@example
#define YYSTYPE CTYPE
#define yyparse cparse
#define yylval clval
...
YYSTYPE yylval;
int yyparse (void);
@end example
This effectively substitutes one name for the other in the entire parser
implementation file, thus the ``original'' names (@code{yylex},
@code{YYSTYPE}, @dots{}) are also usable in the parser implementation file.
However, in the parser header file, the symbols are defined renamed, for
instance:
@example
extern CSTYPE clval;
int cparse (void);
@end example
The macro @code{YYDEBUG} is commonly used to enable the tracing support in
parsers. To comply with this tradition, when @code{api.prefix} is used,
@code{YYDEBUG} (not renamed) is used as a default value:
@example
/* Enabling traces. */
#ifndef CDEBUG
# if defined YYDEBUG
# if YYDEBUG
# define CDEBUG 1
# else
# define CDEBUG 0
# endif
# else
# define CDEBUG 0
# endif
#endif
#if CDEBUG
extern int cdebug;
#endif
@end example
@sp 2
Prior to Bison 2.6, a feature similar to @code{api.prefix} was provided by
the obsolete directive @code{%name-prefix} (@pxref{Table of Symbols, ,Bison
Symbols}) and the option @code{--name-prefix} (@pxref{Bison Options}).
@node Interface
@chapter Parser C-Language Interface
@@ -5729,9 +5808,9 @@ function is available if either the @code{%define api.push-pull push} or
@xref{Push Decl, ,A Push Parser}.
@deftypefun int yypush_parse (yypstate *yyps)
The value returned by @code{yypush_parse} is the same as for yyparse with the
following exception. @code{yypush_parse} will return YYPUSH_MORE if more input
is required to finish parsing the grammar.
The value returned by @code{yypush_parse} is the same as for yyparse with
the following exception: it returns @code{YYPUSH_MORE} if more input is
required to finish parsing the grammar.
@end deftypefun
@node Pull Parser Function
@@ -6011,7 +6090,7 @@ For instance:
@end example
@noindent
results in the following signature:
results in the following signatures:
@example
int yylex (int *nastiness);
@@ -8437,18 +8516,24 @@ parser. This is compliant with POSIX Yacc. You could use
YYDEBUG 1} in the prologue of the grammar file (@pxref{Prologue, , The
Prologue}).
@item the option @option{-t}, @option{--debug}
Use the @samp{-t} option when you run Bison (@pxref{Invocation,
,Invoking Bison}). This is POSIX compliant too.
If the @code{%define} variable @code{api.prefix} is used (@pxref{Multiple
Parsers, ,Multiple Parsers in the Same Program}), for instance @samp{%define
api.prefix x}, then if @code{CDEBUG} is defined, its value controls the
tracing feature (enabled if and only if nonzero); otherwise tracing is
enabled if and only if @code{YYDEBUG} is nonzero.
@item the option @option{-t} (POSIX Yacc compliant)
@itemx the option @option{--debug} (Bison extension)
Use the @samp{-t} option when you run Bison (@pxref{Invocation, ,Invoking
Bison}). With @samp{%define api.prefix c}, it defines @code{CDEBUG} to 1,
otherwise it defines @code{YYDEBUG} to 1.
@item the directive @samp{%debug}
@findex %debug
Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison
Declaration Summary}). This is a Bison extension, which will prove
useful when Bison will output parsers for languages that don't use a
preprocessor. Unless POSIX and Yacc portability matter to
you, this is
the preferred solution.
Add the @code{%debug} directive (@pxref{Decl Summary, ,Bison Declaration
Summary}). This is a Bison extension, especially useful for languages that
don't use a preprocessor. Unless POSIX and Yacc portability matter to you,
this is the preferred solution.
@end table
We suggest that you always enable the debug option so that debugging is
@@ -8924,8 +9009,9 @@ Pretend that @code{%locations} was specified. @xref{Decl Summary}.
@item -p @var{prefix}
@itemx --name-prefix=@var{prefix}
Pretend that @code{%name-prefix "@var{prefix}"} was specified.
@xref{Decl Summary}.
Pretend that @code{%name-prefix "@var{prefix}"} was specified (@pxref{Decl
Summary}). Obsoleted by @code{-Dapi.prefix=@var{prefix}}. @xref{Multiple
Parsers, ,Multiple Parsers in the Same Program}.
@item -l
@itemx --no-lines
@@ -8986,13 +9072,23 @@ separated list of @var{things} among:
Description of the grammar, conflicts (resolved and unresolved), and
parser's automaton.
@item itemset
Implies @code{state} and augments the description of the automaton with
the full set of items for each state, instead of its core only.
@item lookahead
Implies @code{state} and augments the description of the automaton with
each rule's lookahead set.
@item itemset
Implies @code{state} and augments the description of the automaton with
the full set of items for each state, instead of its core only.
@item solved
Implies @code{state}. Explain how conflicts were solved thanks to
precedence and associativity directives.
@item all
Enable all the items.
@item none
Do not generate the report.
@end table
@item --report-file=@var{file}
@@ -11054,9 +11150,24 @@ function is applied to the two semantic values to get a single result.
@end deffn
@deffn {Directive} %name-prefix "@var{prefix}"
Bison declaration to rename the external symbols. @xref{Decl Summary}.
Obsoleted by the @code{%define} variable @code{api.prefix} (@pxref{Multiple
Parsers, ,Multiple Parsers in the Same Program}).
Rename the external symbols (variables and functions) used in the parser so
that they start with @var{prefix} instead of @samp{yy}. Contrary to
@code{api.prefix}, do no rename types and macros.
The precise list of symbols renamed in C parsers is @code{yyparse},
@code{yylex}, @code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yychar},
@code{yydebug}, and (if locations are used) @code{yylloc}. If you use a
push parser, @code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
@code{yypstate_new} and @code{yypstate_delete} will also be renamed. For
example, if you use @samp{%name-prefix "c_"}, the names become
@code{c_parse}, @code{c_lex}, and so on. For C++ parsers, see the
@code{%define namespace} documentation in this section.
@end deffn
@ifset defaultprec
@deffn {Directive} %no-default-prec
Do not assign a precedence to rules that lack an explicit @samp{%prec}
@@ -11216,7 +11327,8 @@ Reporting Function @code{yyerror}}.
An obsolete macro that you define with @code{#define} in the prologue
to request verbose, specific error message strings
when @code{yyerror} is called. It doesn't matter what definition you
use for @code{YYERROR_VERBOSE}, just whether you define it. Using
use for @code{YYERROR_VERBOSE}, just whether you define it.
Supported by the C skeletons only; using
@code{%error-verbose} is preferred. @xref{Error Reporting}.
@end deffn
@@ -11620,8 +11732,8 @@ London, Department of Computer Science, TR-00-12 (December 2000).
@uref{http://www.cs.rhul.ac.uk/research/languages/publications/tomita_style_1.ps}
@end table
@node Index
@unnumbered Index
@node Index of Terms
@unnumbered Index of Terms
@printindex cp
@@ -11676,10 +11788,11 @@ London, Department of Computer Science, TR-00-12 (December 2000).
@c LocalWords: toString deftypeivar deftypeivarx deftypeop YYParser strictfp
@c LocalWords: superclasses boolean getErrorVerbose setErrorVerbose deftypecv
@c LocalWords: getDebugStream setDebugStream getDebugLevel setDebugLevel url
@c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos
@c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos uint
@c LocalWords: getLVal defvar deftypefn deftypefnx gotos msgfmt Corbett LALR's
@c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy
@c LocalWords: Scannerless ispell american
@c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy ints
@c LocalWords: Scannerless ispell american ChangeLog smallexample CSTYPE CLTYPE
@c LocalWords: clval CDEBUG cdebug deftypeopx yyterminate
@c Local Variables:
@c ispell-dictionary: "american"
-3
View File
@@ -1,6 +1,3 @@
A directory of tools provided to people using CVS Bison. None of
these is distributed.
* bench.pl
A primitive Perl script to run benches. Currently its only bench is
the usual calculator: it has a lightweight processing part (but not
+2 -2
View File
@@ -28,7 +28,7 @@ $(BISON): $(BISON_IN)
## Extracting. ##
## ------------ ##
doc = $(top_srcdir)/doc/bison.texinfo
doc = $(top_srcdir)/doc/bison.texi
extexi = $(top_srcdir)/examples/extexi
# Extract in src.
$(srcdir)/calc.stamp: $(doc) $(extexi)
@@ -36,7 +36,7 @@ $(srcdir)/calc.stamp: $(doc) $(extexi)
$(AM_V_at)touch $@.tmp
$(AM_V_at)cd $(srcdir) && \
$(AWK) -f ../extexi -v VERSION="$(VERSION)" \
../../doc/bison.texinfo -- calc++-parser.yy \
../../doc/bison.texi -- calc++-parser.yy \
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
$(AM_V_at)mv $@.tmp $@
-1
View File
@@ -1 +0,0 @@
external: gnulib
+1 -1
Submodule gnulib updated: 338dd5d436...d245e6ddd6
+4
View File
@@ -268,3 +268,7 @@
/xmemdup0.c
/xmemdup0.h
/sys_types.in.h
/obstack_printf.c
/binary-io.c
/mbuiter.c
/xsize.c
+3
View File
@@ -0,0 +1,3 @@
/lock.c
/lock.h
/threadlib.c
+5 -2
View File
@@ -34,6 +34,7 @@
/fprintf-posix.m4
/frexp.m4
/frexpl.m4
/fseterr.m4
/fstat.m4
/getdtablesize.m4
/getopt.m4
@@ -95,6 +96,7 @@
/multiarch.m4
/nls.m4
/nocrash.m4
/off_t.m4
/open.m4
/pathmax.m4
/perror.m4
@@ -150,6 +152,7 @@
/sys_ioctl_h.m4
/sys_socket_h.m4
/sys_stat_h.m4
/sys_types_h.m4
/sys_wait_h.m4
/sysexits.m4
/threadlib.m4
@@ -176,5 +179,5 @@
/xalloc.m4
/xsize.m4
/xstrndup.m4
/off_t.m4
/sys_types_h.m4
/obstack-printf.m4
/extern-inline.m4
+16 -16
View File
@@ -73,7 +73,7 @@ log_resolution (rule *r, symbol_number token,
{
case shift_resolution:
case right_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as shift"),
r->number,
@@ -82,7 +82,7 @@ log_resolution (rule *r, symbol_number token,
case reduce_resolution:
case left_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as reduce"),
r->number,
@@ -90,7 +90,7 @@ log_resolution (rule *r, symbol_number token,
break;
case nonassoc_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as an error"),
r->number,
@@ -102,33 +102,33 @@ log_resolution (rule *r, symbol_number token,
switch (resolution)
{
case shift_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%s < %s)",
r->prec->tag,
symbols[token]->tag);
break;
case reduce_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%s < %s)",
symbols[token]->tag,
r->prec->tag);
break;
case left_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%%left %s)",
symbols[token]->tag);
break;
case right_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%%right %s)",
symbols[token]->tag);
break;
case nonassoc_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
obstack_printf (&solved_conflicts_obstack,
" (%%nonassoc %s)",
symbols[token]->tag);
break;
@@ -145,7 +145,7 @@ log_resolution (rule *r, symbol_number token,
{
case shift_resolution:
case right_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\""
" type=\"shift\">",
r->number,
@@ -154,7 +154,7 @@ log_resolution (rule *r, symbol_number token,
case reduce_resolution:
case left_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\""
" type=\"reduce\">",
r->number,
@@ -162,7 +162,7 @@ log_resolution (rule *r, symbol_number token,
break;
case nonassoc_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\""
" type=\"error\">",
r->number,
@@ -174,33 +174,33 @@ log_resolution (rule *r, symbol_number token,
switch (resolution)
{
case shift_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%s &lt; %s",
xml_escape_n (0, r->prec->tag),
xml_escape_n (1, symbols[token]->tag));
break;
case reduce_resolution:
obstack_fgrow2 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%s &lt; %s",
xml_escape_n (0, symbols[token]->tag),
xml_escape_n (1, r->prec->tag));
break;
case left_resolution:
obstack_fgrow1 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%%left %s",
xml_escape (symbols[token]->tag));
break;
case right_resolution:
obstack_fgrow1 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%%right %s",
xml_escape (symbols[token]->tag));
break;
case nonassoc_resolution:
obstack_fgrow1 (&solved_conflicts_xml_obstack,
obstack_printf (&solved_conflicts_xml_obstack,
"%%nonassoc %s",
xml_escape (symbols[token]->tag));
break;
+23 -4
View File
@@ -311,10 +311,11 @@ Parser:\n\
-S, --skeleton=FILE specify the skeleton to use\n\
-t, --debug instrument the parser for debugging\n\
--locations enable location support\n\
-D, --define=NAME[=VALUE] similar to `%define NAME \"VALUE\"'\n\
-F, --force-define=NAME[=VALUE] override `%define NAME \"VALUE\"'\n\
-D, --define=NAME[=VALUE] similar to '%define NAME \"VALUE\"'\n\
-F, --force-define=NAME[=VALUE] override '%define NAME \"VALUE\"'\n\
-p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
-l, --no-lines don't generate `#line' directives\n\
deprecated by '-Dapi.prefix=PREFIX'\n\
-l, --no-lines don't generate '#line' directives\n\
-k, --token-table include a table of token names\n\
\n\
"), stdout);
@@ -360,7 +361,25 @@ THINGS is a list of comma separated words that can include:\n\
`none' disable the report\n\
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
putc ('\n', stdout);
printf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
printf (_("%s home page: <%s>.\n"), PACKAGE_NAME, PACKAGE_URL);
fputs (_("General help using GNU software: "
"<http://www.gnu.org/gethelp/>.\n"),
stdout);
/* Don't output this redundant message for English locales.
Note we still output for 'C' so that it gets included in the
man page. */
const char *lc_messages = setlocale (LC_MESSAGES, NULL);
if (lc_messages && strcmp (lc_messages, "en_"))
/* TRANSLATORS: Replace LANG_CODE in this URL with your language
code <http://translationproject.org/team/LANG_CODE.html> to
form one of the URLs at http://translationproject.org/team/.
Otherwise, replace the entire URL with your translation team's
email address. */
fputs (_("Report translation bugs to "
"<http://translationproject.org/team/>.\n"), stdout);
fputs (_("For complete documentation, run: info bison.\n"), stdout);
}
exit (status);
+53 -45
View File
@@ -177,10 +177,10 @@ static void
muscle_syncline_grow (char const *key, location loc)
{
char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, "]])[");
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
obstack_quote (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, ")[");
obstack_1grow (&muscle_obstack, 0);
extension = obstack_finish (&muscle_obstack);
muscle_grow (key, extension, "");
@@ -205,11 +205,11 @@ void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2)
{
char *pair;
obstack_sgrow (&muscle_obstack, "[[[");
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, "]], [[");
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]]]");
obstack_sgrow (&muscle_obstack, "[");
obstack_quote (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, ", ");
obstack_quote (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]");
obstack_1grow (&muscle_obstack, 0);
pair = obstack_finish (&muscle_obstack);
muscle_grow (muscle, pair, ",\n");
@@ -259,53 +259,61 @@ muscle_find (char const *key)
}
void
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use
digraphs for special characters in the file name. */
static void
muscle_boundary_grow (char const *key, boundary bound)
{
char *extension;
MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file);
obstack_1grow (&muscle_obstack, ':');
obstack_fgrow1 (&muscle_obstack, "%d", bound.line);
obstack_1grow (&muscle_obstack, '.');
obstack_fgrow1 (&muscle_obstack, "%d", bound.column);
obstack_1grow (&muscle_obstack, '\0');
obstack_sgrow (&muscle_obstack, "[[");
obstack_escape (&muscle_obstack, bound.file);
obstack_1grow (&muscle_obstack, ':');
obstack_printf (&muscle_obstack, "%d", bound.line);
obstack_1grow (&muscle_obstack, '.');
obstack_printf (&muscle_obstack, "%d", bound.column);
obstack_sgrow (&muscle_obstack, "]]");
obstack_1grow (&muscle_obstack, '\0');
extension = obstack_finish (&muscle_obstack);
muscle_grow (key, extension, "");
obstack_free (&muscle_obstack, extension);
}
void
/* In the format `[[file_name:line.column]], [[file_name:line.column]]',
append LOC to MUSCLE. Use digraphs for special characters in each
file name. */
static void
muscle_location_grow (char const *key, location loc)
{
muscle_grow (key, "[[", "");
muscle_boundary_grow (key, loc.start);
muscle_grow (key, "]], [[", "");
muscle_grow (key, "", ", ");
muscle_boundary_grow (key, loc.end);
muscle_grow (key, "]]", "");
}
#define MUSCLE_COMMON_DECODE(Value) \
case '$': \
aver (*++(Value) == ']'); \
aver (*++(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
obstack_1grow (&muscle_obstack, *(Value)); \
#define COMMON_DECODE(Value) \
case '$': \
aver (*++(Value) == ']'); \
aver (*++(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
obstack_1grow (&muscle_obstack, *(Value)); \
break;
/* Reverse of MUSCLE_OBSTACK_SGROW. */
/* Reverse of obstack_escape. */
static char *
muscle_string_decode (char const *key)
string_decode (char const *key)
{
char const *value;
char *value_decoded;
@@ -317,7 +325,7 @@ muscle_string_decode (char const *key)
do {
switch (*value)
{
MUSCLE_COMMON_DECODE (value)
COMMON_DECODE (value)
case '[':
case ']':
aver (false);
@@ -332,7 +340,7 @@ muscle_string_decode (char const *key)
/* Reverse of muscle_location_grow. */
static location
muscle_location_decode (char const *key)
location_decode (char const *key)
{
location loc;
char const *value = muscle_find_const (key);
@@ -342,7 +350,7 @@ muscle_location_decode (char const *key)
while (*++value)
switch (*value)
{
MUSCLE_COMMON_DECODE (value)
COMMON_DECODE (value)
case '[':
aver (false);
break;
@@ -455,7 +463,7 @@ muscle_percent_define_get (char const *variable)
variable, ")");
muscle_insert (usage_name, "");
value = muscle_string_decode (name);
value = string_decode (name);
if (!value)
value = xstrdup ("");
return value;
@@ -469,7 +477,7 @@ muscle_percent_define_get_loc (char const *variable)
if (!muscle_find_const (loc_name))
fatal(_("%s: undefined %%define variable %s"),
"muscle_percent_define_get_loc", quote (variable));
return muscle_location_decode (loc_name);
return location_decode (loc_name);
}
char const *
@@ -573,7 +581,7 @@ muscle_percent_define_check_values (char const * const *values)
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
value = muscle_string_decode (name);
value = string_decode (name);
if (value)
{
for (++values; *values; ++values)
+37 -60
View File
@@ -35,62 +35,47 @@ void muscle_free (void);
/* An obstack dedicated to receive muscle keys and values. */
extern struct obstack muscle_obstack;
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v = Value; \
MUSCLE_INSERT_INT (Key, v); \
} while(0)
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v = Value; \
MUSCLE_INSERT_INT (Key, v); \
} while (0)
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_printf (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
do { \
obstack_printf (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
do { \
obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
do { \
obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
obstack_escape (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
do { \
char const *p; \
for (p = Value; *p; p++) \
switch (*p) \
{ \
case '$': obstack_sgrow (Obstack, "$]["); break; \
case '@': obstack_sgrow (Obstack, "@@" ); break; \
case '[': obstack_sgrow (Obstack, "@{" ); break; \
case ']': obstack_sgrow (Obstack, "@}" ); break; \
default: obstack_1grow (Obstack, *p); break; \
} \
} while(0)
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
quotearg_style (c_quoting_style, \
Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
obstack_escape (&muscle_obstack, \
quotearg_style (c_quoting_style, Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
/* Append VALUE to the current value of KEY. If KEY did not already
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
@@ -110,15 +95,7 @@ void muscle_code_grow (const char *key, const char *value, location loc);
muscle values are output *double* quoted, one needs to strip the first level
of quotes to reach the list itself. */
void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2);
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
LOC to MUSCLE. Use digraphs for special characters in each file name. */
void muscle_location_grow (char const *key, location loc);
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use digraphs
for special characters in the file name. */
void muscle_boundary_grow (char const *key, boundary bound);
const char *a1, const char *a2);
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
+31 -18
View File
@@ -70,7 +70,7 @@ Name (char const *name, \
int i; \
int j = 1; \
\
obstack_fgrow1 (&format_obstack, "%6d", first); \
obstack_printf (&format_obstack, "%6d", first); \
for (i = begin; i < end; ++i) \
{ \
obstack_1grow (&format_obstack, ','); \
@@ -81,7 +81,7 @@ Name (char const *name, \
} \
else \
++j; \
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
obstack_printf (&format_obstack, "%6d", table_data[i]); \
if (table_data[i] < min) \
min = table_data[i]; \
if (max < table_data[i]) \
@@ -93,10 +93,10 @@ Name (char const *name, \
lmin = min; \
lmax = max; \
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
obstack_fgrow1 (&format_obstack, "%s_min", name); \
obstack_printf (&format_obstack, "%s_min", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
obstack_fgrow1 (&format_obstack, "%s_max", name); \
obstack_printf (&format_obstack, "%s_max", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
}
@@ -110,29 +110,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
/*--------------------------------------------------------------------.
| Print to OUT a representation of STRING escaped both for C and M4. |
`--------------------------------------------------------------------*/
/*----------------------------------------------------------------.
| Print to OUT a representation of CP quoted and escaped for M4. |
`----------------------------------------------------------------*/
static void
escaped_output (FILE *out, char const *string)
quoted_output (FILE *out, char const *cp)
{
char const *p;
fprintf (out, "[[");
for (p = quotearg_style (c_quoting_style, string); *p; p++)
switch (*p)
for (; *cp; cp++)
switch (*cp)
{
case '$': fputs ("$][", out); break;
case '@': fputs ("@@", out); break;
case '[': fputs ("@{", out); break;
case ']': fputs ("@}", out); break;
default: fputc (*p, out); break;
default: fputc (*cp, out); break;
}
fprintf (out, "]]");
}
/*----------------------------------------------------------------.
| Print to OUT a representation of STRING quoted and escaped both |
| for C and M4. |
`----------------------------------------------------------------*/
static void
string_output (FILE *out, char const *string)
{
quoted_output (out, quotearg_style (c_quoting_style, string));
}
/*------------------------------------------------------------------.
| Prepare the muscles related to the symbols: translate, tname, and |
@@ -142,7 +152,6 @@ escaped_output (FILE *out, char const *string)
static void
prepare_symbols (void)
{
MUSCLE_INSERT_BOOL ("token_table", token_table_flag);
MUSCLE_INSERT_INT ("tokens_number", ntokens);
MUSCLE_INSERT_INT ("nterms_number", nvars);
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
@@ -176,7 +185,7 @@ prepare_symbols (void)
if (i)
obstack_1grow (&format_obstack, ' ');
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
obstack_escape (&format_obstack, cp);
free (cp);
obstack_1grow (&format_obstack, ',');
j += width;
@@ -300,7 +309,7 @@ user_actions_output (FILE *out)
{
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
rules[r].action_location.start.line);
escaped_output (out, rules[r].action_location.start.file);
string_output (out, rules[r].action_location.start.file);
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);
@@ -406,12 +415,15 @@ symbol_code_props_output (FILE *out, char const *what,
code, optional typename. */
fprintf (out, "%s[", sep);
sep = ",\n";
escaped_output (out, loc.start.file);
string_output (out, loc.start.file);
fprintf (out, ", %d, ", loc.start.line);
escaped_output (out, sym->tag);
quoted_output (out, sym->tag);
fprintf (out, ", %d, [[%s]]", sym->number, code);
if (sym->type_name)
fprintf (out, ", [[%s]]", sym->type_name);
{
fputs (", ", out);
quoted_output (out, sym->type_name);
}
fputc (']', out);
}
}
@@ -624,6 +636,7 @@ prepare (void)
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag);
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
+407 -529
View File
File diff suppressed because it is too large Load Diff
+28 -10
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.5.1_rc2. */
/* A Bison parser, made by GNU Bison 2.6.2.13-429e. */
/* Bison interface for Yacc-like parsers in C
@@ -30,6 +30,15 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef GRAM__________SRC_PARSE_GRAM_H
# define GRAM__________SRC_PARSE_GRAM_H
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int gram_debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
@@ -155,13 +164,11 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2072 of yacc.c */
#line 114 "parse-gram.y"
/* Line 2050 of yacc.c */
#line 115 "parse-gram.y"
symbol *symbol;
symbol_list *list;
@@ -174,17 +181,14 @@ typedef union YYSTYPE
named_ref *named_ref;
/* Line 2072 of yacc.c */
#line 180 "parse-gram.h"
/* Line 2050 of yacc.c */
#line 186 "parse-gram.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
@@ -199,4 +203,18 @@ typedef struct YYLTYPE
#endif
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int gram_parse (void *YYPARSE_PARAM);
#else
int gram_parse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int gram_parse (void);
#else
int gram_parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !GRAM__________SRC_PARSE_GRAM_H */
+25 -12
View File
@@ -20,6 +20,7 @@
#include <config.h>
#include "system.h"
#include "c-ctype.h"
#include "complain.h"
#include "conflicts.h"
#include "files.h"
@@ -347,17 +348,27 @@ grammar_declaration:
}
| "%destructor" "{...}" generic_symlist
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_destructor_set (list, $2, @2);
symbol_list_free ($3);
code_props code;
code_props_symbol_action_init (&code, $2, @2);
code_props_translate_code (&code);
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_destructor_set (list, &code);
symbol_list_free ($3);
}
}
| "%printer" "{...}" generic_symlist
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_printer_set (list, $2, @2);
symbol_list_free ($3);
code_props code;
code_props_symbol_action_init (&code, $2, @2);
code_props_translate_code (&code);
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_printer_set (list, &code);
symbol_list_free ($3);
}
}
| "%default-prec"
{
@@ -724,11 +735,13 @@ add_param (char const *type, char *decl, location loc)
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
while (*--p == ' ' || *p == '\t')
continue;
--p;
while (c_isspace ((unsigned char) *p))
--p;
p[1] = '\0';
while (*++decl == ' ' || *decl == '\t')
continue;
++decl;
while (c_isspace ((unsigned char) *decl))
++decl;
if (! name_start)
complain_at (loc, _("missing identifier in parameter declaration"));
+5 -5
View File
@@ -54,7 +54,7 @@ print_core (struct obstack *oout, state *s)
snritems = nitemset;
}
obstack_fgrow1 (oout, "%d", s->number);
obstack_printf (oout, "%d", s->number);
for (i = 0; i < snritems; i++)
{
item_number *sp;
@@ -68,15 +68,15 @@ print_core (struct obstack *oout, state *s)
r = item_number_as_rule_number (*sp);
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
obstack_printf (oout, "\n%s -> ", rules[r].lhs->tag);
for (sp = rules[r].rhs; sp < sp1; sp++)
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
obstack_printf (oout, "%s ", symbols[*sp]->tag);
obstack_1grow (oout, '.');
for (/* Nothing */; *sp >= 0; ++sp)
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
obstack_printf (oout, " %s", symbols[*sp]->tag);
/* Experimental feature: display the lookahead tokens. */
if (report_flag & report_lookahead_tokens
@@ -95,7 +95,7 @@ print_core (struct obstack *oout, state *s)
obstack_sgrow (oout, "[");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
{
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
obstack_printf (oout, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
obstack_sgrow (oout, "]");
+4 -1
View File
@@ -45,7 +45,10 @@ typedef struct code_props {
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
} kind;
/** \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. */
/**
* \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE.
* Memory is allocated in an obstack freed elsewhere.
*/
char const *code;
/** Undefined iff \c code_props::code is \c NULL. */
location location;
+88 -87
View File
@@ -46,6 +46,9 @@ YY_DECL;
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
static char *fetch_type_name (char *cp, char const **type_name,
location dollar_loc);
static void handle_action_dollar (symbol_list *rule, char *cp,
location dollar_loc);
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
@@ -95,11 +98,15 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
int braces_level = 0;
/* Whether a semicolon is probably needed.
The heuristic is that a semicolon is not needed after '{', '}', ';',
or a C preprocessor directive, and that whitespaces and comments
do not affect this flag.
Note that '{' does not need a semicolon because of '{}'.
A semicolon may be needed before a cpp direcive, but don't bother. */
The heuristic is that a semicolon is not needed after '{', '}',
';', or a C preprocessor directive, and that whitespaces and
comments do not affect this flag. Note that '{' does not need a
semicolon because of '{}'. A semicolon may be needed before a
cpp directive, but don't bother.
While it is maintained in several start-conditions (factoring
opportunities), it is meaningful only for SC_RULE_ACTION. */
bool need_semicolon = false;
/* Whether in a C preprocessor directive. Don't use a start condition
@@ -157,7 +164,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
<SC_RULE_ACTION,SC_SYMBOL_ACTION>{
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
{
"'" {
STRING_GROW;
BEGIN SC_CHARACTER;
@@ -176,42 +184,31 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
STRING_GROW;
BEGIN SC_LINE_COMMENT;
}
[$@] {
warn_at (*loc, _("stray '%s'"), yytext);
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
[\[\]] {
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
}
<SC_RULE_ACTION>
{
"$"("<"{tag}">")?{ref} {
ref_tail_fields = 0;
ref_tail_fields = NULL;
handle_action_dollar (self->rule, yytext, *loc);
if (ref_tail_fields) {
if (ref_tail_fields)
obstack_sgrow (&obstack_for_string, ref_tail_fields);
}
need_semicolon = true;
}
"@"{ref} {
ref_tail_fields = 0;
ref_tail_fields = NULL;
handle_action_at (self->rule, yytext, *loc);
if (ref_tail_fields) {
if (ref_tail_fields)
obstack_sgrow (&obstack_for_string, ref_tail_fields);
}
need_semicolon = true;
}
"$" {
warn_at (*loc, _("stray '$'"));
obstack_sgrow (&obstack_for_string, "$][");
need_semicolon = true;
}
"@" {
warn_at (*loc, _("stray '@'"));
obstack_sgrow (&obstack_for_string, "@@");
need_semicolon = true;
}
"[" {
obstack_sgrow (&obstack_for_string, "@{");
need_semicolon = true;
}
"]" {
obstack_sgrow (&obstack_for_string, "@}");
need_semicolon = true;
}
@@ -263,8 +260,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<SC_SYMBOL_ACTION>
{
"$$" {
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
"$"("<"{tag}">")?"$" {
const char *type_name = NULL;
fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0;
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
self->is_value_used = true;
}
"@$" {
@@ -274,30 +275,18 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
/*-----------------------------------------.
| Escape M4 quoting characters in C code. |
`-----------------------------------------*/
<*>
{
\$ obstack_sgrow (&obstack_for_string, "$][");
\@ obstack_sgrow (&obstack_for_string, "@@");
\[ obstack_sgrow (&obstack_for_string, "@{");
\] obstack_sgrow (&obstack_for_string, "@}");
/* Escape M4 quoting characters in C code. */
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
/* By default, grow the string obstack with the input. */
.|\n STRING_GROW;
/* End of processing. */
<<EOF>> STRING_FINISH; return last_string;
}
/*-----------------------------------------------------.
| By default, grow the string obstack with the input. |
`-----------------------------------------------------*/
<*>.|\n STRING_GROW;
/* End of processing. */
<*><<EOF>> {
STRING_FINISH;
return last_string;
}
%%
static inline bool
@@ -345,7 +334,7 @@ typedef struct
not visible from current midrule. */
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
static variant *variant_table = 0;
static variant *variant_table = NULL;
static unsigned variant_table_size = 0;
static unsigned variant_count = 0;
@@ -367,7 +356,7 @@ static void
variant_table_free (void)
{
free (variant_table);
variant_table = 0;
variant_table = NULL;
variant_table_size = variant_count = 0;
}
@@ -410,7 +399,7 @@ variant_add (uniqstr id, location id_loc, unsigned symbol_index,
}
static const char *
get_at_spec(unsigned symbol_index)
get_at_spec (unsigned symbol_index)
{
static char at_buf[20];
if (symbol_index == 0)
@@ -454,30 +443,30 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
/* Create the explanation message. */
obstack_init (&msg_buf);
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
if (contains_dot_or_dash (id))
obstack_fgrow1 (&msg_buf, "[%s]", id);
obstack_printf (&msg_buf, "[%s]", id);
else
obstack_sgrow (&msg_buf, id);
obstack_sgrow (&msg_buf, tail);
if (var->err & VARIANT_HIDDEN)
{
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
if (contains_dot_or_dash (var->id))
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
obstack_printf (&msg_buf, "[%s]", var->id);
else
obstack_sgrow (&msg_buf, var->id);
obstack_sgrow (&msg_buf, tail);
}
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
obstack_printf (&msg_buf, _(" at %s"), at_spec);
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
{
const char *format =
_(", cannot be accessed from mid-rule action at $%d");
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
obstack_printf (&msg_buf, format, midrule_rhs_index);
}
obstack_1grow (&msg_buf, '\0');
@@ -688,6 +677,31 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
int max_left_semantic_context = 0;
/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
beginning (i.e., after the opening "<", and return the pointer
immediately after it. */
static
char *
fetch_type_name (char *cp, char const **type_name,
location dollar_loc)
{
if (*cp == '<')
{
*type_name = ++cp;
while (*cp != '>')
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
tag_seen = true;
}
return cp;
}
/*------------------------------------------------------------------.
| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
| |
@@ -701,7 +715,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
{
char const *type_name = NULL;
char *cp = text + 1;
char *gt_ptr = 0;
symbol_list *effective_rule;
int effective_rule_length;
int n;
@@ -718,26 +731,14 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
}
/* Get the type name if explicit. */
if (*cp == '<')
{
type_name = ++cp;
while (*cp != '>')
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
gt_ptr = cp;
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
tag_seen = true;
}
cp = fetch_type_name (cp, &type_name, dollar_loc);
n = parse_ref (cp, effective_rule, effective_rule_length,
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
if (gt_ptr)
*gt_ptr = '\0';
/* End type_name. */
if (type_name)
cp[-1] = '\0';
switch (n)
{
@@ -764,11 +765,11 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
}
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow1 (&obstack_for_string,
"]b4_lhs_value([%s])[", type_name);
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
rule->action_props.is_value_used = true;
break;
@@ -785,12 +786,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
cp, quote (effective_rule->content.sym->tag));
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow3 (&obstack_for_string,
"]b4_rhs_value(%d, %d, [%s])[",
effective_rule_length, n, type_name);
obstack_printf (&obstack_for_string,
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
if (n > 0)
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
true;
@@ -826,7 +827,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
locations_flag = true;
n = parse_ref (cp, effective_rule, effective_rule_length,
rule->midrule_parent_rhs_index, text, at_loc, '@');
rule->midrule_parent_rhs_index, text, at_loc, '@');
switch (n)
{
case INVALID_REF:
@@ -837,7 +838,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
break;
default:
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
effective_rule_length, n);
break;
}
+2 -2
View File
@@ -36,7 +36,7 @@
#include "reader.h"
#include "uniqstr.h"
#include <ctype.h>
#include <c-ctype.h>
#include <mbswidth.h>
#include <quote.h>
@@ -560,7 +560,7 @@ splice (\\[ \f\t\v]*\n)*
\\(.|\n) {
char const *p = yytext + 1;
/* Quote only if escaping won't make the character visible. */
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p))
p = quote (p);
else
p = quotearg_style_mem (escape_quoting_style, p, 1);
+20 -18
View File
@@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at);
"@@" fputc ('@', yyout);
"@{" fputc ('[', yyout);
"@}" fputc (']', yyout);
"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */
@\n /* Likewise. */
"@`" continue; /* Used by b4_cat in ../data/bison.m4. */
@\n continue;
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
"@ofile@" QPUTS (outname);
@@ -87,9 +87,9 @@ static void fail_for_invalid_at (char const *at);
}
/* This pattern must not match more than the previous @ patterns. */
@[^@{}`(\n]* fail_for_invalid_at (yytext);
\n out_lineno++; ECHO;
[^@\n]+ ECHO;
@[^@{}`(\n]* fail_for_invalid_at (yytext);
\n out_lineno++; ECHO;
[^@\n]+ ECHO;
<INITIAL><<EOF>> {
if (outname)
@@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at);
return EOF;
}
<SC_AT_DIRECTIVE_ARGS>{
[^@]+ { STRING_GROW; }
<SC_AT_DIRECTIVE_ARGS>
{
[^@]+ STRING_GROW;
"@@" { obstack_1grow (&obstack_for_string, '@'); }
"@{" { obstack_1grow (&obstack_for_string, '['); }
"@}" { obstack_1grow (&obstack_for_string, ']'); }
"@`" /* Empty. Useful for starting an argument
that begins with whitespace. */
@\n /* Empty. */
"@@" obstack_1grow (&obstack_for_string, '@');
"@{" obstack_1grow (&obstack_for_string, '[');
"@}" obstack_1grow (&obstack_for_string, ']');
"@`" continue; /* For starting an argument that begins with whitespace. */
@\n continue;
@[,)] {
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
@@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at);
}
}
@.? { fail_for_invalid_at (yytext); }
@.? fail_for_invalid_at (yytext);
}
<SC_AT_DIRECTIVE_SKIP_WS>{
[ \t\r\n]
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
<SC_AT_DIRECTIVE_SKIP_WS>
{
[ \t\r\n] continue;
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
}
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>{
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
{
<<EOF>> {
fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
}
+10 -16
View File
@@ -223,49 +223,43 @@ symbol_list_null (symbol_list *node)
}
void
symbol_list_destructor_set (symbol_list *node, char const *code, location loc)
symbol_list_destructor_set (symbol_list *node, code_props const *destructor)
{
code_props destructor;
code_props_symbol_action_init (&destructor, code, loc);
code_props_translate_code (&destructor);
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_destructor_set (node->content.sym, &destructor);
symbol_destructor_set (node->content.sym, destructor);
break;
case SYMLIST_TYPE:
semantic_type_destructor_set (
semantic_type_get (node->content.type_name), &destructor);
semantic_type_get (node->content.type_name), destructor);
break;
case SYMLIST_DEFAULT_TAGGED:
default_tagged_destructor_set (&destructor);
default_tagged_destructor_set (destructor);
break;
case SYMLIST_DEFAULT_TAGLESS:
default_tagless_destructor_set (&destructor);
default_tagless_destructor_set (destructor);
break;
}
}
void
symbol_list_printer_set (symbol_list *node, char const *code, location loc)
symbol_list_printer_set (symbol_list *node, code_props const *printer)
{
code_props printer;
code_props_symbol_action_init (&printer, code, loc);
code_props_translate_code (&printer);
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_printer_set (node->content.sym, &printer);
symbol_printer_set (node->content.sym, printer);
break;
case SYMLIST_TYPE:
semantic_type_printer_set (
semantic_type_get (node->content.type_name), &printer);
semantic_type_get (node->content.type_name), printer);
break;
case SYMLIST_DEFAULT_TAGGED:
default_tagged_printer_set (&printer);
default_tagged_printer_set (printer);
break;
case SYMLIST_DEFAULT_TAGLESS:
default_tagless_printer_set (&printer);
default_tagless_printer_set (printer);
break;
}
}
+4 -4
View File
@@ -119,11 +119,11 @@ uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
bool symbol_list_null (symbol_list *node);
/** Set the \c \%destructor for \c node as \c code at \c loc. */
void symbol_list_destructor_set (symbol_list *node, char const *code,
location loc);
void symbol_list_destructor_set (symbol_list *node,
code_props const *destructor);
/** Set the \c \%printer for \c node as \c code at \c loc. */
void symbol_list_printer_set (symbol_list *node, char const *code,
location loc);
void symbol_list_printer_set (symbol_list *node,
code_props const *printer);
#endif /* !SYMLIST_H_ */
+14 -7
View File
@@ -60,23 +60,30 @@ struct symbol
/** The location of its first occurrence. */
location location;
/** Its \c \%type. */
/** Its \c \%type.
Beware that this is the type_name as was entered by the user,
including silly things such as "]" if she entered "%token <]> t".
Therefore, when outputting type_name to M4, be sure to escape it
into "@}". See quoted_output for instance. */
uniqstr type_name;
/** Its \c \%type's location. */
location type_location;
/** Any \c \%destructor declared specifically for this symbol.
Access this field only through <tt>symbol</tt>'s interface functions. For
example, if <tt>symbol::destructor = NULL</tt>, a default \c \%destructor
or a per-type \c \%destructor might be appropriate, and
\c symbol_destructor_get will compute the correct one. */
Access this field only through <tt>symbol</tt>'s interface
functions. For example, if <tt>symbol::destructor = NULL</tt>, a
default \c \%destructor or a per-type \c \%destructor might be
appropriate, and \c symbol_destructor_get will compute the
correct one. */
code_props destructor;
/** Any \c \%printer declared specifically for this symbol.
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
Access this field only through <tt>symbol</tt>'s interface functions.
\sa symbol::destructor */
code_props printer;
symbol_number number;
+48 -44
View File
@@ -38,11 +38,6 @@
# include <stddef.h>
# include <stdlib.h>
# include <string.h>
# if HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# include <unistd.h>
# include <inttypes.h>
@@ -105,7 +100,6 @@ typedef size_t uintptr_t;
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# endif
# define FUNCTION_PRINT() fprintf (stderr, "%s: ", __func__)
/*------.
| NLS. |
@@ -160,36 +154,50 @@ typedef size_t uintptr_t;
# define obstack_chunk_free free
# include <obstack.h>
# define obstack_sgrow(Obs, Str) \
# define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str))
# define obstack_fgrow1(Obs, Format, Arg1) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
/* Output Str escaped for our postprocessing (i.e., escape M4 special
characters).
# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */
# define obstack_escape(Obs, Str) \
do { \
char const *p; \
for (p = Str; *p; p++) \
switch (*p) \
{ \
case '$': obstack_sgrow (Obs, "$]["); break; \
case '@': obstack_sgrow (Obs, "@@" ); break; \
case '[': obstack_sgrow (Obs, "@{" ); break; \
case ']': obstack_sgrow (Obs, "@}" ); break; \
default: obstack_1grow (Obs, *p ); break; \
} \
} while (0)
/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped
for our postprocessing (i.e., escape M4 special characters). If
Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4
programming easier (m4_ifval can be used).
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
# define obstack_quote(Obs, Str) \
do { \
char const* obstack_quote_p = Str; \
if (obstack_quote_p && obstack_quote_p[0]) \
{ \
obstack_sgrow (Obs, "[["); \
obstack_escape (Obs, obstack_quote_p); \
obstack_sgrow (Obs, "]]"); \
} \
else \
obstack_sgrow (Obs, "[]"); \
} while (0)
# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
@@ -205,25 +213,21 @@ do { \
# define TAB_EXT ".tab"
# endif
# ifndef DEFAULT_TMPDIR
# define DEFAULT_TMPDIR "/tmp"
# endif
/*---------------------.
| Free a linked list. |
`---------------------*/
# define LIST_FREE(Type, List) \
do { \
Type *_node, *_next; \
for (_node = List; _node; _node = _next) \
{ \
_next = _node->next; \
free (_node); \
} \
} while (0)
# define LIST_FREE(Type, List) \
do { \
Type *_node, *_next; \
for (_node = List; _node; _node = _next) \
{ \
_next = _node->next; \
free (_node); \
} \
} while (0)
/*---------------------------------------------.
+1 -1
View File
@@ -36,7 +36,7 @@ uniqstr uniqstr_vsprintf (char const *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/* Two uniqstr values have the same value iff they are the same. */
#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2))
#define UNIQSTR_EQ(USTR1, USTR2) (!!((USTR1) == (USTR2)))
/* Compare two uniqstr a la strcmp: negative for <, nul for =, and
positive for >. Undefined order, relies on addresses. */
+5 -5
View File
@@ -73,23 +73,23 @@ check-local: atconfig atlocal $(TESTSUITE)
check_SCRIPTS = bison
# Run the test suite on the *installed* tree.
installcheck-local:
installcheck-local: atconfig atlocal $(TESTSUITE)
$(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
# Be real mean with it.
.PHONY: maintainer-check-g++
maintainer-check-g++: $(TESTSUITE)
maintainer-check-g++: atconfig atlocal $(TESTSUITE)
$(TESTSUITE) $(TESTSUITEFLAGS) --compile-c-with-cxx
.PHONY: maintainer-check-posix
maintainer-check-posix: $(TESTSUITE)
maintainer-check-posix: atconfig atlocal $(TESTSUITE)
$(TESTSUITE) $(TESTSUITEFLAGS) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
.PHONY: maintainer-check-valgrind
maintainer-check-valgrind: $(TESTSUITE)
maintainer-check-valgrind: atconfig atlocal $(TESTSUITE)
test -z '$(VALGRIND)' || \
$(TESTSUITE) $(TESTSUITEFLAGS) \
PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' \
PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \
VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
.PHONY: maintainer-check
+284 -286
View File
File diff suppressed because it is too large Load Diff
+16 -16
View File
@@ -29,14 +29,10 @@ CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
# Is the compiler GCC?
GCC='@GCC@'
# We want no optimization.
O0CFLAGS=`echo '@CFLAGS@' | sed 's/-O[0-9] *//'`
O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9] *//'`
# Sometimes a test group needs to ignore gcc warnings, so it locally
# sets CFLAGS to this.
NO_WERROR_CFLAGS="$O0CFLAGS @WARN_CFLAGS@ @WARN_CFLAGS_TEST@"
NO_WERROR_CXXFLAGS="$O0CXXFLAGS @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@"
NO_WERROR_CFLAGS='@CFLAGS@ @WARN_CFLAGS@ @WARN_CFLAGS_TEST@'
NO_WERROR_CXXFLAGS='@CXXFLAGS@ @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@'
# But most of the time, we want -Werror.
CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@"
@@ -47,10 +43,12 @@ BISON_CXX_WORKS='@BISON_CXX_WORKS@'
# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
if "$at_arg_compile_c_with_cxx"; then
CC_IS_CXX=1
CC=$CXX
O0CFLAGS=$O0CXXFLAGS
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
CFLAGS=$CXXFLAGS
else
CC_IS_CXX=0
fi
@@ -58,24 +56,26 @@ fi
## Other. ##
## ------- ##
# Are special link options needed?
LDFLAGS='@LDFLAGS@'
# Are special libraries needed?
LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
# Empty if no javac was found
CONF_JAVAC='@CONF_JAVAC@'
# Empty if no Java VM was found
CONF_JAVA='@CONF_JAVA@'
# Empty if no xsltproc was found
: ${XSLTPROC='@XSLTPROC@'}
# We need egrep.
: ${EGREP='@EGREP@'}
# Use simple quotes (lib/quote.c).
LC_CTYPE=C
export LC_CTYPE
# Are special link options needed?
LDFLAGS='@LDFLAGS@'
# Are special libraries needed?
LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
# Empty if no xsltproc was found
: ${XSLTPROC='@XSLTPROC@'}
: ${PERL='@PERL@'}
+1 -1
View File
@@ -19,7 +19,7 @@
abs_top_srcdir='@abs_top_srcdir@'
abs_top_builddir='@abs_top_builddir@'
: ${PERL=perl}
: ${PERL='@PERL@'}
# Use the shipped files, not those installed.
BISON_PKGDATADIR=$abs_top_srcdir/data
+4 -5
View File
@@ -1,4 +1,4 @@
# Checking the output filenames. -*- Autotest -*-
# Checking the C++ Features. -*- Autotest -*-
# Copyright (C) 2004-2005, 2007, 2009-2012 Free Software Foundation,
# Inc.
@@ -30,6 +30,7 @@ m4_define([AT_CHECK_DOXYGEN],
[m4_fatal([invalid argument: $1])])
AT_SETUP([Doxygen $1 Documentation])
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
AT_DATA([input.yy],
[[%skeleton "lalr1.cc"
%locations
@@ -38,10 +39,7 @@ AT_DATA([input.yy],
%%
exp:;
%%
yy::parser::error (const location& l, const std::string& m)
{
std::cerr << l << s << std::endl;
}
]AT_YYERROR_DEFINE[
]])
AT_BISON_CHECK([-o input.cc input.yy], 0)
@@ -94,6 +92,7 @@ EXTRACT_STATIC = AT_DOXYGEN_PRIVATE
AT_CHECK([doxygen --version || exit 77], 0, ignore)
AT_CHECK([doxygen], 0, [], [ignore])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
m4_popdef([AT_DOXYGEN_PRIVATE])
+156 -124
View File
@@ -33,21 +33,90 @@
# Don't call this macro directly, because it contains some occurrences
# of `$1' etc. which will be interpreted by m4. So you should call it
# with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does.
#
# When %defines is not passed, generate a single self-contained file.
# Otherwise, generate three: calc.y with the parser, calc-lex.c with
# the scanner, and calc-main.c with "main()". This is in order to
# stress the use of the generated parser header. To avoid code
# duplication, AT_CALC_LEX and AT_CALC_MAIN contain the body of these
# two later files.
m4_define([_AT_DATA_CALC_Y],
[m4_if([$1$2$3], $[1]$[2]$[3], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl
m4_pushdef([AT_CALC_MAIN],
[#include <assert.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#else
# undef alarm
# define alarm(seconds) /* empty */
#endif
AT_SKEL_CC_IF([[
/* A C++ ]AT_NAME_PREFIX[parse that simulates the C signature. */
int
]AT_NAME_PREFIX[parse (]AT_PARAM_IF([semantic_value *result, int *count]))[
{
]AT_NAME_PREFIX[::parser parser]AT_PARAM_IF([ (result, count)])[;
#if ]AT_API_PREFIX[DEBUG
parser.set_debug_level (1);
#endif
return parser.parse ();
}
]])[
semantic_value global_result = 0;
int global_count = 0;
/* A C main function. */
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
[ ]AT_NAME_PREFIX[debug = 1;])])[
status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count]])[);
if (fclose (input))
perror ("fclose");
assert (global_result == result);
assert (global_count == count);
return status;
}
]])
m4_pushdef([AT_CALC_LEX],
[[#include <ctype.h>
int ]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[);
static int get_char (]AT_LEX_FORMALS[);
static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
]AT_YYLEX_DECLARE_EXTERN[
static int get_char (]AT_YYLEX_FORMALS[);
static void unget_char (]AT_YYLEX_PRE_FORMALS[ int c);
]AT_LOCATION_IF([
static YYLTYPE last_yylloc;
static AT_YYLTYPE last_yylloc;
])[
static int
get_char (]AT_LEX_FORMALS[)
get_char (]AT_YYLEX_FORMALS[)
{
int res = getc (input);
]AT_USE_LEX_ARGS[;
@@ -65,7 +134,7 @@ get_char (]AT_LEX_FORMALS[)
}
static void
unget_char (]AT_LEX_PRE_FORMALS[ int c)
unget_char (]AT_YYLEX_PRE_FORMALS[ int c)
{
]AT_USE_LEX_ARGS[;
]AT_LOCATION_IF([
@@ -76,26 +145,26 @@ unget_char (]AT_LEX_PRE_FORMALS[ int c)
}
static int
read_signed_integer (]AT_LEX_FORMALS[)
read_signed_integer (]AT_YYLEX_FORMALS[)
{
int c = get_char (]AT_LEX_ARGS[);
int c = get_char (]AT_YYLEX_ARGS[);
int sign = 1;
int n = 0;
]AT_USE_LEX_ARGS[;
if (c == '-')
{
c = get_char (]AT_LEX_ARGS[);
c = get_char (]AT_YYLEX_ARGS[);
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char (]AT_LEX_ARGS[);
c = get_char (]AT_YYLEX_ARGS[);
}
unget_char (]AT_LEX_PRE_ARGS[ c);
unget_char (]AT_YYLEX_PRE_ARGS[ c);
return sign * n;
}
@@ -107,8 +176,7 @@ read_signed_integer (]AT_LEX_FORMALS[)
| blanks and tabs, returns 0 for EOF. |
`---------------------------------------------------------------*/
int
]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[)
]AT_YYLEX_PROTOTYPE[
{
static int init = 1;
int c;
@@ -130,13 +198,13 @@ int
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
])[
}
while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t');
while ((c = get_char (]AT_YYLEX_ARGS[)) == ' ' || c == '\t');
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char (]AT_LEX_PRE_ARGS[ c);
]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
unget_char (]AT_YYLEX_PRE_ARGS[ c);
]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[);
return NUM;
}
@@ -196,61 +264,47 @@ AT_SKEL_CC_IF(
%code provides
{
#include <stdio.h>
/* The input. */
extern FILE *input;]AT_SKEL_CC_IF([[
#ifndef YYLTYPE
# define YYLTYPE ]AT_NAME_PREFIX[::parser::location_type
#endif
]])[
#include <stdio.h>
/* The input. */
extern FILE *input;
extern semantic_value global_result;
extern int global_count;
}
%code
{
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#else
# undef alarm
# define alarm(seconds) /* empty */
#endif
#define USE(Var)
FILE *input;
static semantic_value global_result = 0;
static int global_count = 0;
static int power (int base, int exponent);
]AT_SKEL_CC_IF(,
[/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
[static void yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s
);])[
int yylex (]AT_LEX_FORMALS[);
]AT_YYLEX_DECLARE_EXTERN[
}
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [[
/* The lalr1.cc skeleton, for backward compatibility, defines
a constructor for position that initializes the filename. The
glr.cc skeleton does not (and in fact cannot: location/position
are stored in a union, from which objects with constructors are
excluded in C++. */
excluded in C++). */
%initial-action {
@$.initialize ();
}
])])[
]])])[
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
@@ -289,6 +343,16 @@ exp:
;
%%
static int
power (int base, int exponent)
{
int res = 1;
assert (0 <= exponent);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
]AT_SKEL_CC_IF(
[AT_LOCATION_TYPE_IF([[
std::ostream&
@@ -302,29 +366,10 @@ exp:
return o;
}
]])
/* A C++ error reporting function. */
void
AT_NAME_PREFIX::parser::error (const location_type& l, const std::string& m)
{
(void) l;
std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
}
/* A C++ yyparse that simulates the C signature. */
int
yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
{
AT_NAME_PREFIX::parser parser[]AT_PARAM_IF([ (result, count)]);
#if YYDEBUG
parser.set_debug_level (1);
#endif
return parser.parse ();
}
],
AT_YYERROR_DEFINE],
[/* A C error reporting function. */
static void
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
yyerror (AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s)
{
@@ -334,67 +379,27 @@ AT_YYERROR_SEES_LOC_IF([
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
fprintf (stderr, "-%d.%d",
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
fprintf (stderr, "-%d",
AT_LOC_LAST_COLUMN - 1);
AT_LOC_LAST_COLUMN - 1);
fprintf (stderr, ": ");])
fprintf (stderr, "%s\n", s);
}])[
]AT_DEFINES_IF([],
[AT_CALC_LEX
AT_CALC_MAIN])])
]AT_DEFINES_IF(, [AT_CALC_LEX])[
static int
power (int base, int exponent)
{
int res = 1;
assert (0 <= exponent);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
/* A C main function. */
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
[ yydebug = 1;])])[
status = yyparse (]AT_PARAM_IF([[&result, &count]])[);
if (fclose (input))
perror ("fclose");
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
]])
AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
]AT_CALC_LEX])])
]AT_CALC_LEX])
AT_DATA_SOURCE([[calc-main.c]AT_SKEL_CC_IF([[c]])],
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
]AT_CALC_MAIN])
])
m4_popdef([AT_CALC_MAIN])
m4_popdef([AT_CALC_LEX])
])# _AT_DATA_CALC_Y
@@ -493,21 +498,39 @@ AT_CHECK([cat stderr], 0, [expout])
])
# AT_CHECK_CALC([BISON-OPTIONS, [EXPECTED-TO-FAIL]])
# --------------------------------------------------
# AT_CHECK_SPACES([FILE])
# -----------------------
# Make sure we did not introduce bad spaces. Checked here because all
# the skeletons are (or should be) exercized here.
m4_define([AT_CHECK_SPACES],
[AT_CHECK([$PERL -ne '
chomp;
print "$.: {$_}\n"
if (# No starting/ending empty lines.
(eof || $. == 1) && /^\s*$/
# No trailing space. FIXME: not ready for "maint".
# || /\s$/
)' $1
])dnl
])
# AT_CHECK_CALC([BISON-OPTIONS])
# ------------------------------
# Start a testing chunk which compiles `calc' grammar with
# BISON-OPTIONS, and performs several tests over the parser.
# However, if EXPECTED-TO-FAIL is nonempty, this test is expected to fail.
m4_define([AT_CHECK_CALC],
[# We use integers to avoid dependencies upon the precision of doubles.
AT_SETUP([Calculator $1])
[m4_ifval([$2], [m4_fatal([$0: expected a single argument])])
m4_ifval([$2], [AT_CHECK([exit 77])])
# We use integers to avoid dependencies upon the precision of doubles.
AT_SETUP([Calculator $1])
AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE([calc], [AT_DEFINES_IF([[lex]])])
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]))
AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([cc], [c])])
AT_DEFINES_IF([AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([hh], [h])])])
# Test the priorities.
_AT_CHECK_CALC([$1],
@@ -622,14 +645,16 @@ AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%debug])
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# ----------------------- #
@@ -651,6 +676,7 @@ AT_CHECK_CALC_GLR()
AT_CHECK_CALC_GLR([%defines])
AT_CHECK_CALC_GLR([%locations])
AT_CHECK_CALC_GLR([%name-prefix "calc"])
AT_CHECK_CALC_GLR([%define api.prefix "calc"])
AT_CHECK_CALC_GLR([%verbose])
AT_CHECK_CALC_GLR([%yacc])
AT_CHECK_CALC_GLR([%error-verbose])
@@ -662,10 +688,12 @@ AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbo
AT_CHECK_CALC_GLR([%debug])
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# ----------------------------- #
@@ -687,11 +715,13 @@ m4_define([AT_CHECK_CALC_LALR1_CC],
AT_CHECK_CALC_LALR1_CC([])
AT_CHECK_CALC_LALR1_CC([%define location_type Span])
AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%error-verbose %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
@@ -714,6 +744,7 @@ m4_define([AT_CHECK_CALC_GLR_CC],
AT_CHECK_CALC_GLR_CC([])
AT_CHECK_CALC_GLR_CC([%define location_type Span])
AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%error-verbose %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%debug])
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
@@ -721,3 +752,4 @@ AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+15 -48
View File
@@ -50,20 +50,17 @@ AT_CLEANUP
AT_SETUP([%nonassoc and eof])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define YYERROR_VERBOSE 1
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
/* The current argument. */
static const char *input;
@@ -71,8 +68,7 @@ static int
yylex (void)
{
static size_t toknum;
if (! (toknum <= strlen (input)))
abort ();
assert (toknum <= strlen (input));
return input[toknum++];
}
@@ -93,6 +89,7 @@ main (int argc, const char *argv[])
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
m4_pushdef([AT_NONASSOC_AND_EOF_CHECK],
[AT_BISON_CHECK([$1[ -o input.c input.y]])
@@ -171,7 +168,7 @@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
#include <string>]], [[
#include <assert.h>
#include <stdio.h>
void yyerror (char const *msg);]])[
]AT_YYERROR_DECLARE])[
]AT_YYLEX_PROTOTYPE[;
#define USE(Var)
}
@@ -212,31 +209,11 @@ public Object getLVal ()
*lvalp = 1;
return *input++;
}]])[
/*----------.
| yyerror. |
`----------*/]AT_SKEL_JAVA_IF([[
public void yyerror (String msg)
{
System.err.println (msg);
}
]AT_YYERROR_DEFINE[
]AT_SKEL_JAVA_IF([[
};
%%]], [AT_SKEL_CC_IF([[
void
yy::parser::error (const yy::location &, std::string const &msg)
{
std::cerr << msg << std::endl;
}]], [[
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}]])])[
%%]])[
/*-------.
| main. |
@@ -471,12 +448,12 @@ AT_CLEANUP
# with minimal LR parser tables.
AT_SETUP([[LAC: %nonassoc requires splitting canonical LR states]])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]],
[[%code {
#include <stdio.h>
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
%error-verbose
@@ -513,19 +490,8 @@ look:
reduce-nonassoc: %prec 'a';
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
yylex (void)
{
char const *input = "aaa";
return *input++;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["aaa"])[
int
main (void)
@@ -533,6 +499,7 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
# Show canonical LR's failure.
AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
+51 -70
View File
@@ -23,15 +23,15 @@ AT_BANNER([[C++ Type Syntax (GLR).]])
# and with RESOLVE1 and RESOLVE2 as annotations on the conflicted rule for
# stmt. Then compile the result.
m4_define([_AT_TEST_GLR_CXXTYPES],
[
AT_BISON_OPTION_PUSHDEFS([$1])
[AT_BISON_OPTION_PUSHDEFS([%glr-parser $1])
AT_DATA_GRAMMAR([types.y],
[[/* Simplified C++ Type and Expression Grammar. */
$1
%{
%code requires
{
#include <stdio.h>
union Node {
struct {
@@ -51,33 +51,22 @@ $1
} term;
};
typedef union Node Node;
#define YYSTYPE Node *
}
%code
{
static Node *new_nterm (char const *, Node *, Node *, Node *);
static Node *new_term (char *);
static void free_node (Node *);
static char *node_to_string (Node *);
#define YYSTYPE Node *
]m4_bmatch([$2], [stmtMerge],
[ static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);])[
#define YYINITDEPTH 10
#define YYSTACKEXPANDABLE 1
struct YYLTYPE;
#if YYPURE
# if YYLSP_NEEDED
# define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
# define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
# else
# define LEX_PARAMETERS YYSTYPE *lvalp
# endif
#endif
#ifndef LEX_PARAMETERS
# define LEX_PARAMETERS void
#endif
#ifndef ERROR_PARAMETERS
# define ERROR_PARAMETERS char const *s
#endif
int yylex (LEX_PARAMETERS);
void yyerror (ERROR_PARAMETERS);
%}
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
%token TYPENAME ID
@@ -133,19 +122,20 @@ declarator : ID
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
int
main (int argc, char **argv)
{
if (argc != 2)
abort ();
assert (argc == 2);
if (!freopen (argv[1], "r", stdin))
return 3;
return yyparse ();
}
int
yylex (LEX_PARAMETERS)
]AT_YYERROR_DEFINE[
]AT_YYLEX_PROTOTYPE[
{
char buffer[256];
int c;
@@ -162,8 +152,7 @@ yylex (LEX_PARAMETERS)
while (1)
{
if (feof (stdin))
abort ();
assert (!feof (stdin));
c = getchar ();
switch (c)
{
@@ -181,11 +170,9 @@ yylex (LEX_PARAMETERS)
break;
default:
{
int tok;
#if YYLSP_NEEDED
int tok;]AT_LOCATION_IF([[
yylloc.first_line = yylloc.last_line = lineNum;
yylloc.first_column = colNum;
#endif
yylloc.first_column = colNum;]])[
if (isalpha (c))
{
i = 0;
@@ -194,8 +181,7 @@ yylex (LEX_PARAMETERS)
{
buffer[i++] = c;
colNum += 1;
if (i == sizeof buffer - 1)
abort ();
assert (i != sizeof buffer - 1);
c = getchar ();
}
while (isalnum (c) || c == '_');
@@ -210,27 +196,14 @@ yylex (LEX_PARAMETERS)
colNum += 1;
tok = c;
yylval = YY_NULL;
}
#if YYLSP_NEEDED
yylloc.last_column = colNum-1;
#endif
}]AT_LOCATION_IF([[
yylloc.last_column = colNum-1;]])[
return tok;
}
}
}
}
void
yyerror (ERROR_PARAMETERS)
{
#if YYPURE && YYLSP_NEEDED
/* Pacify GCC by using llocp. */
if (! llocp)
abort ();
#endif
fprintf (stderr, "%s\n", s);
}
static Node *
new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
{
@@ -351,7 +324,7 @@ AT_BISON_OPTION_POPDEFS
])
m4_define([_AT_RESOLVED_GLR_OUTPUT],
[[[+(z,q)
[[+(z,q)
<declare>(T,x)
<init-declare>(T,x,y)
=(x,y)
@@ -360,10 +333,10 @@ m4_define([_AT_RESOLVED_GLR_OUTPUT],
<init-declare>(T,y,+(z,q))
<error>
+(z,q)
]]])
]])
m4_define([_AT_RESOLVED_GLR_OUTPUT_WITH_LOC],
[[[3.0-3.5: +(z,q)
[[3.0-3.5: +(z,q)
5.0-5.3: <declare>(T,x)
7.0-7.7: <init-declare>(T,x,y)
9.0-9.5: =(x,y)
@@ -372,10 +345,10 @@ m4_define([_AT_RESOLVED_GLR_OUTPUT_WITH_LOC],
15.0-15.13: <init-declare>(T,y,+(z,q))
17.0-17.15: <error>
19.0-19.5: +(z,q)
]]])
]])
m4_define([_AT_AMBIG_GLR_OUTPUT],
[[[+(z,q)
[[+(z,q)
<declare>(T,x)
<init-declare>(T,x,y)
=(x,y)
@@ -384,10 +357,10 @@ m4_define([_AT_AMBIG_GLR_OUTPUT],
<OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
<error>
+(z,q)
]]])
]])
m4_define([_AT_AMBIG_GLR_OUTPUT_WITH_LOC],
[[[3.0-3.5: +(z,q)
[[3.0-3.5: +(z,q)
5.0-5.3: <declare>(T,x)
7.0-7.7: <init-declare>(T,x,y)
9.0-9.5: =(x,y)
@@ -396,15 +369,23 @@ m4_define([_AT_AMBIG_GLR_OUTPUT_WITH_LOC],
15.0-15.13: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
17.0-17.15: <error>
19.0-19.5: +(z,q)
]]])
]])
m4_define([_AT_GLR_STDERR],
[[[syntax error
]]])
[[syntax error
]])
m4_define([_AT_GLR_STDERR_WITH_LOC],
[[17.5-4: syntax error
]])
m4_define([_AT_VERBOSE_GLR_STDERR],
[[[syntax error, unexpected ID, expecting '=' or '+' or ')'
]]])
[[syntax error, unexpected ID, expecting '=' or '+' or ')'
]])
m4_define([_AT_VERBOSE_GLR_STDERR_WITH_LOC],
[[17.5-4: syntax error, unexpected ID, expecting '=' or '+' or ')'
]])
## ---------------------------------------------------- ##
## Compile the grammar described in the documentation. ##
@@ -414,59 +395,59 @@ AT_SETUP([GLR: Resolve ambiguity, impure, no locations])
_AT_TEST_GLR_CXXTYPES([],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
[_AT_RESOLVED_GLR_OUTPUT], [_AT_GLR_STDERR])
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
[_AT_RESOLVED_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
[_AT_RESOLVED_GLR_OUTPUT], [_AT_GLR_STDERR])
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
[_AT_RESOLVED_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
_AT_TEST_GLR_CXXTYPES([],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
[_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
_AT_TEST_GLR_CXXTYPES([%locations],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
[_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
[_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
[%merge <stmtMerge>],[%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
[_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
AT_CLEANUP
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
_AT_TEST_GLR_CXXTYPES([%error-verbose],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_VERBOSE_GLR_STDERR)
[_AT_AMBIG_GLR_OUTPUT], [_AT_VERBOSE_GLR_STDERR])
AT_CLEANUP
+4 -1
View File
@@ -35,7 +35,10 @@ dnl time comes, just use sed to drop the line numbers. For now, as LR(1)
dnl support is rapidly evolving, let's keep that information to be careful.
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
m4_pushdef([AT_LALR1_DIFF_CHECK],
[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
[dnl We need diff -u, which is not portable.
AT_CHECK([diff -u /dev/null /dev/null || exit 77], [0], [ignore])
AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
AT_CHECK([[diff -u input-lalr.output input.output \
| sed -n '/^@@/,$p' | sed 's/^ $//']],
+138 -282
View File
@@ -24,6 +24,7 @@ AT_BANNER([[GLR Regression Tests]])
AT_SETUP([Badly Collapsed GLR States])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr1.y],
[[/* Regression Test: Improper state compression */
/* Reported by Scott McPeak */
@@ -31,11 +32,12 @@ AT_DATA_GRAMMAR([glr-regr1.y],
%{
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define YYSTYPE int
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
int yylex (void);
void yyerror (char const *msg);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
@@ -71,12 +73,7 @@ main (void)
return yyparse ();
}
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
int
yylex (void)
@@ -84,8 +81,7 @@ yylex (void)
for (;;)
{
int ch;
if (feof (stdin))
abort ();
assert (!feof (stdin));
ch = getchar ();
if (ch == EOF)
return 0;
@@ -94,6 +90,7 @@ yylex (void)
}
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
[glr-regr1.y: conflicts: 1 shift/reduce
@@ -119,6 +116,7 @@ AT_CLEANUP
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr2a.y],
[[/* Regression Test: Improper handling of embedded actions and $-N */
/* Reported by S. Eken */
@@ -130,8 +128,9 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int yylex (void);
void yyerror (char const *);
#include <assert.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%glr-parser
@@ -171,7 +170,7 @@ var_printer: 'v'
{ printf ("Variable: '%s'\n", $-1); }
%%
]AT_YYERROR_DEFINE[
FILE *input;
int
@@ -179,9 +178,9 @@ yylex (void)
{
char buf[50];
char *s;
if (feof (stdin))
abort ();
switch (fscanf (input, " %1[a-z,]", buf)) {
assert (!feof (stdin));
switch (fscanf (input, " %1[a-z,]", buf))
{
case 1:
return buf[0];
case EOF:
@@ -191,19 +190,13 @@ yylex (void)
}
if (fscanf (input, "%49s", buf) != 1)
return 0;
if (sizeof buf - 1 <= strlen (buf))
abort ();
assert (strlen (buf) < sizeof buf - 1);
s = (char *) malloc (strlen (buf) + 1);
strcpy (s, buf);
yylval = s;
return 'V';
}
void
yyerror (char const *s)
{ printf ("%s\n", s);
}
int
main (int argc, char **argv)
{
@@ -212,6 +205,7 @@ main (int argc, char **argv)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
[glr-regr2a.y: conflicts: 2 shift/reduce
@@ -238,6 +232,7 @@ AT_CLEANUP
AT_SETUP([Improper merging of GLR delayed action sets])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr3.y],
[[/* Regression Test: Improper merging of GLR delayed action sets. */
/* Reported by M. Rosien */
@@ -246,10 +241,11 @@ AT_DATA_GRAMMAR([glr-regr3.y],
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
static int MergeRule (int x0, int x1);
static void yyerror (char const * s);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
#define RULE(x) (1 << (x))
@@ -290,13 +286,12 @@ NT6 : P1 NT1 O1 T3 P2 { $$ = RULE(11) | $2; } %merge<MergeRule>
%%
static int MergeRule (int x0, int x1) {
static int
MergeRule (int x0, int x1)
{
return x0 | x1;
}
static void yyerror(char const * s) {
fprintf(stderr,"error: %s\n",s);
}
]AT_YYERROR_DEFINE[
FILE *input = YY_NULL;
@@ -307,8 +302,7 @@ int T[] = { T1, T2, T3, T4 };
int yylex (void)
{
char inp[3];
if (feof (stdin))
abort ();
assert (!feof (stdin));
if (fscanf (input, "%2s", inp) == EOF)
return 0;
switch (inp[0])
@@ -320,12 +314,15 @@ int yylex (void)
return BAD_CHAR;
}
int main(int argc, char* argv[]) {
int
main(int argc, char* argv[])
{
input = stdin;
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
@@ -347,6 +344,7 @@ AT_CLEANUP
AT_SETUP([Duplicate representation of merged trees])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr4.y],
[[
%union { char *ptr; }
@@ -359,8 +357,8 @@ AT_DATA_GRAMMAR([glr-regr4.y],
#include <string.h>
static char *merge (YYSTYPE, YYSTYPE);
static char *make_value (char const *, char const *);
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static char *ptrs[100];
static char **ptrs_next = ptrs;
%}
@@ -384,16 +382,8 @@ A2: 'a' { $$ = make_value ("A2", "'a'"); } ;
B: 'a' { $$ = make_value ("B", "'a'"); } ;
%%
static int
yylex (void)
{
static char const input[] = "a";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
return input[toknum++];
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
int
main (void)
@@ -423,13 +413,8 @@ merge (YYSTYPE s1, YYSTYPE s2)
sprintf (value, format, s1.ptr, s2.ptr);
return value;
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
[glr-regr4.y: conflicts: 1 reduce/reduce
@@ -450,13 +435,14 @@ AT_CLEANUP
AT_SETUP([User destructor for unresolved GLR semantic value])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr5.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
%}
@@ -480,29 +466,15 @@ start:
;
%%
static int
yylex (void)
{
static char const input[] = "a";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
return input[toknum++];
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYLEX_DEFINE(["a"])[
]AT_YYERROR_DEFINE[
int
main (void)
{
return yyparse () != 1;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
[glr-regr5.y: conflicts: 1 reduce/reduce
@@ -523,13 +495,14 @@ AT_CLEANUP
AT_SETUP([User destructor after an error during a split parse])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr6.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%glr-parser
@@ -545,29 +518,15 @@ AT_DATA_GRAMMAR([glr-regr6.y],
start: 'a' | 'a' ;
%%
static int
yylex (void)
{
static char const input[] = "a";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
return input[toknum++];
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
int
main (void)
{
return yyparse () != 1;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
[glr-regr6.y: conflicts: 1 reduce/reduce
@@ -590,13 +549,14 @@ AT_CLEANUP
AT_SETUP([Duplicated user destructor for lookahead])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr7.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
#define YYSTACKEXPANDABLE 0
typedef struct count_node {
int count;
@@ -641,12 +601,7 @@ yylex (void)
return 'a';
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
int
main (void)
{
@@ -660,6 +615,7 @@ main (void)
return status;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
[glr-regr7.y: conflicts: 2 reduce/reduce
@@ -682,14 +638,14 @@ AT_CLEANUP
AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr8.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
static void yyerror (char const *msg);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%token T_CONSTANT
@@ -723,12 +679,7 @@ OptSignalWord : /* empty */
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
static int lexIndex;
int yylex (void)
@@ -758,6 +709,7 @@ main (void)
return 0;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
[glr-regr8.y: conflicts: 1 reduce/reduce
@@ -780,13 +732,14 @@ AT_CLEANUP
AT_SETUP([No users destructors if stack 0 deleted])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr9.y],
[[
%{
# include <stdio.h>
# include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
# define YYSTACKEXPANDABLE 0
static int tokens = 0;
static int destructors = 0;
@@ -822,12 +775,7 @@ yylex (void)
return 'a';
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
int
main (void)
{
@@ -841,6 +789,7 @@ main (void)
return !exit_status;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
[glr-regr9.y: conflicts: 1 reduce/reduce
@@ -860,13 +809,14 @@ AT_CLEANUP
AT_SETUP([Corrupted semantic options if user action cuts parse])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr10.y],
[[
%{
# include <stdlib.h>
# include <stdio.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
#define GARBAGE_SIZE 50
static char garbage[GARBAGE_SIZE];
%}
@@ -883,21 +833,8 @@ start:
;
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
static int called;
if (called++)
abort ();
return 0;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE[
int
main (void)
@@ -908,6 +845,7 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
[glr-regr10.y: conflicts: 1 reduce/reduce
@@ -925,12 +863,13 @@ AT_CLEANUP
AT_SETUP([Undesirable destructors if user action cuts parse])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr11.y],
[[
%{
# include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static int destructors = 0;
# define USE(val)
%}
@@ -949,21 +888,8 @@ start:
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
static char const input[] = "a";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
return input[toknum++];
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
int
main (void)
@@ -977,6 +903,7 @@ main (void)
return exit_status;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
[glr-regr11.y: conflicts: 1 reduce/reduce
@@ -994,6 +921,7 @@ AT_CLEANUP
AT_SETUP([Leaked semantic values if user action cuts parse])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr12.y],
[[
%glr-parser
@@ -1006,9 +934,10 @@ AT_DATA_GRAMMAR([glr-regr12.y],
%{
# include <stdlib.h>
# include <assert.h>
static int merge (YYSTYPE, YYSTYPE);
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static int parent_rhs_before_value = 0;
static int merged_value = 0;
static int parent_rhs_after_value = 0;
@@ -1068,23 +997,10 @@ merge (YYSTYPE s1, YYSTYPE s2)
return dummy;
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
static int const input[] = { PARENT_RHS_AFTER, 0 };
static size_t toknum;
if (! (toknum < sizeof input / sizeof *input))
abort ();
if (input[toknum] == PARENT_RHS_AFTER)
parent_rhs_after_value = 1;
return input[toknum++];
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([{ PARENT_RHS_AFTER, 0 }],
[if (res == PARENT_RHS_AFTER)
parent_rhs_after_value = 1;])[
int
main (void)
@@ -1108,6 +1024,7 @@ main (void)
return exit_status;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
@@ -1127,6 +1044,7 @@ AT_CLEANUP
AT_SETUP([Incorrect lookahead during deterministic GLR])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr13.y],
[[
/* Tests:
@@ -1138,8 +1056,9 @@ AT_DATA_GRAMMAR([glr-regr13.y],
%{
#include <stdio.h>
static void yyerror (char const *);
static int yylex (void);
#include <assert.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static void print_lookahead (char const *);
#define USE(value)
%}
@@ -1190,24 +1109,9 @@ change_lookahead:
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
static char const input[] = "ab";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = toknum + 1;
yylval.value = input[toknum] + 'A' - 'a';
return input[toknum++];
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["ab"],
[yylval.value = res + 'A' - 'a'])[
static void
print_lookahead (char const *reduction)
@@ -1237,6 +1141,7 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr13.c glr-regr13.y]], 0, [], [])
AT_COMPILE([glr-regr13])
@@ -1263,6 +1168,7 @@ AT_CLEANUP
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr14.y],
[[
/* Tests:
@@ -1289,8 +1195,9 @@ AT_DATA_GRAMMAR([glr-regr14.y],
%{
#include <stdlib.h>
#include <stdio.h>
static void yyerror (char const *);
static int yylex (void);
#include <assert.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static void print_lookahead (char const *);
static char merge (union YYSTYPE, union YYSTYPE);
#define USE(value)
@@ -1399,19 +1306,13 @@ no_look:
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static char const input[] = "abcdddd";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
assert (toknum < sizeof input);
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = toknum + 1;
yylval.value = input[toknum] + 'A' - 'a';
@@ -1453,6 +1354,7 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
[glr-regr14.y: conflicts: 3 reduce/reduce
@@ -1483,6 +1385,7 @@ AT_CLEANUP
AT_SETUP([Leaked semantic values when reporting ambiguity])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr15.y],
[[
%glr-parser
@@ -1490,8 +1393,8 @@ AT_DATA_GRAMMAR([glr-regr15.y],
%{
# include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static int parent_rhs_before_value = 0;
# define USE(val)
%}
@@ -1529,21 +1432,8 @@ ambiguity1: ;
ambiguity2: ;
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
static int called;
if (called++)
abort ();
return 0;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE[
int
main (void)
@@ -1557,6 +1447,7 @@ main (void)
return exit_status;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
[glr-regr15.y: conflicts: 2 reduce/reduce
@@ -1575,6 +1466,8 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr16.y],
[[
%glr-parser
@@ -1582,8 +1475,9 @@ AT_DATA_GRAMMAR([glr-regr16.y],
%{
# include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
# include <assert.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
static int lookahead_value = 0;
# define USE(val)
%}
@@ -1596,23 +1490,10 @@ alt2: ;
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
static char const input[] = "ab";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
if (input[toknum] == 'b')
lookahead_value = 1;
return input[toknum++];
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["ab"],
[if (res == 'b')
lookahead_value = 1])[
int
main (void)
@@ -1626,6 +1507,7 @@ main (void)
return exit_status;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
[glr-regr16.y: conflicts: 1 reduce/reduce
@@ -1644,6 +1526,9 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
AT_SETUP([Uninitialized location when reporting ambiguity])
AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations %define api.pure])
AT_DATA_GRAMMAR([glr-regr17.y],
[[
%glr-parser
@@ -1654,8 +1539,8 @@ AT_DATA_GRAMMAR([glr-regr17.y],
%union { int dummy; }
%{
static void yyerror (YYLTYPE *, char const *);
static int yylex (YYSTYPE *, YYLTYPE *);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%initial-action {
@@ -1685,21 +1570,15 @@ empty1: ;
empty2: ;
%%
# include <assert.h>
static void
yyerror (YYLTYPE *locp, char const *msg)
{
fprintf (stderr, "%d.%d-%d.%d: %s.\n", locp->first_line,
locp->first_column, locp->last_line, locp->last_column, msg);
}
]AT_YYERROR_DEFINE[
static int
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
{
static char const input[] = "ab";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
assert (toknum < sizeof input);
lvalp->dummy = 0;
llocp->first_line = llocp->last_line = 2;
llocp->first_column = toknum + 1;
@@ -1713,6 +1592,7 @@ main (void)
return yyparse () != 1;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
[glr-regr17.y: conflicts: 3 reduce/reduce
@@ -1720,7 +1600,7 @@ AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
AT_COMPILE([glr-regr17])
AT_PARSER_CHECK([[./glr-regr17]], 0, [],
[1.1-2.3: syntax is ambiguous.
[1.1-2.2: syntax is ambiguous
])
AT_CLEANUP
@@ -1731,13 +1611,15 @@ AT_CLEANUP
## -------------------------------------------------------------##
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr18.y],
[[%glr-parser
%{
#include <stdlib.h>
static void yyerror (char const *);
static int yylex ();
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%union {
@@ -1757,28 +1639,15 @@ sym3: %merge<merge> { $$ = 0; } ;
%type <type3> sym3;
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex ()
{
static int called;
if (called++)
abort ();
return 0;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE[
int
main (void)
{
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
@@ -1796,13 +1665,14 @@ AT_CLEANUP
AT_SETUP([Ambiguity reports])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%debug
@@ -1816,23 +1686,8 @@ start:
b: 'b';
d: /* nada. */;
%%
static int
yylex (void)
{
static char const input[] = "abc";
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
return input[toknum++];
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYLEX_DEFINE(["abc"])[
]AT_YYERROR_DEFINE[
int
main (void)
{
@@ -1840,6 +1695,7 @@ main (void)
return !!yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]], 0, [],
[input.y: conflicts: 1 reduce/reduce
+158 -34
View File
@@ -19,47 +19,26 @@
AT_BANNER([[Parser Headers.]])
## ---------------------- ##
## %union and --defines. ##
## ---------------------- ##
AT_SETUP([%union and --defines])
AT_DATA([input.y],
[%union
{
int integer;
char *string ;
}
%%
exp: {};
])
AT_BISON_CHECK([--defines input.y])
AT_CLEANUP
## --------------------- ##
## Invalid CPP headers. ##
## --------------------- ##
# AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
# -------------------------------------
# AT_TEST_CPP_GUARD_H(BASE-NAME, [DIRECTIVES])
# --------------------------------------------
# FIXME: Much of this can be covered by calc.at.
m4_define([AT_TEST_CPP_GUARD_H],
[AT_SETUP([Invalid CPP guards: $1])
[AT_SETUP([Invalid CPP guards: $2 --defines=$1.h])
AT_BISON_OPTION_PUSHDEFS([$2])
# Possibly create inner directories.
dirname=`AS_DIRNAME([$1])`
AS_MKDIR_P([$dirname])
AT_DATA_GRAMMAR([$1.y],
[%{
[$2
%{
#include <$1.h>
void yyerror (const char *);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
dummy:;
@@ -67,15 +46,18 @@ dummy:;
#include <$1.h>
])
AT_BISON_CHECK([--defines=$1.h --output=y.tab.c $1.y])
AT_BISON_CHECK([--defines=$1.h --output=$1.c $1.y])
AT_COMPILE([y.tab.o], [-I. -c y.tab.c])
AT_COMPILE([$1.o], [-I. -c $1.c])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
AT_TEST_CPP_GUARD_H([input/input])
AT_TEST_CPP_GUARD_H([9foo])
AT_TEST_CPP_GUARD_H([input/input], [%glr-parser])
AT_TEST_CPP_GUARD_H([9foo], [%glr-parser])
@@ -129,9 +111,151 @@ main (void)
# Link and execute, just to make sure everything is fine (and in
# particular, that MY_LLOC is indeed defined somewhere).
AT_COMPILE([caller.o], [-c caller.c])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([caller.o])
AT_COMPILE([input.o])
AT_COMPILE([caller], [caller.o input.o])
AT_PARSER_CHECK([./caller])
AT_CLEANUP
## ----------------- ##
## Several parsers. ##
## ----------------- ##
AT_SETUP([Several parsers])
# AT_TEST([PREFIX], [DIRECTIVES])
# -------------------------------
# Generate and compile to *.o. Make sure there is no (allowed) YY*
# nor yy* identifiers in the header. Check that headers are
# self-contained, and can be compiled by a C++ compiler.
m4_pushdef([AT_TEST],
[AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2])
AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])],
[[%define api.prefix "$1_"
$2
%error-verbose
%union
{
int integer;
}
%{
#include <stdio.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%%
exp:
'x' '1' { printf ("x1\n"); }
| 'x' '2' { printf ("x2\n"); }
| 'x' '3' { printf ("x3\n"); }
| 'x' '4' { printf ("x4\n"); }
| 'x' '5' { printf ("x5\n"); }
| 'x' '6' { printf ("x6\n"); }
| 'x' '7' { printf ("x7\n"); }
| 'x' '8' { printf ("x8\n"); }
;
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["$1"])[
]])
AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])])
# Check there is no 'yy' left.
# C++ output relies on namespaces and still uses yy a lot.
AT_SKEL_CC_IF([],
[AT_CHECK([$EGREP yy $1.h], [1])])
# Check there is not 'YY' left.
# Ignore comments, YYPARSE_PARAM (obsolete), YYPUSH_MORE(_DEFINED)?
# (constant definition), YY_\w+_INCLUDED (header guards).
#
# YYDEBUG (not renamed) can be read, but not changed.
AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \
-e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ |
$EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?|_[0-9A-Z_]+_INCLUDED)|(defined|if) YYDEBUG']],
[1])
AT_LANG_COMPILE([$1.o])
AT_CHECK([[echo "$1" >>expout]])
AT_BISON_OPTION_POPDEFS
])# AT_TEST
AT_DATA([main.cc],
[AT_DATA_SOURCE_PROLOGUE
[// If we are compiling with CC=$CXX, then do not load the C headers
// inside extern "C", since they were _not_ compiled this way.
#if ! CC_IS_CXX
extern "C"
{
#endif
#include "x1.h"
#include "x2.h"
#include "x3.h"
#include "x4.h"
#include "x6.h"
#include "x7.h"
#include "x8.h"
#if ! CC_IS_CXX
}
#endif
#include "x5.hh"
//#include "x6.hh"
#define RUN(S) \
do { \
int res = S; \
if (res) \
std::cerr << #S": " << res << std::endl; \
} while (false)
int
main (void)
{
RUN(x1_parse());
RUN(x2_parse());
RUN(x3_parse());
RUN(x4_parse());
x5_::parser p5;
RUN(p5.parse());
RUN(x6_parse());
RUN(x7_parse());
RUN(x8_parse());
// x6_::parser p6;
// RUN(p6.parse());
return 0;
}
]])# main.cc
AT_TEST([x1], [])
AT_TEST([x2], [%locations %debug])
AT_TEST([x3], [%glr-parser])
AT_TEST([x4], [%locations %debug %glr-parser])
AT_TEST([x5], [%locations %debug %language "c++"])
AT_TEST([x6], [%define api.pure])
AT_TEST([x7], [%define api.push-pull both])
AT_TEST([x8], [%define api.pure %define api.push-pull both])
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
AT_CHECK([./parser], [0], [[expout]])
# Check that the headers are self-contained, and protected against
# multiple inclusions. While at it, check they are sane for C++.
for h in *.h *.hh
do
# No shell expansion with AT_DATA.
cat >$h.cc <<EOF
AT_DATA_SOURCE_PROLOGUE
#include "$h"
#include "$h"
EOF
AT_COMPILE_CXX([$h.o])
done
m4_popdef([AT_TEST])
AT_CLEANUP
+148 -23
View File
@@ -69,7 +69,7 @@ AT_CLEANUP
# _AT_UNUSED_VALUES_DECLARATIONS()
# --------------------------------------------
# --------------------------------
# Generate the token, type, and destructor
# declarations for the unused values tests.
@@ -391,7 +391,7 @@ AT_CLEANUP
AT_SETUP([Torturing the Scanner])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y], [])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1: syntax error, unexpected end of file
@@ -442,6 +442,7 @@ char apostrophe = '\'';
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
%}
/* %{ and %} can be here too. */
@@ -468,8 +469,8 @@ char quote[] = "@:>@@:>@,";
%}
%{
static void yyerror (const char *s);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%type <ival> '@<:@'
@@ -501,7 +502,7 @@ value_as_yystype (value val)
res.ival = val;
return res;
}
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
@@ -509,20 +510,13 @@ yylex (void)
#output "; /* "
*/
static size_t toknum;
if (! (toknum < sizeof input))
abort ();
assert (toknum < sizeof input);
yylval = value_as_yystype (input[toknum]);
return input[toknum++];
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
]])
# Pacify Emacs'font-lock-mode: "
# Pacify Emacs' font-lock-mode: "
AT_DATA([main.c],
[[typedef int value;
@@ -536,10 +530,11 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-d -v -o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([main.o], [-c main.c])
AT_COMPILE([input.o])
AT_COMPILE([main.o])
AT_COMPILE([input], [input.o main.o])
AT_PARSER_CHECK([./input], 0,
[[[@<:@],
@@ -621,14 +616,15 @@ AT_CLEANUP
AT_SETUP([Symbols])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%token WITH-DASH
%token WITHOUT_DASH "WITHOUT-DASH"
%token WITH.PERIOD
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
%code {
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
%%
start: with-dash without_dash with.period without_period;
@@ -637,7 +633,10 @@ without_dash: "WITHOUT-DASH";
with.period: WITH.PERIOD;
without_period: "WITHOUT.PERIOD";
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE[
]])
AT_BISON_OPTION_POPDEFS
# POSIX Yacc accept periods, but not dashes.
AT_BISON_CHECK([--yacc input.y], [1], [],
@@ -655,7 +654,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
AT_BISON_CHECK([-o input.c input.y])
# Make sure we don't export silly token identifiers with periods or dashes.
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
# Periods are genuine letters, they can start identifiers.
@@ -1195,7 +1194,7 @@ AT_DATA([empty.y],
start: '';
start: '
]])
AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]])
AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
AT_BISON_CHECK([empty.y], [1], [],
[[empty.y:2.8-9: warning: empty character literal
@@ -1210,7 +1209,7 @@ AT_DATA([two.y],
start: 'ab';
start: 'ab
]])
AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]])
AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
AT_BISON_CHECK([two.y], [1], [],
[[two.y:2.8-11: warning: extra characters in character literal
@@ -1225,7 +1224,7 @@ AT_DATA([three.y],
start: 'abc';
start: 'abc
]])
AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]])
AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
AT_BISON_CHECK([three.y], [1], [],
[[three.y:2.8-12: warning: extra characters in character literal
@@ -1254,7 +1253,7 @@ start: '\777' '\0' '\xfff' '\x0'
# Beside we cannot even expect "echo '\0'" to output two characters
# (well three with \n): at least Bash 3.2 converts the two-character
# sequence "\0" into a single NUL character.
AT_CHECK([[perl -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
|| exit 77]])
AT_BISON_CHECK([input.y], [1], [],
@@ -1341,3 +1340,129 @@ input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
AT_CLEANUP
## ------------------------------------------------------ ##
## %name-prefix and %define api.prefix are incompatible. ##
## ------------------------------------------------------ ##
AT_SETUP([[%name-prefix and %define api.prefix are incompatible]])
# AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
# --------------------------------------------
m4_pushdef([AT_TEST],
[AT_DATA([[input.y]],
[[$1
%%
exp:;
]])
AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
[[$3: '%name-prefix' and '%define api.prefix' cannot be used together
]])
])
AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
m4_popdef([AT_TEST])
AT_CLEANUP
## -------------- ##
## Stray $ or @. ##
## -------------- ##
AT_SETUP([[Stray $ or @]])
# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
# check that the warnings are reported once, not three times.
AT_DATA_GRAMMAR([[input.y]],
[[%token TOK
%destructor { $%; @%; } <*> exp TOK;
%initial-action { $%; @%; };
%printer { $%; @%; } <*> exp TOK;
%%
exp: TOK { $%; @%; $$ = $1; };
]])
AT_BISON_CHECK([[input.y]], 0, [],
[[input.y:10.19: warning: stray '$'
input.y:10.23: warning: stray '@'
input.y:11.19: warning: stray '$'
input.y:11.23: warning: stray '@'
input.y:12.19: warning: stray '$'
input.y:12.23: warning: stray '@'
input.y:14.19: warning: stray '$'
input.y:14.23: warning: stray '@'
]])
AT_CLEANUP
## ---------------- ##
## Code injection. ##
## ---------------- ##
AT_SETUP([[Code injection]])
m4_pattern_allow([^m4_errprintn$])
# AT_TEST([MACRO])
# ----------------
# Try to have MACRO be run by bison.
m4_pushdef([AT_TEST],
[AT_DATA([[input.y]],
[[%type <$1(DEAD %type)> exp
%token <$1(DEAD %token)> a
%initial-action
{
$$;
$<$1(DEAD %initial-action)>$
};
%printer
{
$$
$<$1(DEAD %printer)>$
} <> <*>;
%lex-param
{
$1(DEAD %lex-param)
};
%parse-param
{
$1(DEAD %parse-param)
};
%%
exp:
a a[last]
{
$$;
$][1;
$<$1(DEAD action 1)>$
$<$1(DEAD action 2)>1
$<$1(DEAD action 3)>last
$<$1(DEAD action 4)>0
;
};
]])
# FIXME: Provide a means to iterate over all the skeletons.
AT_BISON_CHECK([[-d input.y]])
AT_BISON_CHECK([[-d -S glr.c input.y]])
AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
AT_BISON_CHECK([[-d -S glr.cc input.y]])
AT_BISON_CHECK([[ -S lalr1.java input.y]])
])
AT_TEST([m4_errprintn])
AT_TEST([@:>@m4_errprintn])
m4_popdef([AT_TEST])
AT_CLEANUP
+5 -15
View File
@@ -32,6 +32,7 @@ AT_BANNER([[Java Calculator.]])
m4_define([_AT_DATA_JAVA_CALC_Y],
[m4_if([$1$2$3], $[1]$[2]$[3], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl
AT_BISON_OPTION_PUSHDEFS([%language "Java" $4])
AT_DATA([Calc.y],
[[/* Infix notation calculator--calc */
%language "Java"
@@ -122,20 +123,8 @@ AT_LOCATION_IF([[
public Position getEndPos() {
return yypos;
}
public void yyerror (Calc.Location l, String s)
{
if (l == null)
System.err.println (s);
else
System.err.println (l + ": " + s);
}
]], [[
public void yyerror (String s)
{
System.err.println (s);
}
]])[
]AT_YYERROR_DEFINE[
Integer yylval;
@@ -211,11 +200,12 @@ class Position {
}
]])
AT_BISON_OPTION_POPDEFS
])# _AT_DATA_JAVA_CALC_Y
# AT_DATA_CALC_Y([BISON-OPTIONS])
# -------------------------------------------------
# -------------------------------
# Produce `calc.y'.
m4_define([AT_DATA_JAVA_CALC_Y],
[_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1])
@@ -224,7 +214,7 @@ m4_define([AT_DATA_JAVA_CALC_Y],
# _AT_CHECK_JAVA_CALC_ERROR(BISON-OPTIONS, INPUT,
# [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
# ---------------------------------------------------------
# --------------------------------------------------------------
# Run `calc' on INPUT, and expect a `syntax error' message.
#
# If INPUT starts with a slash, it is used as absolute input file name,
+326 -129
View File
@@ -17,10 +17,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# We want a recent Autotest.
m4_version_prereq([2.58])
# m4_null_if(VAL, IF-TRUE, IF-FALSE)
# ----------------------------------
# If VAL evaluates to empty or 0, run IF-TRUE, otherwise IF-FALSE.
m4_define([m4_null_if],
[m4_case(m4_quote($1),
[0], [$2],
[], [$2],
[$3])])
## ------------- ##
## Basic tests. ##
## ------------- ##
@@ -30,7 +38,7 @@ m4_version_prereq([2.58])
# Expect COUNT matches of the PERL-REGEXP in FILE. The file is
# taken in "slurp" mode, i.e., one can match end-of-lines.
m4_define([AT_MATCHES_CHECK],
[AT_CHECK([perl -0777 -ne '
[AT_CHECK([$PERL -0777 -ne '
my $count = 0;
s{$2}{ ++$count; "" }gem;
printf "$count\n";' $1], [0], [$3
@@ -45,6 +53,8 @@ m4_divert_text([PREPARE_TESTS],
{
for at_save_file in stderr experr expout
do
test ! -f at-bison-check-$at_save_file.bak ||
as_fn_error 1 "fatal error: back-up on top of a back-up"
test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak
done
}
@@ -91,7 +101,8 @@ m4_popdef([AT_LOC_LAST_COLUMN])])
# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
# -----------------------------------------
m4_define([AT_BISON_OPTION_PUSHDEFS],
[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])])
[m4_divert_text([KILL],
[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])])])
# _AT_BISON_OPTION_PUSHDEFS($1, $2, [BISON-OPTIONS])
@@ -108,8 +119,12 @@ m4_pushdef([AT_SKEL_CC_IF],
[m4_bmatch([$3], [%language "[Cc]\+\+"\|%skeleton "[a-z0-9]+\.cc"], [$1], [$2])])
m4_pushdef([AT_SKEL_JAVA_IF],
[m4_bmatch([$3], [%language "[Jj][Aa][Vv][Aa]"\|%skeleton "[a-z0-9]+\.java"], [$1], [$2])])
m4_pushdef([AT_LANG],
[AT_SKEL_JAVA_IF([java],
[AT_SKEL_CC_IF([c++],
[c])])])
m4_pushdef([AT_GLR_IF],
[m4_bmatch([$3], [%glr-parser\|%skeleton "glr\.], [$1], [$2])])
[m4_bmatch([$3], [%glr-parser\|%skeleton "glr\..*"], [$1], [$2])])
m4_pushdef([AT_LALR1_CC_IF],
[AT_SKEL_CC_IF([AT_GLR_IF([$2], [$1])], [$2])])
m4_pushdef([AT_GLR_CC_IF],
@@ -134,9 +149,15 @@ m4_pushdef([AT_PURE_AND_LOC_IF],
m4_pushdef([AT_GLR_OR_PARAM_IF],
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [%name-prefix ".*"],
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
[m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
[yy])])
m4_pushdef([AT_API_prefix],
[m4_bmatch([$3], [%define api\.prefix ".*"],
[m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
[yy])])
m4_pushdef([AT_API_PREFIX],
[m4_toupper(AT_API_prefix)])
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
@@ -155,27 +176,35 @@ m4_pushdef([AT_PURE_LEX_IF],
[AT_PURE_IF([$1],
[AT_SKEL_CC_IF([$1], [$2])])])
m4_pushdef([AT_YYSTYPE],
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]],
[AT_API_PREFIX[STYPE]])])
m4_pushdef([AT_YYLTYPE],
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::location_type]],
[AT_API_PREFIX[LTYPE]])])
AT_PURE_LEX_IF(
[m4_pushdef([AT_LOC], [(*llocp)])
m4_pushdef([AT_VAL], [(*lvalp)])
m4_pushdef([AT_LEX_FORMALS],
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
m4_pushdef([AT_LEX_ARGS],
m4_pushdef([AT_YYLEX_FORMALS],
[AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
m4_pushdef([AT_YYLEX_ARGS],
[lvalp[]AT_LOCATION_IF([, llocp])])
m4_pushdef([AT_USE_LEX_ARGS],
[(void) lvalp;AT_LOCATION_IF([(void) llocp])])
m4_pushdef([AT_LEX_PRE_FORMALS],
[AT_LEX_FORMALS, ])
m4_pushdef([AT_LEX_PRE_ARGS],
[AT_LEX_ARGS, ])
m4_pushdef([AT_YYLEX_PRE_FORMALS],
[AT_YYLEX_FORMALS, ])
m4_pushdef([AT_YYLEX_PRE_ARGS],
[AT_YYLEX_ARGS, ])
],
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
m4_pushdef([AT_LEX_FORMALS], [void])
m4_pushdef([AT_LEX_ARGS], [])
m4_pushdef([AT_YYLEX_FORMALS], [void])
m4_pushdef([AT_YYLEX_ARGS], [])
m4_pushdef([AT_USE_LEX_ARGS], [])
m4_pushdef([AT_LEX_PRE_FORMALS], [])
m4_pushdef([AT_LEX_PRE_ARGS], [])
m4_pushdef([AT_YYLEX_PRE_FORMALS], [])
m4_pushdef([AT_YYLEX_PRE_ARGS], [])
])
# Handle the different types of location components.
@@ -192,16 +221,21 @@ AT_SKEL_CC_IF(
# AT_BISON_OPTION_POPDEFS
# -----------------------
m4_define([AT_BISON_OPTION_POPDEFS],
[m4_popdef([AT_LEX_PRE_ARGS])
m4_popdef([AT_LEX_PRE_FORMALS])
[m4_divert_text([KILL],
[m4_popdef([AT_YYLEX_PRE_ARGS])
m4_popdef([AT_YYLEX_PRE_FORMALS])
m4_popdef([AT_USE_LEX_ARGS])
m4_popdef([AT_LEX_ARGS])
m4_popdef([AT_LEX_FORMALS])
m4_popdef([AT_YYLEX_ARGS])
m4_popdef([AT_YYLEX_FORMALS])
m4_popdef([AT_YYLTYPE])
m4_popdef([AT_YYSTYPE])
m4_popdef([AT_VAL])
m4_popdef([AT_LOC])
m4_popdef([AT_PURE_LEX_IF])
m4_popdef([AT_YYERROR_SEES_LOC_IF])
m4_popdef([AT_YYERROR_ARG_LOC_IF])
m4_popdef([AT_API_PREFIX])
m4_popdef([AT_API_prefix])
m4_popdef([AT_NAME_PREFIX])
m4_popdef([AT_GLR_OR_PARAM_IF])
m4_popdef([AT_PURE_AND_LOC_IF])
@@ -212,11 +246,12 @@ m4_popdef([AT_LEXPARAM_IF])
m4_popdef([AT_YACC_IF])
m4_popdef([AT_GLR_IF])
m4_popdef([AT_SKEL_CC_IF])
m4_popdef([AT_LANG])
m4_popdef([AT_SKEL_JAVA_IF])
m4_popdef([AT_GLR_CC_IF])
m4_popdef([AT_LALR1_CC_IF])
m4_popdef([AT_DEFINES_IF])
AT_LOC_POPDEF
AT_LOC_POPDEF])dnl
])# AT_BISON_OPTION_POPDEFS
@@ -267,8 +302,123 @@ m4_define([AT_DATA_GRAMMAR],
$2])
])
# AT_YYLEX_PROTOTYPE
# AT_YYLEX_DECLARE_EXTERN
# AT_YYLEX_DECLARE
# AT_YYLEX_DEFINE([INPUT], [ACTION])
# ----------------------------------
# INPUT can be empty, or in double quotes, or a list (in braces).
# ACTION may compute yylval for instance, using "res" as token type,
# and "toknum" as the number of calls to yylex (starting at 0).
m4_define([AT_YYLEX_PROTOTYPE],
[int AT_NAME_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
])
m4_define([AT_YYLEX_DECLARE_EXTERN],
[AT_YYLEX_PROTOTYPE;dnl
])
m4_define([AT_YYLEX_DECLARE],
[static AT_YYLEX_DECLARE_EXTERN[]dnl
])
m4_define([AT_YYLEX_DEFINE],
[[#include <assert.h>
static
]AT_YYLEX_PROTOTYPE[
{
]m4_bmatch([$1], [^\(".*"\)?$],
[[static char const input[] = ]m4_default([$1], [""])],
[[static int const input[] = ]$1])[;
static size_t toknum = 0;
int res;
]AT_USE_LEX_ARGS[;
assert (toknum < sizeof input / sizeof input[0]);
res = input[toknum++];
]$2[;]AT_LOCATION_IF([[
]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
return res;
}]dnl
])
# AT_YYERROR_PROTOTYPE
# AT_YYERROR_DECLARE_EXTERN
# AT_YYERROR_DECLARE
# AT_YYERROR_DEFINE
# -------------------------
# Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
m4_define([AT_YYERROR_FORMALS],
[m4_case(AT_LANG,
[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE *llocp, ])[const char *msg]])[]dnl
])
m4_define([AT_YYERROR_PROTOTYPE],
[m4_case(AT_LANG,
[c], [[void ]AT_NAME_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
])
m4_define([AT_YYERROR_DECLARE_EXTERN],
[m4_case(AT_LANG,
[c], [AT_YYERROR_PROTOTYPE;])[]dnl
])
m4_define([AT_YYERROR_DECLARE],
[m4_case(AT_LANG,
[c], [static AT_YYERROR_DECLARE_EXTERN])[]dnl
])
m4_define([AT_YYERROR_DEFINE],
[m4_case(AT_LANG,
[c], [[#include <stdio.h>
/* A C error reporting function. */
static
]AT_YYERROR_PROTOTYPE[
{
]AT_YYERROR_SEES_LOC_IF([[
fprintf (stderr, "%d.%d",
]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[)
fprintf (stderr, "-%d.%d",
]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1);
else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1)
fprintf (stderr, "-%d",
]AT_LOC_LAST_COLUMN[ - 1);
fprintf (stderr, ": ");]])[
fprintf (stderr, "%s\n", msg);
}]],
[c++], [[/* A C++ error reporting function. */
void
]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
{
(void) l;
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
}]],
[java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
{
if (l == null)
System.err.println (s);
else
System.err.println (l + ": " + s);
}
]], [[
public void yyerror (String s)
{
System.err.println (s);
}]])],
[m4_fatal([$0: invalid language: ]AT_LANG)])dnl
])
## --------------- ##
## Running Bison. ##
## --------------- ##
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
# -------------------------------------------------
# High-level routine that may call bison several times, under different
# conditions.
#
# Check Bison by invoking `bison BISON_ARGS'. BISON_ARGS should not contain
# shell constructs (such as redirection or pipes) that would prevent
# appending additional command-line arguments for bison. OTHER_AT_CHECK_ARGS
@@ -289,83 +439,93 @@ $2])
#
# 4. If stderr contains a warning, -Wnone and --warnings=none suppress it.
m4_define([AT_BISON_CHECK],
[m4_if(m4_quote($2), [0], [AT_BISON_CHECK_XML($@)],
m4_quote($2), [], [AT_BISON_CHECK_XML($@)])
[m4_null_if([$2], [AT_BISON_CHECK_XML($@)])
AT_BISON_CHECK_NO_XML($@)])
m4_define([AT_BISON_WERROR_MSG],
[[bison: warnings being treated as errors]])
# AT_BISON_CHECK_(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
# --------------------------------------------------
# Low-level macro to run bison once.
m4_define([AT_BISON_CHECK_],
[AT_CHECK(AT_QUELL_VALGRIND[[ bison ]]$@)])
# AT_BISON_CHECK_WARNINGS(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
# ----------------------------------------------------------
# Check that warnings (if some are expected) are correctly
# turned into errors with -Werror, etc.
m4_define([AT_BISON_CHECK_WARNINGS],
[m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
[m4_null_if([$2], [AT_BISON_CHECK_WARNINGS_($@)])])])
m4_define([AT_BISON_CHECK_WARNINGS_],
[[# Defining POSIXLY_CORRECT causes bison to complain if options
# are added after the grammar file name, so skip these checks
# in that case.
if test -z "${POSIXLY_CORRECT+set}"; then
]AT_SAVE_SPECIAL_FILES[
# To avoid expanding it repeatedly, store specified stdout.
]AT_DATA([expout], [$3])[
# Run with -Werror.
]AT_BISON_CHECK_([$1[ -Werror]], [[1]], [expout], [stderr])[
# Build expected stderr up to and including the "warnings being
# treated as errors" message.
]AT_DATA([[at-bison-check-warnings]], [$4])[
at_bison_check_first=`sed -n \
'/: warning: /{=;q;}' at-bison-check-warnings`
: ${at_bison_check_first:=1}
at_bison_check_first_tmp=`sed -n \
'/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
: ${at_bison_check_first_tmp:=1}
if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
at_bison_check_first=$at_bison_check_first_tmp
fi
if test $at_bison_check_first -gt 1; then
sed -n "1,`expr $at_bison_check_first - 1`"p \
at-bison-check-warnings > experr
fi
echo ']AT_BISON_WERROR_MSG[' >> experr
# Finish building expected stderr and check. Unlike warnings,
# complaints cause bison to exit early. Thus, with -Werror, bison
# does not necessarily report all warnings that it does without
# -Werror, but it at least reports one.
at_bison_check_last=`sed -n '$=' stderr`
: ${at_bison_check_last:=1}
at_bison_check_last=`expr $at_bison_check_last - 1`
sed -n "$at_bison_check_first,$at_bison_check_last"p \
at-bison-check-warnings >> experr
]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
stderr 1>&2]], [[0]], [[]], [experr])[
# Now check --warnings=error.
cp stderr experr
]AT_BISON_CHECK_([$1[ --warnings=error]], [[1]], [expout], [experr])[
# Now check -Wnone and --warnings=none by making sure that
# -Werror doesn't change the exit status when -Wnone or
# --warnings=none is specified.
]AT_BISON_CHECK_([$1[ -Wnone -Werror]], [[0]], [expout])[
]AT_BISON_CHECK_([$1[ --warnings=none -Werror]], [[0]], [expout])[
]AT_RESTORE_SPECIAL_FILES[
fi]dnl
])
# AT_BISON_CHECK_NO_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
# --------------------------------------------------------
# Same as AT_BISON_CHECK except don't perform XML/XSLT checks. This is useful
# when a tortured grammar's XML is known to be too large for xsltproc to
# handle.
m4_define([AT_BISON_CHECK_NO_XML],
[AT_CHECK(m4_if(m4_quote($2), [0], [], m4_quote($2), [], [],
[AT_QUELL_VALGRIND ])[[bison ]]$@)
m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0], [[
# Defining POSIXLY_CORRECT causes bison to complain if options
# are added after the grammar file name, so skip these checks
# in that case.
if test -z "${POSIXLY_CORRECT+set}"; then
]AT_SAVE_SPECIAL_FILES[
# To avoid expanding it repeatedly, store specified stdout.
]AT_DATA([expout], [$3])[
# Run with -Werror.
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
[[1]], [expout], [stderr])[
# Build expected stderr up to and including the "warnings being
# treated as errors" message.
]AT_DATA([[at-bison-check-warnings]], [$4])[
at_bison_check_first=`sed -n \
'/: warning: /{=;q;}' at-bison-check-warnings`
: ${at_bison_check_first:=1}
at_bison_check_first_tmp=`sed -n \
'/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
: ${at_bison_check_first_tmp:=1}
if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
at_bison_check_first=$at_bison_check_first_tmp
fi
if test $at_bison_check_first -gt 1; then
sed -n "1,`expr $at_bison_check_first - 1`"p \
at-bison-check-warnings > experr
fi
echo ']AT_BISON_WERROR_MSG[' >> experr
# Finish building expected stderr and check. Unlike warnings,
# complaints cause bison to exit early. Thus, with -Werror, bison
# does not necessarily report all warnings that it does without
# -Werror, but it at least reports one.
at_bison_check_last=`sed -n '$=' stderr`
: ${at_bison_check_last:=1}
at_bison_check_last=`expr $at_bison_check_last - 1`
sed -n "$at_bison_check_first,$at_bison_check_last"p \
at-bison-check-warnings >> experr
]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
stderr 1>&2]], [[0]], [[]], [experr])[
# Now check --warnings=error.
cp stderr experr
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
[[1]], [expout], [experr])[
# Now check -Wnone and --warnings=none by making sure that
# -Werror doesn't change the exit status when -Wnone or
# --warnings=none is specified.
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Wnone -Werror]],
[[0]], [expout])[
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \
-Werror]], [[0]], [expout])[
]AT_RESTORE_SPECIAL_FILES[
fi
]])
])
[AT_CHECK(m4_null_if([$2], [], [AT_QUELL_VALGRIND ])[[bison ]]$@)
AT_BISON_CHECK_WARNINGS($@)])
# AT_BISON_CHECK_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
# -----------------------------------------------------
@@ -383,11 +543,11 @@ m4_define([AT_BISON_CHECK_XML],
[--xml=[^][ ]*], [])])dnl
# Don't combine these Bison invocations since we want to be sure that
# --report=all isn't required to get the full XML file.
AT_CHECK([[bison --report=all --report-file=xml-tests/test.output \
--graph=xml-tests/test.dot ]]AT_BISON_ARGS,
[[0]], [ignore], [ignore])
AT_CHECK([[bison --xml=xml-tests/test.xml ]]AT_BISON_ARGS,
[[0]], [ignore], [ignore])
AT_BISON_CHECK_([[--report=all --report-file=xml-tests/test.output \
--graph=xml-tests/test.dot ]]AT_BISON_ARGS,
[[0]], [ignore], [ignore])
AT_BISON_CHECK_([[--xml=xml-tests/test.xml ]]AT_BISON_ARGS,
[[0]], [ignore], [ignore])
m4_popdef([AT_BISON_ARGS])dnl
[cp xml-tests/test.output expout]
AT_CHECK([[$XSLTPROC \
@@ -415,6 +575,8 @@ m4_define([AT_BISON_CHECK_XML],
m4_define([AT_QUELL_VALGRIND],
[[[VALGRIND_OPTS="$VALGRIND_OPTS --leak-check=summary --show-reachable=no"; export VALGRIND_OPTS;]]])
## ------------------------ ##
## Compiling C, C++ Files. ##
## ------------------------ ##
@@ -422,21 +584,37 @@ m4_define([AT_QUELL_VALGRIND],
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
# ----------------------------------------
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
# assume that we are linking too; this is a hack.
# Compile SOURCES into OUTPUT.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c" appended.
m4_define([AT_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
[AT_CHECK(m4_join([ ],
[$CC $CFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])])
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
# --------------------------------------------
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
# assume that we are linking too; this is a hack.
# If the C++ compiler does not work, ignore the test.
# ---------------------------------------------
# Compile SOURCES into OUTPUT. If the C++ compiler does not work,
# ignore the test.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".cc" appended.
m4_define([AT_COMPILE_CXX],
[AT_KEYWORDS(c++)
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
AT_CHECK(m4_join([ ],
[$CXX $CXXFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])])
# AT_JAVA_COMPILE(SOURCES)
@@ -445,32 +623,56 @@ AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1
# is not installed.
m4_define([AT_JAVA_COMPILE],
[AT_KEYWORDS(java)
AT_CHECK([[test -n "$CONF_JAVA" || exit 77
test -n "$CONF_JAVAC" || exit 77]])
AT_SKIP_IF([[test -z "$CONF_JAVAC"]])
AT_SKIP_IF([[test -z "$CONF_JAVA"]])
AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
[[0]], [ignore], [ignore])])
# AT_FULL_COMPILE(OUTPUT, [OTHER])
# --------------------------------
# AT_LANG_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]
# --------------------------------------------
# Compile SOURCES into OUTPUT. Skip if compiler does not work.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c"/".cc" appended.
m4_define([AT_LANG_COMPILE],
[m4_case(AT_LANG,
[c], [AT_COMPILE([$1], [$2])],
[c++], [AT_COMPILE_CXX([$1], [$2])],
[java], [AT_JAVA_COMPILE([$1.java], [$2])],
[m4_fatal([unknown language: ]m4_defn([AT_LANG]))])[]dnl
])
# AT_FULL_COMPILE(OUTPUT, [OTHER1], [OTHER2])
# -------------------------------------------
# Compile OUTPUT.y to OUTPUT.c, OUTPUT.cc, or OUTPUT.java, and then
# compile it to OUTPUT or OUTPUT.class. If OTHER is specified, compile
# OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or
# OUTPUT.java along with it. Relies on AT_SKEL_CC_IF and
# AT_SKEL_JAVA_IF.
m4_define([AT_FULL_COMPILE], [
AT_SKEL_JAVA_IF([
AT_BISON_CHECK([[-o ]$1[.java ]$1[.y]])
AT_JAVA_COMPILE([$1[.java]]m4_ifval($2,
[[$1[.java ]$1[-]$2[.java]]]))
], [
AT_SKEL_CC_IF([
AT_BISON_CHECK([[-o ]$1[.cc ]$1[.y]])
AT_COMPILE_CXX([$1]m4_ifval($2, [, [$1[.cc ]$1[-]$2[.cc]]]))
], [
AT_BISON_CHECK([[-o ]$1[.c ]$1[.y]])
AT_COMPILE([$1]m4_ifval($2, [, [$1[.c ]$1[-]$2[.c]]]))
])
])
m4_define([AT_FULL_COMPILE],
[m4_case(AT_LANG,
[java],
[AT_BISON_CHECK([-o $1.java $1.y])
AT_LANG_COMPILE([$1],
m4_join([ ],
[$1.java],
m4_ifval($2, [[$1-$2.java]]),
m4_ifval($3, [[$1-$3.java]])))],
[c++],
[AT_BISON_CHECK([-o $1.cc $1.y])
AT_LANG_COMPILE([$1],
m4_join([ ],
[$1.cc],
m4_ifval($2, [[$1-$2.cc]]),
m4_ifval($3, [[$1-$3.cc]])))],
[c],
[AT_BISON_CHECK([-o $1.c $1.y])
AT_LANG_COMPILE([$1],
m4_join([ ],
[$1.c],
m4_ifval($2, [[$1-$2.c]]),
m4_ifval($3, [[$1-$3.c]])))])
])
@@ -577,12 +779,12 @@ m4_define([AT_TEST_TABLES_AND_PARSE],
[m4_pushdef([AT_COND_CASE], [m4_case([$2], $][@)])
AT_SETUP([$1])
AT_BISON_OPTION_PUSHDEFS([$4])
AT_DATA_GRAMMAR([[input.y]],
[[%code {
#include <stdio.h>
static void yyerror (char const *msg);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
]$4[
@@ -592,13 +794,7 @@ AT_DATA_GRAMMAR([[input.y]],
]$5[
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
@@ -654,6 +850,7 @@ AT_PARSER_CHECK([[./input]],
m4_ifval([$11], [m4_dquote($11)]),
m4_ifval([$12], [m4_dquote($12)]))
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
m4_popdef([AT_COND_CASE])])
+13 -17
View File
@@ -19,7 +19,7 @@
AT_BANNER([[Named references tests.]])
AT_SETUP([Tutorial calculator])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([test.y],
[[
%{
@@ -33,8 +33,8 @@ FILE *input;
static semantic_value global_result = 0;
static int global_count = 0;
static int power (int base, int exponent);
static void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%union
@@ -83,12 +83,7 @@ exp:
| '-' error { $$ = 0; YYERROR; }
;
%%
static void yyerror (const char *s)
{
fprintf (stderr, "%s\n", s);
}
]AT_YYERROR_DEFINE[
static int get_char (void)
{
int res = getc (input);
@@ -119,7 +114,8 @@ static int read_signed_integer (void)
return sign * n;
}
int yylex (void)
static int
yylex (void)
{
int c;
/* Skip white space. */
@@ -166,10 +162,8 @@ int main (int argc, const char **argv)
}
status = yyparse ();
fclose (input);
if (global_result != result)
abort ();
if (global_count != count)
abort ();
assert (global_result == result);
assert (global_count == count);
return status;
}
]])
@@ -190,6 +184,7 @@ AT_DATA([input.txt],
AT_BISON_CHECK([-o test.c test.y])
AT_COMPILE([[test]])
AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
@@ -198,13 +193,13 @@ AT_CLEANUP
AT_SETUP([Undefined and ambiguous references])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([test.y],
[[
%{
static int power (int base, int exponent);
static void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%union
@@ -268,6 +263,7 @@ test.y:55.3-53: symbol not found in production: r12
test.y:56.29-33: invalid reference: '$expo'
test.y:56.3-46: symbol not found in production: expo
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
#######################################################################
+5 -3
View File
@@ -176,10 +176,11 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
# -----------------------------------------------------------------------------
# ---------------------------------------------------------------
m4_define([AT_CHECK_OUTPUT_FILE_NAME],
[AT_SETUP([Output file name: $1])
AT_BISON_OPTION_PUSHDEFS
# Skip if platform doesn't support file name. For example, Cygwin
# doesn't support file names containing ":" or "\".
AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
@@ -187,8 +188,8 @@ AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
AT_DATA_GRAMMAR([glr.y],
[[%glr-parser
%code {
int yylex (void);
void yyerror (const char *);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
}
%%
start: {};
@@ -209,6 +210,7 @@ AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
$2
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
+15 -25
View File
@@ -24,17 +24,18 @@ AT_BANNER([[Push Parsing Tests]])
AT_SETUP([[Memory Leak for Early Deletion]])
# Requires Valgrind.
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]],
[[
%{
#include <assert.h>
#include <stdio.h>
#define YYINITDEPTH 1
void yyerror (char const *msg);
]AT_YYERROR_DECLARE[
%}
%define api.pure %define api.push-pull push
%define api.pure
%define api.push-pull push
%%
@@ -42,11 +43,7 @@ start: 'a' 'b' 'c' ;
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
int
main (void)
@@ -71,6 +68,7 @@ main (void)
return 0;
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]])
AT_COMPILE([[input]])
@@ -85,13 +83,14 @@ AT_CLEANUP
AT_SETUP([[Multiple impure instances]])
m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
AT_BISON_OPTION_PUSHDEFS([%define api.push-pull $1])
AT_DATA_GRAMMAR([[input.y]],
[[
%{
#include <assert.h>
#include <stdio.h>
void yyerror (char const *msg);
int yylex (void);
]AT_YYERROR_DECLARE[
]m4_if([$1], [[both]], [AT_YYLEX_DECLARE([])])[
%}
%define api.push-pull ]$1[
@@ -101,28 +100,16 @@ AT_DATA_GRAMMAR([[input.y]],
start: ;
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
yylex (void)
{
return 0;
}
]AT_YYERROR_DEFINE[
]m4_if([$1], [[both]], [AT_YYLEX_DEFINE])[
int
main (void)
{
yypstate *ps;
int i;
for (i = 0; i < 2; ++i)
{
ps = yypstate_new ();
yypstate *ps = yypstate_new ();
assert (ps);
assert (yypstate_new () == YY_NULL);
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
@@ -140,6 +127,7 @@ main (void)
AT_BISON_CHECK([[-o input.c input.y]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]])
AT_BISON_OPTION_POPDEFS
])
AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
@@ -155,12 +143,14 @@ AT_CLEANUP
AT_SETUP([[Unsupported Skeletons]])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([[input.y]],
[[%glr-parser
%define api.push-pull push
%%
start: ;
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[input.y]], [[1]], [],
[[input.y:2.9-21: %define variable 'api.push-pull' is not used
+194 -200
View File
@@ -24,10 +24,11 @@ AT_BANNER([[Regression tests.]])
AT_SETUP([Trivial grammars])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%{
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
#define YYSTYPE int *
%}
@@ -37,9 +38,10 @@ int yylex (void);
program: 'x';
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
AT_CLEANUP
@@ -52,10 +54,11 @@ AT_CLEANUP
AT_SETUP([YYSTYPE typedef])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%{
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
typedef union { char const *val; } YYSTYPE;
%}
@@ -65,9 +68,10 @@ typedef union { char const *val; } YYSTYPE;
program: { $$ = ""; };
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -83,10 +87,11 @@ AT_SETUP([Early token definitions with --yacc])
# Found in GCJ: they expect the tokens to be defined before the user
# prologue, so that they can use the token definitions in it.
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%{
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%union
@@ -103,9 +108,10 @@ int yylex (void);
exp: MY_TOKEN;
%%
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-y -o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -121,11 +127,12 @@ AT_SETUP([Early token definitions without --yacc])
# Found in GCJ: they expect the tokens to be defined before the user
# prologue, so that they can use the token definitions in it.
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%{
#include <stdio.h>
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
void print_my_token (void);
%}
@@ -146,9 +153,10 @@ print_my_token (void)
exp: MY_TOKEN;
%%
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -161,6 +169,7 @@ AT_CLEANUP
AT_SETUP([Braces parsing])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y],
[[/* Bison used to swallow the character after '}'. */
@@ -168,6 +177,7 @@ AT_DATA([input.y],
exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
%%
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-v -o input.c input.y])
@@ -183,6 +193,7 @@ AT_CLEANUP
AT_SETUP([Duplicate string])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y],
[[/* 'Bison -v' used to dump core when two tokens are defined with the same
string, as LE and GE below. */
@@ -195,6 +206,7 @@ AT_DATA([input.y],
exp: '(' exp ')' | NUM ;
%%
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-v -o input.c input.y], 0, [],
[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
@@ -211,6 +223,7 @@ AT_SETUP([Rule Line Numbers])
AT_KEYWORDS([report])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y],
[[%%
expr:
@@ -240,6 +253,7 @@ expr:
};
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c -v input.y])
@@ -428,13 +442,14 @@ AT_CLEANUP
AT_SETUP([Token definitions])
AT_BISON_OPTION_PUSHDEFS
# Bison managed, when fed with '%token 'f' "f"' to #define 'f'!
AT_DATA_GRAMMAR([input.y],
[%{
#include <stdlib.h>
#include <stdio.h>
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
[%error-verbose
%token MYEOF 0 "end of file"
@@ -447,20 +462,8 @@ int yylex (void);
%%
exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
%%
void
yyerror (char const *s)
{
fprintf (stderr, "%s\n", s);
}
int
yylex (void)
{
static int called;
if (called++)
abort ();
return SPECIAL;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([{ SPECIAL }])[
int
main (void)
@@ -468,6 +471,7 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
# Checking the warning message guarantees that the trigraph "??!" isn't
# unnecessarily escaped here even though it would need to be if encoded in a
@@ -498,22 +502,24 @@ AT_CLEANUP
AT_SETUP([Characters Escapes])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[%{
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
[%%
exp:
'\'' "\'"
| '\"' "\""
| '"' "'"
| '"' "'" /* Pacify font-lock-mode: ". */
;
]])
# Pacify font-lock-mode: "
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -832,13 +838,11 @@ AT_CLEANUP
# so that possible bound checking compilers could check all the skeletons.
m4_define([_AT_DATA_DANCER_Y],
[AT_DATA_GRAMMAR([dancer.y],
[%{
static int yylex (AT_LALR1_CC_IF([int *], [void]));
AT_LALR1_CC_IF([],
[#include <stdlib.h>
#include <stdio.h>
static void yyerror (const char *);])
%}
[[%code provides
{
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
$1
%token ARROW INVALID NUMBER STRING DATA
%defines
@@ -883,15 +887,10 @@ member: STRING
| INVALID
;
%%
AT_LALR1_CC_IF(
[/* A C++ error reporting function. */
void
yy::parser::error (const location&, const std::string& m)
{
std::cerr << m << std::endl;
}
int
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([":"])[
]AT_LALR1_CC_IF(
[int
yyparse ()
{
yy::parser parser;
@@ -900,33 +899,14 @@ yyparse ()
#endif
return parser.parse ();
}
],
[static void
yyerror (const char *s)
{
fprintf (stderr, "%s\n", s);
}])
static int
yylex (AT_LALR1_CC_IF([int *lval], [void]))
[{
static int const tokens[] =
{
':', -1
};
static size_t toknum;
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
if (! (toknum < sizeof tokens / sizeof *tokens))
abort ();
return tokens[toknum++];
}]
])[
int
main (void)
{
return yyparse ();
}
])
]])
])# _AT_DATA_DANCER_Y
@@ -937,7 +917,6 @@ m4_define([AT_CHECK_DANCER],
[AT_SETUP([Dancer $1])
AT_BISON_OPTION_PUSHDEFS([$1])
_AT_DATA_DANCER_Y([$1])
AT_BISON_CHECK([-o dancer.c dancer.y])
AT_FULL_COMPILE([dancer])
AT_PARSER_CHECK([./dancer], 1, [],
[syntax error, unexpected ':'
@@ -960,12 +939,12 @@ AT_CHECK_DANCER([%skeleton "lalr1.cc"])
# --------------------------------
m4_define([_AT_DATA_EXPECT2_Y],
[AT_DATA_GRAMMAR([expect2.y],
[%{
static int yylex (AT_LALR1_CC_IF([int *], [void]));
[[%{
static int yylex (]AT_LALR1_CC_IF([int *], [void]));
AT_LALR1_CC_IF([],
[#include <stdio.h>
[[#include <stdio.h>
#include <stdlib.h>
static void yyerror (const char *);])
]AT_YYERROR_DECLARE])[
%}
$1
%defines
@@ -982,58 +961,46 @@ e: e '+' t | t;
t: A | B;
%%
AT_LALR1_CC_IF(
[/* A C++ error reporting function. */
void
yy::parser::error (const location&, const std::string& m)
{
std::cerr << m << std::endl;
}
int
]AT_YYERROR_DEFINE[
]AT_LALR1_CC_IF(
[int
yyparse ()
{
yy::parser parser;
return parser.parse ();
}
],
[static void
yyerror (const char *s)
{
fprintf (stderr, "%s\n", s);
}])
])[
#include <assert.h>
static int
yylex (AT_LALR1_CC_IF([int *lval], [void]))
[{
yylex (]AT_LALR1_CC_IF([int *lval], [void])[)
{
static int const tokens[] =
{
1000, '+', '+', -1
};
static size_t toknum;
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
if (! (toknum < sizeof tokens / sizeof *tokens))
abort ();
assert (toknum < sizeof tokens / sizeof *tokens);
return tokens[toknum++];
}]
}
int
main (void)
{
return yyparse ();
}
])
]])
])# _AT_DATA_EXPECT2_Y
# AT_CHECK_EXPECT2(BISON-OPTIONS)
# ------------------------------
# -------------------------------
# Generate the grammar, compile it, run it.
m4_define([AT_CHECK_EXPECT2],
[AT_SETUP([Expecting two tokens $1])
AT_BISON_OPTION_PUSHDEFS([$1])
_AT_DATA_EXPECT2_Y([$1])
AT_BISON_CHECK([-o expect2.c expect2.y])
AT_FULL_COMPILE([expect2])
AT_PARSER_CHECK([./expect2], 1, [],
[syntax error, unexpected '+', expecting A or B
@@ -1056,12 +1023,12 @@ AT_SETUP([Braced code in declaration in rules section])
# Bison once mistook braced code in a declaration in the rules section to be a
# rule action.
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%{
#include <stdio.h>
static void yyerror (char const *msg);
static int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%error-verbose
@@ -1079,18 +1046,8 @@ start:
%printer { fprintf (yyoutput, "PRINTER"); } 'a';
%%
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
static int
yylex (void)
{
return 'a';
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
int
main (void)
@@ -1099,6 +1056,7 @@ main (void)
return !yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-t -o input.c input.y])
AT_COMPILE([input])
@@ -1196,12 +1154,12 @@ AT_SETUP([[Token number in precedence declaration]])
# POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
# we lost this in Bison 1.50.
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%{
#include <stdio.h>
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%error-verbose
@@ -1221,19 +1179,8 @@ sr_conflict:
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
yylex (void)
{
static int const input[] = { 1, 2, 3, 0 };
static int const *inputp = input;
return *inputp++;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE([{ 1, 2, 3, 0 }])[
int
main (void)
@@ -1241,6 +1188,7 @@ main (void)
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
@@ -1283,11 +1231,12 @@ AT_CLEANUP
AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%code {
#include <stdio.h>
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
#define YYSTACK_USE_ALLOCA 1
}
@@ -1323,28 +1272,18 @@ syntax_error:
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
yylex (void)
{
/* Induce two syntax error messages (which requires full error
recovery by shifting 3 tokens) in order to detect any loss of the
reallocated buffer. */
static char const *input = "abc";
return *input++;
}
]AT_YYERROR_DEFINE[
/* Induce two syntax error messages (which requires full error
recovery by shifting 3 tokens) in order to detect any loss of the
reallocated buffer. */
]AT_YYLEX_DEFINE(["abc"])[
int
main (void)
{
return yyparse ();
}
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]])
AT_COMPILE([[input]])
@@ -1370,12 +1309,12 @@ AT_CLEANUP
# yyparse would invoke yyerror using the old contents of yymsg.
AT_SETUP([[%error-verbose overflow]])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%code {
#include <stdio.h>
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
/* This prevents this test case from having to induce error messages
large enough to overflow size_t. */
@@ -1441,21 +1380,10 @@ syntax_error2:
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
yylex (void)
{
/* Induce two syntax error messages (which requires full error
recovery by shifting 3 tokens). */
static char const *input = "abc";
return *input++;
}
]AT_YYERROR_DEFINE[
/* Induce two syntax error messages (which requires full error
recovery by shifting 3 tokens). */
]AT_YYLEX_DEFINE(["abc"])[
int
main (void)
{
@@ -1481,7 +1409,7 @@ AT_PARSER_CHECK([[./input]], [[2]], [],
syntax error
memory exhausted
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
@@ -1499,7 +1427,7 @@ AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_GRAMMAR([input.y],
[[%code {
#include <stdio.h>
void yyerror (char const *);
]AT_YYERROR_DECLARE[
int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
}
@@ -1520,13 +1448,7 @@ B: 'b' ;
C: /*empty*/ { printf ("consistent default reduction\n"); } ;
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
int
yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
{
@@ -1559,17 +1481,17 @@ AT_CHECK([[grep 'syntax error,' stderr.txt]], [[0]],
# Check number of default reductions in inconsistent states to be sure
# syntax error is detected before unnecessary reductions are performed.
AT_CHECK([[perl -0777 -ne 'print s/inconsistent default reduction//g;' \
AT_CHECK([[$PERL -0777 -ne 'print s/inconsistent default reduction//g;' \
< stdout.txt || exit 77]], [[0]], [[14]])
# Check number of default reductions in consistent states to be sure
# it is performed before the syntax error is detected.
AT_CHECK([[perl -0777 -ne 'print s/\bconsistent default reduction//g;' \
AT_CHECK([[$PERL -0777 -ne 'print s/\bconsistent default reduction//g;' \
< stdout.txt || exit 77]], [[0]], [[2]])
# Check number of reallocs to be sure reallocated memory isn't somehow
# lost between LAC invocations.
AT_CHECK([[perl -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
AT_CHECK([[$PERL -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
|| exit 77]], [[0]], [[3]])
AT_BISON_OPTION_POPDEFS
@@ -1592,13 +1514,13 @@ AT_CLEANUP
AT_SETUP([[LAC: Memory exhaustion]])
m4_pushdef([AT_LAC_CHECK], [
m4_pushdef([AT_LAC_CHECK],
[AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%code {
#include <stdio.h>
void yyerror (char const *);
int yylex (void);
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
#define YYMAXDEPTH 8
}
@@ -1610,20 +1532,8 @@ S: A A A A A A A A A ;
A: /*empty*/ | 'a' ;
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
yylex (void)
{
static char const *input = "]$1[";
return *input++;
}
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["$1"])[
int
main (void)
{
@@ -1637,12 +1547,12 @@ AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
[[input.y: conflicts: 8 shift/reduce
]])
AT_COMPILE([[input]])
AT_BISON_OPTION_POPDEFS
])
# Check for memory exhaustion during parsing.
AT_LAC_CHECK([[]])
AT_PARSER_CHECK([[./input]], [[2]], [[]],
AT_LAC_CHECK([])
AT_PARSER_CHECK([[./input]], [[2]], [],
[[Starting parse
Entering state 0
Reading a token: Now at end of input.
@@ -1655,8 +1565,8 @@ Stack now 0
# Induce an immediate syntax error with an undefined token, and check
# for memory exhaustion while building syntax error message.
AT_LAC_CHECK([[z]], [[0]])
AT_PARSER_CHECK([[./input]], [[2]], [[]],
AT_LAC_CHECK([z], [[0]])
AT_PARSER_CHECK([[./input]], [[2]], [],
[[Starting parse
Entering state 0
Reading a token: Next token is token $undefined ()
@@ -1673,3 +1583,87 @@ Stack now 0
m4_popdef([AT_LAC_CHECK])
AT_CLEANUP
## ---------------------- ##
## Lex and parse params. ##
## ---------------------- ##
# AT_TEST(SKELETON)
# -----------------
# Check that the identifier of the params is properly fetched
# even when there are trailing blanks.
m4_pushdef([AT_TEST],
[AT_SETUP([[Lex and parse params: $1]])
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton $1])
## FIXME: Improve parsing of parse-param and use the generated
## yyerror.
AT_DATA_GRAMMAR([input.y],
[[%defines
%locations
%skeleton $1
%union { int ival; }
%parse-param { int x }
// Spaces, tabs, and new lines.
%parse-param { @&t@
int y @&t@
@&t@
@&t@
}
%{
#include <stdio.h>
#include <stdlib.h>
]AT_SKEL_CC_IF([], [[
static
void
yyerror (int x, int y, const char *msg)
{
fprintf (stderr, "x: %d, y: %d, %s\n", x, y, msg);
}]])[
]AT_YYLEX_DECLARE[
%}
%%
exp: 'a' { fprintf (stdout, "x: %d, y: %d\n", x, y); };
%%
]AT_YYLEX_DEFINE(["a"])[
]AT_SKEL_CC_IF(
[AT_YYERROR_DEFINE
int
yyparse (int x, int y)
{
yy::parser parser(x, y);
return parser.parse ();
}
])[
int
main (void)
{
return !!yyparse(1, 2);
}
]])
AT_FULL_COMPILE([input])
AT_CHECK([./input], 0, [[x: 1, y: 2
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## FIXME: test Java, and iterate over skeletons.
AT_TEST("yacc.c")
AT_TEST("glr.c")
AT_TEST("lalr1.cc")
AT_TEST("glr.cc")
m4_popdef([AT_TEST])
+5 -8
View File
@@ -83,10 +83,11 @@ AT_CLEANUP
AT_SETUP([[Installed skeleton file names]])
AT_BISON_OPTION_PUSHDEFS
m4_pushdef([AT_GRAM],
[[%{
#include <stdio.h>
void yyerror (char const *msg);
]AT_YYERROR_DECLARE[
int yylex (void);
%}
@@ -99,12 +100,7 @@ start: ;
%%
void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
int
yylex (void)
{
@@ -139,6 +135,7 @@ AT_PARSER_CHECK([[./input-gram]], [[1]], [],
m4_popdef([AT_GRAM])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
@@ -318,7 +315,7 @@ print '@output(@,@)', "\n";
(print "garbage"x10, "\n") for (1..1000);
print "${M4}_divert_pop(0)\n";
]])
AT_CHECK([[perl gen-skel.pl > skel.c || exit 77]])
AT_CHECK([[$PERL gen-skel.pl > skel.c || exit 77]])
AT_DATA([[input.y]],
[[%skeleton "./skel.c"
+109 -40
View File
@@ -27,6 +27,11 @@ AT_BANNER([[User Actions.]])
# errors.
m4_define([AT_SYNCLINES_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
# Transform stderr into something like this:
#
# input.y:4: #error "4"
#
# In case GCC displays column information, strip it down.
#
# input.y:4:2: #error "4" or
@@ -42,6 +47,11 @@ m4_define([AT_SYNCLINES_COMPILE],
# =>
# input.y:4: #error "8"
#
# The message may include a caret-error:
#
# input.y:1:2: error: #error "1"
# #error "1"
# ^
#
# And possibly distcc adds its bits.
#
@@ -54,21 +64,24 @@ m4_define([AT_SYNCLINES_COMPILE],
# distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
# distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
AT_CHECK([[sed -e '/^distcc\[[0-9]*\] /d' \
-e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \
-e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \
-e "/^[^:]*: In function '[^\']*':$/d" \
stderr]],
0, [stdout])
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
s/^distcc\[\d+\] .*\n//gm;
s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm;
s/^([^:]+:\d+):[^#]*( #error)/$][1:$][2/gm;
s/^[^:]*: In function '[^']+':\n//gm;
s/^\ +#error.*\n\ *\^\n//gm;
EOF
]],
0, [stdout])
])
# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
# -----------------------------------------
# AT_TEST(TITLE, INPUT, ERROR-MSG)
# --------------------------------
# Check that compiling the parser produced from INPUT cause GCC
# to issue ERROR-MSG.
m4_define([AT_TEST_SYNCLINE],
m4_pushdef([AT_TEST],
[AT_SETUP([$1])
AT_BISON_OPTION_PUSHDEFS
# It seems impossible to find a generic scheme to check the location
# of an error. Even requiring GCC is not sufficient, since for instance
# the version modified by Apple:
@@ -98,56 +111,59 @@ AT_DATA([[input.y]], [$2])
AT_BISON_CHECK([-o input.c input.y])
AT_SYNCLINES_COMPILE([input.c])
AT_CHECK([cat stdout], 0, [$3])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## --------------------- ##
## Prologue synch line. ##
## --------------------- ##
## ------------------- ##
## Prologue syncline. ##
## ------------------- ##
AT_TEST_SYNCLINE([Prologue synch line],
AT_TEST([Prologue syncline],
[[%{
#error "2"
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0';
%%
]],
[input.y:2: #error "2"
])
## ------------------- ##
## %union synch line. ##
## ------------------- ##
## ----------------- ##
## %union syncline. ##
## ----------------- ##
AT_TEST_SYNCLINE([%union synch line],
AT_TEST([%union syncline],
[[%union {
#error "2"
char dummy;
}
%{
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0';
%%
]],
[input.y:2: #error "2"
])
## ------------------------- ##
## Postprologue synch line. ##
## ------------------------- ##
## ----------------------- ##
## Postprologue syncline. ##
## ----------------------- ##
AT_TEST_SYNCLINE([Postprologue synch line],
AT_TEST([Postprologue syncline],
[[%{
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%union
{
@@ -158,19 +174,20 @@ int yylex (void);
%}
%%
exp: '0';
%%
]],
[input.y:10: #error "10"
])
## ------------------- ##
## Action synch line. ##
## ------------------- ##
## ----------------- ##
## Action syncline. ##
## ----------------- ##
AT_TEST_SYNCLINE([Action synch line],
AT_TEST([Action syncline],
[[%{
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp:
@@ -182,14 +199,14 @@ exp:
])
## --------------------- ##
## Epilogue synch line. ##
## --------------------- ##
## ------------------- ##
## Epilogue syncline. ##
## ------------------- ##
AT_TEST_SYNCLINE([Epilogue synch line],
AT_TEST([Epilogue syncline],
[[%{
void yyerror (const char *s);
int yylex (void);
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0';
@@ -198,3 +215,55 @@ exp: '0';
]],
[input.y:8: #error "8"
])
## -------------------- ##
## %code top syncline. ##
## -------------------- ##
AT_TEST([%code top syncline],
[[%code top {
#error "2"
}
%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0';
%%
]],
[input.y:2: #error "2"
])
m4_popdef([AT_TEST])
## ----------- ##
## %no-lines. ##
## ----------- ##
m4_pushdef([AT_TEST],
[AT_SETUP([%no-lines])
AT_BISON_OPTION_PUSHDEFS([%skeleton "$1" %defines])
AT_DATA_GRAMMAR([input.y],
[%skeleton "$1" %defines
%{
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
%%
exp: '0'
])
AT_BISON_CHECK([--no-lines -o input.AT_SKEL_CC_IF([cc], [c]) -d input.y])
AT_CHECK([[grep '#line' ]AT_SKEL_CC_IF([*.cc *.hh], [*.c *.h])], 1)
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
AT_TEST([yacc.c])
AT_TEST([glr.c])
AT_TEST([lalr1.cc])
AT_TEST([glr.cc])
m4_popdef([AT_TEST])
+78 -87
View File
@@ -42,7 +42,8 @@ esac])
# Create FILE-NAME, containing a self checking parser for a huge
# triangular grammar.
m4_define([AT_DATA_TRIANGULAR_GRAMMAR],
[AT_DATA([[gengram.pl]],
[AT_BISON_OPTION_PUSHDEFS
AT_DATA([[gengram.pl]],
[[#! /usr/bin/perl -w
use strict;
@@ -55,9 +56,10 @@ print <<EOF;
%{
#include <stdio.h>
#include <stdlib.h>
static int yylex (void);
static void yyerror (const char *msg);
#include <assert.h>
#define MAX $max
]AT_YYLEX_DECLARE[
]AT_YYERROR_DECLARE[
%}
%union
{
@@ -76,8 +78,8 @@ for my $size (1 .. $max)
print <<EOF;
%%
input:
exp { if (\@S|@1 != 0) abort (); \$\$ = \@S|@1; }
| input exp { if (\@S|@2 != \@S|@1 + 1) abort (); \$\$ = \@S|@2; }
exp { assert (\@S|@1 == 0); \$\$ = \@S|@1; }
| input exp { assert (\@S|@2 == \@S|@1 + 1); \$\$ = \@S|@2; }
;
exp:
@@ -95,14 +97,15 @@ for my $size (1 .. $max)
};
print ";\n";
print <<EOF;
print <<\EOF;
%%
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static int inner = 1;
static int outer = 0;
if (outer > $max)
if (outer > MAX)
return 0;
else if (inner > outer)
{
@@ -112,13 +115,6 @@ yylex (void)
}
return inner++;
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\\n", msg);
}
int
main (void)
{
@@ -127,8 +123,9 @@ main (void)
}
EOF
]])
AT_BISON_OPTION_POPDEFS
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
mv stdout $1
])
@@ -157,7 +154,8 @@ AT_CLEANUP
# Create FILE-NAME, containing a self checking parser for a huge
# horizontal grammar.
m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
[AT_DATA([[gengram.pl]],
[AT_BISON_OPTION_PUSHDEFS
AT_DATA([[gengram.pl]],
[[#! /usr/bin/perl -w
use strict;
@@ -170,9 +168,9 @@ print <<EOF;
%{
#include <stdio.h>
#include <stdlib.h>
static int yylex (void);
static void yyerror (const char *msg);
#define MAX $max
]AT_YYLEX_DECLARE[
]AT_YYERROR_DECLARE[
%}
%token
@@ -193,25 +191,20 @@ print
(map { "\"$_\"" } (1 .. $max)), ";"),
"\n";
print <<EOF;
print <<\EOF;
%%
#include <assert.h>
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static int counter = 1;
if (counter <= $max)
if (counter <= MAX)
return counter++;
if (counter++ != $max + 1)
abort ();
assert (counter++ == MAX + 1);
return 0;
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\\n", msg);
}
int
main (void)
{
@@ -221,8 +214,9 @@ main (void)
EOF
]])
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
mv stdout $1
AT_BISON_OPTION_POPDEFS
])
@@ -263,7 +257,8 @@ AT_CLEANUP
# Create FILE-NAME, containing a self checking parser for a grammar
# requiring SIZE lookahead tokens.
m4_define([AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR],
[AT_DATA([[gengram.pl]],
[AT_BISON_OPTION_PUSHDEFS
AT_DATA([[gengram.pl]],
[[#! /usr/bin/perl -w
use strict;
@@ -277,9 +272,9 @@ print <<EOF;
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
static int yylex (void);
static void yyerror (const char *msg);
# define MAX $max
]AT_YYLEX_DECLARE[
]AT_YYERROR_DECLARE[
%}
%union
{
@@ -324,17 +319,17 @@ for my $count (1 .. $max)
print "n$count: token { \$\$ = $count; };\n";
};
print <<EOF;
print <<\EOF;
%%
]AT_YYERROR_DEFINE[
static int
yylex (void)
{
static int return_token = 1;
static int counter = 1;
if (counter > $max)
if (counter > MAX)
{
if (counter++ != $max + 1)
abort ();
assert (counter++ == MAX + 1);
return 0;
}
if (return_token)
@@ -346,12 +341,6 @@ yylex (void)
return counter++;
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\\n", msg);
}
int
main (void)
{
@@ -361,8 +350,9 @@ main (void)
EOF
]])
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
mv stdout $1
AT_BISON_OPTION_POPDEFS
])
@@ -390,7 +380,8 @@ AT_CLEANUP
# ------------------------------------------------
# A parser specialized in torturing the stack size.
m4_define([AT_DATA_STACK_TORTURE],
[# A grammar of parens growing the stack thanks to right recursion.
[AT_BISON_OPTION_PUSHDEFS([$2])
# A grammar of parens growing the stack thanks to right recursion.
# exp:
AT_DATA([input.y],
[[%{
@@ -399,8 +390,8 @@ AT_DATA([input.y],
#include <stdio.h>
#include <stdlib.h>
]$1[
static int yylex (void);
static void yyerror (const char *msg);
]AT_YYLEX_DECLARE[
]AT_YYERROR_DECLARE[
%}
]$2[
%error-verbose
@@ -409,59 +400,59 @@ AT_DATA([input.y],
%%
exp: WAIT_FOR_EOF exp | ;
%%
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
]AT_YYERROR_DEFINE[
#include <assert.h>
static int
yylex (void)
{
if (yylval < 0)
abort ();
assert (0 <= yylval);
if (yylval--)
return WAIT_FOR_EOF;
else
return EOF;
}
/* Return argv[1] as an int. */
static int
get_args (int argc, const char **argv)
{
int res;
char *endp;
assert (argc == 2);
res = strtol (argv[1], &endp, 10);
assert (argv[1] != endp);
assert (0 <= res);
assert (res <= INT_MAX);
assert (errno != ERANGE);
return res;
}
int
main (int argc, const char **argv)
{
char *endp;
YYSTYPE yylval_init;
if (argc != 2)
abort ();
yylval_init = strtol (argv[1], &endp, 10);
if (! (argv[1] != endp
&& 0 <= yylval_init && yylval_init <= INT_MAX
&& errno != ERANGE))
abort ();
yydebug = 1;
{
int count;
int status;
]m4_bmatch([$2], [%push-],
[[ yypstate *ps = yypstate_new ();
]])[ for (count = 0; count < 2; ++count)
{
int new_status;
yylval = yylval_init;
]m4_bmatch([$2], [%push-],
[[ new_status = yypull_parse (ps);
]],
[[ new_status = yyparse ();
]])[ if (count > 0 && new_status != status)
abort ();
YYSTYPE yylval_init = get_args (argc, argv);
int status;
int count;
]m4_bmatch([$2], [api.push-pull both],
[[ yypstate *ps = yypstate_new ();
]])[ yydebug = 1;
for (count = 0; count < 2; ++count)
{
int new_status;
yylval = yylval_init;
new_status = ]m4_bmatch([$2], [api.push-pull both],
[[yypull_parse (ps)]],
[[yyparse ()]])[;
if (count == 0)
status = new_status;
}
]m4_bmatch([$2], [%push-],
[[ yypstate_delete (ps);
]])[ return status;
}
else
assert (new_status == status);
}]m4_bmatch([$2], [api.push-pull both],[[
yypstate_delete (ps);]])[
return status;
}
]])
AT_BISON_OPTION_POPDEFS([$2])
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input])
])