Compare commits

...
71 Commits
Author SHA1 Message Date
Akim Demaille 69b22b49d4 version 3.4.2
* NEWS: Record release date.
2019-09-12 17:41:12 +02:00
Akim Demaille ec11f08fb3 CI: always uninstall icc 2019-09-12 13:16:30 +02:00
Akim Demaille 67444a6f0d news: more bug fixes thanks to Marc Schönefeld 2019-09-12 09:07:48 +02:00
Akim Demaille d120a07e6b diagnostics: beware of unexpected EOF when quoting the source file
When the input file contains lone CRs (aka, ^M, \r), the locations see
a new line.  Diagnostics look only at \n as end-of-line, so sometimes
there is an offset in diagnostics.  Worse yet: sometimes we loop
endlessly waiting for \n to come from a continuous stream of EOF.

Fix that:
- check for EOF
- beware not to call end_use_class if begin_use_class was not
  called (which would abort).  This could happen if the actual
  line is shorter that the expected one.

Prompted by a (private) report from Marc Schönefeld.

* src/location.c (location_caret): here.
* tests/diagnostics.at (Carriage return): New.
2019-09-10 19:15:18 +02:00
Akim Demaille 741a58a504 gnulib: update
Contains the creation of the xhash module.
https://lists.gnu.org/archive/html/bug-gnulib/2019-09/msg00046.html

* src/muscle-tab.c, src/state.c, src/symtab.c, src/uniqstr.c:
Use hash_xinitialize.
2019-09-10 19:06:13 +02:00
Akim Demaille d80815ac23 build: fix distcheck
* configure.ac (gl_LIBOBJS): Adjust so that the generated files are
indeed the expected ones.
2019-09-10 19:06:13 +02:00
Akim Demaille 0b417c3479 tests: add noexcept to please GCC 9
bison/tests/c++.at:552: bison --color=no -fno-caret  -o list.cc list.y
    bison/tests/c++.at:552: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o list list.cc $LIBS
    stderr:
    gcc9/c++/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = string; _Args = {string}; _Tp = string]':
    gcc9/c++/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = string; _Args = {string}; _Tp = string; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<string>]'
    gcc9/c++/bits/stl_uninitialized.h:888:67:   required from 'void std::__relocate_object_a(_Tp*, _Up*, _Allocator&) [with _Tp = string; _Up = string; _Allocator = std::allocator<string>]'
    gcc9/c++/bits/stl_uninitialized.h:920:47:   required from '_ForwardIterator std::__relocate_a_1(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = string*; _ForwardIterator = string*; _Allocator = std::allocator<string>]'
    gcc9/c++/bits/stl_uninitialized.h:942:37:   required from '_ForwardIterator std::__relocate_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = string*; _ForwardIterator = string*; _Allocator = std::allocator<string>]'
    gcc9/c++/bits/stl_vector.h:430:35:   required from 'static constexpr bool std::vector<_Tp, _Alloc>::_S_nothrow_relocate(std::true_type) [with _Tp = string; _Alloc = std::allocator<string>; std::true_type = std::integral_constant<bool, true>]'
    gcc9/c++/bits/stl_vector.h:446:28:   required from 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const string&}; _Tp = string; _Alloc = std::allocator<string>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<string*, std::vector<string> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = string*]'
    gcc9/c++/bits/stl_vector.h:1195:4:   required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = string; _Alloc = std::allocator<string>; std::vector<_Tp, _Alloc>::value_type = string]'
    list.y:126:110:   required from here
    gcc9/c++/bits/vector.tcc:459:44:   in 'constexpr' expansion of 'std::vector<string>::_S_use_relocate()'
    list.y:41:7: error: but 'string::string(string&&)' does not throw; perhaps it should be declared 'noexcept' [-Werror=noexcept]
       41 |       string (string&& s)
          |       ^~~~~~

* tests/c++.at (Variants): Add noexcept where appropriate.
2019-09-08 12:04:36 +02:00
Akim Demaille 77dbdd0d59 news: update 2019-09-08 11:38:29 +02:00
Akim Demaille f8db8fe4d7 fix: don't die when EOF token is defined twice
With

    %token EOF 0 EOF 0

we get

    input.y:3.14-16: warning: symbol EOF redeclared [-Wother]
        3 | %token EOF 0 EOF 0
          |              ^~~
    input.y:3.8-10: previous declaration
        3 | %token EOF 0 EOF 0
          |        ^~~
    Assertion failed: (nsyms == ntokens + nvars), function check_and_convert_grammar,
        file /Users/akim/src/gnu/bison/src/reader.c, line 839.

Reported by Marc Schönefeld.

* src/symtab.c (symbol_user_token_number_set): Register only the
first definition of the end of input token.
* tests/input.at (Symbol redeclared): Check that case.
2019-09-08 11:38:29 +02:00
Akim Demaille 375eb71489 tests: check token redeclaration
* src/symtab.c (symbol_class_set): Report previous definitions when
redeclared.
* tests/input.at (Symbol redeclared): New.
2019-09-08 11:38:29 +02:00
Akim Demaille d3a86f7b20 yacc.c: beware of GCC's -Wmaybe-uninitialized
Test 400 (calc.at:773: testing Calculator api.push-pull=both
api.pure=full parse.error=verbose %debug %locations %defines
api.prefix={calc} %verbose %yacc) fails on the CI with GCC 8 on
Bionic:

    400. calc.at:773: testing Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc  ...
    ../../tests/calc.at:773: bison --color=no -fno-caret -Wno-deprecated -o calc.c calc.y
    ../../tests/calc.at:773: $CC $CFLAGS $CPPFLAGS  $LDFLAGS -o calc calc.c calc-lex.c calc-main.c $LIBS
    stderr:
    calc.y: In function 'int calcpush_parse(calcpstate*, int, const CALCSTYPE*, CALCLTYPE*)':
    calc.y:26:20: error: 'yylval.CALCSTYPE::ival' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     %printer { fprintf (yyo, "%d", $$); } <ival>;
                        ^
    calc.c:1272:9: note: 'yylval.CALCSTYPE::ival' was declared here
     YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
             ^~~~~~
    cc1plus: all warnings being treated as errors
    stdout:
    ../../tests/calc.at:773: exit code was 1, expected 0
    400. calc.at:773: 400. Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc  (calc.at:773): FAILED (calc.at:773)

* data/skeletons/c.m4 (yy_symbol_value_print): Disable the warning
locally.
2019-09-08 11:38:29 +02:00
Akim Demaille 29c75ef27f glr.c: initialize vector of bools
The CI, with CC='gcc-7 -fsanitize=undefined,address
-fno-omit-frame-pointer', reports:

    calc.cc:1652:50: runtime error: load of value 190, which is not a valid value for type 'bool'
    ../../tests/calc.at:867: cat stderr
    --- expout	2019-09-05 20:30:37.887257545 +0000
    +++ /home/travis/build/bison-3.4.1.72-79a1-dirty/_build/tests/testsuite.dir/at-groups/438/stdout	2019-09-05 20:30:37.887257545 +0000
    @@ -1 +1,2 @@
     syntax error
    +calc.cc:1652:50: runtime error: load of value 190, which is not a valid value for type 'bool'
    438. calc.at:867: 438. Calculator glr.cc  (calc.at:867): FAILED (calc.at:867)

The problem is that yylookaheadNeeds is not initialized in
yyinitStateSet, and when it is copied, the value is not 0 or 1.

* data/skeletons/glr.c (yylookaheadNeeds): Initialize yylookaheadNeeds.
2019-09-08 11:38:29 +02:00
Akim Demaille 628012d830 gnulib: update
Contains a fix for
https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00016.html.
See
https://lists.gnu.org/archive/html/bug-gnulib/2019-09/msg00005.html.
Reported by 江 祖铭 (Zu-Ming Jiang).
2019-09-08 11:38:29 +02:00
Akim Demaille f788ba2ab6 check for memory exhaustion
hash_initialize returns NULL when out of memory.  Check for it, and
die cleanly instead of crashing.

Reported by 江 祖铭 (Zu-Ming Jiang).
https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00015.html

* src/muscle-tab.c, src/state.c, src/symtab.c, src/uniqstr.c:
Check the value returned by hash_initialize.
2019-09-08 11:38:29 +02:00
László VáradyandAkim Demaille 53526f31df diagnostics: avoid global variables
* src/complain.c (indent_ptr): Remove.
(error_message, complains): Take indent as an argument.
Adjust callers.
2019-09-08 11:38:29 +02:00
László VáradyandAkim Demaille e63811dd86 diagnostics: fix invalid error message indentation
https://lists.gnu.org/archive/html/bison-patches/2019-08/msg00007.html

When Bison is started with a flag that suppresses warning messages, the
error_message() function can produce a few gigabytes of indentation
because of a dangling pointer.

* src/complain.c (error_message): Don't reset indent_ptr here, but...
(complain_indent): here.
* tests/diagnostics.at (Indentation with message suppression): Check
this case.
2019-09-08 11:38:29 +02:00
Akim Demaille 47262c36bb git: ignore files generated in gnulib-po
Because of them, the CI generates "-dirty" tarballs.
2019-09-08 11:38:29 +02:00
Akim Demaille 1e452b1553 c++: avoid duplicate definition of YYUSE
Reported by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-06/msg00009.html

* data/skeletons/lalr1.cc (b4_shared_declarations): Remove the
duplicate definition of YYUSE, the other one coming from
b4_attribute_define.
2019-09-08 09:59:31 +02:00
Akim Demaille ed796869bb gnulib: update
This update brings file from Gettext 0.20, which is not available on
the CI yet.

.travis.yml: Adjust.
Use Bionic now that it's available.
2019-09-08 09:59:31 +02:00
Akim Demaille 12c412f6bb CI: more compilers
* .travis.yml: Bionic is now available, with GCC8.
GCC7 sanitizers work, but they are too longer: cover only part 1.
Redefine part 1 and part 2 so that part 1 is really the core of the
tests: not playing with POSIX and C++ compiler for C code.
2019-09-08 09:01:18 +02:00
Akim Demaille 2663035ea5 CI: fail fast 2019-09-08 09:01:11 +02:00
Akim Demaille de7c66ab41 CI: propagate sftp failures
* .travis.yml (stage: "compile"): here.
2019-09-08 09:00:58 +02:00
Akim Demaille feeacc2d57 CI: avoid useless git costs
Travis answered favorably to my suggestion to provide a means to
disable git clone on some jobs (issue 7542).  See
https://docs.travis-ci.com/user/customizing-the-build/#disabling-git-clone.

* .travis.yml: Disable git globally, enable it for i. the compile job,
and ii. the test job on ICC which needs the install-icc.sh script.
2019-09-08 09:00:49 +02:00
Akim Demaille cc10f9ab24 CI: factor
* .travis.yml (Clang 7 libc++ and ASAN part 2): Reuse bits from "Clang
7 libc++ and ASAN part 1".
2019-09-08 09:00:30 +02:00
Akim Demaille 1dcd6068dd tests: take SHELL into account
Reported by Dennis Clarke.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00053.html

* examples/local.mk, tests/local.mk: here.
2019-05-26 15:29:37 +02:00
Akim Demaille 02f16dc799 gnulib: update to get gnulib translations
This update contains a fix needed for gnulib-po to work properly.
https://lists.gnu.org/archive/html/bug-gnulib/2019-05/msg00146.html
2019-05-26 09:35:31 +02:00
Akim Demaille aa21c457f2 doc: clarify the purpose of symbol_type constructors
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-02/msg00006.html

* doc/bison.texi (Complete Symbols): Here.
2019-05-25 10:28:12 +02:00
Akim Demaille 9f26e6d6b3 thanks: fix an address 2019-05-22 18:09:04 +02:00
Akim Demaille 8d3e782e05 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-05-22 07:45:49 +02:00
Akim Demaille 1c671bad33 version 3.4.1
* NEWS: Record release date.
2019-05-22 07:28:15 +02:00
Akim Demaille 88cd9570b6 NEWS: update 2019-05-22 07:22:51 +02:00
Akim Demaille c423ad17e7 CI: remove useless apt-get update
The apt addons already ran it for us, it is not needed.

* .travis.yml: here.
2019-05-20 09:35:24 +02:00
Akim Demaille 9114b267a8 c++: beware of to_string portability issues
Reported by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00033.html

* m4/bison-cxx-std.m4 (_BISON_CXXSTD_11_snippet): Check it.
2019-05-20 06:27:55 +02:00
Akim Demaille 70c3f3ade5 doc: avoid Texinfo portability issues
Reported by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00024.html
Fixed by Karl Berry.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00034.html

* doc/bison.texi: Don't specify the langage, rely on the default.
Avoid blank pages.
2019-05-20 06:12:47 +02:00
Akim Demaille 1934304acf examples: don't run those that require f?lex when it's not available
Reported by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00026.html

* configure.ac (FLEX_WORKS): New.
* examples/c/lexcalc/local.mk, examples/c/reccalc/local.mk: Use it.
2019-05-19 18:41:59 +02:00
Akim Demaille c8e57e8159 diagnostics: don't crash when libtextstyle is installed
Reported by neok m4700.
https://lists.gnu.org/archive/html/bison-patches/2019-05/msg00025.html
https://github.com/akimd/bison/pull/11

* src/complain.c (complain_init_color): style_file_prepare _needs_ a
string as second argument.
2019-05-19 18:16:47 +02:00
Akim Demaille 1e49f5e1e6 CI: avoid useless git costs
The final gain is small: 2h2min instead 2h9min.  But that is still an
improvement.

* .travis.yml (git.depth): Make the clone very shallow.
(git.submodules): Don't clone gnulib in test jobs.
(jobs.include.compile.script): Do it here.
2019-05-19 17:52:28 +02:00
Akim Demaille 49aae94bed fix: copyable instead of copiable
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00020.html

* data/skeletons/lalr1.cc, doc/bison.texi: here.
2019-05-19 13:53:15 +02:00
Akim Demaille e191bf7b9f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-05-19 11:36:06 +02:00
Akim Demaille f520e150eb version 3.4
* NEWS: Record release date.
2019-05-19 11:19:47 +02:00
Akim Demaille 75db37c564 fix: use copiable, not copyable
Reported by Hans Åberg.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00017.html

* data/skeletons/lalr1.cc, doc/bison.texi: here.
2019-05-19 11:17:44 +02:00
Akim Demaille 886b503e4b NEWS: update for 3.4 2019-05-19 11:01:20 +02:00
Akim Demaille a2f0444c6e tests: adjust to GCC9 diagnostics with a margin
* tests/synclines.at (_AT_SYNCLINES_COMPILE): Remove the margin.
2019-05-19 10:53:02 +02:00
Akim Demaille 66100b640f regen 2019-05-19 10:05:18 +02:00
Akim Demaille de5207244b diagnostics: %pure-parser is obsolete
Reported by Uxio Prego.
http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00029.html

* src/scan-gram.l, src/parse-gram.y (PERCENT_PURE_PARSER)
(handle_pure_parser): New.
Issue a deprecation/update notice for %pure-parser.
* doc/bison.texi (Java Bison Interface): Don't mention %pure-parser.
* tests/actions.at, tests/input.at: Adjust.
2019-05-19 10:05:18 +02:00
Akim Demaille cae8132690 diagnostics: clean up convention for colored diagnostics
* data/diagnostics.css: Rename as...
* data/bison-default.css: this.
Add the GPL header.
This is the convention followed by Bruno Haible in gettext.
Adjust dependencies.
* src/complain.c (complain_init_color): Use BISON_STYLE instead of
BISON_DIAGNOSTICS_STYLE.
2019-05-19 09:50:21 +02:00
Akim Demaille a1a847bfb5 CI: use a pipeline: first build the tarball, then check it
Build the tarball in one job, check it in many.
Unfortunately no real gain in overall duration.
With help from Clément Démoulins.

* .travis.yml: here.
Remove all the tricks that were used to be able to boostrap on old
distros.
(before_install): Merge into 'script', because before_install applies
to all the jobs, and we don't want to run it for the 'compile' job.
2019-05-19 09:45:27 +02:00
Akim Demaille 3ac95de01a examples: fix srcdir/builddir issues
* examples/d/local.mk, examples/java/local.mk: here.
2019-05-18 13:22:58 +02:00
Akim Demaille da7af36a13 gnulib: update
In preparation for Bison 3.4, revert to the version before this
commit:

    commit 03752516b21091cf3c4beea7e8b9bcad462d50ed
    Author: John Darrington <[email protected]>
    Date:   Sun May 12 00:42:36 2019 +0200

    version-etc: Ease translation.

    * lib/version-etc.c (version_etc_arn, emit_bug_reporting_address):
    Move URLs and formatting newlines out of translatable string.

because it changes the messages for --version, translated in
gnulib.po.  These changes are not yet available on the translation
project, so we would have a regression in the set of translated
strings.
2019-05-18 09:10:08 +02:00
Akim Demaille 3f25104caf build: do not use $< in plain rules
It works only in implicit rules (or with GNU Make, but not with
Solaris Make).

Reported by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00009.html
Diagnosed thanks to Kiyoshi Kanazawa.

* examples/c/reccalc/local.mk, examples/d/local.mk,
* examples/java/local.mk: Don't use $< in non implicit rules.
2019-05-13 22:16:23 +02:00
Akim Demaille 6b1933d992 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-05-12 14:25:31 +02:00
Akim Demaille 5163803a63 version 3.3.91
* NEWS: Record release date.
2019-05-12 14:09:10 +02:00
Akim Demaille fee7c78a83 NEWS: update 2019-05-12 14:07:43 +02:00
Akim Demaille 8fc544b03c gnulib: update 2019-05-12 11:39:27 +02:00
Akim Demaille d62d5c4b33 style: remove incorrect comment
* src/getargs.c: here.
It's documented in getargs.h anyway.
2019-05-11 09:19:16 +02:00
Akim Demaille ab3eaff7c4 doc: use colors for diagnostics in TeX too
Thanks to Gavin Smith and Patrice Dumas.
http://lists.gnu.org/archive/html/help-texinfo/2019-04/msg00015.html

* doc/bison.texi (@colorWarning, @colorError, @colorNotice)
(@colorOff): Define for TeX and HTML.
(@dwarning, @derror, @dnotice): Use them.
2019-05-09 19:21:02 +02:00
Akim Demaille 85e83ea968 gnulib: update to fix location tracking in UTF-8 on Solaris
This update contains Bruno Haible's fix for the location tracking
issue reported by Kiyoshi Kanazawa.

https://lists.gnu.org/archive/html/bug-gnulib/2019-05/msg00020.html
https://lists.gnu.org/archive/html/bug-bison/2019-04/msg00020.html
2019-05-08 16:34:31 +02:00
Akim Demaille 0269c6fb03 diagnostics: rename --style=debug as --color=debug
It is more consistent with --color=html, --color=test, etc.

* src/getargs.h, src/getargs.c (style_debug): Rename as...
(color_debug): this.
(getargs_colors): Rename --style=debug as --color=debug.
Adjust dependencies.
2019-05-08 13:36:47 +02:00
Akim Demaille 23e536af49 diagnostics: support --color=html
Based on a message from Bruno Haible.
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=fe18e92743b7226791a5f28d7c786941a1bf8cc9

This does not generate proper HTML: special characters are not escaped
for instance.  This is a hidden feature meant for Bison developers,
not end users.

* src/complain.c (complain_init_color): Support --color=html.
2019-05-08 13:36:47 +02:00
Akim Demaille cd56929097 tests: use %empty instead of comments
* tests/c++.at, tests/glr-regression.at: here.
2019-05-08 09:11:37 +02:00
Akim Demaille 7aa38561f7 fixits: sort them before applying them
An experimental commit introduced a fix-it hint that changes comments
such as "/* empty */" into %empty.  But in some case, because
diagnostics are not necessarily emitted in order, the fixits also come
in disorder, which must never happen, as the fixes are installed in
one pass.

* src/fixits.c (fixits_register): Insert them in order.
2019-05-08 09:10:28 +02:00
Akim Demaille 22a00cfbf2 style: use warning_is_enabled instead of duplicating it
* src/complain.c (deprecated_directive): Here.
2019-05-04 17:50:57 +02:00
Akim Demaille 8c06cb9130 fixits: be sure to preserve the action when adding %empty
Currently we remove the rhs to install %empty instead.

* src/reader.c (grammar_rule_check_and_complete): Insert the missing
%empty in front of the rhs, not in replacement thereof.
* tests/actions.at (Add missing %empty): Check that.
2019-05-03 16:28:28 +02:00
Akim Demaille b5233ba323 tests: don't duplicate the portability prologue
* tests/actions.at, tests/input.at: Don't repeat the prologue, skip it.
* tests/diagnostics.at, tests/local.at: Comment changes.
2019-05-03 16:28:28 +02:00
Akim Demaille 013720f0e7 style: use consistently *_loc for locations
Some members are called foo_location, others are foo_loc.  Stick to
the latter.

* src/gram.h, src/location.h, src/location.c, src/output.c,
* src/parse-gram.y, src/reader.h, src/reader.c, src/reduce.c,
* src/scan-gram.l, src/symlist.h, src/symlist.c, src/symtab.h,
* src/symtab.c:
Use _loc consistently, not _location.
2019-05-03 16:28:28 +02:00
Akim Demaille 365b4d95a4 style: clarify the use of symbol_lists' locations
symbol_list features a 'location' and a 'sym_loc' member.  The former
is expected to be set only for symbol_lists that denote a symbol (not
a type name), and the latter should only denote the location of the
symbol/type name.  Yet both are set, and the name "location" is too
unprecise.

* src/symlist.h, src/symlist.c (symbol_list::location): Rename as
rhs_loc for clarity.  Move it to the "section" of data valid only
for rules.
* src/reader.c, src/scan-code.l: Adjust.
2019-05-03 16:28:28 +02:00
Akim Demaille 5bb44cca81 maint: update gnulib-po/.gitignore 2019-05-03 16:28:28 +02:00
Akim Demaille 15f9f8c853 tests: don't require a D compiler
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2019-04/msg00018.html

* tests/atlocal.in (BISON_DC_WORKS): New.
* tests/local.at (AT_COMPILE_D): Use it.
2019-04-29 22:27:01 +02:00
Akim Demaille 04676a5085 doc: use svg instead of png
* doc/bison.texi, doc/local.mk: here.
2019-04-29 07:44:19 +02:00
Akim Demaille cf44351dd7 doc: use colors
* doc/bison.texi (dwarning, derror, dnotice): New.
Use them in the diagnostics.
* doc/local.mk (AM_MAKEINFOFLAGS): Pass customization variables.
2019-04-29 07:44:19 +02:00
Akim Demaille 614e0bbe23 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-04-28 12:02:35 +02:00
57 changed files with 1298 additions and 801 deletions
+1 -1
View File
@@ -1 +1 @@
3.3.2
3.4.1
+175 -77
View File
@@ -1,8 +1,7 @@
# Travis defines and exports CC and CXX *after* we have defined our
# environment variables via 'env'. So, do not use 'env' to define
# them. Instead, put their definitions in MATRIX_EVAL, which we eval
# after the definitions from Travis.
# environment variables via 'env'. So, do not use 'env' to define them.
# Instead, put their definitions in MATRIX_EVAL, which we eval after the
# definitions from Travis.
language: cpp
env:
@@ -11,8 +10,63 @@ env:
# See https://github.com/nemequ/icc-travis.
secure: B3manbbi0anCAGDJTdAa9TlodzRHeiYD87FKmFzS877dPm8Cm0BDvtUhKBUpBvP8+nbHOWFGrgDmLugSZjTGU+mAxtuQpamUFHvinu0BIk3qtjlqouwvbtIqUu8iiZ3Uqu+xKeAANKRy0YVZGLlEb9F3N119tJ/Fxp1p9bXL1qph+CZ25OFbUgZ2s4F+/AyHMUxJlNXKFe3Qean65hC6edhU3zoaKzr/g/wtbhRmcyWbkOa1dJqzr2yKotcPvrnApGhDzgMKFtohg/t7xfMADDVv6sGS5XNpt25Z+MUCmLg4Z9eD7u109jvRV1eu/jgVafqsthWEhXbuMiFgFhKBKGCNZ0dACIfKZSkFZI6FdM7ovJ6aNhSlxZ2169Ybd22rN1UTHeCQWySPcVVOg5taLVpqe+E8Xhnv4hBO5NrzElWwCMLxIdPUSwVStYvtDr8ZytHWzfot50vSnFKIFpTOr9hP4+AJMVmmqJfaJo2MLBft/q2xkztrMv3lQSj3m4+ma9kPDwXIu9uCutjlnhc00jNx9qegi5VfpAjxcG1R+pX4T20az6ByHk/7LPQsANkT31RJq/jAeD9LEuMOy8miha83q4QuvbFaqPK3PY0el/O1LZaXqLsV2aQ0uqH8YX0l4r5NzHdhb+3lYgvpMBO5ytr/EWJiEyNYV518050IUDE=
matrix:
# Run in two steps:
# 1. Build the tarball
# On a modern distro, with all the needed dependencies, including the whole git history.
# 2. Check it on various environments.
# Less dependencies, and little git content (we would like to have none, but it's not
# an option on Travis).
stages:
- compile
- test
# The 'test' jobs do not need the repo at all, only the 'compile'
# does. Let's save time, bandwith, energy, and polar bears.
git:
clone: false
# matrix.include and jobs.include are aliases
# (https://docs.travis-ci.com/user/conditional-builds-stages-jobs/).
jobs:
include:
- stage: "compile"
git:
clone: true
dist: bionic
script:
- sudo apt-get install -qq autoconf automake autopoint flex gettext graphviz help2man m4 texinfo
- autoconf --version
- automake --version
- autopoint --version
- dot -V
- gettext --version
- help2man --version
- makeinfo --version
- m4 --version
# Travis makes a shallow clone, but we need it in full to build the ChangeLog and apply the fixes in git-log-fix.
- git fetch --unshallow || true
- git submodule update --init --recursive
- ./bootstrap
# gnulib-po/Makefile.in.in is about Gettext 0.20, which is not available in bionic. So it will break here. Override it. Don't use autopoint, which sends some other files in the past.
- cp po/Makefile.in.in gnulib-po
- ./configure --enable-gcc-warnings || { cat config.log && false; }
- make -j2
- make -j2 dist
- dist=$(echo bison*.xz)
# Unfortunately we cannot deterministically know the name of the tarball without the full
# git history (because git describe --abbrev=4 may use more than 4 characters if there are
# conflicts).
#
# So for the sake of the 'test' jobs (that don't even have the repo at all), also expose this
# tarball on a name that only depends on the Travis build number.
#
# Without -b -, exit status is always 0.
- sftp -b - [email protected] <<< "put $dist"$'\n'"ln -s $dist bison-$TRAVIS_BUILD_NUMBER.tar.xz"
## ------- ##
## First. ##
## ------- ##
@@ -20,53 +74,52 @@ matrix:
# Start with three completely different environments, to get
# errors asap.
- name: "GCC 7 -O3"
- name: "GCC 8 -O3"
stage: test
os: linux
dist: xenial
dist: bionic
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
- g++-8
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
# ASAN is time consuming, and we timeout the 50min granted by
# Travis if we run all the tests in on go. Run in two parts.
- name: "Clang 7 libc++ and ASAN part 1"
# Travis if we run all the tests in one go. Run in two parts.
- name: "Clang 8 libc++ and ASAN part 1"
stage: test
os: linux
dist: xenial
addons:
dist: bionic
addons: &clang8
apt:
sources:
- llvm-toolchain-xenial-7
- llvm-toolchain-bionic-8
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
- clang-8
- libc++-8-dev
- libc++abi-8-dev
env:
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
- MATRIX_EVAL="PART=1 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
- MATRIX_EVAL="PART=1 CC='clang-8 -fsanitize=address' CXX='clang++-8 -fsanitize=address -stdlib=libc++'"
- name: "Clang 7 libc++ and ASAN part 2"
- name: "Clang 8 libc++ and ASAN part 2"
stage: test
os: linux
dist: xenial
addons:
apt:
sources:
- llvm-toolchain-xenial-7
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
dist: bionic
addons: *clang8
env:
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
- MATRIX_EVAL="PART=2 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
- MATRIX_EVAL="PART=2 CC='clang-8 -fsanitize=address' CXX='clang++-8 -fsanitize=address -stdlib=libc++'"
- name: "ICC"
stage: test
# We need the build-aux/install-icc.sh script.
git:
clone: true
submodules: false
depth: 1
os: linux
dist: xenial
env:
@@ -81,25 +134,30 @@ matrix:
## GCC. ##
## ----- ##
#- name: "GCC 8 with sanitizers"
# os: linux
# dist: xenial
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - g++-8
# env:
# # Can't use UBSAN: I get:
# # configure:4951: gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer conftest.c
# # /usr/bin/ld: unrecognized option '--push-state' (on trusty)
# # /usr/bin/ld: unrecognized option '--push-state--no-as-needed' (on xenial)
# #
# # https://stackoverflow.com/questions/50024731/ suggests using the gold linker.
# - MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
- name: "GCC 7 with sanitizers"
os: linux
dist: bionic
addons:
apt:
packages:
- g++-7
env:
- MATRIX_EVAL="CC='gcc-7 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-7 -fsanitize=undefined,address -fno-omit-frame-pointer'"
- PART=1
- name: "GCC 7"
stage: test
os: linux
dist: bionic
addons:
apt:
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- name: "GCC 6"
stage: test
os: linux
dist: xenial
addons:
@@ -112,6 +170,7 @@ matrix:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- name: "GCC 5"
stage: test
os: linux
dist: xenial
addons:
@@ -124,6 +183,7 @@ matrix:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- name: "GCC 4.9"
stage: test
os: linux
dist: xenial
addons:
@@ -136,6 +196,7 @@ matrix:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- name: "GCC 4.8"
stage: test
os: linux
dist: xenial
addons:
@@ -148,6 +209,7 @@ matrix:
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
- name: "GCC 4.7"
stage: test
os: linux
dist: xenial
addons:
@@ -160,6 +222,7 @@ matrix:
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
- name: "GCC 4.6"
stage: test
os: linux
dist: xenial
addons:
@@ -175,7 +238,25 @@ matrix:
## Clang. ##
## ------- ##
- name: "Clang 7 -O3 and libc++"
stage: test
os: linux
dist: bionic
addons:
apt:
sources:
- llvm-toolchain-bionic-7
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
env:
- MATRIX_EVAL="CC=clang-7 && CXX='clang++-7 -stdlib=libc++'"
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
- name: "Clang 6 -O3 and libc++"
stage: test
os: linux
dist: xenial
addons:
@@ -191,6 +272,7 @@ matrix:
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
- name: "Clang 5"
stage: test
os: linux
dist: xenial
addons:
@@ -204,6 +286,7 @@ matrix:
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
- name: "Clang 4"
stage: test
os: linux
dist: xenial
addons:
@@ -216,6 +299,7 @@ matrix:
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
- name: "Clang 3.9"
stage: test
os: linux
dist: xenial
addons:
@@ -228,6 +312,7 @@ matrix:
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
- name: "Clang 3.8"
stage: test
os: linux
dist: xenial
addons:
@@ -241,6 +326,7 @@ matrix:
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
- name: "CLang 3.7"
stage: test
os: linux
dist: xenial
addons:
@@ -254,6 +340,7 @@ matrix:
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
- name: "Clang 3.6"
stage: test
os: linux
dist: xenial
addons:
@@ -267,6 +354,7 @@ matrix:
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
- name: "Clang 3.5"
stage: test
os: linux
dist: xenial
addons:
@@ -280,6 +368,7 @@ matrix:
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
- name: "Clang 3.4"
stage: test
os: linux
# Not available on Xenial.
dist: trusty
@@ -290,9 +379,10 @@ matrix:
env:
# No versioned name installed, but beware that Travis installs
# a more modern clang earlier in the default PATH.
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++ && GETTEXT_VERSION=0.18.3'
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
- name: "Clang 3.3"
stage: test
os: linux
# Not available on Xenial.
dist: trusty
@@ -302,54 +392,62 @@ matrix:
- clang-3.3
env:
# See comment for 3.4.
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++ && GETTEXT_VERSION=0.18.3'
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
## From https://docs.gitlab.com/ce/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor.
## Applies to Travis too. Applied to all the 'script's (of all the jobs).
before_script:
- 'which ssh-agent || ( sudo apt-get install openssh-client -y )'
- eval "$(ssh-agent -s)"
# $SSH_PRIVATE_KEY is multiline. Use $'...' to register its value: $'-----BEGIN OPENSSH PRIVATE KEY-----\nXXXXX...\n...==\n-----END OPENSSH PRIVATE KEY-----'.
- echo "$SSH_PRIVATE_KEY" >/tmp/key.id_rsa
- chmod 600 /tmp/key.id_rsa
- ssh-add /tmp/key.id_rsa </dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo '|1|bpc51UGxoDZjCPiwRlCStW32trI=|rfh6mLoLZv/vAvOVrpZXI1hTLxg= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIR+ckMoJTNXHvAQLHWSfrRnrNJGW2ZR6kr5pBVDGCkz1v1RcQ5rleq0NAt9kS3v4hgnuLiEVnK7KDRzcEH3ikc=' >>~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts
before_install:
# Applies only to the jobs that don't have a 'script', i.e., applies to all the 'test' jobs, but not the 'compile' one.
script:
- eval "$MATRIX_EVAL"
- env
- sudo apt-get update -qq
- sudo apt-get install -qq autoconf automake autopoint doxygen flex gettext graphviz help2man m4 texinfo
# Beware not too leak $SSH_PRIVATE_KEY.
# - env
- sudo apt-get install -qq doxygen flex m4
# Install and activate ICC.
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
# Install and activate dmd
# Install and activate dmd.
- mkdir -p ~/dlang && wget https://dlang.org/install.sh -O ~/dlang/install.sh
- source $(source ~/dlang/install.sh dmd -a)
- autoconf --version
- automake --version
- autopoint --version
- $CC --version
- $CXX --version
- dmd --version
- doxygen --version
- flex --version
- gettext --version
- dot -V
- help2man --version
- ld --version
- m4 --version
- makeinfo --version
script:
- git tag -l
# For some reasons, sometimes the checkout does not have any tags,
# so `git describe` fails, so bootstrap fails.
- git describe || git tag v3.0 -m "Fake version 3.0."
- git describe
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
# Unset this variable, otherwise, Java programs' stderr is cluttered
# with `Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m`, which makes
# the test suite fail.
- unset _JAVA_OPTIONS
- if [[ $GETTEXT_VERSION ]]; then sed -i -re "s/(AM_GNU_GETTEXT_VERSION).*/\1([$GETTEXT_VERSION])/" configure.ac; fi
- ./bootstrap
# For some reason, gnulib-po/Makefile.in.in is about Gettext 0.19, so it will break here. Override it.
- if [[ $GETTEXT_VERSION ]]; then autopoint --force; fi
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
# Fail fast from now on.
- set -e
- sftp [email protected]:bison-$TRAVIS_BUILD_NUMBER.tar.xz
- tar xf bison-$TRAVIS_BUILD_NUMBER.tar.xz
- dir=$(tar tf bison-$TRAVIS_BUILD_NUMBER.tar.xz | sed 1q)
- cd $dir
- mkdir _build
- cd _build
- ../configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
- make -j2 $MAKE_ARGS
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat test-suite.log && cat tests/testsuite.log && false; }; fi
- if test ${PART-1} = 1; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
- if test ${PART-2} = 2; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
after_script:
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
- uninstall_intel_software || true
+38 -7
View File
@@ -1,15 +1,45 @@
GNU Bison NEWS
* Noteworthy changes in release 3.3.90 (2019-04-28) [beta]
* Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
** Bug fixes
In some cases, when warnings are disabled, bison could emit tons of white
spaces as diagnostics.
When running out of memory, bison could crash (found by fuzzing).
When defining twice the EOF token, bison would crash.
New warnings from recent compilers have been addressed in the generated
parsers (yacc.c, glr.c, glr.cc).
When lone carriage-return characters appeared in the input file,
diagnostics could hang forever.
* Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
** Bug fixes
Portability fixes.
* Noteworthy changes in release 3.4 (2019-05-19) [stable]
** Deprecated features
The %pure-parser directive is deprecated in favor of '%define api.pure'
since Bison 2.3b (2008-05-27), but no warning was issued; there is one
now. Note that since Bison 2.7 you are strongly encouraged to use
'%define api.pure full' instead of '%define api.pure'.
** New features
*** Colored diagnostics
As an experimental feature, Bison now generates colored diagnostics,
controlled by the new options --color and --style.
As an experimental feature, diagnostics are now colored, controlled by the
new options --color and --style.
Install the libtextstyle library before configuring Bison to use them.
To use them, install the libtextstyle library before configuring Bison.
It is available from
https://alpha.gnu.org/gnu/gettext/
@@ -25,12 +55,13 @@ GNU Bison NEWS
To customize the styles, create a CSS file similar to
/* black-and-white.css */
/* bison-bw.css */
.warning { }
.error { font-weight: 800; text-decoration: underline; }
.note { }
then invoke bison with --style=black-and-white.css.
then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
environment variable to "bison-bw.css".
*** Disabling output
@@ -3614,7 +3645,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir bw
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
+9
View File
@@ -33,6 +33,7 @@ Bruce Lilly [email protected]
Bruno Haible [email protected]
Charles-Henri de Boysson [email protected]
Christian Burger [email protected]
Clément Démoulins [email protected]
Colin Daley [email protected]
Cris Bailiff [email protected]
Cris van Pelt [email protected]
@@ -66,6 +67,7 @@ Frank Heckenbach [email protected]
Frans Englich [email protected]
Gabriel Rassoul [email protected]
Gary L Peskin [email protected]
Gavin Smith [email protected]
Georg Sauthoff [email protected]
George Neuner [email protected]
Gilles Espinasse [email protected]
@@ -87,15 +89,18 @@ Jonathan Fabrizio [email protected]
Jonathan Nieder [email protected]
Josh Soref [email protected]
Juan Manuel Guerrero [email protected]
Karl Berry [email protected]
Kees Zeelenberg [email protected]
Keith Browne [email protected]
Ken Moffat [email protected]
Kiyoshi Kanazawa [email protected]
Laurent Mascherpa [email protected]
László Várady [email protected]
Lie Yan [email protected]
Magnus Fromreide [email protected]
Marc Autret [email protected]
Marc Mendiola [email protected]
Marc Schönefeld [email protected]
Mark Boyall [email protected]
Martin Jacobs [email protected]
Martin Mokrejs [email protected]
@@ -116,6 +121,7 @@ Mike Sullivan [email protected]
Nate Guerin [email protected]
Neil Booth [email protected]
Nelson H. F. Beebe [email protected]
neok m4700 [email protected]
Nick Bowler [email protected]
Nicolas Bedon [email protected]
Nicolas Burrus [email protected]
@@ -128,6 +134,7 @@ Oliver Mangold [email protected]
Paolo Bonzini [email protected]
Paolo Simone Gasparello [email protected]
Pascal Bart [email protected]
Patrice Dumas [email protected]
Paul Eggert [email protected]
Paul Hilfinger [email protected]
Per Allansson [email protected]
@@ -176,6 +183,7 @@ Tom Tromey [email protected]
Tommy Nordgren [email protected]
Troy A. Johnson [email protected]
Tys Lefering [email protected]
Uxio Prego [email protected]
Valentin Tolmer [email protected]
wcventure [email protected]
Victor Khomenko [email protected]
@@ -192,6 +200,7 @@ Wwp [email protected]
xolodho [email protected]
Zack Weinberg [email protected]
長田偉伸 [email protected]
江 祖铭 [email protected]
Many people are not named here because we lost track of them. We
thank them! Please, help us keeping this list up to date.
+2 -1
View File
@@ -25,7 +25,7 @@ gnulib_modules='
error extensions fdl fopen-safer
getopt-gnu
gettext-h git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script
gpl-3.0 inttypes isnan javacomp-script
javaexec-script
ldexpl
libtextstyle-optional
@@ -48,6 +48,7 @@ gnulib_modules='
xalloc
xalloc-die
xconcat-filename
xhash
xlist
xmemdup0
xstrndup
+12
View File
@@ -215,6 +215,7 @@ $LEX_IS_FLEX || test "X$LEX" = X: || {
AC_MSG_WARN([bypassing lex because flex is required])
LEX=:
}
AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX])
AM_CONDITIONAL([FLEX_CXX_WORKS],
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
AC_PROG_YACC
@@ -296,4 +297,15 @@ AC_SUBST([GCC])
AC_CONFIG_FILES([Makefile
po/Makefile.in
doc/yacc.1])
# Fix LIBOBJS to give the Makefile the right file names. Otherwise
# compilation works, but with unexpected file names, so clean rules don't
# remove the actual files and distcheck fails.
AC_CONFIG_COMMANDS_PRE([
case $am__api_version in
1.14*|1.15*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/lib_libbison_a-,g'`;;
*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/libbison_a-,g'`;;
esac
])
AC_OUTPUT
+24
View File
@@ -0,0 +1,24 @@
/* Default styling rules for Bison when doing terminal output.
Copyright (C) 2019 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 <https://www.gnu.org/licenses/>. */
/* This is an experimental feature. The class names may change in the
future. */
.warning { color: purple; }
.error { color: red; }
.note { color: cyan; }
/* Semantic values in Bison's own parser traces. */
.value { color: green; }
-10
View File
@@ -1,10 +0,0 @@
/* CSS style for Bison's diagnostics.
This is an experimental feature. The class names may change in the
future. */
.warning { color: purple; }
.error { color: red; }
.note { color: cyan; }
/* Semantic values in Bison's parser traces. */
.value { color: green; }
+1 -1
View File
@@ -16,7 +16,7 @@
dist_pkgdata_DATA = \
data/README.md \
data/diagnostics.css
data/bison-default.css
skeletonsdir = $(pkgdatadir)/skeletons
dist_skeletons_DATA = \
+2
View File
@@ -545,7 +545,9 @@ m4_if(b4_skeleton, ["yacc.c"],
# endif
]])dnl
b4_percent_code_get([[pre-printer]])dnl
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
b4_symbol_actions([printer])
YY_IGNORE_MAYBE_UNINITIALIZED_END
b4_percent_code_get([[post-printer]])dnl
[}
+6 -3
View File
@@ -1094,17 +1094,20 @@ yyinitStateSet (yyGLRStateSet* yyset)
{
yyset->yysize = 1;
yyset->yycapacity = 16;
yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
yyset->yystates
= (yyGLRState**) YYMALLOC (yyset->yycapacity * sizeof yyset->yystates[0]);
if (! yyset->yystates)
return yyfalse;
yyset->yystates[0] = YY_NULLPTR;
yyset->yylookaheadNeeds =
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
yyset->yylookaheadNeeds
= (yybool*) YYMALLOC (yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
if (! yyset->yylookaheadNeeds)
{
YYFREE (yyset->yystates);
return yyfalse;
}
memset (yyset->yylookaheadNeeds,
0, yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
return yytrue;
}
-3
View File
@@ -459,9 +459,6 @@ m4_if(b4_prefix, [yy], [],
[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
]b4_yylloc_default_define])[
// Suppress unused-variable warnings by "using" E.
#define YYUSE(E) ((void) (E))
// Enable debugging if requested.
#if ]b4_api_PREFIX[DEBUG
+134 -81
View File
@@ -2,10 +2,53 @@
@comment %**start of header
@setfilename bison.info
@documentencoding UTF-8
@documentlanguage en
@include version.texi
@settitle Bison @value{VERSION}
@setchapternewpage odd
@tex
\gdef\rgbWarning{0.50 0 0.50}
\gdef\colorWarning{%
\setcolor{\rgbWarning}%
}
\gdef\rgbError{0.80 0 0}
\gdef\colorError{%
\setcolor{\rgbError}%
}
\gdef\rgbNotice{0 0 0.80}
\gdef\colorNotice{%
\setcolor{\rgbNotice}%
}
\gdef\colorOff{%
\setcolor{\maincolor}%
}
@end tex
@ifnottex
@macro colorWarning
@inlineraw{html, <b style="color:darkviolet">}
@end macro
@macro colorError
@inlineraw{html, <b style="color:red">}
@end macro
@macro colorNotice
@inlineraw{html, <b style="color:darkcyan">}
@end macro
@macro colorOff
@inlineraw{html, </b>}
@end macro
@end ifnottex
@macro dwarning{text}
@colorWarning{}\text\@colorOff{}
@end macro
@macro derror{text}
@colorError{}\text\@colorOff{}
@end macro
@macro dnotice{text}
@colorNotice{}\text\@colorOff{}
@end macro
@finalout
@@ -13,6 +56,7 @@
@c This edition has been formatted so that you can format and print it in
@c the smallbook format.
@c @smallbook
@c @setchapternewpage odd
@c Set following if you want to document %default-prec and %no-default-prec.
@c This feature is experimental and may change in future Bison versions.
@@ -4280,24 +4324,24 @@ $@@3: %empty @{ d(); @};
exp: @@1 "b" @@2 $@@3 "e" @{ f = $1; @}
@end example
There are probably two errors in the above example: the first midrule
action does not generate a value (it does not use @code{$$} although the
final action uses it), and the value of the second one is not used (the
final action does not use @code{$3}). Bison reports these errors when the
There are probably two errors in the above example: the first midrule action
does not generate a value (it does not use @code{$$} although the final
action uses it), and the value of the second one is not used (the final
action does not use @code{$3}). Bison reports these errors when the
@code{midrule-value} warnings are enabled (@pxref{Invocation, ,Invoking
Bison}):
@example
$ @kbd{bison -Wmidrule-value mid.y}
@group
mid.y:2.6-13: warning: unset value: $$
2 | exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
| ^~~~~~~~
mid.y:2.6-13: @dwarning{warning}: unset value: $$
2 | exp: @dwarning{@{ a(); @}} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
| @dwarning{^~~~~~~~}
@end group
@group
mid.y:2.19-31: warning: unused value: $3
2 | exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
| ^~~~~~~~~~~~~
mid.y:2.19-31: @dwarning{warning}: unused value: $3
2 | exp: @{ a(); @} "b" @dwarning{@{ $$ = c(); @}} @{ d(); @} "e" @{ f = $1; @};
| @dwarning{^~~~~~~~~~~~~}
@end group
@end example
@@ -4305,9 +4349,9 @@ mid.y:2.19-31: warning: unused value: $3
It is sometimes useful to turn midrule actions into regular actions, e.g.,
to factor them, or to escape from their limitations. For instance, as an
alternative to @emph{typed} midrule action, you may bury the midrule
action inside a nonterminal symbol and to declare a printer and a destructor
for that symbol:
alternative to @emph{typed} midrule action, you may bury the midrule action
inside a nonterminal symbol and to declare a printer and a destructor for
that symbol:
@example
@group
@@ -9342,12 +9386,12 @@ useless: STR;
@command{bison} reports:
@example
calc.y: warning: 1 nonterminal useless in grammar [-Wother]
calc.y: warning: 1 rule useless in grammar [-Wother]
calc.y:19.1-7: warning: nonterminal useless in grammar: useless [-Wother]
19 | useless: STR;
| ^~~~~~~
calc.y: warning: 7 shift/reduce conflicts [-Wconflicts-sr]
calc.y: @dwarning{warning}: 1 nonterminal useless in grammar [@dwarning{-Wother}]
calc.y: @dwarning{warning}: 1 rule useless in grammar [@dwarning{-Wother}]
calc.y:19.1-7: @dwarning{warning}: nonterminal useless in grammar: useless [@dwarning{-Wother}]
19 | @dwarning{useless: STR;}
| @dwarning{^~~~~~~}
calc.y: @dwarning{warning}: 7 shift/reduce conflicts [@dwarning{-Wconflicts-sr}]
@end example
When given @option{--report=state}, in addition to @file{calc.tab.c}, it
@@ -9764,7 +9808,7 @@ Parser}, for a detailed analysis of the textual report.
@ifnotinfo
@float Figure,fig:graph
@image{figs/example, 430pt}
@center @image{figs/example, 430pt,,,.svg}
@caption{A graphical rendering of the parser.}
@end float
@end ifnotinfo
@@ -9802,7 +9846,7 @@ State 3
A Graphviz rendering of this portion of the graph could be:
@center @image{figs/example-shift, 100pt}
@center @image{figs/example-shift, 100pt,,,.svg}
@subheading Graphical Representation of Reductions
@@ -9824,7 +9868,7 @@ State 1
A Graphviz rendering of this portion of the graph could be:
@center @image{figs/example-reduce, 120pt}
@center @image{figs/example-reduce, 120pt,,,.svg}
When unresolved conflicts are present, because in deterministic parsing
a single decision can be made, Bison can arbitrarily choose to disable a
@@ -10299,15 +10343,15 @@ exp:;
@end group
@group
$ @kbd{bison -u foo.y}
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
1 | %error-verbose
| ^~~~~~~~~~~~~~
foo.y:2.1-27: error: %define variable 'parse.error' redefined
2 | %define parse.error verbose
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.y:1.1-14: @dwarning{warning}: deprecated directive, use '%define parse.error verbose' [@dwarning{-Wdeprecated}]
1 | @dwarning{%error-verbose}
| @dwarning{^~~~~~~~~~~~~~}
foo.y:2.1-27: @dwarning{warning}: %define variable 'parse.error' redefined [@dwarning{-Wother}]
2 | @dwarning{%define parse.error verbose}
| @dwarning{^~~~~~~~~~~~~~~~~~~~~~~~~~~}
foo.y:1.1-14: previous definition
1 | %error-verbose
| ^~~~~~~~~~~~~~
1 | @dnotice{%error-verbose}
| @dnotice{^~~~~~~~~~~~~~}
bison: file 'foo.y' was updated (backup: 'foo.y~')
@end group
@group
@@ -10421,19 +10465,19 @@ Bison reports:
@c width in PDF.
@example
@group
warning: useless precedence and associativity for "="
| %nonassoc "="
| ^~~
@dwarning{warning}: useless precedence and associativity for "="
| %nonassoc @dwarning{"="}
| @dwarning{^~~}
@end group
@group
warning: useless associativity for "*", use %precedence
| %left "*"
| ^~~
@dwarning{warning}: useless associativity for "*", use %precedence
| %left @dwarning{"*"}
| @dwarning{^~~}
@end group
@group
warning: useless precedence for "("
| %precedence "("
| ^~~
@dwarning{warning}: useless precedence for "("
| %precedence @dwarning{"("}
| @dwarning{^~~}
@end group
@end example
@@ -10520,29 +10564,29 @@ When invoked with @option{-fcaret} (or nothing), Bison will report:
@example
@group
in.y:3.20-23: error: ambiguous reference: '$exp'
3 | exp: exp '+' exp @{ $exp = $1 + $2; @};
| ^~~~
in.y:3.20-23: @derror{error}: ambiguous reference: '$exp'
3 | exp: exp '+' exp @{ @derror{$exp} = $1 + $2; @};
| @derror{^~~~}
@end group
@group
in.y:3.1-3: refers to: $exp at $$
3 | exp: exp '+' exp @{ $exp = $1 + $2; @};
| ^~~
3 | @dnotice{exp}: exp '+' exp @{ $exp = $1 + $2; @};
| @dnotice{^~~}
@end group
@group
in.y:3.6-8: refers to: $exp at $1
3 | exp: exp '+' exp @{ $exp = $1 + $2; @};
| ^~~
3 | exp: @dnotice{exp} '+' exp @{ $exp = $1 + $2; @};
| @dnotice{^~~}
@end group
@group
in.y:3.14-16: refers to: $exp at $3
3 | exp: exp '+' exp @{ $exp = $1 + $2; @};
| ^~~
3 | exp: exp '+' @dnotice{exp} @{ $exp = $1 + $2; @};
| @dnotice{^~~}
@end group
@group
in.y:3.32-33: error: $2 of 'exp' has no declared type
3 | exp: exp '+' exp @{ $exp = $1 + $2; @};
| ^~
in.y:3.32-33: @derror{error}: $2 of 'exp' has no declared type
3 | exp: exp '+' exp @{ $exp = $1 + @derror{$2}; @};
| @derror{^~}
@end group
@end example
@@ -10550,11 +10594,11 @@ Whereas, when invoked with @option{-fno-caret}, Bison will only report:
@example
@group
in.y:3.20-23: error: ambiguous reference: $exp
in.y:3.20-23: @derror{error}: ambiguous reference: $exp
in.y:3.1-3: refers to: $exp at $$
in.y:3.6-8: refers to: $exp at $1
in.y:3.14-16: refers to: $exp at $3
in.y:3.32-33: error: $2 of exp has no declared type
in.y:3.32-33: @derror{error}: $2 of exp has no declared type
@end group
@end example
@@ -10578,14 +10622,14 @@ exp:;
@group
$ @kbd{bison -ffixit foo.y}
foo.y:2.1-24: error: %define variable 'api.prefix' redefined
2 | %define api.prefix @{bar@}
| ^~~~~~~~~~~~~~~~~~~~~~~~
foo.y:2.1-24: @derror{error}: %define variable 'api.prefix' redefined
2 | @derror{%define api.prefix @{bar@}}
| @derror{^~~~~~~~~~~~~~~~~~~~~~~~}
foo.y:1.1-24: previous definition
1 | %define api.prefix @{foo@}
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 | @dnotice{%define api.prefix @{foo@}}
| @dnotice{^~~~~~~~~~~~~~~~~~~~~~~~}
fix-it:"foo.y":@{2:1-2:25@}:""
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
foo.y: @dwarning{warning}: fix-its can be applied. Rerun with option '--update'. [@dwarning{-Wother}]
@end group
@end example
@@ -10602,13 +10646,13 @@ exp:;
@end group
@group
$ @kbd{bison foo.y}
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
1 | %error-verbose
| ^~~~~~~~~~~~~~
foo.y:2.1-18: warning: deprecated directive, use '%define api.prefix @{foo@}' [-Wdeprecated]
2 | %name-prefix "foo"
| ^~~~~~~~~~~~~~~~~~
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
foo.y:1.1-14: @dwarning{warning}: deprecated directive, use '%define parse.error verbose' [@dwarning{-Wdeprecated}]
1 | @dwarning{%error-verbose}
| @dwarning{^~~~~~~~~~~~~~}
foo.y:2.1-18: @dwarning{warning}: deprecated directive, use '%define api.prefix @{foo@}' [@dwarning{-Wdeprecated}]
2 | @dwarning{%name-prefix "foo"}
| @dwarning{^~~~~~~~~~~~~~~~~~}
foo.y: @dwarning{warning}: fix-its can be applied. Rerun with option '--update'. [@dwarning{-Wother}]
@end group
@end example
@@ -11688,15 +11732,21 @@ symbol_type (int token, const int&, const location_type&);
symbol_type (int token, const location_type&);
@end example
@noindent
which should be used in a Flex-scanner as follows.
Correct matching between token types and value types is checked via
@code{assert}; for instance, @samp{symbol_type (ID, 42)} would abort. Named
constructors are preferable (see below), as they offer better type safety
(for instance @samp{make_ID (42)} would not even compile), but symbol_type
constructors may help when token types are discovered at run-time, e.g.,
@example
%%
[a-z]+ return yy::parser::symbol_type (TOK_IDENTIFIER, yytext, loc);
[0-9]+ return yy::parser::symbol_type (TOK_INTEGER, text_to_int (yytext), loc);
":" return yy::parser::symbol_type (':', loc);
<<EOF>> return yy::parser::symbol_type (0, loc);
@group
[a-z]+ @{
if (auto i = lookup_keyword (yytext))
return yy::parser::symbol_type (i, loc);
else
return yy::parser::make_ID (yytext, loc);
@}
@end group
@end example
@sp 1
@@ -12371,8 +12421,8 @@ You can create documentation for generated parsers using Javadoc.
Contrary to C parsers, Java parsers do not use global variables; the state
of the parser is always local to an instance of the parser class.
Therefore, all Java parsers are ``pure'', and the @code{%pure-parser} and
@code{%define api.pure} directives do nothing when used in Java.
Therefore, all Java parsers are ``pure'', and the @code{%define api.pure}
directive does nothing when used in Java.
Push parsers are currently unsupported in Java and @code{%define
api.push-pull} have no effect.
@@ -14428,7 +14478,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
@c LocalWords: YYENABLE bindtextdomain Makefile DEFS CPPFLAGS DBISON DeRemer
@c LocalWords: autoreconf Pennello multisets nondeterminism Generalised baz ACM
@c LocalWords: redeclare automata Dparse localedir datadir XSLT midrule Wno
@c LocalWords: multitable headitem hh basename Doxygen fno filename
@c LocalWords: multitable headitem hh basename Doxygen fno filename gdef
@c LocalWords: doxygen ival sval deftypemethod deallocate pos deftypemethodx
@c LocalWords: Ctor defcv defcvx arg accessors arithmetics CPP ifndef CALCXX
@c LocalWords: lexer's calcxx bool LPAREN RPAREN deallocation cerrno climits
@@ -14449,14 +14499,17 @@ London, Department of Computer Science, TR-00-12 (December 2000).
@c LocalWords: errorVerbose subtype subtypes Wmidrule midrule's src rvalues
@c LocalWords: automove evolutions Wother Wconflicts PNG lookaheads Acc sep
@c LocalWords: xsltproc XSL xsl xhtml html num Wprecedence Werror fcaret gv
@c LocalWords: fdiagnostics setlocale nullptr ast srcdir copyable iff drv
@c LocalWords: fdiagnostics setlocale nullptr ast srcdir iff drv rgbWarning
@c LocalWords: deftypefunx pragma Wnull dereference Wdocumentation elif ish
@c LocalWords: Wdeprecated Wregister noinput yyloc yypos PODs sstream Wsign
@c LocalWords: typename emplace Wconversion Wshorten yacchack reentrancy
@c LocalWords: Relocatability exprs fixit Wyacc parseable fixits ffixit
@c LocalWords: Relocatability exprs fixit Wyacc parseable fixits ffixit svg
@c LocalWords: DNDEBUG cstring Wzero workalike POPL workalikes byacc UCB
@c LocalWords: Penello's Penello Byson Byson's Corbett's CSD TOPLAS PDP
@c LocalWords: Beazley's goyacc ocamlyacc SIGACT SIGPLAN
@c LocalWords: Beazley's goyacc ocamlyacc SIGACT SIGPLAN colorWarning
@c LocalWords: setcolor rgbError colorError rgbNotice colorNotice derror
@c LocalWords: colorOff maincolor inlineraw darkviolet darkcyan dwarning
@c LocalWords: dnotice copyable
@c Local Variables:
@c ispell-dictionary: "american"
+12 -7
View File
@@ -14,7 +14,12 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
AM_MAKEINFOFLAGS = --no-split
AM_MAKEINFOFLAGS = \
--no-split \
--set-customization-variable=SECTION_NAME_IN_TITLE=true \
--set-customization-variable=AVOID_MENU_REDUNDANCY=true \
--set-customization-variable=ICONS=true
info_TEXINFOS = doc/bison.texi
doc_bison_TEXINFOS = \
$(CROSS_OPTIONS_TEXI) \
@@ -28,7 +33,7 @@ doc_bison = doc/bison
$(doc_bison).dvi: $(FIGS_GV:.gv=.eps)
$(doc_bison).info: $(FIGS_GV:.gv=.txt)
$(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
$(doc_bison).html: $(FIGS_GV:.gv=.png)
$(doc_bison).html: $(FIGS_GV:.gv=.svg)
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
CLEANDIRS += doc/bison.t2d
@@ -137,14 +142,14 @@ endif
## Graphviz examples generation. ##
## ----------------------------- ##
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
FIGS_GV = \
doc/figs/example.gv \
doc/figs/example-reduce.gv doc/figs/example-shift.gv
EXTRA_DIST += \
$(FIGS_GV) $(FIGS_GV:.gv=.txt) \
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
SUFFIXES += .gv .eps .pdf .png
$(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.svg)
SUFFIXES += .gv .eps .pdf .svg
.gv.eps:
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
@@ -156,9 +161,9 @@ SUFFIXES += .gv .eps .pdf .png
$(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp
$(AM_V_at) mv $@.tmp $@
.gv.png:
.gv.svg:
$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
$(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp
$(AM_V_at) $(DOT) -Gmargin=0 -Tsvg $< >$@.tmp
$(AM_V_at) mv $@.tmp $@
## -------------- ##
+9 -7
View File
@@ -19,15 +19,17 @@ lexcalcdir = $(docdir)/%D%
## Calc. ##
## ------ ##
check_PROGRAMS += %D%/lexcalc
TESTS += %D%/lexcalc.test
EXTRA_DIST += %D%/lexcalc.test
nodist_%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
if FLEX_WORKS
check_PROGRAMS += %D%/lexcalc
TESTS += %D%/lexcalc.test
nodist_%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
# Don't use gnulib's system headers.
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
endif FLEX_WORKS
%D%/parse.c: $(dependencies)
# Don't use gnulib's system headers.
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
EXTRA_DIST += %D%/lexcalc.test
dist_lexcalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
CLEANFILES += %D%/parse.[ch] %D%/scan.c %D%/parse.output
CLEANDIRS += %D%/*.dSYM
+11 -8
View File
@@ -19,11 +19,15 @@ reccalcdir = $(docdir)/%D%
## Calc. ##
## ------ ##
check_PROGRAMS += %D%/reccalc
TESTS += %D%/reccalc.test
EXTRA_DIST += %D%/reccalc.test %D%/scan.l
nodist_%C%_reccalc_SOURCES = %D%/parse.y %D%/scan.h %D%/scan.c
BUILT_SOURCES += $(nodist_%C%_reccalc_SOURCES)
if FLEX_WORKS
check_PROGRAMS += %D%/reccalc
TESTS += %D%/reccalc.test
nodist_%C%_reccalc_SOURCES = %D%/parse.y %D%/scan.h %D%/scan.c
BUILT_SOURCES += $(nodist_%C%_reccalc_SOURCES)
# Don't use gnulib's system headers.
%C%_reccalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
endif FLEX_WORKS
%D%/parse.c: $(dependencies)
# Tell Make that parse.o depends on scan.h, so that scan.h is built
@@ -41,12 +45,11 @@ DASH = -
$(AM_V_LEX)rm -f $@ $@.tmp
$(AM_V_at)$(MKDIR_P) %D%
$(AM_V_at)touch $@.tmp
$(AM_V_at) $(LEX) -o %D%/scan.c --header-file=%D%/scan.h $<
$(AM_V_at)$(LEX) -o%D%/scan.c --header-file=%D%/scan.h $(srcdir)/%D%/scan.l
$(AM_V_at)mv $@.tmp $@
# Don't use gnulib's system headers.
%C%_reccalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
EXTRA_DIST += %D%/reccalc.test %D%/scan.l
dist_reccalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md
CLEANFILES += %D%/parse.[ch] %D%/parse.output %D%/scan.[ch] %D%/*.stamp
CLEANDIRS += %D%/*.dSYM
+2 -2
View File
@@ -27,10 +27,10 @@ EXTRA_DIST += %D%/calc.test
%D%/calc.d: %D%/calc.y $(dependencies)
$(AM_V_GEN)$(MKDIR_P) %D%
$(AM_V_at)$(BISON) $< -o $@
$(AM_V_at)$(BISON) $(srcdir)/%D%/calc.y -o $@
%D%/calc: %D%/calc.d
$(AM_V_GEN) $(DC) $(DCFLAGS) -of$@ $<
$(AM_V_GEN) $(DC) $(DCFLAGS) -of$@ %D%/calc.d
dist_d_DATA = %D%/calc.y %D%/Makefile %D%/README.md
CLEANFILES += %D%/calc %D%/calc.[do]
+2 -2
View File
@@ -27,10 +27,10 @@ EXTRA_DIST += %D%/Calc.test
%D%/Calc.java: %D%/Calc.y $(dependencies)
$(AM_V_GEN)$(MKDIR_P) %D%
$(AM_V_at)$(BISON) $< -o $@
$(AM_V_at)$(BISON) $(srcdir)/%D%/Calc.y -o $@
%D%/Calc.class: %D%/Calc.java
$(AM_V_GEN) $(SHELL) $(top_builddir)/javacomp.sh $<
$(AM_V_GEN) $(SHELL) $(top_builddir)/javacomp.sh %D%/Calc.java
dist_java_DATA = %D%/Calc.y %D%/Makefile %D%/README.md
CLEANFILES += %D%/*.class %D%/Calc.java
+1 -1
View File
@@ -33,7 +33,7 @@
## which guarantees that parse.y is indeed shipped.
dist_noinst_SCRIPTS = %D%/extexi %D%/test
TEST_LOG_COMPILER = $(top_srcdir)/%D%/test
TEST_LOG_COMPILER = $(SHELL) $(top_srcdir)/%D%/test
AM_CXXFLAGS = \
$(WARN_CXXFLAGS) $(WARN_CXXFLAGS_TEST) $(WERROR_CXXFLAGS)
+1 -1
Submodule gnulib updated: 14a920195e...672663aca3
+18
View File
@@ -0,0 +1,18 @@
/*.gmo
/*.po
/LINGUAS
/Makefile
/Makefile.in
/Makefile.in.in
/Makevars
/Makevars.template
/POTFILES
/POTFILES.in
/Rules-quot
/bison-gnulib.pot
/boldquot.sed
/[email protected]
/[email protected]
/insert-header.sin
/quot.sed
/remove-potcdate.sin
+1
View File
@@ -321,3 +321,4 @@
/assure.h
/fsync.c
/textstyle.in.h
/xhash.c
+3
View File
@@ -63,6 +63,9 @@ m4_define([_BISON_CXXSTD_11_snippet],
for (int r: std::set<int>{1, 2})
continue;
}
// GCC 4.8.2 on Solaris 11.3 does not support to_string.
auto e = std::to_string(42);
])
m4_define([_BISON_CXXSTD_14_snippet],
+40 -27
View File
@@ -63,8 +63,6 @@ typedef enum
/** For each warning type, its severity. */
static severity warnings_flag[warnings_size];
static unsigned *indent_ptr = NULL;
styled_ostream_t errstream = NULL;
void
@@ -72,7 +70,7 @@ begin_use_class (const char *s, FILE *out)
{
if (out == stderr)
{
if (style_debug)
if (color_debug)
fprintf (out, "<%s>", s);
else
{
@@ -87,7 +85,7 @@ end_use_class (const char *s, FILE *out)
{
if (out == stderr)
{
if (style_debug)
if (color_debug)
fprintf (out, "</%s>", s);
else
{
@@ -252,25 +250,41 @@ complain_init_color (void)
{
#if HAVE_LIBTEXTSTYLE
if (color_mode == color_yes
|| color_mode == color_html
|| (color_mode == color_tty && isatty (STDERR_FILENO)))
{
style_file_prepare ("BISON_DIAGNOSTICS_STYLE", NULL,
pkgdatadir (),
"diagnostics.css");
style_file_prepare ("BISON_STYLE", "BISON_STYLEDIR", pkgdatadir (),
"bison-default.css");
/* As a fallback, use the default in the current directory. */
struct stat statbuf;
if ((style_file_name == NULL || stat (style_file_name, &statbuf) < 0)
&& stat ("diagnostics.css", &statbuf) == 0)
style_file_name = "diagnostics.css";
&& stat ("bison-default.css", &statbuf) == 0)
style_file_name = "bison-default.css";
}
else
/* No styling. */
style_file_name = NULL;
#endif
/* Workaround clang's warning (starting at Clang 3.5) about the stub
code of html_styled_ostream_create:
| src/complain.c:274:7: error: code will never be executed [-Werror,-Wunreachable-code]
| ? html_styled_ostream_create (file_ostream_create (stderr),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~ */
#if defined __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunreachable-code"
#endif
errstream =
styled_ostream_create (STDERR_FILENO, "(stderr)", TTYCTL_AUTO,
style_file_name);
color_mode == color_html
? html_styled_ostream_create (file_ostream_create (stderr),
style_file_name)
: styled_ostream_create (STDERR_FILENO, "(stderr)", TTYCTL_AUTO,
style_file_name);
#if defined __clang__
# pragma clang diagnostic pop
#endif
}
void
@@ -370,6 +384,7 @@ warnings_print_categories (warnings warn_flags, FILE *out)
*
* \param loc the location, defaulting to the current file,
* or the program name.
* \param indent optional indentation for the error message.
* \param flags the category for this message.
* \param sever to decide the prefix to put before the message
* (e.g., "warning").
@@ -381,8 +396,8 @@ warnings_print_categories (warnings warn_flags, FILE *out)
*/
static
void
error_message (const location *loc, warnings flags, severity sever,
const char *message, va_list args)
error_message (const location *loc, unsigned *indent, warnings flags,
severity sever, const char *message, va_list args)
{
unsigned pos = 0;
@@ -392,15 +407,14 @@ error_message (const location *loc, warnings flags, severity sever,
pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
pos += fprintf (stderr, ": ");
if (indent_ptr)
if (indent)
{
if (*indent_ptr)
if (*indent)
sever = severity_disabled;
if (!*indent_ptr)
*indent_ptr = pos;
else if (*indent_ptr > pos)
fprintf (stderr, "%*s", *indent_ptr - pos, "");
indent_ptr = NULL;
if (!*indent)
*indent = pos;
else if (*indent > pos)
fprintf (stderr, "%*s", *indent - pos, "");
}
const char* style = severity_style (sever);
@@ -435,8 +449,8 @@ error_message (const location *loc, warnings flags, severity sever,
/** Raise a complaint (fatal error, error or just warning). */
static void
complains (const location *loc, warnings flags, const char *message,
va_list args)
complains (const location *loc, unsigned *indent, warnings flags,
const char *message, va_list args)
{
severity s = warning_severity (flags);
if ((flags & complaint) && complaint_status < status_complaint)
@@ -446,7 +460,7 @@ complains (const location *loc, warnings flags, const char *message,
{
if (severity_error <= s && ! complaint_status)
complaint_status = status_warning_as_error;
error_message (loc, flags, s, message, args);
error_message (loc, indent, flags, s, message, args);
}
if (flags & fatal)
@@ -458,7 +472,7 @@ complain (location const *loc, warnings flags, const char *message, ...)
{
va_list args;
va_start (args, message);
complains (loc, flags, message, args);
complains (loc, NULL, flags, message, args);
va_end (args);
}
@@ -467,9 +481,8 @@ complain_indent (location const *loc, warnings flags, unsigned *indent,
const char *message, ...)
{
va_list args;
indent_ptr = indent;
va_start (args, message);
complains (loc, flags, message, args);
complains (loc, indent, flags, message, args);
va_end (args);
}
@@ -521,7 +534,7 @@ deprecated_directive (location const *loc, char const *old, char const *upd)
_("deprecated directive: %s, use %s"),
quote (old), quote_n (1, upd));
/* Register updates only if -Wdeprecated is enabled. */
if (warnings_flag[warning_deprecated] != severity_disabled)
if (warning_is_enabled (Wdeprecated))
fixits_register (loc, upd);
}
+6 -1
View File
@@ -52,6 +52,11 @@ fixit_new (location const *loc, char const* fix)
return res;
}
static int
fixit_cmp (const fixit *a, const fixit *b)
{
return location_cmp (a->location, b->location);
}
static void
fixit_free (fixit *f)
@@ -85,7 +90,7 @@ fixits_register (location const *loc, char const* fix)
(gl_listelement_dispose_fn) fixit_free,
true);
fixit *f = fixit_new (loc, fix);
gl_list_add_last (fixits, f);
gl_sortedlist_add (fixits, (gl_listelement_compar_fn) fixit_cmp, f);
if (feature_flag & feature_fixit_parsable)
fixit_print (f, stderr);
}
+9 -6
View File
@@ -45,7 +45,7 @@ bool no_lines_flag = false;
bool token_table_flag = false;
location yacc_loc = EMPTY_LOCATION_INIT;
bool update_flag = false; /* for -u */
bool style_debug = false; /* --style=debug. */
bool color_debug = false;
bool nondeterministic_parser = false;
bool glr_parser = false;
@@ -596,14 +596,17 @@ getargs_colors (int argc, char *argv[])
{
const char *arg = argv[i];
if (STRPREFIX_LIT ("--color=", arg))
handle_color_option (arg + strlen ("--color="));
{
const char *color = arg + strlen ("--color=");
if (STREQ (color, "debug"))
color_debug = true;
else
handle_color_option (color);
}
else if (STRPREFIX_LIT ("--style=", arg))
{
const char *style = arg + strlen ("--style=");
if (STREQ (style, "debug"))
style_debug = true;
else
handle_style_option (style);
handle_style_option (style);
}
}
complain_init_color ();
+1 -1
View File
@@ -41,7 +41,7 @@ extern bool no_lines_flag; /* for -l */
extern bool token_table_flag; /* for -k */
extern location yacc_loc; /* for -y */
extern bool update_flag; /* for -u */
extern bool style_debug; /* --style=debug. */
extern bool color_debug; /* --color=debug. */
/* GLR_PARSER is true if the input file says to use the GLR
(Generalized LR) parser, and to output some additional information
used by the GLR algorithm. */
+1 -1
View File
@@ -203,7 +203,7 @@ typedef struct
int expected_rr_conflicts;
const char *action;
location action_location;
location action_loc;
} rule;
/* The used rules (size NRULES). */
+43 -26
View File
@@ -30,7 +30,7 @@
#include "getargs.h"
#include "location.h"
location const empty_location = EMPTY_LOCATION_INIT;
location const empty_loc = EMPTY_LOCATION_INIT;
/* If BUF is null, add BUFSIZE (which in this case must be less than
INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to
@@ -229,7 +229,13 @@ location_caret (location loc, const char *style, FILE *out)
/* Advance to the line's position, keeping track of the offset. */
while (caret_info.line < loc.start.line)
caret_info.line += getc (caret_info.source) == '\n';
{
int c = getc (caret_info.source);
if (c == EOF)
/* Something is wrong, that line number does not exist. */
return;
caret_info.line += c == '\n';
}
caret_info.offset = ftell (caret_info.source);
/* Read the actual line. Don't update the offset, so that we keep a pointer
@@ -238,32 +244,43 @@ location_caret (location loc, const char *style, FILE *out)
int c = getc (caret_info.source);
if (c != EOF)
{
bool single_line = loc.start.line == loc.end.line;
/* Quote the file (at most the first line in the case of
multiline locations). */
fprintf (out, "%5d | ", loc.start.line);
bool single_line = loc.start.line == loc.end.line;
/* Consider that single point location (with equal boundaries)
actually denote the character that they follow. */
int byte_end = loc.end.byte +
(single_line && loc.start.byte == loc.end.byte);
/* Byte number. */
int byte = 1;
while (c != EOF && c != '\n')
{
if (byte == loc.start.byte)
begin_use_class (style, out);
fputc (c, out);
c = getc (caret_info.source);
++byte;
if (single_line
? byte == byte_end
: c == '\n' || c == EOF)
end_use_class (style, out);
}
putc ('\n', out);
{
/* Print the carets with the same indentation as above. */
fprintf (out, "%5d | ", loc.start.line);
/* Consider that single point location (with equal boundaries)
actually denote the character that they follow. */
int byte_end = loc.end.byte +
(single_line && loc.start.byte == loc.end.byte);
/* Byte number. */
int byte = 1;
/* Whether we opened the style. If the line is not as
expected (maybe the file was changed since the scanner
ran), we might reach the end before we actually saw the
opening column. */
bool opened = false;
while (c != EOF && c != '\n')
{
if (byte == loc.start.byte)
{
begin_use_class (style, out);
opened = true;
}
fputc (c, out);
c = getc (caret_info.source);
++byte;
if (opened
&& (single_line
? byte == byte_end
: c == '\n' || c == EOF))
end_use_class (style, out);
}
putc ('\n', out);
}
/* Print the carets with the same indentation as above. */
{
fprintf (out, " | %*s", loc.start.column - 1, "");
begin_use_class (style, out);
putc ('^', out);
@@ -275,8 +292,8 @@ location_caret (location loc, const char *style, FILE *out)
for (int i = loc.start.column + 1; i < len; ++i)
putc ('~', out);
end_use_class (style, out);
putc ('\n', out);
}
putc ('\n', out);
}
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ typedef struct
# define GRAM_LTYPE location
# define EMPTY_LOCATION_INIT {{NULL, 0, 0, 0}, {NULL, 0, 0, 0}}
extern location const empty_location;
extern location const empty_loc;
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
size SIZE. */
+2 -2
View File
@@ -126,8 +126,8 @@ muscle_init (void)
/* Initialize the muscle obstack. */
obstack_init (&muscle_obstack);
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
hash_compare_muscles, muscle_entry_free);
muscle_table = hash_xinitialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
hash_compare_muscles, muscle_entry_free);
/* Version and input file. */
MUSCLE_INSERT_STRING ("version", VERSION);
+2 -2
View File
@@ -372,8 +372,8 @@ user_actions_output (FILE *out)
{
fprintf (out, "%s(%d, [b4_syncline(%d, ",
rules[r].is_predicate ? "b4_predicate_case" : "b4_case",
r + 1, rules[r].action_location.start.line);
string_output (out, rules[r].action_location.start.file);
r + 1, rules[r].action_loc.start.line);
string_output (out, rules[r].action_loc.start.file);
fprintf (out, ")dnl\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);
+365 -339
View File
File diff suppressed because it is too large Load Diff
+37 -34
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.3.2.153-f5a4-dirty. */
/* A Bison parser, made by GNU Bison 3.4.1.26-d17af. */
/* Bison interface for Yacc-like parsers in C
@@ -108,32 +108,33 @@ extern int gram_debug;
PERCENT_NO_LINES = 285,
PERCENT_NONDETERMINISTIC_PARSER = 286,
PERCENT_OUTPUT = 287,
PERCENT_REQUIRE = 288,
PERCENT_SKELETON = 289,
PERCENT_START = 290,
PERCENT_TOKEN_TABLE = 291,
PERCENT_VERBOSE = 292,
PERCENT_YACC = 293,
BRACED_CODE = 294,
BRACED_PREDICATE = 295,
BRACKETED_ID = 296,
CHAR = 297,
COLON = 298,
EPILOGUE = 299,
EQUAL = 300,
ID = 301,
ID_COLON = 302,
PERCENT_PERCENT = 303,
PIPE = 304,
PROLOGUE = 305,
SEMICOLON = 306,
TAG = 307,
TAG_ANY = 308,
TAG_NONE = 309,
INT = 310,
PERCENT_PARAM = 311,
PERCENT_UNION = 312,
PERCENT_EMPTY = 313
PERCENT_PURE_PARSER = 288,
PERCENT_REQUIRE = 289,
PERCENT_SKELETON = 290,
PERCENT_START = 291,
PERCENT_TOKEN_TABLE = 292,
PERCENT_VERBOSE = 293,
PERCENT_YACC = 294,
BRACED_CODE = 295,
BRACED_PREDICATE = 296,
BRACKETED_ID = 297,
CHAR = 298,
COLON = 299,
EPILOGUE = 300,
EQUAL = 301,
ID = 302,
ID_COLON = 303,
PERCENT_PERCENT = 304,
PIPE = 305,
PROLOGUE = 306,
SEMICOLON = 307,
TAG = 308,
TAG_ANY = 309,
TAG_NONE = 310,
INT = 311,
PERCENT_PARAM = 312,
PERCENT_UNION = 313,
PERCENT_EMPTY = 314
};
#endif
@@ -159,9 +160,9 @@ union GRAM_STYPE
/* "integer" */
int INT;
/* int.opt */
int yytype_80;
int yytype_81;
/* named_ref.opt */
named_ref* yytype_92;
named_ref* yytype_93;
/* "%param" */
param_type PERCENT_PARAM;
/* token_decl */
@@ -177,7 +178,7 @@ union GRAM_STYPE
/* string_as_id */
symbol* string_as_id;
/* string_as_id.opt */
symbol* yytype_99;
symbol* yytype_100;
/* generic_symlist */
symbol_list* generic_symlist;
/* generic_symlist_item */
@@ -187,15 +188,15 @@ union GRAM_STYPE
/* token_decls */
symbol_list* token_decls;
/* token_decl.1 */
symbol_list* yytype_78;
symbol_list* yytype_79;
/* token_decls_for_prec */
symbol_list* token_decls_for_prec;
/* token_decl_for_prec.1 */
symbol_list* yytype_82;
symbol_list* yytype_83;
/* symbol_decls */
symbol_list* symbol_decls;
/* symbol_decl.1 */
symbol_list* yytype_85;
symbol_list* yytype_86;
/* "%error-verbose" */
uniqstr PERCENT_ERROR_VERBOSE;
/* "%<flag>" */
@@ -204,6 +205,8 @@ union GRAM_STYPE
uniqstr PERCENT_FILE_PREFIX;
/* "%name-prefix" */
uniqstr PERCENT_NAME_PREFIX;
/* "%pure-parser" */
uniqstr PERCENT_PURE_PARSER;
/* "%yacc" */
uniqstr PERCENT_YACC;
/* "[identifier]" */
@@ -215,7 +218,7 @@ union GRAM_STYPE
/* "<tag>" */
uniqstr TAG;
/* tag.opt */
uniqstr yytype_72;
uniqstr yytype_73;
/* tag */
uniqstr tag;
/* variable */
+22 -4
View File
@@ -49,7 +49,7 @@
#include "xmemdup0.h"
static int current_prec = 0;
static location current_lhs_location;
static location current_lhs_loc;
static named_ref *current_lhs_named_ref;
static symbol *current_lhs_symbol;
static symbol_class current_class = unknown_sym;
@@ -94,6 +94,9 @@
static void handle_name_prefix (location const *loc,
char const *directive, char const *value);
/* Handle a %pure-parser directive. */
static void handle_pure_parser (location const *loc, char const *directive);
/* Handle a %require directive. */
static void handle_require (location const *loc, char const *version);
@@ -181,6 +184,7 @@
PERCENT_NONDETERMINISTIC_PARSER
"%nondeterministic-parser"
PERCENT_OUTPUT "%output"
PERCENT_PURE_PARSER "%pure-parser"
PERCENT_REQUIRE "%require"
PERCENT_SKELETON "%skeleton"
PERCENT_START "%start"
@@ -219,7 +223,7 @@
%type <uniqstr>
BRACKETED_ID ID ID_COLON
PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX
PERCENT_YACC
PERCENT_PURE_PARSER PERCENT_YACC
TAG tag tag.opt variable
%printer { fputs ($$, yyo); } <uniqstr>
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
@@ -343,6 +347,7 @@ prologue_declaration:
| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" STRING { spec_outfile = $2; }
| "%param" { current_param = $1; } params { current_param = param_none; }
| "%pure-parser" { handle_pure_parser (&@$, $1); }
| "%require" STRING { handle_require (&@2, $2); }
| "%skeleton" STRING { handle_skeleton (&@2, $2); }
| "%token-table" { token_table_flag = true; }
@@ -651,7 +656,7 @@ rhses.1:
%token PERCENT_EMPTY "%empty";
rhs:
%empty
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_loc,
current_lhs_named_ref); }
| rhs symbol named_ref.opt
{ grammar_current_rule_symbol_append ($2, @2, $3); }
@@ -910,6 +915,7 @@ handle_file_prefix (location const *loc,
deprecated_directive (dir_loc, directive, "%file-prefix");
}
static void
handle_name_prefix (location const *loc,
char const *directive, char const *value)
@@ -944,6 +950,16 @@ handle_name_prefix (location const *loc,
}
static void
handle_pure_parser (location const *loc, char const *directive)
{
bison_directive (loc, directive);
deprecated_directive (loc, directive, "%define api.pure");
muscle_percent_define_insert ("api.pure", *loc, muscle_keyword, "",
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
static void
handle_require (location const *loc, char const *version)
{
@@ -1006,6 +1022,7 @@ handle_skeleton (location const *loc, char const *skel)
skeleton_arg (skeleton_user, grammar_prio, *loc);
}
static void
handle_yacc (location const *loc, char const *directive)
{
@@ -1026,6 +1043,7 @@ handle_yacc (location const *loc, char const *directive)
deprecated_directive (loc, directive, "%fixed-output-files");
}
static void
gram_error (location const *loc, char const *msg)
{
@@ -1050,7 +1068,7 @@ void
current_lhs (symbol *sym, location loc, named_ref *ref)
{
current_lhs_symbol = sym;
current_lhs_location = loc;
current_lhs_loc = loc;
if (sym)
symbol_location_as_lhs_set (sym, loc);
/* In order to simplify memory management, named references for lhs
+38 -37
View File
@@ -62,7 +62,7 @@ grammar_start_symbol_set (symbol *sym, location loc)
{
start_flag = true;
startsymbol = sym;
startsymbol_location = loc;
startsymbol_loc = loc;
}
}
@@ -131,12 +131,12 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
quote (merge_function->name), type,
merge_function->type);
indent += SUB_INDENT;
complain_indent (&merge_function->type_declaration_location, complaint,
complain_indent (&merge_function->type_declaration_loc, complaint,
&indent,
_("previous declaration"));
}
merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc;
merge_function->type_declaration_loc = declaration_loc;
}
/*--------------------------------------.
@@ -295,7 +295,7 @@ grammar_rule_check_and_complete (symbol_list *r)
char const *rhs_type =
first_rhs->content->type_name ? first_rhs->content->type_name : "";
if (!UNIQSTR_EQ (lhs_type, rhs_type))
complain (&r->location, Wother,
complain (&r->rhs_loc, Wother,
_("type clash on default action: <%s> != <%s>"),
lhs_type, rhs_type);
else
@@ -308,7 +308,7 @@ grammar_rule_check_and_complete (symbol_list *r)
if (is_cxx)
{
code_props_rule_action_init (&r->action_props, "{ $$ = $1; }",
r->location, r,
r->rhs_loc, r,
/* name */ NULL,
/* type */ NULL,
/* is_predicate */ false);
@@ -318,7 +318,7 @@ grammar_rule_check_and_complete (symbol_list *r)
}
/* Warn if there is no default for $$ but we need one. */
else
complain (&r->location, Wother,
complain (&r->rhs_loc, Wother,
_("empty rule for typed nonterminal, and no action"));
}
@@ -335,9 +335,9 @@ grammar_rule_check_and_complete (symbol_list *r)
{
warnings warn_flag = midrule_warning ? Wmidrule_values : Wother;
if (n)
complain (&l->location, warn_flag, _("unused value: $%d"), n);
complain (&l->sym_loc, warn_flag, _("unused value: $%d"), n);
else
complain (&l->location, warn_flag, _("unset value: $$"));
complain (&l->rhs_loc, warn_flag, _("unset value: $$"));
}
}
}
@@ -357,9 +357,10 @@ grammar_rule_check_and_complete (symbol_list *r)
&& !r->percent_empty_loc.start.file
&& warning_is_enabled (Wempty_rule))
{
complain (&r->location, Wempty_rule,
_("empty rule without %%empty"));
fixits_register (&r->location, " %empty ");
complain (&r->rhs_loc, Wempty_rule, _("empty rule without %%empty"));
location loc = r->rhs_loc;
loc.end = loc.start;
fixits_register (&loc, " %empty ");
}
/* See comments in grammar_current_rule_prec_set for how POSIX
@@ -369,12 +370,12 @@ grammar_rule_check_and_complete (symbol_list *r)
&& r->ruleprec->tag[0] != '\'' && r->ruleprec->tag[0] != '"'
&& r->ruleprec->content->status != declared
&& !r->ruleprec->content->prec)
complain (&r->location, Wother,
complain (&r->rhs_loc, Wother,
_("token for %%prec is not defined: %s"), r->ruleprec->tag);
/* Check that the (main) action was not typed. */
if (r->action_props.type)
complain (&r->location, Wother,
complain (&r->rhs_loc, Wother,
_("only midrule actions can be typed: %s"), r->action_props.type);
}
@@ -387,8 +388,8 @@ void
grammar_current_rule_end (location loc)
{
/* Put an empty link in the list to mark the end of this rule */
grammar_symbol_append (NULL, grammar_end->location);
current_rule->location = loc;
grammar_symbol_append (NULL, grammar_end->rhs_loc);
current_rule->rhs_loc = loc;
}
@@ -408,11 +409,11 @@ grammar_midrule_action (void)
/* Make a DUMMY nonterminal, whose location is that of the midrule
action. Create the MIDRULE. */
location dummy_location = current_rule->action_props.location;
symbol *dummy = dummy_symbol_get (dummy_location);
location dummy_loc = current_rule->action_props.location;
symbol *dummy = dummy_symbol_get (dummy_loc);
symbol_type_set(dummy,
current_rule->action_props.type, current_rule->action_props.location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_loc);
/* Remember named_ref of previous action. */
named_ref *action_name = current_rule->action_props.named_ref;
@@ -422,7 +423,7 @@ grammar_midrule_action (void)
++nrules;
++nritems;
/* Attach its location and actions to that of the DUMMY. */
midrule->location = dummy_location;
midrule->rhs_loc = dummy_loc;
code_props_rule_action_init (&midrule->action_props,
current_rule->action_props.code,
current_rule->action_props.location,
@@ -443,14 +444,14 @@ grammar_midrule_action (void)
grammar = midrule;
/* End the dummy's rule. */
midrule->next = symbol_list_sym_new (NULL, dummy_location);
midrule->next = symbol_list_sym_new (NULL, dummy_loc);
midrule->next->next = current_rule;
previous_rule_end = midrule->next;
/* Insert the dummy nonterminal replacing the midrule action into
the current rule. Bind it to its dedicated rule. */
grammar_current_rule_symbol_append (dummy, dummy_location,
grammar_current_rule_symbol_append (dummy, dummy_loc,
action_name);
grammar_end->midrule = midrule;
midrule->midrule_parent_rule = current_rule;
@@ -509,11 +510,11 @@ grammar_current_rule_dprec_set (int dprec, location loc)
"%dprec");
else if (current_rule->dprec != 0)
duplicate_rule_directive ("%dprec",
current_rule->dprec_location, loc);
current_rule->dprec_loc, loc);
else
{
current_rule->dprec = dprec;
current_rule->dprec_location = loc;
current_rule->dprec_loc = loc;
}
}
@@ -528,11 +529,11 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
"%merge");
if (current_rule->merger != 0)
duplicate_rule_directive ("%merge",
current_rule->merger_declaration_location, loc);
current_rule->merger_declaration_loc, loc);
else
{
current_rule->merger = get_merge_function (name);
current_rule->merger_declaration_location = loc;
current_rule->merger_declaration_loc = loc;
}
}
@@ -622,7 +623,7 @@ packgram (void)
{
symbol_list *lhs = p;
record_merge_function_type (lhs->merger, lhs->content.sym->content->type_name,
lhs->merger_declaration_location);
lhs->merger_declaration_loc);
/* If the midrule's $$ is set or its $n is used, remove the '$' from the
symbol name so that it's a user-defined symbol so that the default
%destructor and %printer apply. */
@@ -647,10 +648,10 @@ packgram (void)
rules[ruleno].dprec = lhs->dprec;
rules[ruleno].merger = lhs->merger;
rules[ruleno].precsym = NULL;
rules[ruleno].location = lhs->location;
rules[ruleno].location = lhs->rhs_loc;
rules[ruleno].useful = true;
rules[ruleno].action = lhs->action_props.code;
rules[ruleno].action_location = lhs->action_props.location;
rules[ruleno].action_loc = lhs->action_props.location;
rules[ruleno].is_predicate = lhs->action_props.is_predicate;
rules[ruleno].expected_sr_conflicts = lhs->expected_sr_conflicts;
rules[ruleno].expected_rr_conflicts = lhs->expected_rr_conflicts;
@@ -713,18 +714,18 @@ reader (void)
symbols_new ();
/* Construct the accept symbol. */
accept = symbol_get ("$accept", empty_location);
accept = symbol_get ("$accept", empty_loc);
accept->content->class = nterm_sym;
accept->content->number = nvars++;
/* Construct the error token */
errtoken = symbol_get ("error", empty_location);
errtoken = symbol_get ("error", empty_loc);
errtoken->content->class = token_sym;
errtoken->content->number = ntokens++;
/* Construct a token that represents all undefined literal tokens.
It is always token number 2. */
undeftoken = symbol_get ("$undefined", empty_location);
undeftoken = symbol_get ("$undefined", empty_loc);
undeftoken->content->class = token_sym;
undeftoken->content->number = ntokens++;
@@ -801,7 +802,7 @@ check_and_convert_grammar (void)
/* If the user did not define her ENDTOKEN, do it now. */
if (!endtoken)
{
endtoken = symbol_get ("$end", empty_location);
endtoken = symbol_get ("$end", empty_loc);
endtoken->content->class = token_sym;
endtoken->content->number = 0;
/* Value specified by POSIX. */
@@ -823,11 +824,11 @@ check_and_convert_grammar (void)
$accept: %start $end. */
{
symbol_list *p = symbol_list_sym_new (accept, empty_location);
p->location = grammar->location;
p->next = symbol_list_sym_new (startsymbol, empty_location);
p->next->next = symbol_list_sym_new (endtoken, empty_location);
p->next->next->next = symbol_list_sym_new (NULL, empty_location);
symbol_list *p = symbol_list_sym_new (accept, empty_loc);
p->rhs_loc = grammar->rhs_loc;
p->next = symbol_list_sym_new (startsymbol, empty_loc);
p->next->next = symbol_list_sym_new (endtoken, empty_loc);
p->next->next->next = symbol_list_sym_new (NULL, empty_loc);
p->next->next->next->next = grammar;
nrules += 1;
nritems += 3;
+1 -1
View File
@@ -32,7 +32,7 @@ typedef struct merger_list
struct merger_list* next;
uniqstr name;
uniqstr type;
location type_declaration_location;
location type_declaration_loc;
} merger_list;
/* From the parser. */
+1 -1
View File
@@ -382,7 +382,7 @@ reduce_grammar (void)
reduce_print ();
if (!bitset_test (N, accept->content->number - ntokens))
complain (&startsymbol_location, fatal,
complain (&startsymbol_loc, fatal,
_("start symbol %s does not derive any sentence"),
startsymbol->tag);
+5 -5
View File
@@ -57,8 +57,8 @@ static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
/* A string to be pushed to obstack after dollar/at has been handled. */
static char *ref_tail_fields;
static location the_location;
static location *loc = &the_location;
static location current_loc;
static location *loc = &current_loc;
/* A string representing the most recent translation. */
static char *last_string;
@@ -187,7 +187,7 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
"@$" {
obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
muscle_percent_define_ensure("locations", the_location, true);
muscle_percent_define_ensure("locations", *loc, true);
}
}
@@ -507,12 +507,12 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
dollar_or_at);
}
else if (midrule_rhs_index)
complain_indent (&rule->location, complaint, &indent,
complain_indent (&rule->rhs_loc, complaint, &indent,
_("symbol not found in production before $%d: "
"%.*s"),
midrule_rhs_index, len, cp);
else
complain_indent (&rule->location, complaint, &indent,
complain_indent (&rule->rhs_loc, complaint, &indent,
_("symbol not found in production: %.*s"),
len, cp);
+5 -3
View File
@@ -161,7 +161,7 @@ eqopt ({sp}=)?
int context_state PACIFY_CC (= 0);
/* Location of most recent identifier, when applicable. */
location id_loc PACIFY_CC (= empty_location);
location id_loc PACIFY_CC (= empty_loc);
/* Where containing code started, when applicable. Its initial
value is relevant only when yylex is invoked in the SC_EPILOGUE
@@ -252,7 +252,6 @@ eqopt ({sp}=)?
"%prec" return PERCENT_PREC;
"%precedence" return BISON_DIRECTIVE (PRECEDENCE);
"%printer" return BISON_DIRECTIVE (PRINTER);
"%pure-parser" RETURN_PERCENT_FLAG ("api.pure");
"%require" return BISON_DIRECTIVE (REQUIRE);
"%right" return PERCENT_RIGHT;
"%skeleton" return BISON_DIRECTIVE (SKELETON);
@@ -265,6 +264,10 @@ eqopt ({sp}=)?
"%verbose" return BISON_DIRECTIVE (VERBOSE);
"%yacc" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
/* Deprecated since Bison 2.3b (2008-05-27), but the warning is
issued only since Bison 3.4. */
"%pure"[-_]"parser" RETURN_VALUE (PERCENT_PURE_PARSER, uniqstr_new (yytext));
/* Deprecated since Bison 3.0 (2013-07-25), but the warning is
issued only since Bison 3.3. */
"%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
@@ -282,7 +285,6 @@ eqopt ({sp}=)?
"%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec");
"%no"[-_]"lines" DEPRECATED ("%no-lines");
"%output"{eqopt} DEPRECATED ("%output");
"%pure"[-_]"parser" DEPRECATED ("%pure-parser");
"%token"[-_]"table" DEPRECATED ("%token-table");
"%"{id} {
+5 -5
View File
@@ -359,11 +359,11 @@ state_hasher (void const *s, size_t tablesize)
void
state_hash_new (void)
{
state_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
state_hasher,
state_comparator,
NULL);
state_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
state_hasher,
state_comparator,
NULL);
}
+6 -5
View File
@@ -34,7 +34,7 @@ symbol_list_sym_new (symbol *sym, location loc)
res->content_type = SYMLIST_SYMBOL;
res->content.sym = sym;
res->location = res->sym_loc = loc;
res->sym_loc = loc;
res->named_ref = NULL;
res->midrule = NULL;
@@ -42,13 +42,14 @@ symbol_list_sym_new (symbol *sym, location loc)
res->midrule_parent_rhs_index = 0;
/* Members used for LHS only. */
res->rhs_loc = empty_loc;
res->ruleprec = NULL;
res->percent_empty_loc = empty_location;
res->percent_empty_loc = empty_loc;
code_props_none_init (&res->action_props);
res->dprec = 0;
res->dprec_location = empty_location;
res->dprec_loc = empty_loc;
res->merger = 0;
res->merger_declaration_location = empty_location;
res->merger_declaration_loc = empty_loc;
res->expected_sr_conflicts = -1;
res->expected_rr_conflicts = -1;
@@ -73,7 +74,7 @@ symbol_list_type_new (uniqstr type_name, location loc)
res->content.sem_type->location = loc;
res->content.sem_type->status = undeclared;
res->location = res->sym_loc = loc;
res->sym_loc = loc;
res->named_ref = NULL;
res->next = NULL;
+6 -4
View File
@@ -50,7 +50,6 @@ typedef struct symbol_list
*/
semantic_type *sem_type;
} content;
location location;
/* Named reference. */
named_ref *named_ref;
@@ -74,6 +73,9 @@ typedef struct symbol_list
| when several RHSs are bound to a single lhs via "|"). |
`--------------------------------------------------------------*/
/* Location of the RHS. */
location rhs_loc;
/* Precedence/associativity. */
symbol *ruleprec;
@@ -82,13 +84,13 @@ typedef struct symbol_list
code_props action_props;
/* The location of the first %empty for this rule, or \a
empty_location. */
empty_loc. */
location percent_empty_loc;
int dprec;
location dprec_location;
location dprec_loc;
int merger;
location merger_declaration_location;
location merger_declaration_loc;
/* Counts of the number of expected conflicts for this rule, or -1 if none
given. */
+33 -27
View File
@@ -46,7 +46,7 @@ symbol *undeftoken = NULL;
symbol *endtoken = NULL;
symbol *accept = NULL;
symbol *startsymbol = NULL;
location startsymbol_location;
location startsymbol_loc;
/* Precedence relation graph. */
static symgraph **prec_nodes;
@@ -198,7 +198,7 @@ semantic_type_new (uniqstr tag, const location *loc)
uniqstr_assert (tag);
res->tag = tag;
res->location = loc ? *loc : empty_location;
res->location = loc ? *loc : empty_loc;
res->status = undeclared;
for (int i = 0; i < CODE_PROPS_SIZE; ++i)
code_props_none_init (&res->props[i]);
@@ -339,12 +339,12 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
tag_seen = true;
if (sym->content->type_name)
complain_symbol_redeclared (sym, "%type",
sym->content->type_location, loc);
sym->content->type_loc, loc);
else
{
uniqstr_assert (type_name);
sym->content->type_name = type_name;
sym->content->type_location = loc;
sym->content->type_loc = loc;
}
}
}
@@ -426,12 +426,12 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
sym_content *s = sym->content;
if (s->prec)
complain_symbol_redeclared (sym, assoc_to_string (a),
s->prec_location, loc);
s->prec_loc, loc);
else
{
s->prec = prec;
s->assoc = a;
s->prec_location = loc;
s->prec_loc = loc;
}
}
@@ -462,7 +462,13 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
if (declaring)
{
if (s->status == declared)
complain (&loc, Wother, _("symbol %s redeclared"), sym->tag);
{
unsigned i = 0;
complain (&loc, Wother, _("symbol %s redeclared"), sym->tag);
i += SUB_INDENT;
complain_indent (&sym->location, Wother, &i,
_("previous declaration"));
}
else
s->status = declared;
}
@@ -489,7 +495,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
{
*user_token_numberp = user_token_number;
/* User defined $end token? */
if (user_token_number == 0)
if (user_token_number == 0 && !endtoken)
{
endtoken = sym->content->symbol;
/* It is always mapped to 0, so it was already counted in
@@ -587,10 +593,10 @@ symbol_merge_properties (symbol *sym, symbol *str)
{
if (str->content->type_name)
symbol_type_set (sym,
str->content->type_name, str->content->type_location);
str->content->type_name, str->content->type_loc);
else
symbol_type_set (str,
sym->content->type_name, sym->content->type_location);
sym->content->type_name, sym->content->type_loc);
}
@@ -604,10 +610,10 @@ symbol_merge_properties (symbol *sym, symbol *str)
{
if (str->content->prec)
symbol_precedence_set (sym, str->content->prec, str->content->assoc,
str->content->prec_location);
str->content->prec_loc);
else
symbol_precedence_set (str, sym->content->prec, sym->content->assoc,
sym->content->prec_location);
sym->content->prec_loc);
}
}
@@ -773,16 +779,16 @@ hash_semantic_type_hasher (void const *m, size_t tablesize)
void
symbols_new (void)
{
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_symbol_hasher,
hash_symbol_comparator,
symbol_free);
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_semantic_type_hasher,
hash_semantic_type_comparator,
free);
symbol_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
hash_symbol_hasher,
hash_symbol_comparator,
symbol_free);
semantic_type_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
hash_semantic_type_hasher,
hash_semantic_type_comparator,
free);
}
@@ -1034,11 +1040,11 @@ symbols_pack (void)
symbols_token_translations_init ();
if (startsymbol->content->class == unknown_sym)
complain (&startsymbol_location, fatal,
complain (&startsymbol_loc, fatal,
_("the start symbol %s is undefined"),
startsymbol->tag);
else if (startsymbol->content->class == token_sym)
complain (&startsymbol_location, fatal,
complain (&startsymbol_loc, fatal,
_("the start symbol %s is a token"),
startsymbol->tag);
}
@@ -1209,14 +1215,14 @@ print_precedence_warnings (void)
&& !prec_nodes[i]->succ)
{
if (is_assoc_useless (s))
complain (&s->content->prec_location, Wprecedence,
complain (&s->content->prec_loc, Wprecedence,
_("useless precedence and associativity for %s"), s->tag);
else if (s->content->assoc == precedence_assoc)
complain (&s->content->prec_location, Wprecedence,
complain (&s->content->prec_loc, Wprecedence,
_("useless precedence for %s"), s->tag);
}
else if (is_assoc_useless (s))
complain (&s->content->prec_location, Wprecedence,
complain (&s->content->prec_loc, Wprecedence,
_("useless associativity for %s, use %%precedence"), s->tag);
}
free (used_assoc);
+3 -3
View File
@@ -122,7 +122,7 @@ struct sym_content
uniqstr type_name;
/** Its \c \%type's location. */
location type_location;
location type_loc;
/** Any \c \%destructor (resp. \%printer) declared specificially for this
symbol.
@@ -134,7 +134,7 @@ struct sym_content
code_props props[CODE_PROPS_SIZE];
symbol_number number;
location prec_location;
location prec_loc;
int prec;
assoc assoc;
@@ -246,7 +246,7 @@ extern symbol *accept;
/** The user start symbol. */
extern symbol *startsymbol;
/** The location of the \c \%start declaration. */
extern location startsymbol_location;
extern location startsymbol_loc;
/** Whether a symbol declared with a type tag. */
extern bool tag_seen;
+5 -5
View File
@@ -157,11 +157,11 @@ hash_uniqstr (void const *m, size_t tablesize)
void
uniqstrs_new (void)
{
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_uniqstr,
hash_compare_uniqstr,
free);
uniqstrs_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
hash_uniqstr,
hash_compare_uniqstr,
free);
}
+43 -11
View File
@@ -196,16 +196,8 @@ one.y:11.3-8: previous declaration
bison: file 'one.y' was updated (backup: 'one.y~')
]])
AT_CHECK([cat one.y], [],
[[%code top {
/* Load config.h, and adjust to the compiler.
We used to do it here, but each time we add a new line,
we have to adjust all the line numbers in error messages.
It's simpler to use a constant include to a varying file. */
#include <testsuite.h>
}
%%
AT_CHECK([sed -e '1,8d' one.y], [],
[[%%
exp:
%empty {} @&t@
;
@@ -267,6 +259,46 @@ AT_BISON_OPTION_POPDEFS
AT_CLEANUP
## -------------------- ##
## Add missing %empty. ##
## -------------------- ##
AT_SETUP([Add missing %empty])
AT_DATA([input.y],
[[%%
exp: a b c d e
a: {}
b:{
};
c:
d
:
e:
%%
]])
AT_BISON_CHECK([--update -Wall input.y], [], [], [ignore])
AT_CHECK([cat input.y], [],
[[%%
exp: a b c d e
a: %empty {}
b: %empty {
};
c: %empty @&t@
d
: %empty @&t@
e: %empty @&t@
%%
]])
# No warnings.
AT_BISON_CHECK([-Wall input.y])
AT_CLEANUP
## ------------------ ##
## Initial location. ##
## ------------------ ##
@@ -1838,7 +1870,7 @@ AT_DATA_GRAMMAR([input.y],
[[
%define parse.error verbose
%debug
%pure-parser
%define api.pure
%code {
# include <stdio.h>
# include <stdlib.h>
+6
View File
@@ -118,8 +118,14 @@ fi
## Other. ##
## ------- ##
# Empty if no D compiler was found.
: ${DC='@DC@'}
: ${DCFLAGS='@DCFLAGS@'}
if test x"$DC" = x; then
BISON_DC_WORKS=false
else
BISON_DC_WORKS=true
fi
# Empty if no javac was found
: ${CONF_JAVAC='@CONF_JAVAC@'}
+2 -2
View File
@@ -313,7 +313,7 @@ AT_DATA_GRAMMAR([list.y],
}
#if defined __cplusplus && 201103L <= __cplusplus
string (string&& s)
string (string&& s) noexcept
: val_(std::move(s.val_))
{
s.val_.clear();
@@ -893,7 +893,7 @@ error-reduce:
consistent-error:
'a'
| /*empty*/ %prec 'a'
| %empty %prec 'a'
;
// Provide another context in which all rules are useful so that this
+5 -5
View File
@@ -278,17 +278,17 @@ AT_DATA([[input.y]],
[[%expect 1
%%
exp: e 'e';
e: 'e' | /* Nothing. */;
e: 'e' | %empty;
]])
AT_BISON_CHECK([-o input.c input.y], 0, [],
[[input.y:4.9: warning: rule useless in parser due to conflicts [-Wother]
[[input.y:4.10-15: warning: rule useless in parser due to conflicts [-Wother]
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0, [],
[[input.y:4.9: warning: rule useless in parser due to conflicts [-Wother]
4 | e: 'e' | /* Nothing. */;
| ^
[[input.y:4.10-15: warning: rule useless in parser due to conflicts [-Wother]
4 | e: 'e' | %empty;
| ^~~~~~
]])
AT_CLEANUP
+76 -5
View File
@@ -20,6 +20,8 @@ AT_BANNER([[Diagnostics.]])
# AT_TEST($1: TITLE, $2: GRAMMAR, $3: EXIT-STATUS, $4: OUTPUT-WITH-STYLE)
# -----------------------------------------------------------------------
# Run Bison on GRAMMAR with debugging style enabled, and expect
# OUTPUT-WITH-STYLE as diagnostics.
m4_pushdef([AT_TEST],
[
AT_SETUP([$1])
@@ -33,17 +35,23 @@ AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]], [$2])
AT_DATA([experr.orig], [$4])
# For some reason, literal ^M in the input are removed and don't end
# in `input.y`. So use the two-character ^M represent it, and let
# Perl insert real CR characters.
AT_CHECK([perl -pi -e 's{\^M}{\r}gx' input.y])
AT_DATA([experr], [$4])
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
# When no style, same messages, but without style.
AT_CHECK([perl -p -e 's{</?\w+>}{}g' <experr.orig >experr])
AT_CHECK([perl -pi -e 's{(</?\w+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' experr])
# Cannot use AT_BISON_CHECK easily as we need to change the
# environment.
# FIXME: Enhance AT_BISON_CHECK.
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret -Wall input.y], [$3], [], [experr])
AT_CHECK([cp experr.orig experr])
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --style=debug -Wall input.y], [$3], [], [experr])
AT_BISON_OPTION_POPDEFS
@@ -65,18 +73,33 @@ exp: %empty;
[[input.y:9.12-14: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
9 | %token FOO <warning>FOO</warning> FOO
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:9.16-18: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
9 | %token FOO FOO <warning>FOO</warning>
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:10.8-10: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
10 | %token <warning>FOO</warning> FOO FOO
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:10.13-15: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
10 | %token FOO <warning>FOO</warning> FOO
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:10.18-20: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
10 | %token FOO FOO <warning>FOO</warning>
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
]])
@@ -221,7 +244,7 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
# Locations coming from m4 need the byte-column for diagnostics.
AT_TEST([[Locations from M4]],
AT_TEST([[Tabulations and multibyte characters from M4]],
[[%define api.prefix {sun}
%define api.prefix {🌞}
%%
@@ -238,5 +261,53 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
]])
## ----------------- ##
## Carriage return. ##
## ----------------- ##
# Carriage-return used to count as a newline in the scanner, and not
# in diagnostics. Resulting in all sort of nice bugs.
AT_TEST([[Carriage return]],
[[^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M
%token "
%%
]],
[1],
[[input.y:37.8-38.0: <error>error:</error> missing '"' at end of line
input.y:37.8-38.0: <error>error:</error> syntax error, unexpected string, expecting char or identifier or <tag>
]])
m4_popdef([AT_TEST])
## -------------------------------------- ##
## Indentation with message suppression. ##
## -------------------------------------- ##
AT_SETUP([[Indentation with message suppression]])
# https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00002.html
AT_DATA([[input.y]],
[[%define api.pure
%pure-parser
%error-verbose
%%
exp : '0'
]])
AT_BISON_CHECK([[-fcaret -Wno-other input.y]], [0], [],
[[input.y:2.1-12: warning: deprecated directive, use '%define api.pure' [-Wdeprecated]
2 | %pure-parser
| ^~~~~~~~~~~~
input.y:3.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
3 | %error-verbose
| ^~~~~~~~~~~~~~
]])
AT_CLEANUP
+3 -3
View File
@@ -591,7 +591,7 @@ AT_DATA_GRAMMAR([glr-regr7.y],
start:
stack1 start
| stack2 start
| /* empty */
| %empty
;
stack1: 'a' ;
stack2: 'a' ;
@@ -680,11 +680,11 @@ InterfaceDeclaration : OptConstantWord %dprec 1
| OptSignalWord %dprec 2
;
OptConstantWord : /* empty */
OptConstantWord : %empty
| T_CONSTANT
;
OptSignalWord : /* empty */
OptSignalWord : %empty
{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
| T_SIGNAL
;
+43 -14
View File
@@ -615,6 +615,44 @@ AT_CHECK_UNUSED_VALUES([1], [1])
AT_CLEANUP
## ------------------- ##
## Symbol redeclared. ##
## ------------------- ##
AT_SETUP([Symbol redeclared])
AT_DATA([[input.y]],
[[%token FOO FOO
%token BAR 12 BAR 12
%token EOF 0 EOF 0
%%
exp: FOO BAR
]])
AT_BISON_CHECK([-fcaret input.y], [0], [],
[[input.y:1.12-14: warning: symbol FOO redeclared [-Wother]
1 | %token FOO FOO
| ^~~
input.y:1.8-10: previous declaration
1 | %token FOO FOO
| ^~~
input.y:2.15-17: warning: symbol BAR redeclared [-Wother]
2 | %token BAR 12 BAR 12
| ^~~
input.y:2.8-10: previous declaration
2 | %token BAR 12 BAR 12
| ^~~
input.y:3.14-16: warning: symbol EOF redeclared [-Wother]
3 | %token EOF 0 EOF 0
| ^~~
input.y:3.8-10: previous declaration
3 | %token EOF 0 EOF 0
| ^~~
]])
AT_CLEANUP
## --------------------------- ##
## Symbol class redefinition. ##
## --------------------------- ##
@@ -2556,8 +2594,8 @@ input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wd
fix-it:"input.y":{23:1-23:10}:"%no-lines"
input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
fix-it:"input.y":{24:1-24:10}:"%output"
input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
fix-it:"input.y":{25:1-25:13}:"%pure-parser"
input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%define api.pure' [-Wdeprecated]
fix-it:"input.y":{25:1-25:13}:"%define api.pure"
input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
fix-it:"input.y":{26:1-26:13}:"%token-table"
input.y:27.1-14: warning: %define variable 'parse.error' redefined [-Wother]
@@ -2590,16 +2628,8 @@ AT_CHECK([diff input.y.orig input.y~])
AT_CHECK([test ! -f output.c])
# Check the update.
AT_CHECK([cat input.y], [],
[[%code top {
/* Load config.h, and adjust to the compiler.
We used to do it here, but each time we add a new line,
we have to adjust all the line numbers in error messages.
It's simpler to use a constant include to a varying file. */
#include <testsuite.h>
}
AT_CHECK([sed -e '1,8d' input.y], [],
[[
%default-prec
%define parse.error verbose
%expect-rr 0
@@ -2611,7 +2641,7 @@ AT_CHECK([cat input.y], [],
%no-default-prec
%no-lines
%output "output.c"
%pure-parser
%define api.pure
%token-table
%glr-parser
%%
@@ -2686,7 +2716,6 @@ AT_DATA_GRAMMAR([[input.y]],
%no-default-prec
%no-lines
%output "foo"
%pure-parser
%token-table
%% exp : '0'
]])
+4 -3
View File
@@ -390,7 +390,7 @@ m4_define([AT_DATA_SOURCE_PROLOGUE],
# AT_DATA_GRAMMAR_PROLOGUE
# ------------------------
# The prologue that should be included in any grammar which parser is
# The prologue that should be included in any grammar whose parser is
# meant to be compiled.
m4_define([AT_DATA_GRAMMAR_PROLOGUE],
[[%code top {
@@ -400,7 +400,7 @@ m4_define([AT_DATA_GRAMMAR_PROLOGUE],
# AT_DATA_SOURCE(NAME, CONTENT)
# -----------------------------
# Generate the file NAME, which CONTENT is preceded by
# Generate the file NAME, whose CONTENT is preceded by
# AT_DATA_SOURCE_PROLOGUE.
m4_define([AT_DATA_SOURCE],
[AT_DATA([$1],
@@ -411,7 +411,7 @@ $2])
# AT_DATA_GRAMMAR(NAME, CONTENT)
# ------------------------------
# Generate the file NAME, which CONTENT is preceded by
# Generate the file NAME, whose CONTENT is preceded by
# AT_DATA_GRAMMAR_PROLOGUE.
m4_define([AT_DATA_GRAMMAR], [AT_LANG_DISPATCH([$0], $@)])
@@ -977,6 +977,7 @@ AT_CHECK(m4_join([ ],
# with trailing ".o" removed, and ".cc" appended.
m4_define([AT_COMPILE_D],
[AT_KEYWORDS(d)
AT_SKIP_IF([[! $BISON_DC_WORKS]])
AT_CHECK(m4_join([ ],
[$DC $DCFLAGS $3],
[m4_bmatch([$1], [[.]], [-c])],
+1 -1
View File
@@ -85,7 +85,7 @@ $(TESTSUITE): $(TESTSUITE_AT)
## -------------------- ##
# Move into %D%/ so that testsuite.dir etc. be created there.
RUN_TESTSUITE = $(TESTSUITE) -C %D% $(TESTSUITEFLAGS)
RUN_TESTSUITE = $(SHELL) $(TESTSUITE) -C %D% $(TESTSUITEFLAGS)
check_SCRIPTS += $(BISON) %D%/atconfig %D%/atlocal
RUN_TESTSUITE_deps = all $(TESTSUITE) $(check_SCRIPTS)
+4 -5
View File
@@ -397,19 +397,18 @@ AT_BISON_OPTION_POPDEFS
# unnecessarily escaped here even though it would need to be if encoded in a
# C-string literal. Also notice that unnecessary escaping, such as "\?", from
# the user specification is eliminated.
AT_BISON_CHECK([-o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
22 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
| ^~~~~~~
input.y:21.8-14: previous declaration
21 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
| ^~~~~~~
input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
22 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]])
AT_COMPILE([input])
# Checking the error message here guarantees that yytname, which does contain
+10
View File
@@ -90,7 +90,17 @@ m4_define([_AT_SYNCLINES_COMPILE],
# syncline.c:4:2: error: #error "4"
# #error "4"
# ^~~~~
#
# GCC 9 displays a left-hand margin with the line number:
#
# syncline.c: In function 'foo':
# syncline.c:4:2: error: #error "4"
# 4 | #error "4"
# | ^~~~~
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
# Remove left-hand margin.
s/^[\d ]{6}\| //gm;
# 1. Remove useless lines.
# distcc clutter.