Compare commits

...
229 Commits
Author SHA1 Message Date
Akim Demaille ebddc0a0d2 version 3.1.90
* NEWS: Record release date.
2018-10-17 06:32:48 +02:00
Akim Demaille 8359341013 examples: don't generate the position/stack files
* examples/variant-11.yy, examples/variant.yy: Require 3.2.
2018-10-16 22:41:13 +02:00
Akim Demaille c7fe52e514 gnulib: update 2018-10-16 21:07:04 +02:00
Akim Demaille 5cdbc97c9d pacify syntax-checks
* lib/lbitset.c, tests/c++.at: here.
* cfg.mk: Add exceptions.
2018-10-16 18:54:06 +02:00
Akim Demaille 9017924783 regen 2018-10-16 13:41:45 +02:00
Akim Demaille e3fdc37049 generate the default action only for C++
This commit adds restrictions to what was done in
01898726e2 [1].

Rici Lake [2] has shown that it's risky to disable the pre-action, at
least now.  Also, generating the default $$ = $1 action can have bad
effects in some cases [3].

The original change [1] was prompted for C++.  Let's try it there
only, for a start.  We could restrict it further to lalr1.cc with
variants, but we need to see in the wild how this change behaves.  And
it is not unreasonable to expect grammar files in C++ to behave better
wrt types.

See
[1] https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00050.html
[2] https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00061.html
[3] https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00066.html

* src/getargs.c: Style changes.
* src/reader.c (grammar_rule_check_and_complete): Complete only for
C++.
2018-10-16 13:41:09 +02:00
Akim Demaille a99b4f45bb regen 2018-10-16 13:33:32 +02:00
Akim Demaille ea31f21fd8 C++: let %require "3.2" disable the generation of obsolete files
The files stack.hh and position.hh are deprecated.  Rather than
devoting specify %define variables to discard them (api.position.file
and api.stack.file), and rather than having to use special rules when
api.location.file is used, let's simply decide that from %require
"3.2" onwards, these files will not be generated.

The only noticeable thing here is that, in order to be able to check
the behavior of %require "3.2", to have this version (which is still
3.1-*) to accept %require "3.2".

* src/gram.h, src/gram.c (required_version): New.
* src/parse-gram.y (version_check): Set it.
* src/output.c (prepare): Pass it m4.
* data/bison.m4 (b4_required_version_if): Receive it and use it.
* data/location.cc, data/stack.hh: Replace the api.*.file with only
required version comparison.
* tests/input.at: No longer check api.stack.file and api.position.file.
* NEWS, doc/bison.texi: Don't mention them.
Document the %require 3.2 behavior.
* tests/output.at: Use %require 3.2 instead.
2018-10-16 13:33:32 +02:00
Akim Demaille 2b0a9c69df java: bump to Java SE 7
macOS 10.14 no longer supports versions of Java earlier than 5.
And Java 6 will be deprecated by the end of this year.  So let's move
our requirement to Java 7.
Reported by Yu Yijun.
https://lists.gnu.org/archive/html/bug-bison/2018-09/msg00060.html
Suggested by Paul Eggert and Bruno Haible.
http://lists.gnu.org/archive/html/bug-gnulib/2018-10/msg00094.html

* configure.ac: Require Java 7, both compiler and runtime.
2018-10-15 20:28:08 +02:00
Akim Demaille c69944ff8b doc: do not advertise %nterm
Reported by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html

* NEWS, doc/bison.texi: here.
2018-10-15 19:23:49 +02:00
Akim Demaille 01898726e2 generate the default semantic action
Currently, in C, the default semantic action is implemented by being
always run before running the actual user semantic action.  As a
consequence, when the user action is run, $$ is already set as $1.

In C++ with variants, we don't do that, since we cannot manipulate the
semantic value without knowing its exact type.  When variants are
enabled, the only guarantee is that $$ is default contructed and ready
to the used.

Some users still would like the default action to be run with
variants.  Frank Heckenbach's parser in
C++17 (http://lists.gnu.org/archive/html/bug-bison/2018-04/msg00011.html)
provides this feature, but relying on std::variant's dynamic typing,
which we forbid in lalr1.cc.

The simplest seems to be actually generating the default semantic
action (in all languages/skeletons).  This makes the pre-action (that
sets $$ to $1) useless.  But...  maybe some users depend on this, in
spite of the comments that clearly warn againt this.  So let's not
turn this off just yet.

* src/reader.c (grammar_rule_check_and_complete): Rename as...
(grammar_rule_check_and_complete): this.
Install the default semantic action when applicable.
* examples/variant-11.yy, examples/variant.yy, tests/calc.at:
Exercise the default semantic action, even with variants.
2018-10-14 18:53:21 +02:00
JannickandAkim Demaille 20a6c3175f xml2xhtml.xsl: add UTF-8 encoding
To make arrows appear nicely in the browser. Currently it is shown as
some garbled something in mine (Firefox).

* data/xslt/xml2xhtml.xsl: here.
2018-10-14 18:53:21 +02:00
Akim Demaille 45ef3d92a1 reader: reorder some calls to separate checks from assignments
* src/reader.c (packgram): Move assignments to rules[ruleno] after the
checks on the rule.
2018-10-14 15:20:39 +02:00
Akim Demaille fa386893aa C++: style: add missing space before parens
* data/c++.m4, data/lalr1.cc, data/stack.hh, data/variant.hh,
* examples/variant-11.yy: here.
2018-10-14 15:20:39 +02:00
Akim Demaille dc73dc4fb2 gnulib: update timevar
See
https://lists.gnu.org/archive/html/bug-gnulib/2018-10/msg00005.html.
2018-10-14 15:15:29 +02:00
Akim Demaille 677a91aef2 style: modernize lib/vbitset.h 2018-10-11 08:54:14 +02:00
Akim Demaille dab2ee0f74 style: modernize lib/vbitset.c 2018-10-11 08:54:14 +02:00
Akim Demaille 7f49dc7d1d style: modernize lib/lbitset.c 2018-10-11 07:00:34 +02:00
Akim Demaille 5f26baa748 style: modernize lib/lbitset.h 2018-10-11 07:00:34 +02:00
Akim Demaille 80752c0dc1 style: modernize lib/ebitset.c 2018-10-11 07:00:34 +02:00
Akim Demaille f8c9c7acae style: modernize lib/ebitset.h 2018-10-11 07:00:34 +02:00
Akim Demaille 7d324cf00c style: modernize lib/bitsetv.c 2018-10-11 07:00:34 +02:00
Akim Demaille 98364385a6 style: modernize lib/bitsetv.h 2018-10-11 07:00:34 +02:00
Akim Demaille b5197d5770 style: modernize lib/bitsetv-print.c 2018-10-11 07:00:34 +02:00
Akim Demaille e9b69f8655 style: modernize lib/bitsetv-print.h 2018-10-11 07:00:34 +02:00
Akim Demaille 099339df0a style: modernize lib/bitset_stats.c 2018-10-11 07:00:34 +02:00
Akim Demaille 8e4ca87228 style: modernize lib/bitset_stats.h 2018-10-11 07:00:34 +02:00
Akim Demaille 72e2a94d5f style: modernize lib/bitset.c 2018-10-11 07:00:34 +02:00
Akim Demaille 059cb26ca2 style: modernize lib/bitset.h 2018-10-11 07:00:34 +02:00
Akim Demaille c3d32f4a9a style: modernize lib/bbitset.h 2018-10-11 07:00:34 +02:00
Akim Demaille 74484f42f3 style: modernize lib/abitset.c 2018-10-11 07:00:34 +02:00
Akim Demaille 6565b9a566 style: modernize lib/abitset.h 2018-10-10 22:42:58 +02:00
Akim Demaille b8351d06f1 C++: issue a better CPP guard and Doxygen file command
Currently we use "<dir><api.location.file>" as \file argument, and as
base for the CPP guard.  This is not nice when <dir> is absolute, in
which case it is expected that the user will use api.location.include
to get something nicer.  If defined, use that name instead.

* data/location.cc (b4_location_path): New.
Use it.
* tests/c++.at (Shared locations): Check the guard and Doxygen doc.
2018-10-09 18:58:50 +02:00
Akim Demaille 67521bc0e8 C++: remove stray empty line
* data/stack.hh: here.
2018-10-09 17:12:29 +02:00
Akim Demaille 4fb70e4dd3 doc: spell check 2018-10-09 17:02:30 +02:00
Akim Demaille 3ac6af879d doc: document api.*.file and the like
* doc/bison.texi (Exposing the Location Classes): New.
(%define Summary): Document api.location.file, api.location.include,
api.stack.file and api.position.file.
(C++ Bison Interface): stack.hh and position.hh are deprecated.
2018-10-09 17:02:26 +02:00
Akim Demaille f3d09f3108 build: add missing gnulib libs
* src/local.mk (LDADD): Here.
2018-10-07 14:19:47 +02:00
Akim Demaille 1cb6c26b4f build: let timevar be dealt with by gnulib
* lib/local.mk (lib_libbison_a_SOURCES): Remove timevar.
2018-10-07 14:16:30 +02:00
Akim Demaille c164fc0822 build: fix distcheck
Now that distcheck no longer fails (see previous commit), let's
address the shortcomings.

* Makefile.am (CLEANDIRS, clean-local): New.
* doc/local.mk, examples/calc++/local.mk, examples/local.mk,
* examples/mfcalc/local.mk, examples/rpcalc/local.mk,
* src/local.mk
(CLEANDIRS): Get rid of Apple's *.dSYM directories.
(CLEANFILES): Get rid of *.output files.
* examples/variant-11.yy, examples/variant.yy: Don't generate
any of the auxiliary files (location.hh and the like).
2018-10-07 10:41:40 +02:00
Akim Demaille 25347d885c README: work around a nasty behavior of gettext
`make update-po` runs:

    package_gnu="$(PACKAGE_GNU)"; \
    test -n "$$package_gnu" || { \
      if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \
             LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f \
                           -size -10000000c -exec grep 'GNU @PACKAGE@' \
                           /dev/null '{}' ';' 2>/dev/null; \
           else \
             LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \
           fi; \
         } | grep -v 'libtool:' >/dev/null; then \
         package_gnu=yes; \
       else \
         package_gnu=no; \
       fi; \
    }; \

and based on the result, put GNU or not in the following line from
bison.pot:

    # This file is distributed under the same license as the GNU bison package.

It turns out that in my environment some log files had the 'GNU bison'
string (note the lower case), but in distcheck, these files are no
longer visible, so the generate bison.pot was different, and distcheck
failed because we try to update bison.pot, which is read only in
distcheck.

The heuristics should look accept 'GNU Bison', not just 'GNU bison'.
But let's please it to make sure we have our 'GNU'.

* README: Mention 'GNU bison'.
2018-10-07 10:41:40 +02:00
Akim Demaille fa264a0687 NEWS: document api.*.file changes 2018-10-07 08:12:49 +02:00
Akim Demaille 5fe636c7ee c++: provide a means to control how location.hh is included
Users may want to generate the location file elsewhere, say
$top_srcdir/include/ast/location.hh.  Yet, we should not generate
`#include "$top_srcdir/include/ast/location.hh"` but probably
something like `#include <ast/location.hh>`, or `#include
"ast/location.hh", or `#include <location.hh>`.  It entirely depends
on the compiler flags (-I/-isystem) that are used.  Bison cannot guess
what is expected, so let's give the user a means to tell how the
location file should be included.

* data/location.cc (b4_location_file): New.
* data/glr.cc, data/lalr1.cc: Use it.
2018-10-06 18:13:48 +02:00
Akim Demaille 50b8d4ba5a c++: support absolute api.location.file names
In the case a user wants to create location.hh elsewhere, it can be
helpful to define api.location.file to some possibly absolute path
such as -Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"'.
Currently this does not work with `-o foo/parser.cc`, as we join foo/
and $(top_srcdir) together, the latter starting with slash.

We should not try to do that in m4, manipulating file names is quite
complex when you through Windows file name in.  Let m4 delegate this
to gnulib.

* src/scan-skel.l (at_output): Accept up to two arguments.
* data/bison.m4 (b4_output): Adjust.
* tests/skeletons.at (Fatal errors but M4 continues producing output):
Adjust to keep the error.

* data/location.cc, data/stack.hh: Leave the concatenation to @output.
* tests/output.at: Exercise api.location.file with an absolute path.
2018-10-06 17:17:25 +02:00
Akim Demaille 57d69b04b2 c++: when api.location.file is defined, don't generate stack.hh
Make it easier to have fewer files.

* data/stack.hh: Don't generate stack.hh when api.location.file is
specified.
* tests/calc++.at, tests/output.at: Adjust tests.
2018-10-06 17:17:25 +02:00
Akim Demaille 3e6a075f7f c++: make position.hh completely useless
Let's put the definition of position into location.hh, there's no real
value in keeping them separate: they are small, and share the same
requirements.

To help users transition to this new model, still generate position.hh
by default, but as a simple include to location.hh.

* data/location.cc (api.position.file): Accept only 'none' as possible
value.
(position.hh): Make it a stub.
(location.hh): Adjust.
(b4_position_define): Merge into...
(b4_location_define): this.
* data/glr.cc, data/lalr1.cc, tests/input.at, tests/output.at: Adjust.
2018-10-06 17:17:25 +02:00
Akim Demaille 29b1da4e18 c++: make stack.hh completely useless
Let's completely deprecate stack.hh.  Don't provide a means to give it
a new name, allow only its removal.

See https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00151.html
and https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00182.html.

* data/stack.hh: Reduce stack.hh to a simple comment explaining how to
get rid of it.
* data/lalr1.cc: Adjust
* tests/input.at (%define file variables): Adjust.
* tests/output.at: Remove cases where stack.hh was removed.
2018-10-06 17:17:25 +02:00
Akim Demaille 667588ee8a c++: add support for api.position.file and api.location.file
* data/location.cc: Sort includes.
(b4_position_file, b4_location_file): New.
When there's a file for locations but not for positions, include the
definition of position in the location file.
* data/lalr1.cc (b4_shared_declarations): Include the
position/location file when it exists.
Otherwise, define the class.
* data/glr.cc: Likewise.
* tests/input.at (%define file variables): Check them.
* tests/output.at (C++ output): Check various cases with
api.position.file and api.location.file.
2018-10-06 17:17:25 +02:00
Akim Demaille b122a71c83 c++: provide control over the stack.hh file name
It was not a good idea to generate the file stack.hh.  It never was.
But now we have to deal with backward compatibility: if we stop
generating it, the build system of some build system will probably
break.

So offer the user a means to (i) decide what the name of the output
file should be, and (ii) not generate this file at all (its content
will be inline where the parser is defined).

* data/lalr1.cc (b4_percent_define_check_file_complain)
(b4_percent_define_check_file): New.
* data/stack.hh: Generate the file only if api.stack.file is not
empty.
In that case, use it as file name.
* data/lalr1.cc: Adjust to include the right file, or to include
the definition of stack.
* tests/calc.at, tests/output.at: Exercise api.stack.file.
2018-10-06 17:17:25 +02:00
Akim Demaille 1a0b3bf83b tests: c++: don't fuse prefix and namespace
They are not the same concept.  It appears that we still consider that
api.prefix is the default for api.namespace.  We should stop that.

* tests/local.at (AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS):
Separate namespace and prefix.
Adjust dependencies.
2018-10-06 17:16:55 +02:00
Akim Demaille 53bde230c6 style: tests: factor file extension computations
* tests/local.at (AT_LANG_HDR): New.
* tests/calc.at, tests/headers.at, tests/synclines.at: Use it, and
AT_LANG_EXT.
2018-10-06 17:16:54 +02:00
Akim Demaille fd3c17995e c++: style changes
* data/lalr1.cc: Formatting changes.
Remove duplicate definition of YY_NULLPTR.
Add quotes to help Emacs track balanced parens.
2018-10-06 15:45:21 +02:00
Akim Demaille d13a7fdb0a lib: introduce xpath_join
* lib/path-join.h, lib/path-join.c: New.
* lib/local.mk: Adjust.
* src/output.c: Use it.
2018-10-06 15:44:24 +02:00
Akim Demaille a61a84ec6a CI: travis finally knows about llvm-toolchain-trusty-7
See https://github.com/travis-ci/apt-source-safelist/pull/392.
2018-10-06 07:38:15 +02:00
Akim Demaille 394c1aa6f2 gnulib: update 2018-10-06 07:38:15 +02:00
Akim Demaille 5281d09af7 doc: restore spello made on purpose 2018-10-06 07:38:15 +02:00
Akim Demaille 0299b699bb THANKS: add Josh Soref 2018-10-05 07:06:44 +02:00
Josh SorefandAkim Demaille cff8d06e51 spelling: whether 2018-10-05 07:01:06 +02:00
Josh SorefandAkim Demaille 45372aed4e spelling: typedef 2018-10-05 07:01:06 +02:00
Josh SorefandAkim Demaille b89b6517f2 spelling: troubleshooting 2018-10-05 07:01:06 +02:00
Josh SorefandAkim Demaille cd45c269e2 spelling: transparent 2018-10-05 07:01:06 +02:00
Josh SorefandAkim Demaille 44cad07704 spelling: translated 2018-10-05 07:01:06 +02:00
Josh SorefandAkim Demaille f612071298 spelling: transitions 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille a7694cedf9 spelling: transition 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 2fead9abdb spelling: tracking 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille d573ef0d69 spelling: suppress 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 6cdd3287dd spelling: succesful 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 2d60a624c9 spelling: storage 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 5d4bd04588 spelling: safely 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 47f92cb354 spelling: responsibility 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 715fdcffbf spelling: resources 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 153df66692 spelling: releases 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille ce9d542a78 spelling: reduction 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille c66e591fa5 spelling: reachable 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 2495c49077 spelling: rawtoknumflag 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 6c3b482891 spelling: possibly 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 5ec892c480 spelling: persistent 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 9188385b55 spelling: outputting 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 1bf3e2860b spelling: otherwise 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 7d8d1c3f92 spelling: occurrence 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 694c6234f9 spelling: namespace 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 13b70e2218 spelling: minimal 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille fa55bfa71f spelling: invocations 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 93d2986bba spelling: initialize 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 75964cf0df spelling: incorrectly 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 3c2b71cde6 spelling: included 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 37c6dbb8ad spelling: illicit 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 0883e6591f spelling: handling 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille a538d0d8aa spelling: gratuitously 2018-10-05 07:01:05 +02:00
Josh SorefandAkim Demaille 2645ee3519 spelling: grammar 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille ad15cd977a spelling: generation 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 4e97614f5a spelling: generate 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 82c36f0f0b spelling: forewarn 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille ee1bcce627 spelling: fnchange 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 8347aabe14 spelling: family 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 25bdc41ee0 spelling: extensions 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 57e3f5a80c spelling: enum 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 8c3eae0d44 spelling: diagnostics 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 6fe281271c spelling: determined 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 23a37cc1c5 spelling: detailed 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille eb1b04fa00 spelling: descriptive 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille cdc252ace9 spelling: definitions 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 95b55cc5c4 spelling: declaration 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille e96d567a27 spelling: corrupted 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille b62b690ccf spelling: consuming 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 7d687eaee3 spelling: consistently 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille a2ab59fa18 spelling: conflicts 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 777226dd9f spelling: concatenation 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 95e1b48e20 spelling: complete 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille bb077f38f7 spelling: compatibility 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille a6316700e8 spelling: comparison 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 795f7e32cc spelling: combination 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille c721eb9e28 spelling: characters 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille 3aed6a21f5 spelling: builddir 2018-10-05 07:01:04 +02:00
Josh SorefandAkim Demaille b6d3f107fe spelling: assoc 2018-10-05 07:01:03 +02:00
Josh SorefandAkim Demaille 704a04512c spelling: appropriate 2018-10-05 07:01:03 +02:00
Josh SorefandAkim Demaille 2586398fcc spelling: alignment 2018-10-05 07:01:03 +02:00
Josh SorefandAkim Demaille d9b37a62ff spelling: aggregate 2018-10-05 07:01:03 +02:00
Josh SorefandAkim Demaille 3d2bf2a8e3 spelling: adjust 2018-10-05 07:01:03 +02:00
Josh SorefandAkim Demaille a3ced22c06 spelling: additional 2018-10-05 07:01:03 +02:00
Josh SorefandAkim Demaille a2b6281b39 spelling: accurately 2018-10-05 07:01:03 +02:00
Akim Demaille cf4600ca45 README-hacking: details about make check-local 2018-10-05 06:21:59 +02:00
Akim Demaille 8d64416e8c gnulib: update 2018-10-05 06:14:20 +02:00
Akim Demaille 26859f6d61 main: fix error message for missing argument
* src/getargs.c (getargs): Don't display any argv other that argv[0]
when reporting a missing argument.
* tests/bison.in: Neutralize path differences in stderr.
* tests/input.at (Invalid number of arguments): New.
2018-10-04 22:24:11 +02:00
Akim Demaille f84a8e96d1 gnulib: move timevar to it
* lib/timevar.c, lib/timevar.h, m4/timevar.m4: Remove.
* gnulib: Update.
* configure.ac: Adjust.
* lib/timevar.def: Use lower case for the timevvars.
Adjust dependencies.
2018-09-30 14:19:53 +02:00
Akim Demaille 4247df921b style: comment changes
* data/glr.cc, data/lalr1.cc: here.
2018-09-29 12:19:33 +02:00
Akim Demaille 9bdff3d271 gnulib: update 2018-09-29 09:39:00 +02:00
Paul Eggert d03b1a7e8c getargs: use LC_MESSAGES trick only on glibc
* src/getargs.c (usage): Rely on setlocale (LC_MESSAGES, NULL)
trick only on glibc, as POSIX does not specify the output
of setlocale in this case, and the Gnulib localename module
source code indicates that the trick works only on glibc.
2018-09-28 16:41:41 -07:00
Paul Eggert 973c456f63 uniqstr: avoid need for VLAs
C11 no longer requires support for variable-length arrays, and
VS2015 does not have them.  Redo UNIQSTR_CONCAT to use a method
that is simpler and better anyway.
* src/uniqstr.c (uniqstr_vsprintf): Remove; no longer needed.
* src/uniqstr.h (UNIQSTR_GEN_FORMAT, UNIQSTR_GEN_FORMAT_):
* src/uniqstr.c (uniqstr_concat): New function.
* src/uniqstr.h (UNIQSTR_CONCAT): Use it instead of using
uniqstr_vsprintf.
2018-09-28 16:41:41 -07:00
Akim Demaille 2d07940325 doc: clean up the C++ section
* doc/bison.texi: Minor fixes in typography.
It is no longer require to pass --defines for C++ (it was addressed
long ago).
No longer refer to the `variant` define variable, it was replaced by
`api.value.type variant`.
Prefer nullptr to 0 for the null pointer.
Use deftypeop for constructors.
(Complete Symbols): Give the expected signature of yylex.
Don't document the symbol_type constructors, as we want users to focus
on make_TOKEN.
Also show the case without locations.
2018-09-26 21:49:20 +02:00
Akim Demaille 13cdb2d397 CI: fixes for clang and asan
Bison's test 464 (Syntax error as exception) fails on the CI.
Do not use clang with asan on Ubuntu's libc++.
https://bugs.llvm.org/show_bug.cgi?id=17379

* .travis.yml (Clang 7 libc++ and ASAN): New.
(Clang 6 -O3 and libc++): Really use libc++.
(Clang 5): Don't use libc++, nor asan (does not work either, same
reason).
2018-09-26 16:22:32 +02:00
Akim Demaille b2a3a302e6 style: reduce scopes in muscle-tab.c 2018-09-24 21:52:56 +02:00
Akim Demaille 8c4a1163ee style: remove useless parens
* data/bison.m4, data/glr.c, data/glr.cc, data/lalr1.cc,
* data/lalr1.java, data/location.cc, data/yacc.c: Call b4_output_end
without parens.
2018-09-24 21:52:55 +02:00
Akim Demaille cf4e3eecef c++: fix warning message for automove
* src/scan-code.l: Remove 'enabled'.
Use only $k (numeric), even for named references, for clarity.
* tests/c++.at: Adjust expectations.
2018-09-24 21:52:55 +02:00
Akim Demaille 2eaa7ed946 style: minor refactoring
* data/bison.m4: Formatting changes.
* src/scan-code.l: Avoid loops, prefer standard string functions.
(find_prefix_end): Be const correct.
Avoid useless intermediate variables.
(variant_add): Be const correct.
(parse_ref): Prefer variable definitions to assignments.
2018-09-24 21:52:55 +02:00
Akim Demaille e198269f40 CI: don't exit
* .travis.yml: Prefer `false` to `exit`, as it completely ends the
script (so we don't get the logs).
2018-09-24 21:52:55 +02:00
Akim Demaille 6181f05630 CI: really use Clang 3.3 and 3.4, not 5.0
* .travis.yml: Don't define CC/CXX, it does not work.
Use `[[...]]` instead of `[...]`.
Show the compiler versions.
(Clang 3.3, Clang 3.4): Specify the path to avoid using
/usr/local/clang-5.0.0/bin's clang.
2018-09-24 21:52:55 +02:00
Akim Demaille a4ba0d21a1 CI: more compiler configurations
* .travis.yml (GCC 8): Use sanitizers.
(Clang 5 -O3): Remove, replaced by...
(Clang 7 ASAN and libc++, Clang 6 -O3 and libc++): New.
2018-09-23 13:16:40 +02:00
Akim Demaille 5d0764d23b build: rename and simplify the -std checks for C++
Too much code duplication.

* m4/bison-cxx-std.m4: s/BISON_CXX_COMPILE_STDCXX/BISON_CXXSTD/.
(BISON_CXXSTD): New.
* configure.ac: Use it.
2018-09-23 11:50:58 +02:00
Akim Demaille 41ded58286 build: check for C++98 and 03 like the others
* m4/bison-cxx-std.m4 (BISON_CXX_COMPILE_STDCXX_98)
(BISON_CXX_COMPILE_STDCXX_03): New.
* configure.ac: Use them.
2018-09-23 11:50:58 +02:00
Akim Demaille 5649888686 build: use our own version of ax_check_link_flag
The message on configure is misleading:

    checking whether the linker accepts -std=c++11... yes
    checking whether the linker accepts -std=c++14... yes
    checking whether the linker accepts -std=c++17... no

It is the compiler that we check, not just the linker.

* m4/ax_check_link_flag.m4: Remove.
* m4/bison-check-compiler-flag.m4: New.
* m4/bison-cxx-std.m4: Use it.
2018-09-23 11:50:58 +02:00
Akim Demaille e40a3eed34 build: fix Autoconf macros to check for C++ standard flags
* m4/bison-cxx-std.m4: Since now we link the program, we need a
program: main was missing and linking was failing.
2018-09-23 11:50:58 +02:00
Akim Demaille 6537a59c98 tests: fix a memory leak
This has been bugging me for while.  I was hard to reproduce: it
worked only on GNU/Linux, probably because libc++ implements the small
string optimization, while libstdc++ did not and actually allocated on
the heap for this small string.

See https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00110.html.

* tests/types.at (api.value.type): Do not provide a semantic value to
EOF.
2018-09-23 11:50:58 +02:00
Akim Demaille 154bc7ddac doc: work around Flex's use of 'register'
The CI uses an old version of Flex.
See 65fa634cdc.

* doc/bison.texi (calc++/scanner.ll): Here.
2018-09-22 19:40:37 +02:00
Akim Demaille a990213582 timevar: don't declare getrusage if we don't use it
This fails on MinGW.
Reported by Simon Sobisch.
http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00058.html

* lib/timevar.c: Don't provide default prototypes for functions
we don't use.
2018-09-22 15:58:27 +02:00
Akim Demaille 9dfd46a5d5 timevar: get rid of a useless macro
* lib/timevar.h (timevar_report): Rename as...
(timevar_enabled): this.
* lib/timevar.c (TIMEVAR_ENABLE): Remove.
2018-09-22 15:58:27 +02:00
Akim Demaille 984d8cc72c timevar: introduce and use get_current_time
* lib/timevar.c: here.
Remove useless prototypes.
(timevar_accumulate): Be const correct.
2018-09-22 15:58:27 +02:00
Akim Demaille 896b2f75c5 timevar: rename get_time as set_to_current_time
* lib/timevar.c: here.
2018-09-22 15:58:27 +02:00
Akim Demaille 3ce67fa673 timevar: reduce scopes
* lib/timevar.c: here.
2018-09-22 15:58:27 +02:00
Akim Demaille 889dea0275 timevar: document in the header, not in the implementation
* lib/timevar.c: Move documentation from here...
* lib/timevar.h: to there.
2018-09-22 15:58:27 +02:00
Akim Demaille ab3ec56ffe timevar: remove useless 'extern' for prototypes
* lib/timevar.h, lib/timevar.c: here.
2018-09-22 15:58:27 +02:00
Akim Demaille c8da23c372 timevar: rename init_timevar as timevar_init
* lib/timevar.h, lib/timevar.c: here.
* src/main.c: Adjust.
2018-09-22 15:58:27 +02:00
Akim Demaille 69720f1231 timevar: we don't care about backward compatibility
* lib/timevar.h, lib/timevar.c (get_run_time, print_time): Remove.
2018-09-22 15:58:27 +02:00
Akim Demaille 100f8696c7 timevar: prefer #elif
* lib/timevar.c: Use #if/#elif to be clearer about mutually exclusive
cases.
Indent CPP nested directives.
2018-09-22 15:58:27 +02:00
Akim Demaille 8c6b06df1f timevar: assume ANSI C
Suggested by Bruno Haible.
https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00102.html

* lib/timevar.c: Wow...  This was still KnR C!
2018-09-22 15:58:27 +02:00
Akim Demaille 6d9aafc5ad timevar: remove remains of GCC
* lib/timevar.h, lib/timevar.c: Rename the header guard.
Get rid of parts meant for GCC only.
2018-09-22 15:58:27 +02:00
Akim Demaille 878dc0a172 news: c++: move semantics 2018-09-22 14:52:13 +02:00
Akim Demaille a874011e37 c++: issue a warning with a value is moved several times
Suggested by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00022.html

* src/scan-code.l (parse_ref): Check multiple occurrences of rhs
values.
* tests/c++.at (Multiple occurrences of $n and api.value.automove): New.
2018-09-22 11:22:31 +02:00
Akim Demaille 3eb9042a30 c++: introduce api.value.automove
Based on work by Frank Heckenbach.
See http://lists.gnu.org/archive/html/bug-bison/2018-04/msg00000.html
and http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00019.html.

* data/lalr1.cc (b4_rhs_value): Use YY_MOVE api.rhs.automove is set.
* doc/bison.texi (%define Summary): Document api.rhs.automove.
* examples/variant-11.yy: Use it.

* tests/local.at (AT_AUTOMOVE_IF): New.
* tests/c++.at (Variants): Check move semantics.
2018-09-22 09:49:46 +02:00
Akim Demaille aa5de5728c tests: c++: use a custom string type
The forthcoming automove feature, to be properly checked, will require
that we can rely on the value of a moved-from string, which is not
something the C++ standard guarantees.  So introduce our own wrapper.

Suggested by Frank Heckenbach.
https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00111.html

* tests/c++.at (Variants): Introduce and use a new 'string' class.
2018-09-22 09:49:42 +02:00
Akim Demaille 21eeee46e9 tests: prepare a test for automove
The 'Variants' tests are well suited to check support for move, and in
particular for the forthcoming automove feature.  But the tests were
written to show the best practice in C++98, using swap:

    list "," item { std::swap ($$, $1); $$.push_back ($3); }

This cannot work with std::move.  So, make this example simpler, based
on regular assignment instead of swap, which is a regression for
C++98 (as the new traces show), but will be an improvement for modern
C++ with automove.

* tests/c++.at (Variants): Stop using swap.
We don't generate a header file, so remove the 'require' code section.
Adjust expectations.
2018-09-22 08:22:48 +02:00
Akim Demaille db025a6fb7 style: reduce scopes in gram.c
* src/gram.c: here.
2018-09-20 21:19:55 +02:00
Akim Demaille ca822faeec style: reduce scopes in reduce.c
* src/reduce.c: Here.
2018-09-20 21:19:55 +02:00
Akim Demaille ae915ab8e7 gnulib: update 2018-09-20 07:06:52 +02:00
Akim Demaille 27630864e7 build: work around ICC's limitations
Several types of failures.  First, unable to pass the file name
properly to the linker.

    ./synclines.at:416: $CC $CFLAGS $CPPFLAGS  $LDFLAGS -o \"\\\"\" \"\\\"\".c $LIBS
    stderr:
    ld: cannot open output file "/"": No such file or directory
    stdout:

Unable to save under such a file name.

    ./synclines.at:421: $CXX $CXXFLAGS $CPPFLAGS -c $LDFLAGS -o \"\\\"\" \"\\\"\".cc $LIBS
    stderr:
    error: can't open file "/"" for write
    compilation aborted for "\"".cc (code 1)

Spurious output because of warning flags is failed to reject as an
error during configure:

    ./headers.at:343: $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS c-only.o cxx-only.o -o c-and-cxx ||
              exit 77
    --- /dev/null	2018-09-18 21:21:37.745649000 +0000
    +++ /home/travis/build/akimd/bison/tests/testsuite.dir/at-groups/222/stderr	2018-09-18 21:28:17.291919519 +0000
    @@ -0,0 +1,7 @@
    +icpc: command line warning #10006: ignoring unknown option '-Wcast-align'
    +icpc: command line warning #10006: ignoring unknown option '-fparse-all-comments'
    +icpc: command line warning #10006: ignoring unknown option '-Wdocumentation'
    +icpc: command line warning #10006: ignoring unknown option '-Wnull-dereference'
    +icpc: command line warning #10006: ignoring unknown option '-Wnoexcept'
    +icpc: command line warning #10006: ignoring unknown option '-fno-color-diagnostics'
    +icpc: command line warning #10006: ignoring unknown option '-Wno-keyword-macro'
    stdout:

* tests/local.at (AT_SKIP_IF_CANNOT_LINK_C_AND_CXX): Also ignore
stderr, as with ICC we get
* tests/synclines.at (syncline escapes): Don't link the output.
2018-09-20 06:30:46 +02:00
Akim Demaille 857be0e10f doc: fix typo
Introduced in the previous commit.

* doc/bison.texi: here.
2018-09-19 22:13:57 +02:00
Akim Demaille bbfa419b89 style: use midrule only, not mid-rule
The code was already using midrule only, never mid_rule.  This is
simpler to remember, and matches a similar change we made from
look-ahead to lookahead.

* NEWS, doc/bison.texi, src/reader.c, src/scan-code.h, src/scan-code.l
* tests/actions.at, tests/c++.at, tests/existing.at: here.
2018-09-19 22:09:53 +02:00
Akim Demaille b7613423ce style: use _foo for private macros, not foo_
We use both styles, let's stick to a single one.  Autoconf uses the
prefix one, let's do the same.

* data/bison.m4, data/c++.m4, data/c-like.m4, data/lalr1.cc,
* data/variant.hh, data/yacc.c: Rename all the b4_*_ macros
as _b4_*.
2018-09-19 20:42:43 +02:00
Akim Demaille 49dc1b5bf1 build: don't accept a broken standard lib for C++
On the CI, we had failures such as:

    ./c++.at:401:  $PREPARSER ./list
    stderr:
    ./list: error while loading shared libraries: libc++.so.1:
            cannot open shared object file: No such file or directory

because we accepted `-std=c++ -stdlib=libc++` although libc++ is not
installed on the machine.

* m4/ax_check_compile_flag.m4 (AX_CHECK_COMPILE_FLAG): Rewrite as...
* m4/bison-check-compile-flag.m4 (BISON_CHECK_COMPILE_FLAG): this, so
that we use AC_LINK_IFELSE to check the compiler (and its std lib)
instead of AC_COMPILE_IFELSE.
2018-09-19 06:02:41 +02:00
Paul Eggert f475105c2f doc: document older compiler issues
* doc/bison.texi (Compiler Requirements for GLR):
Rename from Compiler Requirements.
(I can't build Bison): Add FAQ for older compilers.
2018-09-18 13:17:46 -07:00
Akim Demaille a60a9e3071 glr.c: work around ICC limitations
The CI is littered with

    #                             -*- compilation -*-
    423. regression.at:907: testing Dancer %glr-parser ...
    ./regression.at:907: bison -fno-caret -o dancer.c dancer.y
    ./regression.at:907: $BISON_C_WORKS
    stderr:
    stdout:
    ./regression.at:907: $CC $CFLAGS $CPPFLAGS  $LDFLAGS -o dancer dancer.c $LIBS
    stderr:
    icc: command line warning #10006: ignoring unknown option '-Wcast-align'
    icc: command line warning #10006: ignoring unknown option '-fparse-all-comments'
    icc: command line warning #10006: ignoring unknown option '-Wdocumentation'
    icc: command line warning #10006: ignoring unknown option '-Wnull-dereference'
    icc: command line warning #10006: ignoring unknown option '-Wbad-function-cast'
    icc: command line warning #10006: ignoring unknown option '-fno-color-diagnostics'
    icc: command line warning #10006: ignoring unknown option '-Wno-keyword-macro'
    dancer.c(755): error #1628: function declared with "noreturn" does return
      }
      ^

    dancer.c(761): error #1628: function declared with "noreturn" does return
      }
      ^

    compilation aborted for dancer.c (code 2)

ICC sees that `longjmp(buf, 1);` does not return, it sees that
`abort();` does not either, but fails to see it for
`longjmp(buf, 1); abort();`

* data/glr.c (YYLONGJMP): Be even clearer on the fact this does not
return.
2018-09-18 17:21:13 +02:00
Akim Demaille c53d599df4 TODO: more 2018-09-18 13:21:39 +02:00
Akim Demaille 9458250968 CI: change strategy to pass CXXFLAGS and the like
Putting them in the env is useless.  We don't want to pass
`CPPFLAGS="$CPPFLAGS"` to configure, as it means "set it to nothing"
when $CPPFLAGS is not set, which is not what we want.

This correctly started to use libc++, but it is not installed on the
Ubuntu.  We will see later if we can use it.

* .travis.yml: Define CONFIGUREFLAGS, and pass it to configure.
2018-09-18 13:21:39 +02:00
Akim Demaille 8cbc235723 CI: also use GCC 4.7 and 4.8
* .travis.yml (matrix): here.
2018-09-18 13:21:39 +02:00
Akim Demaille 9a377eb0a8 CI: name the items of the matrix
* .travis.yml: here.
2018-09-18 13:21:38 +02:00
Akim Demaille 09aa05d89c CI: also check with ICC
* build-aux/install-icc.sh: New.
* .travis.yml (icc): New.
Use -k to get as many errors as possible from the start.
* src/complain.c (warnings_types): Use a more precise type.
2018-09-18 13:21:38 +02:00
Akim Demaille 2b7dca1c86 CI: be sure to exit on failures
a807cfa6eb completely broke the whole
point of having a CI: we always exit with success!
2018-09-18 13:21:38 +02:00
Akim Demaille 3367d8dd5c build: strengthen the C++ standard flag test
On the CI, we have this spurious failure with clang 3.9 with
-std=c++17:

    In file included from list.y:23:
    In file included from /usr/include/c++/4.8/iostream:39:
    In file included from /usr/include/c++/4.8/ostream:38:
    In file included from /usr/include/c++/4.8/ios:42:
    In file included from /usr/include/c++/4.8/bits/ios_base.h:41:
    In file included from /usr/include/c++/4.8/bits/locale_classes.h:40:
    In file included from /usr/include/c++/4.8/string:52:
    In file included from /usr/include/c++/4.8/bits/basic_string.h:2815:
    In file included from /usr/include/c++/4.8/ext/string_conversions.h:43:
    /usr/include/c++/4.8/cstdio:120:11: error: no member named 'gets' in the global namespace
      using ::gets;
            ~~^

This shows that our test, based on gl_WARN_ADD, is a joke.  We have to
really check for at least a bit of C++.

* m4/ax_check_compile_flag.m4, m4/bison-cxx-std.m4: New.
* configure.ac: Use them to make sure the compiler actually works.
2018-09-18 13:21:38 +02:00
Akim Demaille 8da0cef821 tests: fix memory leak
This was reported by ASAN on the CI.

* tests/types.at (api.value.type): Don't set a semantic value to EOF.
2018-09-18 13:21:38 +02:00
Akim Demaille fb1e27cf47 glr.c: prefer true/false to 1/0 in C++
* data/glr.c: here.
2018-09-18 13:21:38 +02:00
Akim Demaille 65fa634cdc doc: work around Flex's use of 'register'
The CI uses an old version of Flex.

* doc/bison.texi (calc++/scanner.ll): Here.
2018-09-18 13:21:38 +02:00
Akim Demaille 7c64b1f4ff tests: fight G++ warnings about zero as null pointer constant
In C++ pre C++11 it is standard practice to use 0 for the null pointer.
But GCC pre 8 -std=c++98 with -Wzero-as-null-pointer-constant warns about
this.

So disable -Wzero-as-null-pointer-constant when compiling C++ pre 11.
Let's do this in AT_DATA_SOURCE_PROLOGUE (which is pasted on top of
all the test grammar files).  Unfortunately, that shifts all the
locations in the expected error messages, which would be too noisy.
Instead, let's introduce testsuite.h, which can vary in length, and
include it in AT_DATA_SOURCE_PROLOGUE.

* tests/testsuite.h: New.
Disable -Wzero-as-null-pointer-constant's warning with GCC pre 8,
C++ pre 11.
* tests/local.at (AT_DATA_SOURCE_PROLOGUE): Use it.
* tests/atlocal.in (CPPFLAGS): Find it.
* tests/local.mk: Ship it.
* data/c.m4 (YY_NULLPTR): Prefer ((void*)0) to 0 in C.
2018-09-18 13:21:38 +02:00
Akim Demaille 9611baf855 CI: make sure git describe works
For some reasons, the checkout on travis may not have any tags, so
`git describe` fails, so bootstrap fails.

* .travis.yml: If git describe fails, install some tag.
2018-09-18 13:21:38 +02:00
Akim Demaille 2559f4cec5 CI: install Doxygen
* .travis.yml: here, so that its tests are not skipped.
Remove valgrind: it's too expensive on the CI, and asan does the job.
2018-09-18 13:21:38 +02:00
Akim Demaille d4fbda2a94 style: prefer %D% in Automake files
* tests/local.mk: Prefer %D%/ to tests/.
2018-09-16 16:20:39 +02:00
Akim Demaille 84dcd7991b style: reduce scopes in complain.c 2018-09-15 08:28:02 +02:00
Akim Demaille 50910389c9 style: reduce scopes in tables.c
* src/tables.c: here.
* src/state.h: Formatting changes.
2018-09-15 07:59:57 +02:00
Akim Demaille 6cc69f4d14 style: reduce scopes in graphviz.c 2018-09-15 07:20:49 +02:00
Akim Demaille 46532a9d3b style: reduce scopes in LR0.c 2018-09-15 07:20:49 +02:00
Akim Demaille 5603f0bdf2 style: reduce scopes in print_graph.c
* src/print_graph.c: here.
2018-09-15 07:20:49 +02:00
Akim Demaille ce99bc67b8 doc: formatting changes
* doc/bison.texi: No changes in the output.
2018-09-15 07:20:49 +02:00
Akim Demaille 9ff76cdda8 tests: run the C++ tests on all the available standards
This is much of course more efficient than in the matrix of the CI (or
on our own machines), but a bit more tedious.

* configure.ac (CXX03_CXXFLAGS, CXX11_CXXFLAGS, CXX14_CXXFLAGS)
(CXX17_CXXFLAGS, CXX2A_CXXFLAGS, STDCXX_FLAGS): New.
* tests/atlocal.in: Receive them.
* tests/local.at (AT_FOR_EACH_CXX): New.
* tests/c++.at: Use AT_FOR_EACH_CXX.
2018-09-13 19:01:42 +02:00
Akim Demaille 84744e5f63 tests: allow to override variables with envvars
* tests/atlocal.in: Allow the user to change interesting variables
(CFLAGS, CXXFLAGS, etc.).
2018-09-13 19:01:42 +02:00
Akim Demaille 09bc1b99c9 lalr1.cc: modern C++ no longer needs an assignment for symbols
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2018-03/msg00002.html

Actually the assignment operator should never be needed: the C++98
requirements for vector::push_back is CopyInsertable, which does not require
an assignment operator.  However, libstdc++ shipped with GCC up to (and
including) 6 uses the assignment operator (which affects Clang on top of
libstdc++, but also ICC).  So let's keep it for legacy C++.

See https://gcc.godbolt.org/z/q0XXmC.

* data/lalr1.cc (stack_symbol_type::operator=): Remove.
* data/c++.m4 (basic_symbol::operator=): Ditto.
* tests/c++.at (C++ Variant-based Symbols Unit Tests): Adjust.
2018-09-13 19:01:42 +02:00
Akim Demaille f19ecae3b2 lalr1.cc: support move semantics
Modern C++ (i.e., C++11 and later) introduced "move only" types: types such
as std::unique_ptr<T> that can never be duplicated.  They must never be
copied (by assignments and constructors), they must be "moved".  The
implementation of lalr1.cc used to copy symbols (including their semantic
values).  This commit ensures that values are only moved in modern C++, yet
remain compatible with C++98/C++03.

Suggested by Frank Heckenbach, who provided a full implementation on
top of C++17's std::variant.
See http://lists.gnu.org/archive/html/bug-bison/2018-03/msg00002.html,
and https://lists.gnu.org/archive/html/bison-patches/2018-04/msg00002.html.

Symbols (terminal/non terminal) are handled by several functions that used
to take const-refs, which resulted eventually in a copy pushed on the stack.
With modern C++ (C++11 and later) the callers must use std::move, and the
callees must take their arguments as rvalue refs (foo&&).  In order to avoid
duplicating these functions to support both legacy C++ and modern C++, let's
introduce macros (YY_MOVE, YY_RVREF, etc.)  that rely on copy-semantics for
C++98/03, and move-semantics for modern C++.

That's easy for inner types, when the parser's functions pass arguments to
each other.  Functions facing the user (make_NUMBER, make_STRING, etc.)
should support both rvalue-refs (for instance to support move-only types:
make_INT (std::make_unique<int> (1))), and lvalue-refs (so that we can pass
a variable: make_INT (my_int)).  To avoid the multiplication of the
signatures (there is also the location), let's take the argument by value.

See:
https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00024.html.

* data/c++.m4 (b4_cxx_portability): New.
(basic_symbol): In C++11, replace copy-ctors with move-ctors.
In C++11, replace copies with moves.
* data/lalr1.cc (stack_symbol_type, yypush_): Likewise.
Use YY_MOVE to avoid useless copies.
* data/variant.hh (variant): Support move-semantics.
(make_SYMBOL): In C++11, in order to support both read-only lvalues,
and rvalues, take the argument as a copy.
* data/stack.hh (yypush_): Use rvalue-refs in C++11.
* tests/c++.at: Use move semantics.

* tests/headers.at: Adjust to the new macros (YY_MOVE, etc.).

* configure.ac (CXX98_CXXFLAGS, CXX11_CXXFLAGS, CXX14_CXXFLAGS)
(CXX17_CXXFLAGS, ENABLE_CXX11): New.
* tests/atlocal.in: Receive them.

* examples/variant.yy: Don't define things in std.
* examples/variant-11.test, examples/variant-11.yy: New.
Check the support of move-only types.
* examples/README, examples/local.mk: Adjust.
2018-09-13 19:01:33 +02:00
Akim Demaille e3257f88e2 tests: factor the definition of full compilation
* tests/local.at (AT_LANG_EXT): New.
(AT_FULL_COMPILE): Simplify.
2018-09-12 22:06:23 +02:00
Akim Demaille b4ea71a8b2 CI: use clang with libc++
GCC uses libstdc++.  Let's also check libc++.

* .travis.yml: here.
2018-09-10 06:37:27 +02:00
Akim Demaille c85418ba07 CI: use address sanitizer
* .travis.yml (matrix): Use the latest (available) clang with asan.
2018-09-10 06:35:53 +02:00
Akim Demaille 0e38617ad7 CI: sort the matrix in reverse-chronological
There are only three builds at a time: show the result of modern
compilers first.

* .travis.yml (matrix): Sort in reverse-chronological.
2018-09-10 06:34:21 +02:00
Akim Demaille 493182f70e build: use -fparse-all-comments with -Wdocumentation
Clang checks only /** ... */ comments without this flag.

* configure.ac (warn_common): Also check -fparse-all-comments.
2018-09-10 06:31:56 +02:00
Akim Demaille ed2c9a69d3 TODO: minor updates 2018-09-09 15:25:36 +02:00
Akim Demaille 333bcd2ee3 build: fix support for --disable-dependency-tracking
Reported by Juan Manuel Guerrero.
https://lists.gnu.org/archive/html/bug-bison/2014-07/msg00000.html.

* examples/local.mk (%D%/extracted.stamp): Make sure the output
directory exists.
* examples/extexi (process): Likewise.
2018-09-09 15:14:20 +02:00
Akim Demaille 04705b9370 configure.ac: fix definition of NO_EXCEPTIONS_CXXFLAGS
* configure.ac: Always define it, not just when --enable-gcc-warnings
is passed.
2018-09-09 13:56:52 +02:00
Akim Demaille 79331541ae skeletons: style/comment changes
* data/c++.m4, data/c.m4, data/glr.c: Here.
2018-09-09 13:50:00 +02:00
Akim Demaille d6fb1813ee variant: indent better the generated code
* data/variant.hh (b4_basic_symbol_constructor_declare)
(b4_basic_symbol_constructor_define): here.
2018-09-09 11:40:23 +02:00
Akim Demaille 7194099027 lalr1.cc: don't generate useless constructors when variant is used
This generates less code, which is nicer to read, but also takes less
chances with compilers such as G++ 4.8 that are too strict and check
"dead code" (templated code that is not instantiated).

* data/c++.m4 (b4_symbol_type_declare, b4_symbol_type_define): When
variants are used, don't generate code meant for non variants.
2018-09-09 11:40:23 +02:00
Akim Demaille 171b6bacb9 CI: Clang 6.0 is not available
But Clang 3.3 and 3.4 are.

* .travis.yml (addons): Remove, it appears to be ignore if the matrix
also defines it.
(matrix): Update.
2018-09-09 11:40:15 +02:00
Akim Demaille e1c33f04d1 build: work around warnings in Flex
See ea0db44fed.  We also need to disable
the warning in the examples (but don't want to clutter the
documentation with such details).

* doc/bison.texi (scanner.ll): Disable Clang's -Wdocumentation.
While at it, hide the other kludges.
2018-09-08 12:13:29 +02:00
Akim Demaille 3c22b260b1 CI: more compiler configurations
* .travis.yml: here.
2018-09-08 08:03:09 +02:00
Akim Demaille e5000890a4 configure: reveal the name of the Valgrind suppression file we use
* configure.ac: here.
* build-aux/Linux.valgrind (libstdcxx_init): New.
2018-09-08 08:02:42 +02:00
Akim Demaille ea0db44fed build: work around warnings in Flex 2.5.35
That's the version on Ubuntu Precise.
See also 1dac131ec4.

* src/flex-scanner.h: Disable -Wdocumentation.
* doc/bison.texi: Turn off a warning triggered by Flex 2.6.4.
2018-09-08 07:53:08 +02:00
Akim Demaille ec99c418a7 CI: show the version of the tools we use
We have failures on Flex output, which are probably related to an old
release.  Let's check.

    In file included from src/scan-code-c.c:3:
    src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command
          [-Werror,-Wdocumentation]
     * @param line_number
       ~~~~~~~~~~~~~~~~~^

* .travis.yml: here.
2018-09-08 07:50:39 +02:00
Akim Demaille a807cfa6eb CI: run more maintainer tests and show the logs
Running all these tests might be overkill: it is very long, and don't
need full portability checks.  Besides, some tests under Valgrind are
too slow and get killed by the CI (timeout of 10min without output).

* .travis.yml: here.
2018-09-08 07:48:15 +02:00
Akim Demaille 41c43ef3d7 CI: enable compiler warnings
* .travis.yml: here.
* README-hacking: We no longer aim at K&R C.
2018-09-08 07:01:50 +02:00
Akim Demaille 1dac131ec4 build: work around GCC warnings on Flex code
See ef98967ada.

* src/flex-scanner.h: Disable -Wnull-dereference for GCC 6+.
2018-09-06 21:28:24 +02:00
Akim Demaille 9268d9aceb tests: fix target naming convention
We have some maintainer-check-foo and some maintainer-foo-check.  Keep
only the former.

* tests/local.mk (maintainer-push-check, maintainer-xml-check)
(maintainer-release-check): Rename as...
(maintainer-check-push, maintainer-check-xml)
(maintainer-check-release): these.
2018-09-06 21:28:24 +02:00
Akim Demaille bb5603c2f0 tests: fix variable naming convention
Most of our variables for C++ flags are named FOO_CXXFLAGS, not
CXXFLAGS_FOO.

* configure.ac, tests/atlocal.in, tests/calc.at
(NO_EXCEPTIONS_CXXFLAGS): Rename as...
(CXXFLAGS_NO_EXCEPTIONS): this.
2018-09-06 21:28:24 +02:00
Akim Demaille 2c29a70819 tests: fix maintainer-check-g++ make recipe
Clang++ issues warnings when it's used to compile C.  This make target
is precisely checking whether we can do that.

* configure.ac (NO_DEPRECATED_CXXFLAGS): New.
* tests/atlocal.in: Use it.
2018-09-06 21:28:24 +02:00
Akim Demaille cf31256f9a tests: fix maintainer-check-valgrind make recipe
* tests/local.mk (maintainer-check-valgrind): Run the with Valgrind
when it's available, not the converse.
2018-09-06 21:28:24 +02:00
Akim Demaille 7132650bba CI: prepare for travis
* .travis.yml: New.
2018-09-06 13:51:36 +02:00
Akim Demaille d908fb3f18 examples: beware of shell portability issues
This completes 2d7e743802.

Some shells don't grok "local var=`cmd`" very well: they need the rhs
to be quoted.

    ./examples/test: 72: local: you.,: bad variable name
    FAIL examples/variant.test (exit status: 2)

Reported by Étienne Renault.

* examples/test (run): Quote the values in 'local' assignments.
2018-09-06 13:51:19 +02:00
Akim Demaille d023679818 tests: style changes
* tests/c++.at: Formatting changes.
Use 'using' to shorten the code.
2018-09-04 13:46:13 +02:00
Akim Demaille d87c8ac79a tests: disable GCC7 warnings for some tests
With GCC7 we have warnings (false positive):

    x8.c: In function 'x8_parse':
    x8.c:1233:16: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             yylval = *yypushed_val;
             ~~~~~~~^~~~~~~~~~~~~~~
    x8.c: In function 'x8_pull_parse':
    x8.c:1233:16: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             yylval = *yypushed_val;
             ~~~~~~~^~~~~~~~~~~~~~~

See also 9645a2b20e.

* tests/local.at (AT_PUSH_IF): New.
(AT_BISON_OPTION_POPDEFS): Pop it, and pop AT_PURE_IF.
* tests/headers.at (Several parsers, Several parsers): Disable these
warnings when in push parser.
2018-09-02 18:15:55 +02:00
Akim Demaille a7e46f6e41 C++: don't issue the definition of symbol_type when not used
Currently, in glr.cc, we emit the definitions of basic_symbol and
symbol_type, although there are not used.

* data/c++.m4 (b4_public_types_declare): Extract these definitions from
here, and move them...
(b4_symbol_type_declare): here.
(b4_public_types_declare): Also remove the definition of the symbol
constructors.
* data/lalr1.cc (b4_shared_declarations): Adjust: call
b4_symbol_type_declare and b4_symbol_constructor_declare.
2018-09-02 11:25:28 +02:00
Akim Demaille 2d7e743802 examples: beware of shell portability issues
Some shells don't grok `local var=$val` very well: they need the rhs
to be quoted.

    ./examples/test: 66: local: you.,: bad variable name
    FAIL examples/variant.test (exit status: 2)

Reported by Étienne Renault.

* examples/test (run): Quote the values in 'local' assignments.
2018-09-02 09:37:53 +02:00
Akim Demaille 50fb434689 C++: leave 'inline' on the definition, not the declaration
This is for consistency with the other uses of 'inline' in the C++
skeletons.  On examples/variant.yy, this change gives:

    --- examples/variant.hh	2018-08-31 07:16:57.214222580 +0200
    +++ examples/variant.hh	2018-08-31 07:19:52.285431997 +0200
    @@ -444,15 +444,15 @@
         typedef basic_symbol<by_type> symbol_type;

         // Symbol constructors declarations.
    -    static inline
    +    static
         symbol_type
         make_END_OF_FILE (const location_type& l);

    -    static inline
    +    static
         symbol_type
         make_TEXT (const ::std::string& v, const location_type& l);

    -    static inline
    +    static
         symbol_type
         make_NUMBER (const int& v, const location_type& l);

    @@ -945,19 +945,23 @@
         };
         return static_cast<token_type> (yytoken_number_[type]);
       }
    +
       // Implementation of make_symbol for each symbol type.
    +  inline
       parser::symbol_type
       parser::make_END_OF_FILE (const location_type& l)
       {
         return symbol_type (token::END_OF_FILE, l);
       }

    +  inline
       parser::symbol_type
       parser::make_TEXT (const ::std::string& v, const location_type& l)
       {
         return symbol_type (token::TEXT, v, l);
       }

    +  inline
       parser::symbol_type
       parser::make_NUMBER (const int& v, const location_type& l)
       {
    @@ -967,7 +971,7 @@

     } // yy
    -#line 971 "examples/variant.hh" // lalr1.cc:380
    +#line 975 "examples/variant.hh" // lalr1.cc:380

and no changes on variant.cc.

* data/c++.m4 (b4_public_types_define): Formatting changes.
* data/variant.hh (b4_symbol_value_template_, b4_symbol_constructor_declare_):
Move the 'inline' from declaration to implementation.
2018-08-31 07:25:57 +02:00
Akim Demaille b5d4eb8913 c++: style changes
Instead of

    parser::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
      : super_type (that.state, that.location)
    {
      value = that.value;
    }

generate

    parser::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
      : super_type (that.state, that.value, that.location)
    {}

* data/lalr1.cc (stack_symbol_type): Improve the copy ctor, when not
using the variants.
(yypush_): Rename arguments for clarity.
2018-08-30 08:14:33 +02:00
Akim Demaille 2116ad3a28 c++: the assignment operator does not have to be const
* data/lalr1.cc (stack_symbol_type::operator=): Don't copy the
argument, move it.
2018-08-30 08:14:33 +02:00
Akim Demaille 15233a3728 tests: style changes
* tests/c++.at (C++ Variant-based Symbols): Rename as...
(C++ Variant-based Symbols Unit Tests): this.
Comment/style changes.
2018-08-30 08:14:21 +02:00
Akim Demaille b476c143c0 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-08-27 22:30:02 +02:00
124 changed files with 4230 additions and 3364 deletions
+1 -1
View File
@@ -1 +1 @@
3.0.5
3.1
+293
View File
@@ -0,0 +1,293 @@
# 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.
language: cpp
env:
global:
# ICC serial number.
secure: ED3w6rzxuE6tVu3oyxha2MoGMRzRQCtinvr9uor1gw9TGKB80esTLx4KyX0xHemUdyQVarFDDQfVS5rf7jSDY8XiWIR6O+2Af9/30gb+8eyngyvACu7E28n+1XHmYWIEHsbvB9mic6C60FBj5sPcDnFWZeyttGL0WooSjYHiw1Egafwqbeu1mD3Aet9OI9VaLQvy0KcWAdVrYWSI9UWLvLM+xPVUjPFko4oS+dTlETzVnmn6JFbZX1OKONtfcvdoDRFBzs3iHm5dQUt/Fz+y/DtKSuvF3zvePHSgF6c8URbEPPjBdh87gkovSLyy+83fVeh4WMkF8b+dGZmikQv6kRsjKJdbQrS8tiMhZlORC5Gfmn4HXNgmapL+paUweakH7UZQHm6d5SZoBgCHNazfqMrywbZsZkGvZTDQIVG1Be7Lhh2BDFbPhPZNDvI9XYiqZP0QSb0BVfeO+AUSRcUPM7TvarxB74jYdfpTBu7sqJP6dSwhcDTEUhHmuLGjzsNm3uTZe8SUw/TGGx5uPTXNsCjJq6ClIOAIYXZTXLbBmIL/NBWCy0MUpD+9zsiknU7vzzq1RfgCCExhvYgosTjBLcX1kKI+eRSU5M44e+xCg4xx0m9WfafbKbhA20FfnWxCFIkZeVpkOOsexJ9zfe0SflVLxkd7vmci5SCBixLVbN0=
matrix:
include:
## ----- ##
## GCC. ##
## ----- ##
#- name: "GCC 8 with sanitizers"
# os: linux
# 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'
# - 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 -O3"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
- name: "GCC 6"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- name: "GCC 5"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- name: "GCC 4.9"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
env:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- name: "GCC 4.8"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
env:
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
- name: "GCC 4.7"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.7
env:
- MATRIX_EVAL="CC=gcc-4.7 && CXX=g++-4.7"
- name: "GCC 4.6"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.6
env:
- MATRIX_EVAL="CC=gcc-4.6 && CXX=g++-4.6"
## ------- ##
## Clang. ##
## ------- ##
- name: "Clang 7 libc++ and ASAN"
os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-7
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
env:
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
- MATRIX_EVAL="CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
- name: "Clang 6 -O3 and libc++"
os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-6.0
- ubuntu-toolchain-r-test
packages:
- clang-6.0
- libc++-dev
env:
- MATRIX_EVAL="CC=clang-6.0 && CXX='clang++-6.0 -stdlib=libc++'"
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
- name: "Clang 5"
os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
- libc++-dev
env:
- MATRIX_EVAL="CC='clang-5.0' CXX='clang++-5.0'"
- name: "Clang 4"
os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-4.0
packages:
- clang-4.0
env:
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
- name: "Clang 3.9"
os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-3.9
packages:
- clang-3.9
env:
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
- name: "Clang 3.8"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages:
- clang-3.8
env:
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
- name: "CLang 3.7"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- clang-3.7
env:
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
- name: "Clang 3.6"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
packages:
- clang-3.6
env:
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
- name: "Clang 3.5"
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
packages:
- clang-3.5
env:
- MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5"
- name: "Clang 3.4"
os: linux
addons:
apt:
packages:
- clang-3.4
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++'
- name: "Clang 3.3"
os: linux
addons:
apt:
packages:
- clang-3.3
env:
# See comment for 3.4.
- MATRIX_EVAL='CC=/usr/bin/clang && CXX=/usr/bin/clang++'
## ----- ##
## ICC. ##
## ----- ##
- name: "ICC"
os: linux
env:
# ICC's warnings are often very wrong (e.g., it thinks foo ?
# "bar" : "baz" is char* instead of const char*), so don't try
# to work around the, and obviously, don't die on them.
- MATRIX_EVAL="CC=icc && CXX=icpc"
- MAKE_ARGS='WERROR_CFLAGS= WERROR_CXXFLAGS='
before_install:
- eval "$MATRIX_EVAL"
- env
- sudo apt-get update -qq
- sudo apt-get install -qq autoconf automake autopoint doxygen flex gettext graphviz help2man m4 texinfo
- if [[ $CC == "icc" ]]; then build-aux/install-icc.sh; fi
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
- autoconf --version
- automake --version
- autopoint --version
- $CC --version
- $CXX --version
- doxygen --version
- flex --version
- gettext --version
- dot -V
- help2man --version
- m4 --version
- makeinfo --version
script:
- git show
- 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
- ./bootstrap
- if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
- make -j2 $MAKE_ARGS
- make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }
- make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }
- make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }
after_script:
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
+43 -43
View File
@@ -3671,12 +3671,12 @@
2009-02-25 Akim Demaille <[email protected]>
Copyright years.
* data/glr.c: Add 2007 and 2008 here, consistenly with the comments.
* data/glr.c: Add 2007 and 2008 here, consistently with the comments.
2009-02-25 Akim Demaille <[email protected]>
Style changes.
* etc/bench.pl.in (generate_grammar_list): Consitently use
* etc/bench.pl.in (generate_grammar_list): Consistently use
location_type, not yy::location.
2009-02-25 Akim Demaille <[email protected]>
@@ -3702,7 +3702,7 @@
Remove trailing blanks.
The epilogue has its own ending \n, no need to add another.
* data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputing the
* data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputting the
epilogue.
* data/glr.cc: dnl when extending the epilogue.
Remove stray "private:".
@@ -3764,7 +3764,7 @@
2008-12-11 Akim Demaille <[email protected]>
Pass the token type to yysyntax_error.
* data/yacc.c (yysyntax_error): Take the transated token instead
* data/yacc.c (yysyntax_error): Take the translated token instead
of the raw number.
Adjust callers.
* TODO: Update.
@@ -5019,7 +5019,7 @@
Now instead of monolithic tables, we define one macro per cell. For
instance "b4_symbol(0, tag)" is a macro name which contents is
self-decriptive. The macro "b4_symbol" provides easier access to
self-descriptive. The macro "b4_symbol" provides easier access to
these cells.
* src/output.c (type_names_output): Remove.
@@ -5200,7 +5200,7 @@
2008-11-09 Akim Demaille <[email protected]>
Agregate yylval and yylloc.
Aggregate yylval and yylloc.
* data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
(parser::yyla): this.
@@ -5815,7 +5815,7 @@
of members. Document that token names are added as fields.
Document constructors accurately. Remove error method.
(Java Scanner Interface): Move note on %pure-parser to Java Bison
Interface. Describe %code lexer and yylex accutately.
Interface. Describe %code lexer and yylex accurately.
Remove documentation that does not match the code.
(Java Action Features): New.
(Java Differences): Add reference. Add item on semantic values.
@@ -6432,7 +6432,7 @@
* djgpp/config.site: Copyright timestamp adjusted.
* djgpp/config_h.sed: Copyright timestamp adjusted.
* djgpp/djunpack.bat: Copyright timestamp adjusted.
* djgpp/fnchnage.lst: Add filenames that are not 8.3 clean to the
* djgpp/fnchange.lst: Add filenames that are not 8.3 clean to the
filename translation list.
* djgpp/subpipe.c (init_subpipe): Check the environment variables
TMPDIR, TMP and TEMP, in that order, to determinate where the temp
@@ -7588,7 +7588,7 @@
2007-03-07 Juan Manuel Guerrero <[email protected]>
DJGPP spefic issue. Inhibit the use of disallowed characters for
file name genertion on Win98, WinXP, etc. These are |<>":?*\
file name generation on Win98, WinXP, etc. These are |<>":?*\
and concern testsuite case 46.
* Makefile.am: djgpp/testsuite.sed added to EXTRA_DIST
* djgpp/testsuite.sed: Inhibit the use of disallowed characters.
@@ -8796,7 +8796,7 @@
2006-12-13 Paul Eggert <[email protected]>
* TODO: Add pointer to Sylvain Schmitz's work on static detection
of potential ambiguities in GLR grammers.
of potential ambiguities in GLR grammars.
2006-12-12 Joel E. Denny <[email protected]>
@@ -9059,7 +9059,7 @@
* src/scan-gram.l (<SC_BRACED_CODE>): Use val->code for BRACED_CODE,
which is "{...}" in the parser.
* tests/Makefile.am (maintainer-check-valgrind): Set
VALGRIND_OPTS='--leak-check=full --show-reacheable=yes' before invoking
VALGRIND_OPTS='--leak-check=full --show-reachable=yes' before invoking
Valgrind.
* tests/calc.at (_AT_DATA_CALC_Y): fclose the FILE* so Valgrind doesn't
complain.
@@ -12349,7 +12349,7 @@
* data/lalr1.cc: here.
(location.hh): Include it after the user prologue, in case the
filename type is defined by the user.
Forward declation location and position before the pre-prologue.
Forward declaration location and position before the pre-prologue.
(yyresult_): Rename as...
(yyresult): this, it's a local variable, not an attribute.
* data/Makefile.am (dist_pkgdata_DATA): Adjust.
@@ -12439,8 +12439,8 @@
(Table of Symbols): Under YYSTACK_USE_ALLOCA, Don't claim that the
user must declare alloca.
* HACKING (release): Forwarn the Translation Project about
stable releses.
* HACKING (release): Forewarn the Translation Project about
stable releases.
2005-09-20 Akim Demaille <[email protected]>
@@ -13165,7 +13165,7 @@
not GNU M4, and that it works with any POSIX-compatible Awk.
* examples/calc++/Makefile.am (run_extexi): Remove; not used.
($(calc_extracted)): Renamed from $(calc_sources_extracted),
so that we also get calc++-parser.yy. Geneate it.
so that we also get calc++-parser.yy. Generate it.
Use $(AWK), not gawk, since any conforming Awk will do.
Put comment before action, since older 'make' can't handle comment
in action.
@@ -13993,7 +13993,7 @@
* src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc,
to allocate kernel_base, kernel_items, kernel_size, since
they needn't be initialized to 0.
(allocate_storgae): Likewise, for shiftset, redset, shift_symbol.
(allocate_storage): Likewise, for shiftset, redset, shift_symbol.
* src/closure.c (new_closure): Likewise, for itemset.
* src/derives.c (derives_compute): Likewise, for delts, derives, q.
* src/lalr.c (set_goto_map): Likewise, for temp_map.
@@ -14181,7 +14181,7 @@
2004-10-05 Akim Demaille <[email protected]>
In Bison 1.875's yacc.c, YYLLOC_DEFAULT was called regardless
whether the reducion was empty or not. This leaves room to
whether the reduction was empty or not. This leaves room to
improve the use of YYLLOC_DEFAULT in such a case.
lalr1.cc is still experimental, so changing this is acceptable.
And finally, there are probably not many users who changed the
@@ -16524,7 +16524,7 @@
(struct state): Renamed from struct state_s.
(state): Renamed from state_t.
(transitions): Renamed from transitions_t. Unused (and
misspelled) transtion_s tag removed.
misspelled) transition_s tag removed.
(errs): Renamed from errs_t. Unused errs_s tag removed.
(reductions): Renamed from reductions_t. Unused tag
reductions_s removed.
@@ -16612,9 +16612,9 @@
Fix misspelling in names.
* src/vcg.h (enum_alignment_e): Renamed from enum_alignement_e.
* src/vcg.h (enum_alignment_e): Renamed from enum_alignment_e.
* src/vcg_defaults.h (G_NODE_ALIGNMENT): Renamed from
G_NODE_ALIGNEMENT.
G_NODE_ALIGNMENT.
* lib/timevar.c (timevar_report): Renamed from time_report,
@@ -16866,7 +16866,7 @@
* src/tables.c (conflict_row, pack_vector): Likewise.
* src/vcg.c (get_color_str, get_textmode_str, get_shape_str,
get_layoutalgorithm_str, get_decision_str, get_orientation_str,
get_node_alignement_str, get_arrow_mode_str, get_crossing_type_str,
get_node_alignment_str, get_arrow_mode_str, get_crossing_type_str,
get_view_str, get_linestyle_str, get_arrowstyle_str): Likewise.
* lib/argmatch.h (ARRAY_CARDINALITY): Do not bother to #undef.
@@ -17365,7 +17365,7 @@
(scanner_last_string_free): Remove; not used.
(percent_percent_count): Move decl to just before use.
(SC_ESCAPED_CHARACTER): Return ID at unexpected end of file,
not the (never otherwised-used) CHARACTER.
not the (never otherwise-used) CHARACTER.
2002-11-07 Akim Demaille <[email protected]>
@@ -18052,7 +18052,7 @@
suite using a GLR parser driven by LALR tables. It fails with -O2
because `struct stat' gives two different answers on my machine:
88 (definition of an auto var) and later 96 (memset on this var).
Hence the stack is badly corrumpted. The headers inclusion is to
Hence the stack is badly corrupted. The headers inclusion is to
blame: if I move the awk.h inclusion before GLR's system header
inclusion, the two struct stat have the same size.
@@ -18962,7 +18962,7 @@
2002-07-16 Akim Demaille <[email protected]>
* src/assoc.c, src/asssoc.h (assoc_t, assoc_to_string): New.
* src/assoc.c, src/assoc.h (assoc_t, assoc_to_string): New.
Adjust all former `associativity' dependencies.
* src/symtab.c (symbol_new): Default associativity is `undef', not
`right'.
@@ -20105,7 +20105,7 @@
* data/bison.c++: Catch up with bison.simple:
2002-05-24 Paul Hilfinger <[email protected]>
and Paul Eggert <[email protected]>: `error' handing.
and Paul Eggert <[email protected]>: `error' handling.
2002-05-26 Akim Demaille <[email protected]>: stos_, token_number_,
and popping traces.
@@ -20455,7 +20455,7 @@
single characters while replacing `[' and `]' with quadrigraphs, to
avoid troubles with M4 quotes.
(copy_comment): Output characters with copy_character.
(read_additionnal_code): Likewise.
(read_additional_code): Likewise.
(copy_string2): Likewise.
(copy_definition): Likewise.
@@ -20638,7 +20638,7 @@
* data/bison.simple, data/bison.c++: Adjust.
* tests/torture.at (Big triangle): Move the limit from 254 to
500.
* tests/regression.at (Web2c Actions): Ajust.
* tests/regression.at (Web2c Actions): Adjust.
Trying with bigger grammars shows various phenomena: at 3000 (28Mb
of grammar file) bison is killed by my system, at 2000 (12Mb) bison
@@ -20949,7 +20949,7 @@
2002-03-05 Robert Anisko <[email protected]>
* src/reader.c (read_additionnal_code): `c' should be an integer, not
* src/reader.c (read_additional_code): `c' should be an integer, not
a character.
Reported by Nicolas Tisserand and Nicolas Burrus.
@@ -21070,7 +21070,7 @@
* src/L0.c, src/LR0.h (nstates): Be size_t.
Adjust comparisons (signed vs unsigned).
* src/conflics.c, src/lalr.c, src/lalr.h, src/output.c (LA): Now a
* src/conflicts.c, src/lalr.c, src/lalr.h, src/output.c (LA): Now a
bitset*.
Adjust all dependencies.
@@ -22337,7 +22337,7 @@
* src/bison.simple: Remove #line just before %%epilogue. It
is now handled in ...
* src/reader.c (read_additionnal_code): Add the output of a
* src/reader.c (read_additional_code): Add the output of a
#line for the epilogue.
2001-12-10 Marc Autret <[email protected]>
@@ -22797,7 +22797,7 @@
on user names when possible.
(YYSTACK_USE_ALLOCA): Do not define; just use any existing defn.
Simplify test for whather <alloca.h> exists.
Simplify test for whether <alloca.h> exists.
(<stdlib.h>): Include if we will use malloc, and if standard C or C++.
@@ -23563,7 +23563,7 @@
2001-10-04 Akim Demaille <[email protected]>
* src/reader.c (parse_union_decl): Push the caracters in
* src/reader.c (parse_union_decl): Push the characters in
union_obstack, not attrs_obstack.
2001-10-04 Akim Demaille <[email protected]>
@@ -23844,7 +23844,7 @@
* src/vcg.h (graph_s): color, textcolor, bordercolor are now
enum color_e.
* src/print_graph.c (print_graph): Initalize graph.layoutalgorithm
* src/print_graph.c (print_graph): Initialize graph.layoutalgorithm
to `normal'.
* src/reader.c (parse_token_decl): Initialize token with tok_eof.
* src/lex.h: Adjust prototype.
@@ -23999,7 +23999,7 @@
* src/vcg.c: Remove includes of `complain.h' and `xalloc.h'.
(get_xxxx_str): Use assert () instead of complain ().
Remove return invokations in default cases.
Remove return invocations in default cases.
(get_decision_str): Modify default behaviour. Remove second argument.
Echo modifications on calls.
(output_graph): Fix.
@@ -24030,7 +24030,7 @@
informations about %union.
(parse_union_decl): Copy the union_obstack in the muscle stype.
* src/bison.simple: Add new #line directive.
Add typdef %%stype YYSTYPE.
Add typedef %%stype YYSTYPE.
2001-09-23 Pascal Bart <[email protected]>
@@ -24115,7 +24115,7 @@
(parse_union_decl): Update.
(parse_macro_decl): Rename parse_muscle_decl.
Update to use renamed functions and variable.
(read_declarations, copy_action, read_additionnal_code, : Updated
(read_declarations, copy_action, read_additional_code, : Updated
with correct variables and functions names.
(packsymbols, reader): Likewise.
@@ -24196,7 +24196,7 @@
2001-08-31 Pascal Bart <[email protected]>, Marc Autret <[email protected]>
* src/reader.c (read_additionnal_code): Rename %%user_code to
* src/reader.c (read_additional_code): Rename %%user_code to
%%epilogue.
* src/output.c (output): Rename %%declarations to %%prologue.
* src/bison.simple: Echo modifications.
@@ -24240,7 +24240,7 @@
2001-08-29 Marc Autret <[email protected]>
* src/bison.simple: Add %%user_code directive at the end.
* src/reader.c (read_additionnal_code): New.
* src/reader.c (read_additional_code): New.
(reader): Use it.
* src/output.c (output_program): Remove.
(output): Update.
@@ -24303,7 +24303,7 @@
(readgram): Disable a piece of code that was writing a default
definition for 'YYSTYPE'.
(reader_output_yylsp): Remove.
(packsymbols): Output token defintions to a macro.
(packsymbols): Output token definitions to a macro.
(copy_definition): Disable C output.
* src/reader.c (parse_macro_decl): New function used to parse macro
@@ -24641,7 +24641,7 @@
2001-07-08 Pascal Bart <[email protected]>
* src/bison.simple (yyparse): Suppress warning `comparaison
* src/bison.simple (yyparse): Suppress warning `comparison
between signed and unsigned'.
2001-07-05 Pascal Bart <[email protected]>
@@ -25128,7 +25128,7 @@
* tests/calc.m4: Test it.
For regularity of the names, replace each
(nolineflag, toknumflag, rawtokenumflag, noparserflag): with...
(nolineflag, toknumflag, rawtoknumflag, noparserflag): with...
(no_lineflag, token_tableflag, rawflag, no_parserflag): this.
In addition replace each `flag' with `_flag'.
@@ -25731,7 +25731,7 @@
* src/getargs.c, src/Makefile.am, src/reader.c, src/version.c:
Have configure build version string instead of relying on ANSI string
concatentation.
concatenation.
1999-06-14 Jesse Thilo <[email protected]>
@@ -25741,7 +25741,7 @@
* acconfig.h, configure.in:
Have configure build version string instead of relying on ANSI string
concatentation.
concatenation.
1999-06-08 Jesse Thilo <[email protected]>
+4
View File
@@ -43,6 +43,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
# instead of "-Ilib" avoids infinite recursions on #include_next.
AM_CPPFLAGS = -I. -I./lib -I$(top_srcdir) -I$(top_srcdir)/lib
BUILT_SOURCES =
CLEANDIRS =
CLEANFILES =
DISTCLEANFILES =
EXTRA_DIST += $(dist_TESTS)
@@ -64,6 +65,9 @@ include lib/local.mk
include src/local.mk
include tests/local.mk
clean-local:
rm -rf $(CLEANDIRS)
# See comments in build-aux/git-version-gen. However, we make .version depend
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
# working copy (for example, when you run autoreconf && make). Allowing these
+168 -15
View File
@@ -1,5 +1,155 @@
GNU Bison NEWS
* Noteworthy changes in release 3.1.90 (2018-10-17) [beta]
** Backward incompatible changes
Support for DJGPP, which have been unmaintained and untested for years, is
obsolete. Unless there is activity to revive it, it will be removed.
** New features
*** C++: Support for move semantics (lalr1.cc)
The lalr1.cc skeleton now fully supports C++ move semantics, while
maintaining compatibility with C++98. You may now store move-only types
when using Bison's variants. For instance:
%code {
#include <memory>
#include <vector>
}
%skeleton "lalr1.cc"
%define api.value.type variant
%%
%token <int> INT "int";
%type <std::unique_ptr<int>> int;
%type <std::vector<std::unique_ptr<int>>> list;
list:
%empty {}
| list int { $$ = std::move($1); $$.emplace_back(std::move($2)); }
int: "int" { $$ = std::make_unique<int>($1); }
*** C++: Implicit move of right-hand side values (lalr1.cc)
In modern C++ (C++11 and later), you should always use 'std::move' with
the values of the right-hand side symbols ($1, $2, etc.), as they will be
popped from the stack anyway. Using 'std::move' is mandatory for
move-only types such as unique_ptr, and it provides a significant speedup
for large types such as std::string, or std::vector, etc.
If '%define api.value.automove' is set, every occurrence '$n' is replaced
by 'std::move ($n)'. The second rule in the previous grammar can be
simplified to:
list: list int { $$ = $1; $$.emplace_back($2); }
With automove enabled, the semantic values are no longer lvalues, so do
not use the swap idiom:
list: list int { std::swap($$, $1); $$.emplace_back($2); }
This idiom is anyway obsolete: it is preferable to move than to swap.
A warning is issued when automove is enabled, and a value is used several
times.
input.yy:16.31-32: warning: multiple occurrences of $2 with api.value.automove enabled [-Wother]
exp: "twice" exp { $$ = $2 + $2; }
^^
Enabling api.value.automove does not require support for modern C++. The
generated code is valid C++98/03, but will use copies instead of moves.
The new examples/variant-11.yy shows these features in action.
*** C++: The implicit default semantic action is always run
When variants are enabled, the default action was not run, so
exp: "number"
was equivalent to
exp: "number" {}
It now behaves like in all the other cases, as
exp: "number" { $$ = $1; }
possibly using std::move if automove is enabled.
We do not expect backward compatibility issues. However, beware of
forward compatibility issues: if you rely on default actions with
variants, be sure to '%require "3.2"' to avoid older versions of Bison to
generate incorrect parsers.
*** C++: Renaming location.hh
When both %defines and %locations are enabled, Bison generates a
location.hh file. If you don't use locations outside of the parser, you
may avoid its creation with:
%define api.location.file none
However this file is useful if, for instance, your parser builds an AST
decorated with locations: you may use Bison's location independently of
Bison's parser. You can now give it another name, for instance:
%define api.location.file "my-location.hh"
This name can have directory components, and even be absolute. The name
under which the location file is included is controlled by
api.location.include.
This way it is possible to have several parsers share the same location
file.
For instance, in src/foo/parser.hh, generate the include/ast/loc.hh file:
%locations
%define api.namespace {foo}
%define api.location.file "include/ast/loc.hh"
%define api.location.include {<ast/loc.hh>}
and use it in src/bar/parser.hh:
%locations
%define api.namespace {bar}
%code requires {#include <ast/loc.hh>}
%define api.location.type {bar::location}
Absolute file names are supported, so in your Makefile, passing the flag
-Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"' to bison is
safe.
*** C++: stack.hh and position.hh are deprecated
When asked to generate a header file (%defines), the lalr1.cc skeleton
generates a stack.hh file. This file had no interest for users; it is now
made useless: its content is included in the parser definition. It is
still generated for backward compatibility.
When in addition to %defines, location support is requested (%locations),
the file position.hh is also generated. It is now also useless: its
content is now included in location.hh.
These files are no longer generated when your grammar file requires at
least Bison 3.2 (%require "3.2").
** Bug fixes
Portability issues on MinGW and VS2015.
Portability issues in the test suite.
Portability/warning issues with Flex.
* Noteworthy changes in release 3.1 (2018-08-27) [stable]
** Backward incompatible changes
@@ -698,9 +848,9 @@ GNU Bison NEWS
fixed, and introducing tokens with any of %token, %left, %right,
%precedence, or %nonassoc yields the same result.
When mixing declarations of tokens with a litteral character (e.g., 'a')
or with an identifier (e.g., B) in a precedence declaration, Bison
numbered the litteral characters first. For example
When mixing declarations of tokens with a literal character (e.g., 'a') or
with an identifier (e.g., B) in a precedence declaration, Bison numbered
the literal characters first. For example
%right A B 'c' 'd'
@@ -1021,7 +1171,7 @@ GNU Bison NEWS
Although introduced more than four years ago, XML and Graphviz reports
were not properly documented.
The translation of mid-rule actions is now described.
The translation of midrule actions is now described.
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
@@ -2017,16 +2167,16 @@ GNU Bison NEWS
The prologue alternatives are experimental. More user feedback will help to
determine whether they should become permanent features.
** Revised warning: unset or unused mid-rule values
** Revised warning: unset or unused midrule values
Since Bison 2.2, Bison has warned about mid-rule values that are set but not
Since Bison 2.2, Bison has warned about midrule values that are set but not
used within any of the actions of the parent rule. For example, Bison warns
about unused $2 in:
exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
Now, Bison also warns about mid-rule values that are used but not set. For
example, Bison warns about unset $$ in the mid-rule action in:
Now, Bison also warns about midrule values that are used but not set. For
example, Bison warns about unset $$ in the midrule action in:
exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
@@ -2052,7 +2202,7 @@ GNU Bison NEWS
Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
"<*>" and "<>" combined achieve the same effect with one exception: Bison no
longer applies any %destructor to a mid-rule value if that mid-rule value is
longer applies any %destructor to a midrule value if that midrule value is
not actually ever referenced using either $$ or $n in a semantic action.
The default %destructor's and %printer's are experimental. More user
@@ -2230,7 +2380,7 @@ GNU Bison NEWS
| exp "+" exp { $$ = $1; (void) $3; }
;
If there are mid-rule actions, the warning is issued if no action
If there are midrule actions, the warning is issued if no action
uses it. The following triggers no warning: $1 and $3 are used.
exp: exp { push ($1); } '+' exp { push ($3); sum (); };
@@ -2505,13 +2655,13 @@ GNU Bison NEWS
typed: ... untyped;
** Values of mid-rule actions
** Values of midrule actions
The following code:
foo: { ... } { $$ = $1; } ...
was incorrectly rejected: $1 is defined in the second mid-rule
action, and is equal to the $$ of the first mid-rule action.
was incorrectly rejected: $1 is defined in the second midrule
action, and is equal to the $$ of the first midrule action.
* Changes in version 1.50, 2002-10-04:
@@ -2647,7 +2797,7 @@ GNU Bison NEWS
** Type clashes
Previous versions don't complain when there is a type clash on
the default action if the rule has a mid-rule action, such as in:
the default action if the rule has a midrule action, such as in:
%type <foo> bar
%%
@@ -2958,7 +3108,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
LocalWords: Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
LocalWords: Alexandre MERCHANTABILITY yytype
LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir
LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles outout PROG
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW
Local Variables:
mode: outline
+1 -1
View File
@@ -47,7 +47,7 @@ End:
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software
Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of GNU bison, the GNU Compiler Compiler.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
+14 -14
View File
@@ -190,12 +190,15 @@ Use liberally.
** TESTSUITEFLAGS
The default is for make check to run all tests sequentially. This can be
very time consumming when checking repeatedly or on slower setups. This can
be sped up in two ways:
To run just the testsuite (not the tests related to the examples), run `make
check-local`.
The default is for make check-local to run all tests sequentially. This can
be very time consuming when checking repeatedly or on slower setups. This
can be sped up in two ways:
Using -j, in a make-like fashion, for example:
$ make check TESTSUITEFLAGS='-j8'
$ make check-local TESTSUITEFLAGS='-j8'
Running only the tests of a certain category, as specified in the AT files
with AT_KEYWORDS([[category]]). Categories include:
@@ -206,7 +209,7 @@ with AT_KEYWORDS([[category]]). Categories include:
- report, for automaton dumps
To run a specific set of tests, use -k (for "keyword"). For example:
$ make check TESTSUITEFLAGS='-k c++'
$ make check-local TESTSUITEFLAGS='-k c++'
Both can be combined.
@@ -259,24 +262,21 @@ release:
- runs the parsers under Valgrind.
- runs the test suite with G++ as C compiler...
- run "make maintainer-push-check", which runs "make maintainer-check" while
- run "make maintainer-check-push", which runs "make maintainer-check" while
activating the push implementation and its pull interface wrappers in many
test cases that were originally written to exercise only the pull
implementation. This makes certain the push implementation can perform
every task the pull implementation can.
- run "make maintainer-xml-check", which runs "make maintainer-check" while
- run "make maintainer-check-xml", which runs "make maintainer-check" while
checking Bison's XML automaton report for every working grammar passed to
Bison in the test suite. The check just diffs the output of Bison's
included XSLT style sheets with the output of --report=all and --graph.
- running "make maintainer-release-check" takes care of running
maintainer-check, maintainer-push-check and maintainer-xml-check.
- running "make maintainer-check-release" takes care of running
maintainer-check, maintainer-check-push and maintainer-check-xml.
- Change tests/atlocal/CFLAGS to add your preferred options. For instance,
"-traditional" to check that the parsers are K&R. Note that it does not
make sense for glr.c, which should be ANSI, but currently is actually GNU
C, nor for lalr1.cc.
- Change tests/atlocal/CFLAGS to add your preferred options.
- Test with a very recent version of GCC for both C and C++. Testing with
older versions that are still in use is nice too.
@@ -294,7 +294,7 @@ In particular, be sure to read README-release.
week before a stable release, to give them time to translate them. Before
generating the *.pot files, make sure that po/POTFILES.in and
runtime-po/POTFILES.in list all files with translatable strings. This
helps: grep -l '\<_(' *
helps: grep -l '\<_(' *.
** Tests
See above.
+3
View File
@@ -51,6 +51,7 @@ Didier Godefroy [email protected]
Efi Fogel [email protected]
Enrico Scholz [email protected]
Eric Blake [email protected]
Étienne Renault [email protected]
Evgeny Stambulchik [email protected]
Fabrice Bauzac [email protected]
Ferdinand Thiessen [email protected]
@@ -77,6 +78,7 @@ Johan van Selst [email protected]
John Horigan [email protected]
Jonathan Fabrizio [email protected]
Jonathan Nieder [email protected]
Josh Soref [email protected]
Juan Manuel Guerrero [email protected]
Kees Zeelenberg [email protected]
Keith Browne [email protected]
@@ -145,6 +147,7 @@ Sebastian Setzer [email protected]
Sebastien Fricker [email protected]
Sergei Steshenko [email protected]
Shura [email protected]
Simon Sobisch [email protected]
Stefano Lattarini [email protected]
Stephen Cameron [email protected]
Steve Murphy [email protected]
+23
View File
@@ -196,6 +196,24 @@ DeRemer and Penello: they already provide the algorithm.
* Extensions
** Multiple start symbols
Would be very useful when parsing closely related languages.
** Better error messages
The users are not provided with enough tools to forge their error messages.
See for instance "Is there an option to change the message produced by
YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
** %include
This is a popular demand. We already made many changes in the parser that
should make this reasonably easy to implement.
** Push parsers
There is demand for push parsers in Java and C++. And GLR I guess.
** Generate code instead of tables
This is certainly quite a lot of work. See
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.4539.
** $-1
We should find a means to provide an access to values deep in the
@@ -231,6 +249,10 @@ XML output for GNU Bison and gcc
XML output for GNU Bison
http://yaxx.sourceforge.net/
** Counterexample generation
https://lists.gnu.org/archive/html/bug-bison/2016-06/msg00000.html
http://www.cs.cornell.edu/andru/papers/cupex/
* Unit rules
Maybe we could expand unit rules, i.e., transform
@@ -365,6 +387,7 @@ Here's a proposal for how a new implementation might look:
Local Variables:
mode: outline
coding: utf-8
fill-column: 76
End:
-----
+6 -16
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2018-07-25.07; # UTC
scriptversion=2018-10-13.05; # UTC
# Bootstrap this package from checked-out sources.
@@ -162,18 +162,11 @@ bootstrap_post_import_hook() { :; }
# Override it via your own definition in bootstrap.conf.
bootstrap_epilogue() { :; }
# The command to download all .po files for a specified domain into
# a specified directory. Fill in the first %s is the domain name, and
# the second with the destination directory. Use rsync's -L and -r
# options because the latest/%s directory and the .po files within are
# all symlinks.
# The command to download all .po files for a specified domain into a
# specified directory. Fill in the first %s with the destination
# directory and the second with the domain name.
po_download_command_format=\
"rsync --include '*.po' --exclude '*' -Lrtvz \
'translationproject.org::tp/latest/%s/' '%s'"
# Fallback for downloading .po files (if rsync fails).
po_download_command_format2=\
"wget --mirror -nd -q -np -A.po -P '%s' \
"wget --mirror --level=1 -nd -q -A.po -P '%s' \
https://translationproject.org/latest/%s/"
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
@@ -741,10 +734,7 @@ download_po_files() {
subdir=$1
domain=$2
echo "$me: getting translations into $subdir for $domain..."
cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
eval "$cmd" && return
# Fallback to HTTPS.
cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
eval "$cmd"
}
+1
View File
@@ -35,6 +35,7 @@ gnulib_modules='
readme-release
realloc-posix
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
timevar
unistd unistd-safer unlink unlocked-io
update-copyright unsetenv verify
warnings
+13
View File
@@ -15,6 +15,19 @@
# Valgrind suppression file for Bison.
# Travis Trusty, 2018-09-07.
{
libstdcxx_init
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
obj:/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
fun:call_init.part.0
fun:call_init
fun:_dl_init
obj:/lib/x86_64-linux-gnu/ld-2.19.so
}
# Linux prague 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015
# x86_64 GNU/Linux
{
+1 -1
View File
@@ -35,7 +35,7 @@ while (<STDIN>)
$arg =~ s/^=//;
$arg = lc ($arg);
my $dir_arg = $arg;
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
# If the argument is complete (e.g., for --define[=NAME[=VALUE]]),
# put each word in @var, to build @var{name}[=@var{value}], not
# @var{name[=value]}].
$arg =~ s/(\w+)/\@var{$1}/g;
+234
View File
@@ -0,0 +1,234 @@
#!/bin/sh
# Install Intel Parallel Studio on Travis CI
# https://github.com/nemequ/icc-travis
#
# Originally written for Squash <https://github.com/quixdb/squash> by
# Evan Nemerson. For documentation, bug reports, support requests,
# etc. please use <https://github.com/nemequ/icc-travis>.
#
# To the extent possible under law, the author(s) of this script have
# waived all copyright and related or neighboring rights to this work.
# See <https://creativecommons.org/publicdomain/zero/1.0/> for
# details.
# Tools - Not very useful in non-interactive mode.
COMPONENTS_VTUNE="intel-vtune-amplifier-xe-2016-cli__x86_64;intel-vtune-amplifier-xe-2016-common__noarch;intel-vtune-amplifier-xe-2016-cli-common__noarch;intel-vtune-amplifier-xe-2016-collector-64linux__x86_64;intel-vtune-amplifier-xe-2016-sep__noarch;intel-vtune-amplifier-xe-2016-gui-common__noarch;intel-vtune-amplifier-xe-2016-gui__x86_64;intel-vtune-amplifier-xe-2016-common-pset__noarch"
COMPONENTS_INSPECTOR="intel-inspector-xe-2016-cli__x86_64;intel-inspector-xe-2016-cli-common__noarch;intel-inspector-xe-2016-gui-common__noarch;intel-inspector-xe-2016-gui__x86_64;intel-inspector-xe-2016-cli-pset__noarch"
COMPONENTS_ADVISOR="intel-advisor-xe-2016-cli__x86_64;intel-advisor-xe-2016-cli-common__noarch;intel-advisor-xe-2016-gui-common__noarch;intel-advisor-xe-2016-gui__x86_64;intel-advisor-xe-2016-cli-pset__noarch"
COMPONENTS_GDB="intel-gdb-gt__x86_64;intel-gdb-gt-src__noarch;intel-gdb-gt-libelfdwarf__x86_64;intel-gdb-gt-devel__x86_64;intel-gdb-gt-common__noarch;intel-gdb-ps-cdt__x86_64;intel-gdb-ps-cdt-source__x86_64;intel-gdb-ps-mic__x86_64;intel-gdb-ps-mpm__x86_64;intel-gdb__x86_64;intel-gdb-source__noarch;intel-gdb-python-source__noarch;intel-gdb-common__noarch;intel-gdb-ps-common__noarch"
# Parallel libraries
COMPONENTS_MPI="intel-mpi-rt-core__x86_64;intel-mpi-rt-mic__x86_64;intel-mpi-sdk-core__x86_64;intel-mpi-sdk-mic__x86_64;intel-mpi-psxe__x86_64;intel-mpi-rt-psxe__x86_64"
COMPONENTS_TBB="intel-tbb-libs__noarch;intel-mkl-ps-tbb__x86_64;intel-mkl-ps-tbb-devel__x86_64;intel-mkl-ps-tbb-mic__x86_64;intel-mkl-ps-tbb-mic-devel__x86_64;intel-tbb-source__noarch;intel-tbb-devel__noarch;intel-tbb-common__noarch;intel-tbb-ps-common__noarch;intel-tbb-psxe__noarch"
COMPONENTS_MKL="intel-mkl__x86_64;intel-mkl-ps__x86_64;intel-mkl-common__noarch;intel-mkl-ps-common__noarch;intel-mkl-devel__x86_64;intel-mkl-ps-mic-devel__x86_64;intel-mkl-ps-f95-devel__x86_64;intel-mkl-gnu-devel__x86_64;intel-mkl-ps-gnu-devel__x86_64;intel-mkl-ps-pgi-devel__x86_64;intel-mkl-sp2dp-devel__x86_64;intel-mkl-ps-cluster-devel__x86_64;intel-mkl-ps-cluster-common__noarch;intel-mkl-ps-f95-common__noarch;intel-mkl-ps-cluster__x86_64;intel-mkl-gnu__x86_64;intel-mkl-ps-gnu__x86_64;intel-mkl-ps-pgi__x86_64;intel-mkl-sp2dp__x86_64;intel-mkl-ps-mic__x86_64;intel-mkl-ps-tbb__x86_64;intel-mkl-ps-tbb-devel__x86_64;intel-mkl-ps-tbb-mic__x86_64;intel-mkl-ps-tbb-mic-devel__x86_64;intel-mkl-psxe__noarch"
COMPONENTS_IPP="intel-ipp-l-common__noarch;intel-ipp-l-ps-common__noarch;intel-ipp-l-st__x86_64;intel-ipp-l-mt__x86_64;intel-ipp-l-st-devel__x86_64;intel-ipp-l-ps-st-devel__x86_64;intel-ipp-l-mt-devel__x86_64;intel-ipp-psxe__noarch"
COMPONENTS_IPP_CRYPTO="intel-crypto-ipp-st-devel__x86_64;intel-crypto-ipp-ps-st-devel__x86_64;intel-crypto-ipp-st__x86_64;intel-crypto-ipp-mt-devel__x86_64;intel-crypto-ipp-mt__x86_64;intel-crypto-ipp-ss-st-devel__x86_64;intel-crypto-ipp-common__noarch"
COMPONENTS_DAAL="intel-daal__x86_64;intel-daal-common__noarch"
# Compilers
COMPONENTS_OPENMP="intel-openmp-l-all__x86_64;intel-openmp-l-ps-mic__x86_64;intel-openmp-l-ps__x86_64;intel-openmp-l-ps-ss__x86_64;intel-openmp-l-all-devel__x86_64;intel-openmp-l-ps-mic-devel__x86_64;intel-openmp-l-ps-devel__x86_64;intel-openmp-l-ps-ss-devel__x86_64"
COMPONENTS_COMPILER_COMMON="intel-comp-l-all-vars__noarch;intel-comp-l-all-common;intel-comp-l-ps-common;intel-comp-l-all-devel;intel-comp-l-ps-ss-devel;intel-comp-l-ps-ss-wrapper;intel-comp-l-all-devel;intel-comp-l-ps-devel__x86_64;intel-comp-l-ps-ss-devel__x86_64;intel-psf-intel__x86_64;intel-icsxe-pset;intel-ipsf__noarch;intel-ccompxe__noarch;${COMPONENTS_OPENMP}"
COMPONENTS_IFORT="intel-ifort-l-ps__x86_64;intel-ifort-l-ps-vars__noarch;intel-ifort-l-ps-common__noarch;intel-ifort-l-ps-devel__x86_64;${COMPONENTS_COMPILER_COMMON}"
COMPONENTS_ICC="intel-icc-l-all__x86_64;intel-icc-l-ps-ss__x86_64;intel-icc-l-all-vars__noarch;intel-icc-l-all-common__noarch;intel-icc-l-ps-common__noarch;intel-icc-l-all-devel__x86_64;intel-icc-l-ps-devel__x86_64;intel-icc-l-ps-ss-devel__x86_64;${COMPONENTS_COMPILER_COMMON}"
DESTINATION="${HOME}/intel"
TEMPORARY_FILES="/tmp"
PHONE_INTEL="no"
COMPONENTS=""
add_components() {
if [ ! -z "${COMPONENTS}" ]; then
COMPONENTS="${COMPONENTS};$1"
else
COMPONENTS="$1"
fi
}
while [ $# != 0 ]; do
case "$1" in
"--dest")
DESTINATION="$(realpath "$2")"; shift
;;
"--tmpdir")
TEMPORARY_FILES="$2"; shift
;;
"--components")
shift
OLD_IFS="${IFS}"
IFS=","
for component in $1; do
case "$component" in
"icc")
add_components "${COMPONENTS_ICC}"
;;
"mpi")
add_components "${COMPONENTS_MPI}"
;;
"vtune")
add_components "${COMPONENTS_VTUNE}"
;;
"inspector")
add_components "${COMPONENTS_INSPECTOR}"
;;
"advisor")
add_components "${COMPONENTS_ADVISOR}"
;;
"tbb")
add_components "${COMPONENTS_TBB}"
;;
"ifort")
add_components "${COMPONENTS_IFORT}"
;;
"mkl")
add_components "${COMPONENTS_MKL}"
;;
"openmp")
# Noop, here for compatability. OpenMP is installed with icc and ifort now.
;;
"ipp")
add_components "${COMPONENTS_IPP}"
;;
"ipp-crypto")
add_components "${COMPONENTS_IPP_CRYPTO}"
;;
"gdb")
add_components "${COMPONENTS_GDB}"
;;
"daal")
add_components "${COMPONENTS_DAAL}"
;;
*)
echo "Unknown component '$component'"
exit 1
;;
esac
done
IFS="${OLD_IFS}"
;;
*)
echo "Unrecognized argument '$1'"
exit 1
;;
esac
shift
done
if [ -z "${COMPONENTS}" ]; then
COMPONENTS="${COMPONENTS_ICC}"
fi
INSTALLER_SCRIPT="parallel_studio_xe_2016_update3_online.sh"
INSTALLER="${TEMPORARY_FILES}/${INSTALLER_SCRIPT}"
INSTALLER_URL="http://registrationcenter-download.intel.com/akdlm/irc_nas/9061/${INSTALLER_SCRIPT}"
SILENT_CFG="${TEMPORARY_FILES}/silent.cfg"
SUCCESS_INDICATOR="${TEMPORARY_FILES}/icc-travis-success"
if [ ! -e "${TEMPORARY_FILES}" ]; then
echo "${TEMPORARY_FILES} does not exist, creating..."
mkdir -p "${TEMPORARY_FILES}" || (sudo mkdir -p "${TEMPORARY_FILES}" && sudo chown -R "${USER}:${USER}" "${TEMPORARY_FILES}")
fi
if [ ! -e "${DESTINATION}" ]; then
echo "${DESTINATION} does not exist, creating..."
mkdir -p "${DESTINATION}" || (sudo mkdir -p "${DESTINATION}" && sudo chown -R "${USER}:${USER}" "${DESTINATION}")
fi
if [ ! -e "${INSTALLER}" ]; then
wget -O "${INSTALLER}" "${INSTALLER_URL}" || exit 1
fi
chmod u+x "${INSTALLER}"
# See https://software.intel.com/en-us/articles/intel-composer-xe-2015-silent-installation-guide
echo "# Generated silent configuration file" > "${SILENT_CFG}"
echo "ACCEPT_EULA=accept" >> "${SILENT_CFG}"
echo "INSTALL_MODE=NONRPM" >> "${SILENT_CFG}"
echo "CONTINUE_WITH_OPTIONAL_ERROR=yes" >> "${SILENT_CFG}"
echo "PSET_INSTALL_DIR=${DESTINATION}" >> "${SILENT_CFG}"
echo "CONTINUE_WITH_INSTALLDIR_OVERWRITE=yes" >> "${SILENT_CFG}"
echo "COMPONENTS=${COMPONENTS}" >> "${SILENT_CFG}"
echo "PSET_MODE=install" >> "${SILENT_CFG}"
echo "PHONEHOME_SEND_USAGE_DATA=${PHONE_INTEL}" >> "${SILENT_CFG}"
if [ "x" != "x${INTEL_SERIAL_NUMBER}" ]; then
echo "ACTIVATION_SERIAL_NUMBER=${INTEL_SERIAL_NUMBER}" >> "${SILENT_CFG}"
echo "ACTIVATION_TYPE=serial_number" >> "${SILENT_CFG}"
else
echo "ACTIVATION_TYPE=trial_lic" >> "${SILENT_CFG}"
fi
attempt=1;
while [ $attempt -le 3 ]; do
if [ ! -e "${TEMPORARY_FILES}/parallel-studio-install-data" ]; then
mkdir -p "${TEMPORARY_FILES}/parallel-studio-install-data" || (sudo mkdir -p "${TEMPORARY_FILES}/parallel-studio-install-data" && sudo chown -R "${USER}:${USER}" "${TEMPORARY_FILES}")
fi
("${INSTALLER}" \
-t "${TEMPORARY_FILES}/parallel-studio-install-data" \
-s "${SILENT_CFG}" \
--cli-mode \
--user-mode && \
touch "${SUCCESS_INDICATOR}") &
# So Travis doesn't die in case of a long download/installation.
#
# NOTE: a watched script never terminates.
elapsed=0;
while kill -0 $! 2>/dev/null; do
sleep 1
elapsed=$(expr $elapsed + 1)
if [ $(expr $elapsed % 60) -eq 0 ]; then
mins_elapsed=$(expr $elapsed / 60)
if [ $mins_elapsed = 1 ]; then
minute_string="minute"
else
minute_string="minutes"
fi
echo "Still running... (about $(expr $elapsed / 60) ${minute_string} so far)."
fi
done
if [ ! -e "${SUCCESS_INDICATOR}" ]; then
echo "Installation failed."
exit 1
fi
if [ ! -e "${DESTINATION}/bin/compilervars.sh" ]; then
# Sometimes the installer returns successfully without actually
# installing anything. Let's try again…
echo "Installation attempt #${attempt} completed, but unable to find compilervars.sh."
find "${DESTINATION}"
else
break
fi
rm -vrf "${TEMPORARY_FILES}/parallel-studio-install-data"
echo "Trying again..."
attempt=$(expr $attempt + 1)
done
if [ ! -e "${DESTINATION}/bin/compilervars.sh" ]; then
echo "Installation failed."
exit 1
fi
# Apparently the installer drops the license file in a location it
# doesn't know to check.
ln -s "${DESTINATION}"/licenses ~/Licenses
# Add configuration information to ~/.bashrc. Unfortunately this will
# not be picked up automatically by Travis, so you'll still need to
# source ~/.bashrc in your .travis.yml
#
# Container-based builds include a `[ -z "$PS1" ] && return` near the
# beginning of the file, so appending won't work, we'll need to
# prepend.
echo "export INTEL_INSTALL_PATH=\"${DESTINATION}\"" >> ~/.bashrc-intel
echo ". \"\${INTEL_INSTALL_PATH}/bin/compilervars.sh\" intel64" >> ~/.bashrc-intel
echo "export LD_LIBRARY_PATH=\"\${INTEL_INSTALL_PATH}/ism/bin/intel64:\${INTEL_INSTALL_PATH}/lib/intel64_lin:\$LD_LIBRARY_PATH\"" >> ~/.bashrc-intel
echo "export PATH=\"\${INTEL_INSTALL_PATH}/bin:\$PATH\"" >> ~/.bashrc-intel
echo "function uninstall_intel_software {" >> ~/.bashrc-intel
echo " find \"\${INTEL_INSTALL_PATH}\" -name 'uninstall.sh' -not -path '*/ism/uninstall.sh' -exec {} -s \;" >> ~/.bashrc-intel
echo "}" >> ~/.bashrc-intel
cat ~/.bashrc >> ~/.bashrc-intel
mv ~/.bashrc-intel ~/.bashrc
+23 -23
View File
@@ -26,11 +26,11 @@ regen: _version
manual_title = The Yacc-compatible Parser Generator
gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc
# It's useful to run maintainer-*check* targets during development, but we
# It's useful to run maintainer-check* targets during development, but we
# don't want to wait on a recompile because of an update to $(VERSION). Thus,
# override the _is-dist-target from GNUmakefile so that maintainer-*check*
# override the _is-dist-target from GNUmakefile so that maintainer-check*
# targets are filtered out.
_is-dist-target = $(filter-out %clean maintainer-check% maintainer-%-check, \
_is-dist-target = $(filter-out %clean maintainer-check%, \
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
url_dir_list = \
@@ -158,24 +158,24 @@ sc_space_before_open_paren:
exclude = \
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \
prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
prohibit_doubled_word=^tests/named-refs.at$$ \
prohibit_magic_number_exit=^doc/bison.texi$$ \
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
prohibit_tab_based_indentation=\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
space_before_open_paren=^(data/|djgpp/) \
two_space_separator_in_usage=^(bootstrap) \
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
prohibit_always_true_header_tests=^djgpp/subpipe.h$$|^lib/timevar.c$$ \
prohibit_always_true_header_tests+=?|^m4/timevar.m4$$ \
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
prohibit_doubled_word=^tests/named-refs.at$$ \
prohibit_magic_number_exit=^doc/bison.texi$$ \
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
prohibit_strcmp=^doc/bison\.texi|tests/local\.at$$ \
prohibit_tab_based_indentation=install-icc.sh|\.(am|mk)$$|^djgpp/|^\.git|Makefile$$ \
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
space_before_open_paren=^(data/|djgpp/) \
two_space_separator_in_usage=^(bootstrap|build-aux/install-icc.sh) \
unmarked_diagnostics=^(djgpp/|doc/bison.texi$$|tests/c\+\+\.at$$) \
)
+22 -6
View File
@@ -21,7 +21,8 @@
# better to avoid a typo in the 'configure --help' entry for the YACC
# environment variable.
AC_PREREQ([2.68])
m4_pattern_forbid([^gl_[A-Z]])
m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
m4_pattern_allow([^BISON_USE_NLS$])
AC_INIT([GNU Bison],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
@@ -70,6 +71,17 @@ AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
[lv_cv_gcc_pragma_push_works=no])
CFLAGS=$save_CFLAGS])
AC_LANG_PUSH([C++])
gl_WARN_ADD([-fno-exceptions], [NO_EXCEPTIONS_CXXFLAGS])
BISON_CXXSTD([98])
BISON_CXXSTD([03])
BISON_CXXSTD([11])
BISON_CXXSTD([14])
BISON_CXXSTD([17])
BISON_CXXSTD([2a])
AM_CONDITIONAL([ENABLE_CXX11], [test x"$CXX11_CXXFLAGS" != x])
AC_LANG_POP([C++])
AC_ARG_ENABLE([gcc-warnings],
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended).
Also, issue synclines from the examples/ to
@@ -81,7 +93,8 @@ AC_ARG_ENABLE([gcc-warnings],
[enable_gcc_warnings=no])
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
if test "$enable_gcc_warnings" = yes; then
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align -Wdocumentation
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
-fparse-all-comments -Wdocumentation
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
warn_cxx='-Wnoexcept'
@@ -150,13 +163,15 @@ if test "$enable_gcc_warnings" = yes; then
gl_WARN_ADD([-Wno-null-conversion], [FLEX_SCANNER_CXXFLAGS])
# So does G++ 4.8...
gl_WARN_ADD([-Wno-sign-compare], [FLEX_SCANNER_CXXFLAGS])
# ... possiby in std=c++11 mode.
# ... possibly in std=c++11 mode.
gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
CXXFLAGS=$save_CXXFLAGS
gl_WARN_ADD([-fno-exceptions], [CXXFLAGS_NO_EXCEPTIONS])
# Clang++ deprecates compiling C.
gl_WARN_ADD([-Wno-deprecated], [WNO_DEPRECATED_CXXFLAGS])
AC_LANG_POP([C++])
fi
BISON_TEST_FOR_WORKING_C_COMPILER
BISON_C_COMPILER_POSIXLY_CORRECT
BISON_TEST_FOR_WORKING_CXX_COMPILER
@@ -204,7 +219,6 @@ gl_INIT
# Checks for library functions.
AC_CHECK_FUNCS_ONCE([setlocale])
AM_WITH_DMALLOC
BISON_PREREQ_TIMEVAR
# Gettext.
# We use gnulib, which is only guaranteed to work properly with the
@@ -243,6 +257,8 @@ case $VALGRIND:$uname in
fi
;;
esac
AC_MSG_CHECKING([Valgrind suppression file])
AC_MSG_RESULT([$suppfile])
# Whether we cannot run the compiled bison.
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
@@ -251,7 +267,7 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
# Needed by tests/atlocal.in.
AC_SUBST([GCC])
gt_JAVACOMP([1.3], [1.4])
gt_JAVACOMP([1.7], [1.7])
gt_JAVAEXEC
AC_CONFIG_FILES([Makefile
+74 -29
View File
@@ -61,23 +61,35 @@ This special exception was added by the Free Software Foundation in
version 2.2 of Bison.])])
# b4_required_version_if(VERSION, IF_NEWER, IF_OLDER)
# ---------------------------------------------------
# If the version %require'd by the user is VERSION (or newer) expand
# IF_NEWER, otherwise IF_OLDER. VERSION should be an integer, e.g.,
# 302 for 3.2.
m4_define([b4_required_version_if],
[m4_if(m4_eval($1 <= b4_required_version),
[1], [$2], [$3])])
## -------- ##
## Output. ##
## -------- ##
# b4_output_begin(FILE)
# ---------------------
# b4_output_begin(FILE1, FILE2)
# -----------------------------
# Enable output, i.e., send to diversion 0, expand after "#", and
# generate the tag to output into FILE. Must be followed by EOL.
# FILE is FILE1 concatenated to FILE2. FILE2 can be empty, or be
# absolute: do the right thing.
m4_define([b4_output_begin],
[m4_changecom()
m4_divert_push(0)dnl
@output(m4_unquote([$1])@)@dnl
@output(m4_unquote([$1])@,m4_unquote([$2])@)@dnl
])
# b4_output_end()
# ---------------
# b4_output_end
# -------------
# Output nothing, restore # as comment character (no expansions after #).
m4_define([b4_output_end],
[m4_divert_pop(0)
@@ -389,11 +401,11 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
#
# The following macros provide access to these values.
# b4_symbol_(NUM, FIELD)
# _b4_symbol(NUM, FIELD)
# ----------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined.
m4_define([b4_symbol_],
m4_define([_b4_symbol],
[m4_indir([b4_symbol($1, $2)])])
@@ -404,8 +416,8 @@ m4_define([b4_symbol_],
m4_define([b4_symbol],
[m4_case([$2],
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
[b4_symbol_([$1], [id])])],
[b4_symbol_($@)])])
[_b4_symbol([$1], [id])])],
[_b4_symbol($@)])])
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
@@ -443,7 +455,7 @@ m4_define([b4_symbol_action],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[(*yylocationp)])dnl
b4_symbol_case_([$1])[]dnl
_b4_symbol_case([$1])[]dnl
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline([@oline@], [@ofile@])
@@ -478,10 +490,10 @@ m4_ifval(m4_defn([b4_actions_]),
m4_popdef([b4_actions_])dnl
])
# b4_symbol_case_(SYMBOL-NUM)
# _b4_symbol_case(SYMBOL-NUM)
# ---------------------------
# Issue a "case NUM" for SYMBOL-NUM.
m4_define([b4_symbol_case_],
m4_define([_b4_symbol_case],
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
])
@@ -536,16 +548,16 @@ m4_define([b4_token_format],
## Types. ##
## ------- ##
# b4_type_action_(NUMS)
# _b4_type_action(NUMS)
# ---------------------
# Run actions for the symbol NUMS that all have the same type-name.
# Skip NUMS that have no type-name.
#
# To specify the action to run, define b4_dollar_dollar(NUMBER,
# TAG, TYPE).
m4_define([b4_type_action_],
m4_define([_b4_type_action],
[b4_symbol_if([$1], [has_type],
[m4_map([ b4_symbol_case_], [$@])[]dnl
[m4_map([ _b4_symbol_case], [$@])[]dnl
b4_dollar_dollar([b4_symbol([$1], [number])],
[b4_symbol([$1], [tag])],
[b4_symbol([$1], [type])]);
@@ -701,7 +713,7 @@ m4_define([b4_percent_define_use],
# b4_percent_define_get([[foo]])
m4_define([b4_percent_define_get],
[b4_percent_define_use([$1])dnl
b4_percent_define_ifdef_([$1],
_b4_percent_define_ifdef([$1],
[m4_indir([b4_percent_define(]$1[)])],
[$2])])
@@ -710,7 +722,7 @@ b4_percent_define_ifdef_([$1],
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
# if the %define variable VARIABLE is undefined, complain fatally since that's
# a Bison or skeleton error. Otherwise, return its definition location in a
# form approriate for the first two arguments of b4_warn_at, b4_complain_at, or
# form appropriate for the first two arguments of b4_warn_at, b4_complain_at, or
# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no
# reason to suspect that the user-supplied value has yet influenced the output.
#
@@ -755,15 +767,15 @@ m4_define([b4_percent_define_get_syncline],
[m4_indir([b4_percent_define_syncline(]$1[)])],
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
# b4_percent_define_ifdef_(VARIABLE, IF-TRUE, [IF-FALSE])
# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
# ------------------------------------------------------
# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
# IF-FALSE. Don't record usage of VARIABLE.
#
# For example:
#
# b4_percent_define_ifdef_([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef_],
# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([_b4_percent_define_ifdef],
[m4_ifdef([b4_percent_define(]$1[)],
[$2],
[$3])])
@@ -779,11 +791,44 @@ m4_define([b4_percent_define_ifdef_],
#
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef],
[b4_percent_define_ifdef_([$1],
[_b4_percent_define_ifdef([$1],
[b4_percent_define_use([$1])$2],
[$3])])
# b4_percent_define_check_file_complain(VARIABLE)
# -----------------------------------------------
# Warn about %define variable VARIABLE having an incorrect
# value.
m4_define([b4_percent_define_check_file_complain],
[b4_complain_at(b4_percent_define_get_loc([$1]),
[[%%define variable '%s' requires 'none' or '"..."' values]],
[$1])])
# b4_percent_define_check_file(MACRO, VARIABLE, DEFAULT)
# ------------------------------------------------------
# If the %define variable VARIABLE:
# - is undefined, then if DEFAULT is non-empty, define MACRO to DEFAULT
# - is a string, define MACRO to its value
# - is the keyword 'none', do nothing
# - otherwise, warn about the incorrect value.
m4_define([b4_percent_define_check_file],
[b4_percent_define_ifdef([$2],
[m4_case(b4_percent_define_get_kind([$2]),
[string],
[m4_define([$1], b4_percent_define_get([$2]))],
[keyword],
[m4_if(b4_percent_define_get([$2]), [none], [],
[b4_percent_define_check_file_complain([$2])])],
[b4_percent_define_check_file_complain([$2])])
],
[m4_ifval([$3],
[m4_define([$1], [$3])])])
])
## --------- ##
## Options. ##
## --------- ##
@@ -824,7 +869,7 @@ m4_define([b4_percent_define_flag_if],
#
# b4_percent_define_default([[foo]], [[default value]])
m4_define([b4_percent_define_default],
[b4_percent_define_ifdef_([$1], [],
[_b4_percent_define_ifdef([$1], [],
[m4_define([b4_percent_define(]$1[)], [$2])dnl
m4_define([b4_percent_define_kind(]$1[)],
[m4_default([$3], [keyword])])dnl
@@ -839,26 +884,26 @@ m4_define([b4_percent_define_default],
# Define b4_NAME_if that executes its $1 or $2 depending whether
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
# to '_'.
m4_define([b4_percent_define_if_define_],
m4_define([_b4_percent_define_if_define],
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
[b4_percent_define_flag_if(m4_default([$2], [$1]),
[$3], [$4])])])
m4_define([b4_percent_define_if_define],
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
b4_percent_define_if_define_([$1], [$2], $[1], $[2])])
_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
# ---------------------------------------------------------------------
m4_define([b4_percent_define_check_kind],
[b4_percent_define_ifdef_([$1],
[_b4_percent_define_ifdef([$1],
[m4_if(b4_percent_define_get_kind([$1]), [$2], [],
[b4_error([m4_default([$3], [complain])],
b4_percent_define_get_loc([$1]),
[m4_case([$2],
[code], [[%%define variable '%s' requires '{...}' values]],
[code], [[%%define variable '%s' requires '{...}' values]],
[keyword], [[%%define variable '%s' requires keyword values]],
[string], [[%%define variable '%s' requires '"..."' values]])],
[string], [[%%define variable '%s' requires '"..."' values]])],
[$1])])])dnl
])
@@ -884,7 +929,7 @@ m4_define([b4_percent_define_check_values],
[_b4_percent_define_check_values(b4_sublist)])])
m4_define([_b4_percent_define_check_values],
[b4_percent_define_ifdef_([$1],
[_b4_percent_define_ifdef([$1],
[b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl
m4_pushdef([b4_good_value], [0])dnl
m4_if($#, 1, [],
@@ -946,7 +991,7 @@ m4_define([b4_percent_code_ifdef],
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
# ----------------------------------------------
# ----------------------------------------------------------
b4_percent_define_if_define([token_ctor], [api.token.constructor])
b4_percent_define_if_define([locations]) # Whether locations are tracked.
b4_percent_define_if_define([parse.assert])
+72 -39
View File
@@ -24,11 +24,20 @@ b4_percent_define_ifdef([[api.value.union.name]],
m4_include(b4_pkgdatadir/[c.m4])
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
## ----- ##
## C++. ##
## ----- ##
# b4_comment(TEXT, [PREFIX])
# --------------------------
# Put TEXT in comment. Prefix all the output lines with PREFIX.
m4_define([b4_comment],
[b4_comment_([$1], [$2// ], [$2// ])])
[_b4_comment([$1], [$2// ], [$2// ])])
# b4_inline(hh|cc)
# ----------------
@@ -40,12 +49,26 @@ m4_define([b4_inline],
]],
[m4_fatal([$0: invalid argument: $1])])])
## -------- ##
## Checks. ##
## -------- ##
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
# b4_cxx_portability
# ------------------
m4_define([b4_cxx_portability],
[// Support move semantics when possible.
#if defined __cplusplus && 201103L <= __cplusplus
# define YY_MOVE std::move
# define YY_MOVE_OR_COPY move
# define YY_MOVE_REF(Type) Type&&
# define YY_RVREF(Type) Type&&
# define YY_COPY(Type) Type
#else
# define YY_MOVE
# define YY_MOVE_OR_COPY copy
# define YY_MOVE_REF(Type) Type&
# define YY_RVREF(Type) const Type&
# define YY_COPY(Type) const Type&
#endif[]dnl
])
## ---------------- ##
## Default values. ##
@@ -88,7 +111,7 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
[[namespace reference is empty]])])
# Instead of assuming the C++ compiler will do it, Bison should reject any
# invalid b4_namepsace_ref that would be converted to a valid
# invalid b4_namespace_ref that would be converted to a valid
# b4_namespace_open. The problem is that Bison doesn't always output
# b4_namespace_ref to uncommented code but should reserve the ability to do so
# in future releases without risking breaking any existing user grammars.
@@ -192,11 +215,18 @@ m4_define([b4_public_types_declare],
/// Internal symbol number for tokens (subsumed by symbol_number_type).
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
]])
/// A complete symbol.
# b4_symbol_type_declare
# ----------------------
# Define symbol_type, the external type for symbols used for symbol
# constructors.
m4_define([b4_symbol_type_declare],
[[ /// A complete symbol.
///
/// Expects its Base type to provide access to the symbol type
/// via type_get().
/// via type_get ().
///
/// Provide access to semantic value]b4_locations_if([ and location])[.
template <typename Base>
@@ -208,19 +238,20 @@ m4_define([b4_public_types_declare],
/// Default constructor.
basic_symbol ();
/// Copy constructor.
basic_symbol (const basic_symbol& other);
/// Move or copy constructor.
basic_symbol (YY_RVREF (basic_symbol) other);
]b4_variant_if([[
/// Constructor for valueless symbols, and symbols from each type.
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
/// Constructor for valueless symbols.
basic_symbol (typename Base::kind_type t]b4_locations_if([,
const location_type& l])[);]])[
YY_MOVE_REF (location_type) l])[);
/// Constructor for symbols with semantic value.
basic_symbol (typename Base::kind_type t,
const semantic_type& v]b4_locations_if([,
const location_type& l])[);
YY_RVREF (semantic_type) v]b4_locations_if([,
YY_RVREF (location_type) l])[);]])[
/// Destroy the symbol.
~basic_symbol ();
@@ -241,8 +272,10 @@ m4_define([b4_public_types_declare],
location_type location;])[
private:
#if defined __cplusplus && __cplusplus < 201103L
/// Assignment operator.
basic_symbol& operator= (const basic_symbol& other);
#endif
};
/// Type access provider for token (enum) based symbols.
@@ -281,8 +314,7 @@ m4_define([b4_public_types_declare],
/// "External" symbols: returned by the scanner.
typedef basic_symbol<by_type> symbol_type;
]b4_symbol_constructor_declare])
]])
# b4_public_types_define(hh|cc)
@@ -302,27 +334,15 @@ m4_define([b4_public_types_define],
{}
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other)
, value (]b4_variant_if([], [other.value])[)]b4_locations_if([
, location (other.location)])[
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (YY_RVREF (basic_symbol) other)
: Base (YY_MOVE (other))
, value (]b4_variant_if([], [YY_MOVE (other.value)]))b4_locations_if([
, location (YY_MOVE (other.location))])[
{]b4_variant_if([
b4_symbol_variant([other.type_get ()], [value], [copy],
[other.value])])[
b4_symbol_variant([other.type_get ()], [value], [YY_MOVE_OR_COPY],
[YY_MOVE (other.value)])])[
}
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
[const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: Base (t)
, value (]b4_variant_if([], [v])[)]b4_locations_if([
, location (l)])[
{]b4_variant_if([[
(void) v;
]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[}
]b4_variant_if([[
// Implementation of basic_symbol constructor for each type.
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
@@ -330,11 +350,23 @@ m4_define([b4_public_types_define],
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
b4_locations_if([const location_type& l]))[)
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
: Base (t)
, value ()]b4_locations_if([
, location (l)])[
{}]])[
{}
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
[YY_RVREF (semantic_type) v],
b4_locations_if([YY_RVREF (location_type) l]))[)
: Base (t)
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([
, location (YY_MOVE (l))])[
{]b4_variant_if([[
(void) v;
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
@@ -375,9 +407,9 @@ m4_define([b4_public_types_define],
{
super_type::move (s);
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
[s.value])],
[value = s.value;])[]b4_locations_if([
location = s.location;])[
[YY_MOVE (s.value)])],
[value = YY_MOVE (s.value);])[]b4_locations_if([
location = YY_MOVE (s.location);])[
}
// by_type.
@@ -426,6 +458,7 @@ m4_define([b4_public_types_define],
return static_cast<token_type> (yytoken_number_[type]);
}
]])[]dnl
b4_symbol_constructor_define])
+6 -6
View File
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# b4_comment_(TEXT, OPEN, CONTINUE, END)
# _b4_comment(TEXT, OPEN, CONTINUE, END)
# --------------------------------------
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
# Avoid adding indentation to the first line, as the indentation comes
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
#
# Prefix all the output lines with PREFIX.
m4_define([b4_comment_],
m4_define([_b4_comment],
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
\(.\)], [
$3\1])$4])
@@ -34,17 +34,17 @@ $3\1])$4])
# --------------------------
# Put TEXT in comment. Prefix all the output lines with PREFIX.
m4_define([b4_comment],
[b4_comment_([$1], [$2/* ], [$2 ], [ */])])
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
# _b4_dollar_dollar(VALUE, FIELD, DEFAULT-FIELD)
# ----------------------------------------------
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
# pointer.
m4_define([b4_dollar_dollar_],
m4_define([_b4_dollar_dollar],
[b4_symbol_value([$1],
m4_if([$2], [[]],
[[$3]], [[$2]]))])
@@ -56,7 +56,7 @@ m4_define([b4_dollar_dollar_],
# and b4_at_dollar for LOCATION.
m4_define([b4_dollar_pushdef],
[m4_pushdef([b4_dollar_dollar],
[b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
[_b4_dollar_dollar([$1], m4_dquote($][1), [$2])])dnl
m4_pushdef([b4_at_dollar], [$3])dnl
])
m4_define([b4_dollar_popdef],
+17 -9
View File
@@ -263,21 +263,23 @@ m4_define([b4_attribute_define],
])
## ---------##
## Values. ##
## ---------##
# b4_null_define
# --------------
# Portability issues: define a YY_NULLPTR appropriate for the current
# language (C, C++98, or C++11).
#
# In C++ pre C++11 it is standard practice to use 0 (not NULL) for the
# null pointer. In C, prefer ((void*)0) to avoid having to include stdlib.h.
m4_define([b4_null_define],
[# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULLPTR 0
# define YY_NULLPTR ((void*)0)
# endif
# endif[]dnl
])
@@ -288,6 +290,12 @@ m4_define([b4_null_define],
# Return a null pointer constant.
m4_define([b4_null], [YY_NULLPTR])
## ---------##
## Values. ##
## ---------##
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
# -------------------------------------------------------------
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
@@ -361,7 +369,7 @@ m4_define([b4_token_enums_defines],
# ----------------------------
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
# TYPE if TYPE is given, otherwise just return VAL. The result can be
# used safetly, it is put in parens to avoid nasty precedence issues.
# used safely, it is put in parens to avoid nasty precedence issues.
# TYPE is *not* put in braces, provide some if needed.
m4_define([b4_symbol_value],
[($1[]m4_ifval([$2], [.$2]))])
+16 -10
View File
@@ -203,7 +203,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C],
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]b4_output_end()
]b4_output_end
])])
@@ -217,9 +217,9 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
]b4_identification[
b4_percent_code_get([[top]])[
]b4_percent_code_get([[top]])[
]m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
@@ -292,19 +292,25 @@ b4_percent_code_get[]dnl
#define YYSIZEMAX ((size_t) -1)
#ifdef __cplusplus
typedef bool yybool;
typedef bool yybool;
# define yytrue true
# define yyfalse false
#else
typedef unsigned char yybool;
typedef unsigned char yybool;
# define yytrue 1
# define yyfalse 0
#endif
#define yytrue 1
#define yyfalse 0
#ifndef YYSETJMP
# include <setjmp.h>
# define YYJMP_BUF jmp_buf
# define YYSETJMP(Env) setjmp (Env)
/* Pacify clang. */
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
/* Pacify Clang and ICC. */
# define YYLONGJMP(Env, Val) \
do { \
longjmp (Env, Val); \
YYASSERT (0); \
} while (yyfalse)
#endif
]b4_attribute_define[
@@ -2573,4 +2579,4 @@ m4_if(b4_prefix, [yy], [],
#define yylloc ]b4_prefix[lloc]])])[
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
+14 -11
View File
@@ -234,25 +234,28 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
b4_namespace_close
])
# b4_shared_declarations
# ----------------------
# Declaration that might either go into the header (if --defines)
# or open coded in the parser body.
# b4_shared_declarations(hh|cc)
# -----------------------------
# Declaration that might either go into the header (if --defines, $1 = hh)
# or in the implementation file.
m4_define([b4_shared_declarations],
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
b4_percent_code_get([[requires]])[
#include <iostream>
#include <stdexcept>
#include <string>
#include <iostream>]b4_defines_if([
b4_bison_locations_if([[#include "location.hh"]])])[
]m4_ifdef([b4_location_file],
[[# include ]b4_location_include])[
]b4_null_define[
]b4_YYDEBUG_define[
]b4_namespace_open[
]b4_defines_if([],
[b4_bison_locations_if([b4_position_define
b4_location_define])])[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[b4_location_define])])[
/// A Bison parser.
class ]b4_parser_class_name[
@@ -336,7 +339,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]b4_output_end()])
]b4_output_end])
# Let glr.c (and b4_shared_declarations) believe that the user
# arguments include the parser itself.
+67 -51
View File
@@ -20,6 +20,7 @@ m4_include(b4_pkgdatadir/[c++.m4])
# api.value.type=variant is valid.
m4_define([b4_value_type_setup_variant])
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
# --------------------------------------------------------------
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
@@ -83,9 +84,14 @@ m4_define([b4_rhs_state],
# --------------------------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
m4_define([_b4_rhs_value],
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
m4_define([b4_rhs_value],
[b4_percent_define_ifdef([api.value.automove],
[YY_MOVE (_b4_rhs_value($@))],
[_b4_rhs_value($@)])])
# b4_rhs_location(RULE-LENGTH, NUM)
# ---------------------------------
@@ -106,7 +112,7 @@ b4_dollar_pushdef([yysym.value],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[yysym.location])dnl
b4_symbol_case_([$1])
_b4_symbol_case([$1])
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline([@oline@], [@ofile@])
@@ -142,10 +148,11 @@ b4_bison_locations_if([# Backward compatibility.
m4_include(b4_pkgdatadir/[stack.hh])
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
# b4_shared_declarations(hh|cc)
# -----------------------------
# Declaration that might either go into the header (if --defines, $1 = hh)
# or open coded in the parser body.
# or in the implementation file.
m4_define([b4_shared_declarations],
[b4_percent_code_get([[requires]])[
]b4_parse_assert_if([# include <cassert>])[
@@ -153,21 +160,23 @@ m4_define([b4_shared_declarations],
# include <iostream>
# include <stdexcept>
# include <string>
# include <vector>]b4_defines_if([[
# include "stack.hh"
]b4_bison_locations_if([[# include "location.hh"]])])[
# include <vector>
]b4_cxx_portability[
]m4_ifdef([b4_location_include],
[[# include ]b4_location_include])[
]b4_variant_if([b4_variant_includes])[
]b4_attribute_define[
]b4_null_define[
]b4_YYDEBUG_define[
]b4_namespace_open[
]b4_defines_if([],
[b4_stack_define
b4_bison_locations_if([b4_position_define
b4_location_define])])[
]b4_stack_define[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[b4_location_define])])[
]b4_variant_if([b4_variant_define])[
@@ -176,6 +185,7 @@ b4_location_define])])[
{
public:
]b4_public_types_declare[
]b4_symbol_type_declare[
/// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
@@ -206,6 +216,8 @@ b4_location_define])])[
/// Report a syntax error.
void error (const syntax_error& err);
]b4_symbol_constructor_declare[
private:
/// This class is not copyable.
]b4_parser_class_name[ (const ]b4_parser_class_name[&);
@@ -315,12 +327,14 @@ b4_location_define])])[
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
/// Copy construct (for efficiency).
stack_symbol_type (const stack_symbol_type& that);
/// Move or copy construction.
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
/// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back.
stack_symbol_type& operator= (const stack_symbol_type& that);
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
#if defined __cplusplus && __cplusplus < 201103L
/// Assignment, needed by push_back by some old implementations.
stack_symbol_type& operator= (YY_MOVE_REF (stack_symbol_type) that);
#endif
};
/// Stack type.
@@ -332,17 +346,17 @@ b4_location_define])])[
/// Push a new state on the stack.
/// \param m a debug message to display
/// if null, no trace is output.
/// \param s the symbol
/// \param sym the symbol
/// \warning the contents of \a s.value is stolen.
void yypush_ (const char* m, stack_symbol_type& s);
void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
/// Push a new look ahead token on the state on the stack.
/// \param m a debug message to display
/// if null, no trace is output.
/// \param s the state
/// \param sym the symbol (for its value and location).
/// \warning the contents of \a s.value is stolen.
void yypush_ (const char* m, state_type s, symbol_type& sym);
/// \warning the contents of \a sym.value is stolen.
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols the three stacks.
void yypop_ (unsigned n = 1);
@@ -391,7 +405,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations(hh)[
]b4_cpp_guard_close([b4_spec_defines_file])
b4_output_end()
b4_output_end
])
@@ -401,13 +415,11 @@ b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [],
[
// Take the name prefix into account.
#define yylex b4_prefix[]lex])[
[#]define yylex b4_prefix[]lex])[
// First part of user declarations.
]b4_user_pre_prologue[
]b4_null_define[
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
[b4_shared_declarations([cc])])[
@@ -585,34 +597,34 @@ m4_if(b4_prefix, [yy], [],
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
{}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
: super_type (that.state]b4_locations_if([, that.location])[)
{
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [copy], [that.value])],
[[value = that.value;]])[
}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
: super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, that.location])[)
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
: super_type (YY_MOVE (that.state)]b4_variant_if([], [, YY_MOVE (that.value)])b4_locations_if([, YY_MOVE (that.location)])[)
{]b4_variant_if([
b4_symbol_variant([that.type_get ()],
[value], [move], [that.value])])[
[value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
: super_type (s]b4_variant_if([], [, YY_MOVE (that.value)])[]b4_locations_if([, YY_MOVE (that.location)])[)
{]b4_variant_if([
b4_symbol_variant([that.type_get ()],
[value], [move], [YY_MOVE (that.value)])])[
// that is emptied.
that.type = empty_symbol;
}
#if defined __cplusplus && __cplusplus < 201103L
]b4_parser_class_name[::stack_symbol_type&
]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that)
]b4_parser_class_name[::stack_symbol_type::operator= (YY_MOVE_REF (stack_symbol_type) that)
{
state = that.state;
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [copy], [that.value])],
[[value = that.value;]])[]b4_locations_if([
location = that.location;])[
[value], [move], [YY_MOVE (that.value)])],
[[value = YY_MOVE (that.value);]])[]b4_locations_if([
location = YY_MOVE (that.location);])[
return *this;
}
#endif
template <typename Base>
void
@@ -647,18 +659,22 @@ m4_if(b4_prefix, [yy], [],
#endif
void
]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym)
]b4_parser_class_name[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
{
stack_symbol_type t (s, sym);
yypush_ (m, t);
if (m)
YY_SYMBOL_PRINT (m, sym);
yystack_.push (YY_MOVE (sym));
}
void
]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
{
if (m)
YY_SYMBOL_PRINT (m, s);
yystack_.push (s);
#if defined __cplusplus && 201103L <= __cplusplus
yypush_ (m, stack_symbol_type (s, YY_MOVE (sym)));
#else
stack_symbol_type ss (s, sym);
yypush_ (m, ss);
#endif
}
void
@@ -754,7 +770,7 @@ b4_dollar_popdef])[]dnl
location values to have been already stored, initialize these
stacks with a primary value. */
yystack_.clear ();
yypush_ (YY_NULLPTR, 0, yyla);
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
// A new symbol was pushed on the stack.
yynewstate:
@@ -816,7 +832,7 @@ b4_dollar_popdef])[]dnl
--yyerrstatus_;
// Shift the lookahead token.
yypush_ ("Shifting", yyn, yyla);
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate;
/*-----------------------------------------------------------.
@@ -885,7 +901,7 @@ b4_dollar_popdef])[]dnl
YY_STACK_PRINT ();
// Shift the result of the reduction.
yypush_ (YY_NULLPTR, yylhs);
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
}
goto yynewstate;
@@ -974,7 +990,7 @@ b4_dollar_popdef])[]dnl
// Shift the error token.
error_token.state = yyn;
yypush_ ("Shifting", error_token);
yypush_ ("Shifting", YY_MOVE (error_token));
}
goto yynewstate;
@@ -1180,7 +1196,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
]b4_namespace_close[
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
m4_popdef([b4_copyright_years])dnl
+1 -1
View File
@@ -1068,4 +1068,4 @@ b4_percent_code_get[]dnl
}
b4_epilogue[]dnl
b4_output_end()
b4_output_end
+68 -39
View File
@@ -18,10 +18,47 @@
m4_pushdef([b4_copyright_years],
[2002-2015, 2018])
# b4_position_define
# b4_position_file
# ----------------
# Name of the file containing the position class, if we want this file.
b4_defines_if([b4_required_version_if([302], [],
[m4_define([b4_position_file], [position.hh])])])])
# b4_location_file
# ----------------
# Name of the file containing the position/location class,
# if we want this file.
b4_percent_define_check_file([b4_location_file],
[[api.location.file]],
b4_defines_if([[location.hh]]))
# b4_location_include
# -------------------
# If location.hh is to be generated, the name under which should it be
# included.
#
# b4_location_path
# ----------------
# The path to use for the CPP guard.
m4_ifdef([b4_location_file],
[m4_define([b4_location_include],
[b4_percent_define_get([[api.location.include]],
["b4_location_file"])])
m4_define([b4_location_path],
b4_percent_define_get([[api.location.include]],
["b4_dir_prefix[]b4_location_file"]))
m4_define([b4_location_path],
m4_substr(m4_defn([b4_location_path]), 1, m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
])
# b4_location_define
# ------------------
# Define class position.
m4_define([b4_position_define],
# Define the position and location classes.
m4_define([b4_location_define],
[[ /// Abstract a position.
class position
{
@@ -73,10 +110,11 @@ m4_define([b4_position_define],
unsigned column;
private:
/// Compute max(min, lhs+rhs).
/// Compute max (min, lhs+rhs).
static unsigned add_ (unsigned lhs, int rhs, int min)
{
return static_cast<unsigned>(std::max(min, static_cast<int>(lhs) + rhs));
return static_cast<unsigned> (std::max (min,
static_cast<int> (lhs) + rhs));
}
};
@@ -139,13 +177,8 @@ m4_define([b4_position_define],
ostr << *pos.filename << ':';
return ostr << pos.line << '.' << pos.column;
}
]])
# b4_location_define
# ------------------
m4_define([b4_location_define],
[[ /// Abstract a location.
/// Abstract a location.
class location
{
public:
@@ -287,16 +320,31 @@ m4_define([b4_location_define],
]])
b4_defines_if([
b4_output_begin([b4_dir_prefix[]position.hh])
b4_copyright([Positions for Bison parsers in C++])[
m4_ifdef([b4_position_file], [[
]b4_output_begin([b4_dir_prefix], [b4_position_file])[
// Starting with Bison 3.2, this file is useless: the structure it
// used to define is now defined in "]b4_location_file[".
//
// To get rid of this file:
// 1. add 'require "3.2"' (or newer) to your grammar file
// 2. remove references to this file from your build system
// 3. if you used to include it, include "]b4_location_file[" instead.
#include ]b4_location_include[
]b4_output_end[
]])
m4_ifdef([b4_location_file], [[
]b4_output_begin([b4_dir_prefix], [b4_location_file])[
]b4_copyright([Locations for Bison parsers in C++])[
/**
** \file ]b4_dir_prefix[position.hh
** Define the ]b4_namespace_ref[::position class.
** \file ]b4_location_path[
** Define the ]b4_namespace_ref[::location class.
*/
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
]b4_cpp_guard_open([b4_location_path])[
# include <algorithm> // std::max
# include <iostream>
@@ -304,31 +352,12 @@ b4_copyright([Positions for Bison parsers in C++])[
]b4_null_define[
]b4_namespace_open[
]b4_position_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
b4_output_end()
b4_output_begin([b4_dir_prefix[]location.hh])
b4_copyright([Locations for Bison parsers in C++])[
/**
** \file ]b4_dir_prefix[location.hh
** Define the ]b4_namespace_ref[::location class.
*/
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
# include "position.hh"
]b4_namespace_open[
]b4_location_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
b4_output_end()
])
]b4_cpp_guard_close([b4_location_path])[
]b4_output_end[
]])
m4_popdef([b4_copyright_years])
+19 -26
View File
@@ -15,8 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
[2002-2015, 2018])
# b4_stack_file
# -------------
# Name of the file containing the stack class, if we want this file.
b4_defines_if([b4_required_version_if([302], [],
[m4_define([b4_stack_file], [stack.hh])])])
# b4_stack_define
# ---------------
@@ -62,9 +67,9 @@ m4_define([b4_stack_define],
///
/// Close to move-semantics.
void
push (T& t)
push (YY_MOVE_REF (T) t)
{
seq_.push_back (T());
seq_.push_back (T ());
operator[](0).move (t);
}
@@ -129,25 +134,13 @@ m4_define([b4_stack_define],
};
]])
b4_defines_if(
[b4_output_begin([b4_dir_prefix[]stack.hh])
b4_copyright([Stack handling for Bison parsers in C++])[
/**
** \file ]b4_dir_prefix[stack.hh
** Define the ]b4_namespace_ref[::stack class.
*/
]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
# include <vector>
]b4_namespace_open[
]b4_stack_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
b4_output_end()
])
m4_popdef([b4_copyright_years])
m4_ifdef([b4_stack_file],
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
// Starting with Bison 3.2, this file is useless: the structure it
// used to define is now defined with the parser itself.
//
// To get rid of this file:
// 1. add 'require "3.2"' (or newer) to your grammar file
// 2. remove references to this file from your build system.
]b4_output_end[
]])
+51 -35
View File
@@ -29,7 +29,7 @@ m4_define([b4_symbol_variant],
[$2.$3< $][3 > (m4_shift3($@))])dnl
switch ($1)
{
b4_type_foreach([b4_type_action_])[]dnl
b4_type_foreach([_b4_type_action])[]dnl
default:
break;
}
@@ -55,15 +55,15 @@ dummy[]_b4_char_sizeof_counter])
# ---------------------------
# To be mapped on the list of type names to produce:
#
# char dummy1[sizeof(type_name_1)];
# char dummy2[sizeof(type_name_2)];
# char dummy1[sizeof (type_name_1)];
# char dummy2[sizeof (type_name_2)];
#
# for defined type names.
m4_define([b4_char_sizeof],
[b4_symbol_if([$1], [has_type],
[
m4_map([ b4_symbol_tag_comment], [$@])dnl
char _b4_char_sizeof_dummy@{sizeof(b4_symbol([$1], [type]))@};
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
])])
@@ -101,11 +101,11 @@ m4_define([b4_variant_define],
/// Construct and fill.
template <typename T>
variant (const T& t)]b4_parse_assert_if([
variant (YY_RVREF (T) t)]b4_parse_assert_if([
: yytypeid_ (&typeid (T))])[
{
YYASSERT (sizeof (T) <= S);
new (yyas_<T> ()) T (t);
new (yyas_<T> ()) T (YY_MOVE (t));
}
/// Destruction, allowed only if empty.
@@ -163,7 +163,7 @@ m4_define([b4_variant_define],
/// Both variants must be built beforehand, because swapping the actual
/// data requires reading it (with as()), and this is not possible on
/// unconstructed variants: it would require some dynamic testing, which
/// should not be the variant's responsability.
/// should not be the variant's responsibility.
/// Swapping between built and (possibly) non-built is done with
/// variant::move ().
template <typename T>
@@ -183,10 +183,26 @@ m4_define([b4_variant_define],
move (self_type& other)
{
build<T> ();
# if defined __cplusplus && 201103L <= __cplusplus
as<T> () = YY_MOVE (other.as<T> ());
# else
swap<T> (other);
# endif
other.destroy<T> ();
}
# if defined __cplusplus && 201103L <= __cplusplus
/// Move the content of \a other to this.
template <typename T>
void
move (self_type&& other)
{
build<T> ();
as<T> () = YY_MOVE (other.as<T> ());
other.destroy<T> ();
}
#endif
/// Copy the content of \a other to this.
template <typename T>
void
@@ -206,7 +222,7 @@ m4_define([b4_variant_define],
private:
/// Prohibit blind copies.
self_type& operator=(const self_type&);
self_type& operator= (const self_type&);
variant (const self_type&);
/// Accessor to raw memory as \a T.
@@ -255,7 +271,7 @@ m4_define([b4_value_type_declare],
{]b4_type_foreach([b4_char_sizeof])[};
/// Symbol semantic values.
typedef variant<sizeof(union_type)> semantic_type;][]dnl
typedef variant<sizeof (union_type)> semantic_type;][]dnl
])
@@ -283,18 +299,18 @@ m4_define([b4_symbol_value_template],
## ------------- ##
# b4_symbol_constructor_declare_(SYMBOL-NUMBER)
# _b4_symbol_constructor_declare(SYMBOL-NUMBER)
# ---------------------------------------------
# Declare the overloaded version of make_symbol for the (common) type of
# these SYMBOL-NUMBERS. Use at class-level.
m4_define([b4_symbol_constructor_declare_],
m4_define([_b4_symbol_constructor_declare],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ static inline
[ static
symbol_type
make_[]b4_symbol_([$1], [id]) (dnl
make_[]_b4_symbol([$1], [id]) (dnl
b4_join(b4_symbol_if([$1], [has_type],
[const b4_symbol([$1], [type])& v]),
b4_locations_if([const location_type& l])));
[YY_COPY (b4_symbol([$1], [type])) v]),
b4_locations_if([YY_COPY (location_type) l])));
])])])
@@ -305,24 +321,25 @@ b4_join(b4_symbol_if([$1], [has_type],
# Use at class-level.
m4_define([b4_symbol_constructor_declare],
[ // Symbol constructors declarations.
b4_symbol_foreach([b4_symbol_constructor_declare_])])
b4_symbol_foreach([_b4_symbol_constructor_declare])])
# b4_symbol_constructor_define_(SYMBOL-NUMBER)
# _b4_symbol_constructor_define(SYMBOL-NUMBER)
# --------------------------------------------
# Define symbol constructor for this SYMBOL-NUMBER.
m4_define([b4_symbol_constructor_define_],
m4_define([_b4_symbol_constructor_define],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ b4_parser_class_name::symbol_type
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
[ inline
b4_parser_class_name::symbol_type
b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl
b4_join(b4_symbol_if([$1], [has_type],
[const b4_symbol([$1], [type])& v]),
b4_locations_if([const location_type& l])))
[YY_COPY (b4_symbol([$1], [type])) v]),
b4_locations_if([YY_COPY (location_type) l])))
{
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
b4_symbol_if([$1], [has_type], [v]),
b4_locations_if([l])));
b4_symbol_if([$1], [has_type], [YY_MOVE (v)]),
b4_locations_if([YY_MOVE (l)])));
}
])])])
@@ -332,27 +349,26 @@ b4_join(b4_symbol_if([$1], [has_type],
# -----------------------------------
# Generate a constructor declaration for basic_symbol from given type.
m4_define([b4_basic_symbol_constructor_declare],
[[
basic_symbol (]b4_join(
[[ basic_symbol (]b4_join(
[typename Base::kind_type t],
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
b4_locations_if([const location_type& l]))[);
b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type])) v]),
b4_locations_if([YY_RVREF (location_type) l]))[);
]])
# b4_basic_symbol_constructor_define
# ----------------------------------
# Generate a constructor implementation for basic_symbol from given type.
m4_define([b4_basic_symbol_constructor_define],
[[
template <typename Base>
[[ template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
b4_locations_if([const location_type& l]))[)
b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type])) v]),
b4_locations_if([YY_RVREF (location_type) l]))[)
: Base (t)]b4_symbol_if([$1], [has_type], [
, value (v)])[]b4_locations_if([
, location (l)])[
, value (YY_MOVE (v))])[]b4_locations_if([
, location (YY_MOVE (l))])[
{}
]])
# b4_symbol_constructor_define
@@ -360,4 +376,4 @@ m4_define([b4_basic_symbol_constructor_define],
# Define the overloaded versions of make_symbol for all the value types.
m4_define([b4_symbol_constructor_define],
[ // Implementation of make_symbol for each symbol type.
b4_symbol_foreach([b4_symbol_constructor_define_])])
b4_symbol_foreach([_b4_symbol_constructor_define])])
+1
View File
@@ -38,6 +38,7 @@
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>
<xsl:value-of select="bison-xml-report/filename"/>
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
+8 -8
View File
@@ -237,11 +237,11 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
YYSIZE_T yyes_capacity;]])])
# b4_declare_yyparse_push_
# _b4_declare_yyparse_push
# ------------------------
# Declaration of yyparse (and dependencies) when using the push parser
# (including in pull mode).
m4_define([b4_declare_yyparse_push_],
m4_define([_b4_declare_yyparse_push],
[[#ifndef YYPUSH_MORE_DEFINED
# define YYPUSH_MORE_DEFINED
enum { YYPUSH_MORE = 4 };
@@ -265,18 +265,18 @@ b4_function_declare([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *ps]], [[ps]]])dnl
])
# b4_declare_yyparse_
# _b4_declare_yyparse
# -------------------
# When not the push parser.
m4_define([b4_declare_yyparse_],
m4_define([_b4_declare_yyparse],
[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)])
# b4_declare_yyparse
# ------------------
m4_define([b4_declare_yyparse],
[b4_push_if([b4_declare_yyparse_push_],
[b4_declare_yyparse_])[]dnl
[b4_push_if([_b4_declare_yyparse_push],
[_b4_declare_yyparse])[]dnl
])
@@ -1908,12 +1908,12 @@ yypushreturn:]])[
return yyresult;
}
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])[
]b4_copyright([Bison interface for Yacc-like parsers in C])[
]b4_shared_declarations[
]b4_output_end()
]b4_output_end
])# b4_defines_if
+1 -1
View File
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
=======================
The DJGPP port of Bison offers LFN and SFN support depending on which
OS it is running. If LFN support is available or not is determinated at
OS it is running. If LFN support is available or not is determined at
run time. If LFN support is available (DOS session under Win9X, Win2K,
WinXP, etc.) the standard posix file name extensions will be used.
These are: y.tab.c, y.tab.c++, y.tab.h, y.output, etc. If only SFN
+5 -5
View File
@@ -80,10 +80,10 @@ goto NextArgument
if "%1" == "no-dep" goto NextArgument
if "%1" == "no-DEP" goto NextArgument
if "%1" == "NO-DEP" goto NextArgument
if "%1" == "dep" goto DependecyTraking
if "%1" == "DEP" goto DependecyTraking
if "%1" == "dep" goto DependecyTracking
if "%1" == "DEP" goto DependecyTracking
goto LibiconvPrefixOption
:DependecyTraking
:DependecyTracking
if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
@@ -290,7 +290,7 @@ if errorlevel 1 goto SedError2
mv -f config.hin %XSRC%/lib/config.hin
Rem Fixing ilicit testsuite file name.
Rem Fixing illicit testsuite file name.
test -f %XSRC%/tests/c++.at
if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.at
@@ -300,7 +300,7 @@ sed -f %XSRC%/djgpp/testsuite.sed %XSRC%/tests/testsuite.org > testsuite.tmp
if errorlevel 1 goto SedError3
mv -f ./testsuite.tmp %XSRC%/tests/testsuite
Rem Fixing ilicit calc++ file names in the calc++ directory.
Rem Fixing illicit calc++ file names in the calc++ directory.
test -d %XSRC%/examples/calc++
if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
test -d %XSRC%/examples/calcxx
+1 -1
View File
@@ -1405,7 +1405,7 @@ EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
+415 -198
View File
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -30,9 +30,7 @@ $(doc_bison).pdf: $(FIGS_GV:.gv=.pdf)
$(doc_bison).html: $(FIGS_GV:.gv=.png)
TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
CLEANDIRS = doc/bison.t2d
clean-local:
rm -rf $(CLEANDIRS)
CLEANDIRS += doc/bison.t2d
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
+1 -1
View File
@@ -53,7 +53,7 @@ will generate eight different cases.
=item B<-b>, B<--bench>
Predefined benches, that is, combimation between a grammar and a I<directives>
Predefined benches, that is, combination between a grammar and a I<directives>
request.
=over 4
+10 -14
View File
@@ -13,6 +13,10 @@ A C++ example that uses variants (they allow to use any C++ type as semantic
value type) and symbol constructors (they ensure consistency between
declared token type and effective semantic value).
* variant-11.yy
Another C++ example, closely related to the previous one, but exhibiting
support for C++11's move semantics.
-----
Local Variables:
@@ -22,19 +26,11 @@ End:
Copyright (C) 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the "GNU Free
Documentation License" file as part of this distribution.
# LocalWords: mfcalc calc parsers yy
+1 -1
View File
@@ -36,7 +36,7 @@ CLEANFILES += \
%D%/parser.output \
%D%/parser.stamp \
%D%/scanner.cc
CLEANDIRS += %D%/*.dSYM
## -------------------- ##
## Building & testing. ##
+19 -2
View File
@@ -32,9 +32,24 @@
# output before block 2, even if the latter appears before). The same
# number may be used several time, in which case the order of
# appearance is used.
#
# Use @ignore for code to extract that must not be part of the
# documentation. For instance:
#
# @ignore
# @comment file: calc++/scanner.ll
# @example
# // Work around an incompatibility in Flex.
# # undef yywrap
# # define yywrap() 1
# @end example
# @end ignore
use strict;
use File::Basename qw(dirname);
use File::Path qw(make_path);
# Whether we generate synclines.
my $synclines = 0;
@@ -80,7 +95,9 @@ sub file_wanted ($)
undef
}
# process ($in)
# -------------
# Read input file $in, and generate the outputs.
sub process ($)
{
my ($in) = @_;
@@ -140,7 +157,7 @@ sub process ($)
# Output the files.
for my $file (keys %file)
{
# No spurious end of line: use printf.
make_path (dirname ($file));
my $o = new IO::File(">$file")
or die "$file: cannot create: $?";
print $o $file{$file}{$_}
+15 -1
View File
@@ -33,6 +33,7 @@ extracted =
CLEANFILES += $(extracted) %D%/extracted.stamp
%D%/extracted.stamp: $(doc) $(extexi)
$(AM_V_GEN)rm -f $@ $@.tmp
$(AM_V_at)$(MKDIR_P) %D%
$(AM_V_at)touch $@.tmp
$(AM_V_at)$(extract) $(extracted)
$(AM_V_at)mv $@.tmp $@
@@ -45,14 +46,27 @@ $(extracted): %D%/extracted.stamp
## Examples. ##
## ---------- ##
examplesdir = $(docdir)/examples
dist_examples_DATA = %D%/README %D%/variant.yy
dist_examples_DATA = %D%/README %D%/variant.yy %D%/variant-11.yy
check_PROGRAMS += %D%/variant
nodist_%C%_variant_SOURCES = %D%/variant.yy
%C%_variant_CPPFLAGS = -I$(top_builddir)
dist_TESTS += %D%/variant.test
%D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
if ENABLE_CXX11
check_PROGRAMS += %D%/variant-11
nodist_%C%_variant_11_SOURCES = %D%/variant-11.yy
%C%_variant_11_CXXFLAGS = $(CXX11_CXXFLAGS)
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
dist_TESTS += %D%/variant-11.test
%D%/variant-11.cc: $(BISON_IN) $(dist_pkgdata_DATA)
endif
CLEANFILES += %D%/variant.output %D%/variant-11.output
CLEANDIRS += %D%/*.dSYM
include %D%/calc++/local.mk
include %D%/mfcalc/local.mk
+1
View File
@@ -20,6 +20,7 @@
BUILT_SOURCES += $(mfcalc_sources)
CLEANFILES += %D%/mfcalc.[ch] %D%/mfcalc.output
CLEANDIRS += %D%/*.dSYM
mfcalc_extracted = %D%/calc.h %D%/mfcalc.y
mfcalc_sources = $(mfcalc_extracted)
+1
View File
@@ -20,6 +20,7 @@
BUILT_SOURCES += $(rpcalc_sources)
CLEANFILES += %D%/rpcalc.[ch] %D%/rpcalc.output
CLEANDIRS += %D%/*.dSYM
rpcalc_extracted = %D%/rpcalc.y
rpcalc_sources = $(rpcalc_extracted)
+4 -4
View File
@@ -23,7 +23,7 @@ number=1
# Exit status of this script.
exit=true
# top_buiddir.
# top_builddir.
cwd=`pwd`
# The exercised program.
@@ -60,16 +60,16 @@ cd $$.dir
run ()
{
# Expected exit status.
local sta_exp=$1
local sta_exp="$1"
shift
# Expected output.
local out_exp=$1
local out_exp="$1"
shift
# Effective exit status.
local sta_eff=0
$prog "$@" - <input >out_eff || sta_eff=$?
# Effective output.
local out_eff=`cat out_eff`
local out_eff="`cat out_eff`"
if test $sta_eff -eq $sta_exp; then
if test "$out_eff" = "$out_exp"; then
echo "$me: PASS: $number"
+19
View File
@@ -0,0 +1,19 @@
#! /bin/sh
# Copyright (C) 2018 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
: >input
run 0 "{I have three numbers for you., 1, 2, 3, And that's all!}"
+161
View File
@@ -0,0 +1,161 @@
/*
Copyright (C) 2008-2015, 2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
%require "3.2"
%debug
%language "c++"
%define api.token.constructor
%define api.value.type variant
%define api.value.automove
%define api.location.file none
%define parse.assert
%locations
%code requires // *.hh
{
#include <memory> // std::unique_ptr
#include <string>
#include <vector>
using string_uptr = std::unique_ptr<std::string>;
using string_uptrs = std::vector<string_uptr>;
}
%code // *.cc
{
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
namespace yy
{
// Prototype of the yylex function providing subsequent tokens.
static parser::symbol_type yylex ();
// Print a vector of strings.
std::ostream&
operator<< (std::ostream& o, const string_uptrs& ss)
{
o << '{';
const char *sep = "";
for (const auto& s: ss)
{
o << sep << *s;
sep = ", ";
}
return o << '}';
}
}
template <typename... Args>
string_uptr
make_string_uptr (Args&&... args)
{
// std::make_unique is C++14.
return string_uptr (new std::string{std::forward<Args> (args)...});
}
// Convert to string.
template <typename T>
std::string
to_string (const T& t)
{
auto&& o = std::ostringstream{};
o << t;
return o.str ();
}
}
%token <string_uptr> TEXT;
%token <int> NUMBER;
%printer { yyo << '(' << &$$ << ") " << $$; } <*>;
%printer { yyo << *$$; } <string_uptr>;
%token END_OF_FILE 0;
%type <string_uptr> item;
%type <string_uptrs> list;
%%
result:
list { std::cout << $1 << '\n'; }
;
list:
%empty { /* Generates an empty string list */ }
| list item { $$ = $1; $$.emplace_back ($2); }
;
item:
TEXT
| NUMBER { $$ = make_string_uptr (to_string ($1)); }
;
%%
namespace yy
{
// The yylex function providing subsequent tokens:
// TEXT "I have three numbers for you."
// NUMBER 1
// NUMBER 2
// NUMBER 3
// TEXT "And that's all!"
// END_OF_FILE
static
parser::symbol_type
yylex ()
{
static auto count = 0u;
auto stage = count;
++count;
auto loc = parser::location_type{nullptr, stage + 1, stage + 1};
switch (stage)
{
case 0:
return parser::make_TEXT (make_string_uptr ("I have three numbers for you."), std::move (loc));
case 1:
case 2:
case 3:
return parser::make_NUMBER (stage, std::move (loc));
case 4:
return parser::make_TEXT (make_string_uptr ("And that's all!"), std::move (loc));
default:
return parser::make_END_OF_FILE (std::move (loc));
}
}
// Mandatory error function
void
parser::error (const parser::location_type& loc, const std::string& msg)
{
std::cerr << loc << ": " << msg << '\n';
}
}
int
main ()
{
auto&& p = yy::parser{};
p.set_debug_level (!!getenv ("YYDEBUG"));
return p.parse ();
}
// Local Variables:
// mode: C++
// End:
+10 -13
View File
@@ -15,11 +15,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
%require "3.2"
%debug
%language "c++"
%defines
%define api.token.constructor
%define api.value.type variant
%define api.location.file none
%define parse.assert
%locations
@@ -37,22 +38,18 @@ typedef std::vector<std::string> strings_type;
#include <iterator>
#include <sstream>
// Prototype of the yylex function providing subsequent tokens.
namespace yy
{
// Prototype of the yylex function providing subsequent tokens.
static parser::symbol_type yylex ();
}
// Printing a vector of strings.
// Koening look up will look into std, since that's an std::vector.
namespace std
{
// Print a vector of strings.
std::ostream&
operator<< (std::ostream& o, const strings_type& ss)
{
o << '{';
const char *sep = "";
for (strings_type::const_iterator i = ss.begin(), end = ss.end();
for (strings_type::const_iterator i = ss.begin (), end = ss.end ();
i != end; ++i)
{
o << sep << *i;
@@ -62,10 +59,10 @@ typedef std::vector<std::string> strings_type;
}
}
// Conversion to string.
// Convert to string.
template <typename T>
std::string
string_cast (const T& t)
to_string (const T& t)
{
std::ostringstream o;
o << t;
@@ -93,8 +90,8 @@ list:
;
item:
TEXT { std::swap ($$, $1); }
| NUMBER { $$ = string_cast ($1); }
TEXT
| NUMBER { $$ = to_string ($1); }
;
%%
@@ -114,7 +111,7 @@ namespace yy
{
static int stage = -1;
++stage;
parser::location_type loc(YY_NULLPTR, stage + 1, stage + 1);
parser::location_type loc (YY_NULLPTR, stage + 1, stage + 1);
switch (stage)
{
case 0:
+1 -1
Submodule gnulib updated: a05181f4bd...a79f2a2871
+16
View File
@@ -273,3 +273,19 @@
/xstrndup.h
/stat-time.c
/stat-time.h
/timevar.c
/timevar.h
/sys_time.in.h
/sys_times.in.h
/gethrxtime.c
/gethrxtime.h
/getrusage.c
/gettime.c
/gettimeofday.c
/localtime-buffer.c
/localtime-buffer.h
/sys_resource.in.h
/timespec.c
/timespec.h
/xtime.c
/xtime.h
+58 -101
View File
@@ -36,10 +36,10 @@ static bitset_bindex
abitset_resize (bitset src, bitset_bindex size)
{
/* These bitsets have a fixed size. */
if (BITSET_SIZE_ (src) != size)
abort ();
if (BITSET_SIZE_ (src) != size)
abort ();
return size;
return size;
}
/* Find list of up to NUM bits set in BSET starting from and including
@@ -49,19 +49,14 @@ static bitset_bindex
abitset_small_list (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
bitset_windex size;
bitset_word word;
word = ABITSET_WORDS (src)[0];
bitset_word word = ABITSET_WORDS (src)[0];
/* Short circuit common case. */
if (!word)
return 0;
size = BITSET_SIZE_ (src);
bitno = *next;
bitset_windex size = BITSET_SIZE_ (src);
bitset_bindex bitno = *next;
if (bitno >= size)
return 0;
@@ -70,6 +65,7 @@ abitset_small_list (bitset src, bitset_bindex *list,
/* If num is 1, we could speed things up with a binary search
of the word of interest. */
bitset_bindex count;
if (num >= BITSET_WORD_BITS)
{
for (count = 0; word; bitno++)
@@ -142,16 +138,10 @@ static bitset_bindex
abitset_list_reverse (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex rbitno;
bitset_bindex count;
bitset_windex windex;
unsigned bitcnt;
bitset_bindex bitoff;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_bindex n_bits = BITSET_SIZE_ (src);
rbitno = *next;
bitset_bindex rbitno = *next;
/* If num is 1, we could speed things up with a binary search
of the word of interest. */
@@ -159,19 +149,17 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
if (rbitno >= n_bits)
return 0;
count = 0;
bitset_bindex count = 0;
bitno = n_bits - (rbitno + 1);
bitset_bindex bitno = n_bits - (rbitno + 1);
windex = bitno / BITSET_WORD_BITS;
bitcnt = bitno % BITSET_WORD_BITS;
bitoff = windex * BITSET_WORD_BITS;
bitset_windex windex = bitno / BITSET_WORD_BITS;
unsigned bitcnt = bitno % BITSET_WORD_BITS;
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
do
{
bitset_word word;
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
for (; word; bitcnt--)
{
if (word & BITSET_MSB)
@@ -196,23 +184,21 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
/* Find list of up to NUM bits set in BSET starting from and including
*NEXT and store in array LIST. Return with actual number of bits
found and with *NEXT indicating where search stopped. */
*NEXT and store in array LIST. Return with actual number of bits
found and with *NEXT indicating where search stopped. */
static bitset_bindex
abitset_list (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
bitset_windex windex;
bitset_bindex bitoff;
bitset_windex size = src->b.csize;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_word word;
bitno = *next;
bitset_bindex bitno = *next;
count = 0;
bitset_bindex count = 0;
if (!bitno)
{
/* Many bitsets are zero, so make this common case fast. */
@@ -302,9 +288,7 @@ abitset_list (bitset src, bitset_bindex *list,
static inline void
abitset_unused_clear (bitset dst)
{
unsigned last_bit;
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
if (last_bit)
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
((bitset_word) 1 << last_bit) - 1;
@@ -315,9 +299,7 @@ static void
abitset_ones (bitset dst)
{
bitset_word *dstp = ABITSET_WORDS (dst);
size_t bytes;
bytes = sizeof (bitset_word) * dst->b.csize;
size_t bytes = sizeof (bitset_word) * dst->b.csize;
memset (dstp, -1, bytes);
abitset_unused_clear (dst);
@@ -328,9 +310,7 @@ static void
abitset_zero (bitset dst)
{
bitset_word *dstp = ABITSET_WORDS (dst);
size_t bytes;
bytes = sizeof (bitset_word) * dst->b.csize;
size_t bytes = sizeof (bitset_word) * dst->b.csize;
memset (dstp, 0, bytes);
}
@@ -339,10 +319,9 @@ abitset_zero (bitset dst)
static bool
abitset_empty_p (bitset dst)
{
bitset_windex i;
bitset_word *dstp = ABITSET_WORDS (dst);
for (i = 0; i < dst->b.csize; i++)
for (bitset_windex i = 0; i < dst->b.csize; i++)
if (dstp[i])
return false;
@@ -366,13 +345,12 @@ abitset_copy1 (bitset dst, bitset src)
static void
abitset_not (bitset dst, bitset src)
{
bitset_windex i;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = ~(*srcp++);
for (bitset_windex i = 0; i < size; i++)
*dstp++ = ~(*srcp++);
abitset_unused_clear (dst);
}
@@ -380,14 +358,13 @@ abitset_not (bitset dst, bitset src)
static bool
abitset_equal_p (bitset dst, bitset src)
{
bitset_windex i;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
if (*srcp++ != *dstp++)
return false;
for (bitset_windex i = 0; i < size; i++)
if (*srcp++ != *dstp++)
return false;
return true;
}
@@ -395,14 +372,13 @@ abitset_equal_p (bitset dst, bitset src)
static bool
abitset_subset_p (bitset dst, bitset src)
{
bitset_windex i;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return false;
for (bitset_windex i = 0; i < size; i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return false;
return true;
}
@@ -410,14 +386,13 @@ abitset_subset_p (bitset dst, bitset src)
static bool
abitset_disjoint_p (bitset dst, bitset src)
{
bitset_windex i;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
if (*srcp++ & *dstp++)
return false;
for (bitset_windex i = 0; i < size; i++)
if (*srcp++ & *dstp++)
return false;
return true;
}
@@ -426,28 +401,26 @@ abitset_disjoint_p (bitset dst, bitset src)
static void
abitset_and (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = *src1p++ & *src2p++;
for (bitset_windex i = 0; i < size; i++)
*dstp++ = *src1p++ & *src2p++;
}
static bool
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = *src1p++ & *src2p++;
@@ -464,28 +437,26 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
static void
abitset_andn (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = *src1p++ & ~(*src2p++);
for (bitset_windex i = 0; i < size; i++)
*dstp++ = *src1p++ & ~(*src2p++);
}
static bool
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = *src1p++ & ~(*src2p++);
@@ -502,28 +473,26 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
static void
abitset_or (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = *src1p++ | *src2p++;
for (bitset_windex i = 0; i < size; i++)
*dstp++ = *src1p++ | *src2p++;
}
static bool
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = *src1p++ | *src2p++;
@@ -540,13 +509,12 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
static void
abitset_xor (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
for (bitset_windex i = 0; i < size; i++)
*dstp++ = *src1p++ ^ *src2p++;
}
@@ -554,14 +522,13 @@ abitset_xor (bitset dst, bitset src1, bitset src2)
static bool
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = *src1p++ ^ *src2p++;
@@ -578,22 +545,20 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
static void
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
for (bitset_windex i = 0; i < size; i++)
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
}
static bool
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
@@ -601,7 +566,7 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
@@ -618,22 +583,20 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
for (bitset_windex i = 0; i < size; i++)
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
}
static bool
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
@@ -641,7 +604,7 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
@@ -658,22 +621,20 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
for (bitset_windex i = 0; i < size; i++)
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
}
static bool
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
@@ -681,7 +642,7 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
for (i = 0; i < size; i++, dstp++)
for (bitset_windex i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
@@ -699,9 +660,9 @@ static void
abitset_copy (bitset dst, bitset src)
{
if (BITSET_COMPATIBLE_ (dst, src))
abitset_copy1 (dst, src);
abitset_copy1 (dst, src);
else
bitset_copy_ (dst, src);
bitset_copy_ (dst, src);
}
@@ -784,14 +745,12 @@ struct bitset_vtable abitset_vtable = {
size_t
abitset_bytes (bitset_bindex n_bits)
{
bitset_windex size;
size_t bytes;
size_t header_size = offsetof (union bitset_union, a.words);
struct bitset_align_struct { char a; union bitset_union b; };
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
size = ABITSET_N_WORDS (n_bits);
bytes = header_size + size * sizeof (bitset_word);
bitset_windex size = ABITSET_N_WORDS (n_bits);
size_t bytes = header_size + size * sizeof (bitset_word);
/* Align the size properly for a vector of abitset objects. */
if (header_size % bitset_alignment != 0
@@ -808,9 +767,7 @@ abitset_bytes (bitset_bindex n_bits)
bitset
abitset_init (bitset bset, bitset_bindex n_bits)
{
bitset_windex size;
size = ABITSET_N_WORDS (n_bits);
bitset_windex size = ABITSET_N_WORDS (n_bits);
BITSET_NBITS_ (bset) = n_bits;
/* Use optimized routines if bitset fits within a single word.
+2 -2
View File
@@ -23,8 +23,8 @@
#include "bitset.h"
extern size_t abitset_bytes (bitset_bindex);
size_t abitset_bytes (bitset_bindex);
extern bitset abitset_init (bitset, bitset_bindex);
bitset abitset_init (bitset, bitset_bindex);
#endif
+10 -10
View File
@@ -281,24 +281,24 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
/* Private functions for bitset implementations. */
extern bool bitset_toggle_ (bitset, bitset_bindex);
bool bitset_toggle_ (bitset, bitset_bindex);
extern bitset_bindex bitset_count_ (bitset);
bitset_bindex bitset_count_ (bitset);
extern bitset_bindex bitset_size_ (bitset);
bitset_bindex bitset_size_ (bitset);
extern bool bitset_copy_ (bitset, bitset);
bool bitset_copy_ (bitset, bitset);
extern void bitset_and_or_ (bitset, bitset, bitset, bitset);
void bitset_and_or_ (bitset, bitset, bitset, bitset);
extern bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
extern void bitset_andn_or_ (bitset, bitset, bitset, bitset);
void bitset_andn_or_ (bitset, bitset, bitset, bitset);
extern bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
extern void bitset_or_and_ (bitset, bitset, bitset, bitset);
void bitset_or_and_ (bitset, bitset, bitset, bitset);
extern bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
#endif /* _BBITSET_H */
+16 -34
View File
@@ -39,11 +39,10 @@ const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
size_t
bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
{
size_t bytes;
if (bitset_stats_enabled)
return bitset_stats_bytes ();
size_t bytes;
switch (type)
{
default:
@@ -134,12 +133,9 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
bitset
bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
{
size_t bytes;
bitset bset;
size_t bytes = bitset_bytes (type, n_bits);
bytes = bitset_bytes (type, n_bits);
bset = xcalloc (1, bytes);
bitset bset = xcalloc (1, bytes);
/* The cache is disabled until some elements are allocated. If we
have variable length arrays, then we may need to allocate a dummy
@@ -154,12 +150,9 @@ bitset
bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex n_bits, enum bitset_type type)
{
size_t bytes;
bitset bset;
size_t bytes = bitset_bytes (type, n_bits);
bytes = bitset_bytes (type, n_bits);
bset = obstack_alloc (bobstack, bytes);
bitset bset = obstack_alloc (bobstack, bytes);
memset (bset, 0, bytes);
return bitset_init (bset, n_bits, type);
@@ -171,9 +164,7 @@ bitset_obstack_alloc (struct obstack *bobstack,
bitset
bitset_create (bitset_bindex n_bits, unsigned attr)
{
enum bitset_type type;
type = bitset_type_choose (n_bits, attr);
enum bitset_type type = bitset_type_choose (n_bits, attr);
return bitset_alloc (n_bits, type);
}
@@ -200,9 +191,7 @@ bitset_obstack_free (bitset bset)
enum bitset_type
bitset_type_get (bitset bset)
{
enum bitset_type type;
type = BITSET_TYPE_ (bset);
enum bitset_type type = BITSET_TYPE_ (bset);
if (type != BITSET_STATS)
return type;
@@ -214,9 +203,7 @@ bitset_type_get (bitset bset)
const char *
bitset_type_name_get (bitset bset)
{
enum bitset_type type;
type = bitset_type_get (bset);
enum bitset_type type = bitset_type_get (bset);
return bitset_type_names[type];
}
@@ -240,7 +227,7 @@ bitset_next (bitset src, bitset_bindex bitno)
extern bool
bitset_compatible_p (bitset bset1, bitset bset2)
{
return BITSET_COMPATIBLE_ (bset1, bset2);
return BITSET_COMPATIBLE_ (bset1, bset2);
}
@@ -291,15 +278,13 @@ bitset_only_set_p (bitset src, bitset_bindex bitno)
static void
bitset_print (FILE *file, bitset bset, bool verbose)
{
unsigned pos;
bitset_bindex i;
bitset_iterator iter;
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
(unsigned long) bitset_size (bset));
pos = 30;
unsigned pos = 30;
bitset_bindex i;
bitset_iterator iter;
BITSET_FOR_EACH (iter, bset, i, 0)
{
if (pos > 70)
@@ -357,7 +342,7 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
bitset_bindex
bitset_size_ (bitset src)
{
return BITSET_NBITS_ (src);
return BITSET_NBITS_ (src);
}
@@ -366,7 +351,6 @@ bitset_bindex
bitset_count_ (bitset src)
{
bitset_bindex list[BITSET_LIST_SIZE];
bitset_bindex next;
bitset_bindex num;
bitset_bindex count;
@@ -374,7 +358,7 @@ bitset_count_ (bitset src)
bitset implementation that uses a direct technique (based on
masks) for counting the number of bits set in a word. */
next = 0;
bitset_bindex next = 0;
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
count += num)
continue;
@@ -411,13 +395,11 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
enum bitset_ops op)
{
bool changed = false;
bool stats_enabled_save;
bitset tmp;
/* Create temporary bitset. */
stats_enabled_save = bitset_stats_enabled;
bool stats_enabled_save = bitset_stats_enabled;
bitset_stats_enabled = false;
tmp = bitset_alloc (0, bitset_type_get (dst));
bitset tmp = bitset_alloc (0, bitset_type_get (dst));
bitset_stats_enabled = stats_enabled_save;
switch (op)
+25 -25
View File
@@ -99,37 +99,37 @@ typedef struct
/* Return bytes required for bitset of desired type and size. */
extern size_t bitset_bytes (enum bitset_type, bitset_bindex);
size_t bitset_bytes (enum bitset_type, bitset_bindex);
/* Initialise a bitset with desired type and size. */
extern bitset bitset_init (bitset, bitset_bindex, enum bitset_type);
bitset bitset_init (bitset, bitset_bindex, enum bitset_type);
/* Select an implementation type based on the desired bitset size
and attributes. */
extern enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
/* Create a bitset of desired type and size. The bitset is zeroed. */
extern bitset bitset_alloc (bitset_bindex, enum bitset_type);
bitset bitset_alloc (bitset_bindex, enum bitset_type);
/* Free bitset. */
extern void bitset_free (bitset);
void bitset_free (bitset);
/* Create a bitset of desired type and size using an obstack. The
bitset is zeroed. */
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex, enum bitset_type);
bitset bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex, enum bitset_type);
/* Free bitset allocated on obstack. */
extern void bitset_obstack_free (bitset);
void bitset_obstack_free (bitset);
/* Create a bitset of desired size and attributes. The bitset is zeroed. */
extern bitset bitset_create (bitset_bindex, bitset_attrs);
bitset bitset_create (bitset_bindex, bitset_attrs);
/* Return bitset type. */
extern enum bitset_type bitset_type_get (bitset);
enum bitset_type bitset_type_get (bitset);
/* Return bitset type name. */
extern const char *bitset_type_name_get (bitset);
const char *bitset_type_name_get (bitset);
/* Set bit BITNO in bitset BSET. */
@@ -181,7 +181,7 @@ bitset_test (bitset bset, bitset_bindex bitno)
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
/* Change size of bitset. */
extern void bitset_resize (bitset, bitset_bindex);
void bitset_resize (bitset, bitset_bindex);
/* Return number of bits set in bitset SRC. */
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
@@ -281,25 +281,25 @@ extern void bitset_resize (bitset, bitset_bindex);
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
/* Return true if both bitsets are of the same type and size. */
extern bool bitset_compatible_p (bitset bset1, bitset bset2);
bool bitset_compatible_p (bitset bset1, bitset bset2);
/* Find next set bit from the given bit index. */
extern bitset_bindex bitset_next (bitset, bitset_bindex);
bitset_bindex bitset_next (bitset, bitset_bindex);
/* Find previous set bit from the given bit index. */
extern bitset_bindex bitset_prev (bitset, bitset_bindex);
bitset_bindex bitset_prev (bitset, bitset_bindex);
/* Find first set bit. */
extern bitset_bindex bitset_first (bitset);
bitset_bindex bitset_first (bitset);
/* Find last set bit. */
extern bitset_bindex bitset_last (bitset);
bitset_bindex bitset_last (bitset);
/* Return nonzero if this is the only set bit. */
extern bool bitset_only_set_p (bitset, bitset_bindex);
bool bitset_only_set_p (bitset, bitset_bindex);
/* Dump bitset. */
extern void bitset_dump (FILE *, bitset);
void bitset_dump (FILE *, bitset);
/* Loop over all elements of BSET, starting with MIN, setting INDEX
to the index of each set bit. For example, the following will print
@@ -368,13 +368,13 @@ extern void bitset_dump (FILE *, bitset);
/* Release any memory tied up with bitsets. */
extern void bitset_release_memory (void);
void bitset_release_memory (void);
/* Enable bitset stats gathering. */
extern void bitset_stats_enable (void);
void bitset_stats_enable (void);
/* Disable bitset stats gathering. */
extern void bitset_stats_disable (void);
void bitset_stats_disable (void);
/* Read bitset stats file of accummulated stats. */
void bitset_stats_read (const char *file_name);
@@ -383,12 +383,12 @@ void bitset_stats_read (const char *file_name);
void bitset_stats_write (const char *file_name);
/* Dump bitset stats. */
extern void bitset_stats_dump (FILE *);
void bitset_stats_dump (FILE *);
/* Function to debug bitset from debugger. */
extern void debug_bitset (bitset);
void debug_bitset (bitset);
/* Function to debug bitset stats from debugger. */
extern void debug_bitset_stats (void);
void debug_bitset_stats (void);
#endif /* _BITSET_H */
+36 -45
View File
@@ -108,18 +108,15 @@ static void
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
unsigned n_bins, unsigned *bins)
{
unsigned i;
unsigned total;
total = 0;
for (i = 0; i < n_bins; i++)
unsigned total = 0;
for (unsigned i = 0; i < n_bins; i++)
total += bins[i];
if (!total)
return;
fprintf (file, "%s %s", name, msg);
for (i = 0; i < n_bins; i++)
for (unsigned i = 0; i < n_bins; i++)
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
i * 100.0 / n_bins,
(i + 1) * 100.0 / n_bins, bins[i],
@@ -132,37 +129,39 @@ static void
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
unsigned n_bins, unsigned *bins)
{
unsigned i;
unsigned total;
unsigned max_width;
total = 0;
for (i = 0; i < n_bins; i++)
unsigned total = 0;
for (unsigned i = 0; i < n_bins; i++)
total += bins[i];
if (!total)
return;
/* Determine number of useful bins. */
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
continue;
n_bins = i;
{
unsigned i;
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
continue;
n_bins = i;
}
/* 2 * ceil (log10 (2) * (N - 1)) + 1. */
max_width = 2 * (unsigned) (0.30103 * (n_bins - 1) + 0.9999) + 1;
unsigned max_width = 2 * (unsigned) (0.30103 * (n_bins - 1) + 0.9999) + 1;
fprintf (file, "%s %s", name, msg);
for (i = 0; i < 2; i++)
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
max_width, i, bins[i], 100.0 * bins[i] / total);
{
unsigned i;
for (i = 0; i < 2; i++)
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
max_width, i, bins[i], 100.0 * bins[i] / total);
for (; i < n_bins; i++)
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1),
1UL << (i - 1),
(1UL << i) - 1,
bins[i],
(100.0 * bins[i]) / total);
for (; i < n_bins; i++)
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1),
1UL << (i - 1),
(1UL << i) - 1,
bins[i],
(100.0 * bins[i]) / total);
}
}
@@ -205,8 +204,6 @@ bitset_stats_print_1 (FILE *file, const char *name,
static void
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
{
int i;
if (!bitset_stats_info)
return;
@@ -215,7 +212,7 @@ bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
if (bitset_stats_info->runs > 1)
fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
for (i = 0; i < BITSET_TYPE_NUM; i++)
for (int i = 0; i < BITSET_TYPE_NUM; i++)
bitset_stats_print_1 (file, bitset_type_names[i],
&bitset_stats_info->types[i]);
}
@@ -242,15 +239,13 @@ bitset_stats_disable (void)
void
bitset_stats_read (const char *file_name)
{
FILE *file;
if (!bitset_stats_info)
return;
if (!file_name)
file_name = BITSET_STATS_FILE;
file = fopen (file_name, "r");
FILE *file = fopen (file_name, "r");
if (file)
{
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
@@ -272,15 +267,13 @@ bitset_stats_read (const char *file_name)
void
bitset_stats_write (const char *file_name)
{
FILE *file;
if (!bitset_stats_info)
return;
if (!file_name)
file_name = BITSET_STATS_FILE;
file = fopen (file_name, "w");
FILE *file = fopen (file_name, "w");
if (file)
{
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
@@ -352,7 +345,7 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
static bool
bitset_stats_toggle (bitset src, bitset_bindex bitno)
{
return BITSET_TOGGLE_ (src->s.bset, bitno);
return BITSET_TOGGLE_ (src->s.bset, bitno);
}
@@ -573,15 +566,14 @@ static bitset_bindex
bitset_stats_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex count;
bitset_bindex count = BITSET_LIST_ (bset->s.bset, list, num, next);
BITSET_STATS_LISTS_INC (bset->s.bset);
bitset_bindex tmp;
bitset_bindex size;
bitset_bindex i;
count = BITSET_LIST_ (bset->s.bset, list, num, next);
BITSET_STATS_LISTS_INC (bset->s.bset);
/* Log histogram of number of set bits. */
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
continue;
@@ -663,7 +655,7 @@ struct bitset_vtable bitset_stats_vtable = {
enum bitset_type
bitset_stats_type_get (bitset bset)
{
return BITSET_TYPE_ (bset->s.bset);
return BITSET_TYPE_ (bset->s.bset);
}
@@ -677,9 +669,6 @@ bitset_stats_bytes (void)
bitset
bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
{
size_t bytes;
bitset sbset;
bset->b.vtable = &bitset_stats_vtable;
/* Disable cache. */
@@ -691,6 +680,8 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
/* Set up the actual bitset implementation that
we are a wrapper over. */
size_t bytes;
bitset sbset;
switch (type)
{
default:
+3 -3
View File
@@ -25,10 +25,10 @@
extern bool bitset_stats_enabled;
extern enum bitset_type bitset_stats_type_get (bitset);
enum bitset_type bitset_stats_type_get (bitset);
extern size_t bitset_stats_bytes (void);
size_t bitset_stats_bytes (void);
extern bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
#endif
+6 -7
View File
@@ -29,7 +29,6 @@
void
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
{
bitset_bindex i, j;
bitset_bindex hsize = bitset_size (bset[0]);
/* Title. */
@@ -37,32 +36,32 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
/* Column numbers. */
fputs (" ", out);
for (i = 0; i < hsize; ++i)
for (bitset_bindex i = 0; i < hsize; ++i)
putc (i / 10 ? '0' + i / 10 : ' ', out);
putc ('\n', out);
fputs (" ", out);
for (i = 0; i < hsize; ++i)
for (bitset_bindex i = 0; i < hsize; ++i)
fprintf (out, "%d", (int) (i % 10));
putc ('\n', out);
/* Bar. */
fputs (" .", out);
for (i = 0; i < hsize; ++i)
for (bitset_bindex i = 0; i < hsize; ++i)
putc ('-', out);
fputs (".\n", out);
/* Contents. */
for (i = 0; bset[i]; ++i)
for (bitset_bindex i = 0; bset[i]; ++i)
{
fprintf (out, "%2lu|", (unsigned long) i);
for (j = 0; j < hsize; ++j)
for (bitset_bindex j = 0; j < hsize; ++j)
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
fputs ("|\n", out);
}
/* Bar. */
fputs (" `", out);
for (i = 0; i < hsize; ++i)
for (bitset_bindex i = 0; i < hsize; ++i)
putc ('-', out);
fputs ("'\n", out);
+1 -1
View File
@@ -24,6 +24,6 @@
#include "bitsetv.h"
/* Dump vector of bitsets as a matrix. */
extern void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
#endif /* _BITSETV_H */
+14 -35
View File
@@ -29,23 +29,19 @@ bitset *
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
enum bitset_type type)
{
size_t vector_bytes;
size_t bytes;
bitset *bsetv;
bitset_bindex i;
/* Determine number of bytes for each set. */
bytes = bitset_bytes (type, n_bits);
size_t bytes = bitset_bytes (type, n_bits);
/* If size calculation overflows, memory is exhausted. */
if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
xalloc_die ();
/* Allocate vector table at head of bitset array. */
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
size_t vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
vector_bytes -= vector_bytes % bytes;
bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
bitset *bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
bitset_bindex i = 0;
for (i = 0; i < n_vecs; i++)
{
bsetv[i] = (bitset) (void *) ((char *) bsetv + vector_bytes + i * bytes);
@@ -64,9 +60,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
bitset *
bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
{
enum bitset_type type;
type = bitset_type_choose (n_bits, attr);
enum bitset_type type = bitset_type_choose (n_bits, attr);
return bitsetv_alloc (n_vecs, n_bits, type);
}
@@ -75,10 +69,8 @@ bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
void
bitsetv_free (bitsetv bsetv)
{
bitset_bindex i;
for (i = 0; bsetv[i]; i++)
BITSET_FREE_ (bsetv[i]);
for (bitset_bindex i = 0; bsetv[i]; i++)
BITSET_FREE_ (bsetv[i]);
free (bsetv);
}
@@ -87,9 +79,7 @@ bitsetv_free (bitsetv bsetv)
void
bitsetv_zero (bitsetv bsetv)
{
bitset_bindex i;
for (i = 0; bsetv[i]; i++)
for (bitset_bindex i = 0; bsetv[i]; i++)
bitset_zero (bsetv[i]);
}
@@ -98,9 +88,7 @@ bitsetv_zero (bitsetv bsetv)
void
bitsetv_ones (bitsetv bsetv)
{
bitset_bindex i;
for (i = 0; bsetv[i]; i++)
for (bitset_bindex i = 0; bsetv[i]; i++)
bitset_ones (bsetv[i]);
}
@@ -110,11 +98,8 @@ bitsetv_ones (bitsetv bsetv)
void
bitsetv_transitive_closure (bitsetv bsetv)
{
bitset_bindex i;
bitset_bindex j;
for (i = 0; bsetv[i]; i++)
for (j = 0; bsetv[j]; j++)
for (bitset_bindex i = 0; bsetv[i]; i++)
for (bitset_bindex j = 0; bsetv[j]; j++)
if (bitset_test (bsetv[j], i))
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
}
@@ -127,10 +112,8 @@ bitsetv_transitive_closure (bitsetv bsetv)
void
bitsetv_reflexive_transitive_closure (bitsetv bsetv)
{
bitset_bindex i;
bitsetv_transitive_closure (bsetv);
for (i = 0; bsetv[i]; i++)
for (bitset_bindex i = 0; bsetv[i]; i++)
bitset_set (bsetv[i], i);
}
@@ -141,10 +124,8 @@ void
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
bitsetv bsetv)
{
bitset_windex i;
fprintf (file, "%s\n", title);
for (i = 0; bsetv[i]; i++)
for (bitset_windex i = 0; bsetv[i]; i++)
{
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
bitset_dump (file, bsetv[i]);
@@ -157,9 +138,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
void
debug_bitsetv (bitsetv bsetv)
{
bitset_windex i;
for (i = 0; bsetv[i]; i++)
for (bitset_windex i = 0; bsetv[i]; i++)
{
fprintf (stderr, "%lu: ", (unsigned long) i);
debug_bitset (bsetv[i]);
+9 -9
View File
@@ -27,35 +27,35 @@ typedef bitset * bitsetv;
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
type TYPE. */
extern bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
attribute hints specified by ATTR. */
extern bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned);
bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned);
/* Free vector of bitsets. */
extern void bitsetv_free (bitsetv);
void bitsetv_free (bitsetv);
/* Zero vector of bitsets. */
extern void bitsetv_zero (bitsetv);
void bitsetv_zero (bitsetv);
/* Set vector of bitsets. */
extern void bitsetv_ones (bitsetv);
void bitsetv_ones (bitsetv);
/* Given a vector BSETV of N bitsets of size N, modify its contents to
be the transitive closure of what was given. */
extern void bitsetv_transitive_closure (bitsetv);
void bitsetv_transitive_closure (bitsetv);
/* Given a vector BSETV of N bitsets of size N, modify its contents to
be the reflexive transitive closure of what was given. This is
the same as transitive closure but with all bits on the diagonal
of the bit matrix set. */
extern void bitsetv_reflexive_transitive_closure (bitsetv);
void bitsetv_reflexive_transitive_closure (bitsetv);
/* Dump vector of bitsets. */
extern void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
/* Function to debug vector of bitsets from debugger. */
extern void debug_bitsetv (bitsetv);
void debug_bitsetv (bitsetv);
#endif /* _BITSETV_H */
+117 -242
View File
@@ -123,14 +123,11 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
static bitset_bindex
ebitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
if (n_bits == BITSET_NBITS_ (src))
return n_bits;
oldsize = EBITSET_SIZE (src);
newsize = EBITSET_N_ELTS (n_bits);
bitset_windex oldsize = EBITSET_SIZE (src);
bitset_windex newsize = EBITSET_N_ELTS (n_bits);
if (oldsize < newsize)
{
@@ -234,9 +231,7 @@ ebitset_elt_alloc (void)
static inline ebitset_elt *
ebitset_elt_calloc (void)
{
ebitset_elt *elt;
elt = ebitset_elt_alloc ();
ebitset_elt *elt = ebitset_elt_alloc ();
memset (EBITSET_WORDS (elt), 0, sizeof (EBITSET_WORDS (elt)));
return elt;
}
@@ -254,12 +249,8 @@ ebitset_elt_free (ebitset_elt *elt)
static inline void
ebitset_elt_remove (bitset bset, bitset_windex eindex)
{
ebitset_elts *elts;
ebitset_elt *elt;
elts = EBITSET_ELTS (bset);
elt = elts[eindex];
ebitset_elts *elts = EBITSET_ELTS (bset);
ebitset_elt *elt = elts[eindex];
elts[eindex] = 0;
ebitset_elt_free (elt);
@@ -270,9 +261,7 @@ ebitset_elt_remove (bitset bset, bitset_windex eindex)
static inline void
ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
{
ebitset_elts *elts;
elts = EBITSET_ELTS (bset);
ebitset_elts *elts = EBITSET_ELTS (bset);
/* Assume that the elts entry not allocated. */
elts[eindex] = elt;
}
@@ -282,9 +271,7 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
static inline bool
ebitset_elt_zero_p (ebitset_elt *elt)
{
int i;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
for (int i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (elt)[i])
return false;
@@ -296,24 +283,18 @@ static ebitset_elt *
ebitset_elt_find (bitset bset, bitset_bindex bindex,
enum ebitset_find_mode mode)
{
ebitset_elt *elt;
bitset_windex size;
bitset_windex eindex;
ebitset_elts *elts;
bitset_windex eindex = bindex / EBITSET_ELT_BITS;
eindex = bindex / EBITSET_ELT_BITS;
elts = EBITSET_ELTS (bset);
size = EBITSET_SIZE (bset);
ebitset_elts *elts = EBITSET_ELTS (bset);
bitset_windex size = EBITSET_SIZE (bset);
if (eindex < size)
{
if ((elt = elts[eindex]))
ebitset_elt *elt = elts[eindex];
if (elt)
{
if (EBITSET_WORDS (elt) == bset->b.cdata)
return elt;
EBITSET_CACHE_SET (bset, eindex);
if (EBITSET_WORDS (elt) != bset->b.cdata)
EBITSET_CACHE_SET (bset, eindex);
return elt;
}
}
@@ -333,10 +314,12 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
ebitset_resize (bset, bindex);
/* Create a new element. */
elt = ebitset_elt_calloc ();
ebitset_elt_add (bset, elt, eindex);
EBITSET_CACHE_SET (bset, eindex);
return elt;
{
ebitset_elt *elt = ebitset_elt_calloc ();
ebitset_elt_add (bset, elt, eindex);
EBITSET_CACHE_SET (bset, eindex);
return elt;
}
case EBITSET_SUBST:
return &ebitset_zero_elts[0];
@@ -348,15 +331,12 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
static inline bitset_windex
ebitset_weed (bitset bset)
{
ebitset_elts *elts;
bitset_windex j;
bitset_windex count;
if (EBITSET_ZERO_P (bset))
return 0;
elts = EBITSET_ELTS (bset);
count = 0;
ebitset_elts *elts = EBITSET_ELTS (bset);
bitset_windex count = 0;
bitset_windex j;
for (j = 0; j < EBITSET_SIZE (bset); j++)
{
ebitset_elt *elt = elts[j];
@@ -391,14 +371,11 @@ ebitset_weed (bitset bset)
static inline void
ebitset_zero (bitset bset)
{
ebitset_elts *elts;
bitset_windex j;
if (EBITSET_ZERO_P (bset))
return;
elts = EBITSET_ELTS (bset);
for (j = 0; j < EBITSET_SIZE (bset); j++)
ebitset_elts *elts = EBITSET_ELTS (bset);
for (bitset_windex j = 0; j < EBITSET_SIZE (bset); j++)
{
ebitset_elt *elt = elts[j];
@@ -415,10 +392,6 @@ ebitset_zero (bitset bset)
static inline bool
ebitset_equal_p (bitset dst, bitset src)
{
ebitset_elts *selts;
ebitset_elts *delts;
bitset_windex j;
if (src == dst)
return true;
@@ -428,12 +401,11 @@ ebitset_equal_p (bitset dst, bitset src)
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
return false;
selts = EBITSET_ELTS (src);
delts = EBITSET_ELTS (dst);
ebitset_elts *selts = EBITSET_ELTS (src);
ebitset_elts *delts = EBITSET_ELTS (dst);
for (j = 0; j < EBITSET_SIZE (src); j++)
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
unsigned i;
ebitset_elt *selt = selts[j];
ebitset_elt *delt = delts[j];
@@ -442,7 +414,7 @@ ebitset_equal_p (bitset dst, bitset src)
if ((selt && !delt) || (!selt && delt))
return false;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
return false;
}
@@ -454,10 +426,6 @@ ebitset_equal_p (bitset dst, bitset src)
static inline void
ebitset_copy_ (bitset dst, bitset src)
{
ebitset_elts *selts;
ebitset_elts *delts;
bitset_windex j;
if (src == dst)
return;
@@ -466,17 +434,15 @@ ebitset_copy_ (bitset dst, bitset src)
if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src))
ebitset_resize (dst, BITSET_NBITS_ (src));
selts = EBITSET_ELTS (src);
delts = EBITSET_ELTS (dst);
for (j = 0; j < EBITSET_SIZE (src); j++)
ebitset_elts *selts = EBITSET_ELTS (src);
ebitset_elts *delts = EBITSET_ELTS (dst);
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
ebitset_elt *selt = selts[j];
if (selt)
{
ebitset_elt *tmp;
tmp = ebitset_elt_alloc ();
ebitset_elt *tmp = ebitset_elt_alloc ();
delts[j] = tmp;
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
sizeof (EBITSET_WORDS (selt)));
@@ -567,60 +533,41 @@ static bitset_bindex
ebitset_list_reverse (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex n_bits;
bitset_bindex bitno;
bitset_bindex rbitno;
unsigned bcount;
bitset_bindex boffset;
bitset_windex windex;
bitset_windex eindex;
bitset_windex woffset;
bitset_bindex count;
bitset_windex size;
ebitset_elts *elts;
if (EBITSET_ZERO_P (bset))
return 0;
size = EBITSET_SIZE (bset);
n_bits = size * EBITSET_ELT_BITS;
rbitno = *next;
bitset_windex size = EBITSET_SIZE (bset);
bitset_bindex n_bits = size * EBITSET_ELT_BITS;
bitset_bindex rbitno = *next;
if (rbitno >= n_bits)
return 0;
elts = EBITSET_ELTS (bset);
ebitset_elts *elts = EBITSET_ELTS (bset);
bitno = n_bits - (rbitno + 1);
bitset_bindex bitno = n_bits - (rbitno + 1);
windex = bitno / BITSET_WORD_BITS;
eindex = bitno / EBITSET_ELT_BITS;
woffset = windex - eindex * EBITSET_ELT_WORDS;
bitset_windex windex = bitno / BITSET_WORD_BITS;
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
bitset_windex woffset = windex - eindex * EBITSET_ELT_WORDS;
/* If num is 1, we could speed things up with a binary search
of the word of interest. */
count = 0;
bcount = bitno % BITSET_WORD_BITS;
boffset = windex * BITSET_WORD_BITS;
bitset_bindex count = 0;
unsigned bcount = bitno % BITSET_WORD_BITS;
bitset_bindex boffset = windex * BITSET_WORD_BITS;
do
{
ebitset_elt *elt;
bitset_word *srcp;
elt = elts[eindex];
ebitset_elt *elt = elts[eindex];
if (elt)
{
srcp = EBITSET_WORDS (elt);
bitset_word *srcp = EBITSET_WORDS (elt);
do
{
bitset_word word;
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
for (; word; bcount--)
for (bitset_word word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
word; bcount--)
{
if (word & BITSET_MSB)
{
@@ -656,41 +603,32 @@ static bitset_bindex
ebitset_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_windex windex;
bitset_windex eindex;
bitset_bindex count;
bitset_windex size;
ebitset_elt *elt;
bitset_word word;
ebitset_elts *elts;
if (EBITSET_ZERO_P (bset))
return 0;
bitno = *next;
count = 0;
bitset_bindex bitno = *next;
bitset_bindex count = 0;
elts = EBITSET_ELTS (bset);
size = EBITSET_SIZE (bset);
eindex = bitno / EBITSET_ELT_BITS;
ebitset_elts *elts = EBITSET_ELTS (bset);
bitset_windex size = EBITSET_SIZE (bset);
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
if (bitno % EBITSET_ELT_BITS)
{
/* We need to start within an element. This is not very common. */
elt = elts[eindex];
ebitset_elt *elt = elts[eindex];
if (elt)
{
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
windex = bitno / BITSET_WORD_BITS;
bitset_windex windex = bitno / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
{
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
bitset_word word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
for (; word; bitno++)
{
@@ -718,22 +656,21 @@ ebitset_list (bitset bset, bitset_bindex *list,
for (; eindex < size; eindex++)
{
int i;
bitset_word *srcp;
elt = elts[eindex];
ebitset_elt *elt = elts[eindex];
if (!elt)
continue;
srcp = EBITSET_WORDS (elt);
windex = eindex * EBITSET_ELT_WORDS;
bitset_windex windex = eindex * EBITSET_ELT_WORDS;
if ((count + EBITSET_ELT_BITS) < num)
{
/* The coast is clear, plant boot! */
#if EBITSET_ELT_WORDS == 2
word = srcp[0];
bitset_word word = srcp[0];
if (word)
{
if (!(word & 0xffff))
@@ -774,7 +711,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
windex++;
bitno = windex * BITSET_WORD_BITS;
#else
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
for (int i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
{
bitno = windex * BITSET_WORD_BITS;
@@ -806,11 +743,11 @@ ebitset_list (bitset bset, bitset_bindex *list,
/* Tread more carefully since we need to check
if array overflows. */
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
for (int i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
{
bitno = windex * BITSET_WORD_BITS;
for (word = srcp[i]; word; bitno++)
for (bitset_word word = srcp[i]; word; bitno++)
{
if (word & 1)
{
@@ -836,31 +773,22 @@ ebitset_list (bitset bset, bitset_bindex *list,
static inline void
ebitset_unused_clear (bitset dst)
{
unsigned last_bit;
bitset_bindex n_bits;
n_bits = BITSET_NBITS_ (dst);
last_bit = n_bits % EBITSET_ELT_BITS;
bitset_bindex n_bits = BITSET_NBITS_ (dst);
unsigned last_bit = n_bits % EBITSET_ELT_BITS;
if (last_bit)
{
bitset_windex eindex;
ebitset_elts *elts;
ebitset_elt *elt;
ebitset_elts *elts = EBITSET_ELTS (dst);
elts = EBITSET_ELTS (dst);
bitset_windex eindex = n_bits / EBITSET_ELT_BITS;
eindex = n_bits / EBITSET_ELT_BITS;
elt = elts[eindex];
ebitset_elt *elt = elts[eindex];
if (elt)
{
bitset_windex windex;
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
windex = n_bits / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
bitset_windex windex = n_bits / BITSET_WORD_BITS;
bitset_windex woffset = eindex * EBITSET_ELT_WORDS;
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
windex++;
@@ -874,14 +802,11 @@ ebitset_unused_clear (bitset dst)
static void
ebitset_ones (bitset dst)
{
bitset_windex j;
ebitset_elt *elt;
for (j = 0; j < EBITSET_SIZE (dst); j++)
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
{
/* Create new elements if they cannot be found. Perhaps
we should just add pointers to a ones element? */
elt =
ebitset_elt *elt =
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
}
@@ -893,14 +818,11 @@ ebitset_ones (bitset dst)
static bool
ebitset_empty_p (bitset dst)
{
ebitset_elts *elts;
bitset_windex j;
if (EBITSET_ZERO_P (dst))
return 1;
elts = EBITSET_ELTS (dst);
for (j = 0; j < EBITSET_SIZE (dst); j++)
ebitset_elts *elts = EBITSET_ELTS (dst);
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
{
ebitset_elt *elt = elts[j];
@@ -923,23 +845,18 @@ ebitset_empty_p (bitset dst)
static void
ebitset_not (bitset dst, bitset src)
{
unsigned i;
ebitset_elt *selt;
ebitset_elt *delt;
bitset_windex j;
ebitset_resize (dst, BITSET_NBITS_ (src));
for (j = 0; j < EBITSET_SIZE (src); j++)
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
/* Create new elements for dst if they cannot be found
or substitute zero elements if src elements not found. */
selt =
ebitset_elt *selt =
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
delt =
ebitset_elt *delt =
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
for (i = 0; i < EBITSET_ELT_WORDS; i++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
}
EBITSET_NONZERO_SET (dst);
@@ -951,26 +868,16 @@ ebitset_not (bitset dst, bitset src)
static bool
ebitset_subset_p (bitset dst, bitset src)
{
bitset_windex j;
ebitset_elts *selts;
ebitset_elts *delts;
bitset_windex ssize;
bitset_windex dsize;
ebitset_elts *selts = EBITSET_ELTS (src);
ebitset_elts *delts = EBITSET_ELTS (dst);
selts = EBITSET_ELTS (src);
delts = EBITSET_ELTS (dst);
bitset_windex ssize = EBITSET_SIZE (src);
bitset_windex dsize = EBITSET_SIZE (dst);
ssize = EBITSET_SIZE (src);
dsize = EBITSET_SIZE (dst);
for (j = 0; j < ssize; j++)
for (bitset_windex j = 0; j < ssize; j++)
{
unsigned i;
ebitset_elt *selt;
ebitset_elt *delt;
selt = j < ssize ? selts[j] : 0;
delt = j < dsize ? delts[j] : 0;
ebitset_elt *selt = j < ssize ? selts[j] : 0;
ebitset_elt *delt = j < dsize ? delts[j] : 0;
if (!selt && !delt)
continue;
@@ -980,7 +887,7 @@ ebitset_subset_p (bitset dst, bitset src)
if (!delt)
delt = &ebitset_zero_elts[0];
for (i = 0; i < EBITSET_ELT_WORDS; i++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (delt)[i]
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
return false;
@@ -993,31 +900,21 @@ ebitset_subset_p (bitset dst, bitset src)
static bool
ebitset_disjoint_p (bitset dst, bitset src)
{
bitset_windex j;
ebitset_elts *selts;
ebitset_elts *delts;
bitset_windex ssize;
bitset_windex dsize;
ebitset_elts *selts = EBITSET_ELTS (src);
ebitset_elts *delts = EBITSET_ELTS (dst);
selts = EBITSET_ELTS (src);
delts = EBITSET_ELTS (dst);
bitset_windex ssize = EBITSET_SIZE (src);
bitset_windex dsize = EBITSET_SIZE (dst);
ssize = EBITSET_SIZE (src);
dsize = EBITSET_SIZE (dst);
for (j = 0; j < ssize; j++)
for (bitset_windex j = 0; j < ssize; j++)
{
unsigned i;
ebitset_elt *selt;
ebitset_elt *delt;
selt = j < ssize ? selts[j] : 0;
delt = j < dsize ? delts[j] : 0;
ebitset_elt *selt = j < ssize ? selts[j] : 0;
ebitset_elt *delt = j < dsize ? delts[j] : 0;
if (!selt || !delt)
continue;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
return false;
}
@@ -1029,42 +926,27 @@ ebitset_disjoint_p (bitset dst, bitset src)
static bool
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
bitset_windex size;
ebitset_elts *selts1;
ebitset_elts *selts2;
ebitset_elts *delts;
bitset_word *srcp1;
bitset_word *srcp2;
bitset_word *dstp;
bool changed = false;
unsigned i;
bitset_windex j;
ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
ssize1 = EBITSET_SIZE (src1);
ssize2 = EBITSET_SIZE (src2);
dsize = EBITSET_SIZE (dst);
size = ssize1;
bitset_windex ssize1 = EBITSET_SIZE (src1);
bitset_windex ssize2 = EBITSET_SIZE (src2);
bitset_windex dsize = EBITSET_SIZE (dst);
bitset_windex size = ssize1;
if (size < ssize2)
size = ssize2;
selts1 = EBITSET_ELTS (src1);
selts2 = EBITSET_ELTS (src2);
delts = EBITSET_ELTS (dst);
ebitset_elts *selts1 = EBITSET_ELTS (src1);
ebitset_elts *selts2 = EBITSET_ELTS (src2);
ebitset_elts *delts = EBITSET_ELTS (dst);
bitset_windex j = 0;
for (j = 0; j < size; j++)
{
ebitset_elt *selt1;
ebitset_elt *selt2;
ebitset_elt *delt;
selt1 = j < ssize1 ? selts1[j] : 0;
selt2 = j < ssize2 ? selts2[j] : 0;
delt = j < dsize ? delts[j] : 0;
ebitset_elt *selt1 = j < ssize1 ? selts1[j] : 0;
ebitset_elt *selt2 = j < ssize2 ? selts2[j] : 0;
ebitset_elt *delt = j < dsize ? delts[j] : 0;
if (!selt1 && !selt2)
{
@@ -1085,16 +967,16 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
else
delts[j] = 0;
srcp1 = EBITSET_WORDS (selt1);
srcp2 = EBITSET_WORDS (selt2);
dstp = EBITSET_WORDS (delt);
bitset_word *srcp1 = EBITSET_WORDS (selt1);
bitset_word *srcp2 = EBITSET_WORDS (selt2);
bitset_word *dstp = EBITSET_WORDS (delt);
switch (op)
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ | *srcp2++;
@@ -1107,7 +989,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
case BITSET_OP_AND:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & *srcp2++;
@@ -1120,7 +1002,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
case BITSET_OP_XOR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ ^ *srcp2++;
@@ -1133,7 +1015,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
case BITSET_OP_ANDN:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & ~(*srcp2++);
@@ -1159,12 +1041,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
/* If we have elements of DST left over, free them all. */
for (; j < dsize; j++)
{
ebitset_elt *delt;
changed = true;
delt = delts[j];
ebitset_elt *delt = delts[j];
if (delt)
ebitset_elt_remove (dst, j);
}
@@ -1177,19 +1056,17 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
static bool
ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
bool changed;
if (EBITSET_ZERO_P (src2))
{
ebitset_weed (dst);
changed = EBITSET_ZERO_P (dst);
bool changed = EBITSET_ZERO_P (dst);
ebitset_zero (dst);
return changed;
}
else if (EBITSET_ZERO_P (src1))
{
ebitset_weed (dst);
changed = EBITSET_ZERO_P (dst);
bool changed = EBITSET_ZERO_P (dst);
ebitset_zero (dst);
return changed;
}
@@ -1207,8 +1084,6 @@ ebitset_and (bitset dst, bitset src1, bitset src2)
static bool
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
bool changed;
if (EBITSET_ZERO_P (src2))
{
return ebitset_copy_cmp (dst, src1);
@@ -1216,7 +1091,7 @@ ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
else if (EBITSET_ZERO_P (src1))
{
ebitset_weed (dst);
changed = EBITSET_ZERO_P (dst);
bool changed = EBITSET_ZERO_P (dst);
ebitset_zero (dst);
return changed;
}
@@ -1279,9 +1154,9 @@ static void
ebitset_copy (bitset dst, bitset src)
{
if (BITSET_COMPATIBLE_ (dst, src))
ebitset_copy_ (dst, src);
ebitset_copy_ (dst, src);
else
bitset_copy_ (dst, src);
bitset_copy_ (dst, src);
}
+3 -3
View File
@@ -23,10 +23,10 @@
#include "bitset.h"
extern size_t ebitset_bytes (bitset_bindex);
size_t ebitset_bytes (bitset_bindex);
extern bitset ebitset_init (bitset, bitset_bindex);
bitset ebitset_init (bitset, bitset_bindex);
extern void ebitset_release_memory (void);
void ebitset_release_memory (void);
#endif
+68 -123
View File
@@ -145,9 +145,7 @@ lbitset_elt_alloc (void)
static inline lbitset_elt *
lbitset_elt_calloc (void)
{
lbitset_elt *elt;
elt = lbitset_elt_alloc ();
lbitset_elt *elt = lbitset_elt_alloc ();
memset (elt->words, 0, sizeof (elt->words));
return elt;
}
@@ -210,8 +208,6 @@ lbitset_elt_unlink (bitset bset, lbitset_elt *elt)
static inline void
lbitset_prune (bitset bset, lbitset_elt *elt)
{
lbitset_elt *next;
if (!elt)
return;
@@ -230,6 +226,7 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
bset->b.csize = 0;
}
lbitset_elt *next;
for (; elt; elt = next)
{
next = elt->next;
@@ -242,9 +239,7 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
static inline bool
lbitset_elt_zero_p (lbitset_elt *elt)
{
int i;
for (i = 0; i < LBITSET_ELT_WORDS; i++)
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
if (elt->words[i])
return false;
@@ -257,9 +252,8 @@ static inline void
lbitset_elt_link (bitset bset, lbitset_elt *elt)
{
bitset_windex windex = elt->index;
lbitset_elt *ptr;
lbitset_elt *current;
lbitset_elt *current;
if (bset->b.csize)
current = LBITSET_CURRENT (bset);
else
@@ -277,6 +271,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
somewhere before the current element. */
else if (windex < bset->b.cindex)
{
lbitset_elt *ptr;
for (ptr = current;
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
continue;
@@ -294,6 +289,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
/* Otherwise, it must go somewhere after the current element. */
else
{
lbitset_elt *ptr;
for (ptr = current;
ptr->next && ptr->next->index < windex; ptr = ptr->next)
continue;
@@ -319,7 +315,6 @@ static lbitset_elt *
lbitset_elt_find (bitset bset, bitset_windex windex,
enum lbitset_find_mode mode)
{
lbitset_elt *elt;
lbitset_elt *current;
if (bset->b.csize)
@@ -336,6 +331,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
if (current)
{
lbitset_elt *elt;
if (windex < bset->b.cindex)
{
for (elt = current;
@@ -371,8 +367,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
case LBITSET_CREATE:
windex -= windex % LBITSET_ELT_WORDS;
elt = lbitset_elt_calloc ();
lbitset_elt *elt = lbitset_elt_calloc ();
elt->index = windex;
lbitset_elt_link (bset, elt);
return elt;
@@ -387,10 +382,8 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
static inline void
lbitset_weed (bitset bset)
{
lbitset_elt *elt;
lbitset_elt *next;
for (elt = LBITSET_HEAD (bset); elt; elt = next)
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt; elt = next)
{
next = elt->next;
if (lbitset_elt_zero_p (elt))
@@ -403,9 +396,7 @@ lbitset_weed (bitset bset)
static void
lbitset_zero (bitset bset)
{
lbitset_elt *head;
head = LBITSET_HEAD (bset);
lbitset_elt *head = LBITSET_HEAD (bset);
if (!head)
return;
@@ -418,22 +409,20 @@ lbitset_zero (bitset bset)
static inline bool
lbitset_equal_p (bitset dst, bitset src)
{
lbitset_elt *selt;
lbitset_elt *delt;
int j;
if (src == dst)
return true;
lbitset_weed (src);
lbitset_weed (dst);
lbitset_elt *selt;
lbitset_elt *delt;
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
return false;
for (j = 0; j < LBITSET_ELT_WORDS; j++)
for (int j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != selt->words[j])
return false;
}
@@ -445,22 +434,18 @@ lbitset_equal_p (bitset dst, bitset src)
static inline void
lbitset_copy (bitset dst, bitset src)
{
lbitset_elt *elt;
lbitset_elt *head;
lbitset_elt *prev;
lbitset_elt *tmp;
if (src == dst)
return;
lbitset_zero (dst);
head = LBITSET_HEAD (src);
lbitset_elt *head = LBITSET_HEAD (src);
if (!head)
return;
prev = 0;
for (elt = head; elt; elt = elt->next)
lbitset_elt *prev = 0;
lbitset_elt *tmp;
for (lbitset_elt *elt = head; elt; elt = elt->next)
{
tmp = lbitset_elt_alloc ();
tmp->index = elt->index;
@@ -507,10 +492,10 @@ lbitset_copy_cmp (bitset dst, bitset src)
static bitset_bindex
lbitset_resize (bitset src, bitset_bindex size)
{
BITSET_NBITS_ (src) = size;
BITSET_NBITS_ (src) = size;
/* Need to prune any excess bits. FIXME. */
return size;
/* Need to prune any excess bits. FIXME. */
return size;
}
/* Set bit BITNO in bitset DST. */
@@ -569,29 +554,19 @@ static bitset_bindex
lbitset_list_reverse (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex rbitno;
bitset_bindex bitno;
unsigned bcount;
bitset_bindex boffset;
bitset_windex windex;
bitset_bindex count;
lbitset_elt *elt;
bitset_word word;
bitset_bindex n_bits;
elt = LBITSET_TAIL (bset);
lbitset_elt *elt = LBITSET_TAIL (bset);
if (!elt)
return 0;
n_bits = (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
rbitno = *next;
bitset_bindex n_bits = (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
bitset_bindex rbitno = *next;
if (rbitno >= n_bits)
return 0;
bitno = n_bits - (rbitno + 1);
bitset_bindex bitno = n_bits - (rbitno + 1);
windex = bitno / BITSET_WORD_BITS;
bitset_windex windex = bitno / BITSET_WORD_BITS;
/* Skip back to starting element. */
for (; elt && elt->index > windex; elt = elt->prev)
@@ -600,6 +575,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
if (!elt)
return 0;
unsigned bcount;
if (windex >= elt->index + LBITSET_ELT_WORDS)
{
/* We are trying to start in no-mans land so start
@@ -612,8 +588,8 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
bcount = bitno % BITSET_WORD_BITS;
}
count = 0;
boffset = windex * BITSET_WORD_BITS;
bitset_bindex count = 0;
bitset_bindex boffset = windex * BITSET_WORD_BITS;
/* If num is 1, we could speed things up with a binary search
of the word of interest. */
@@ -626,7 +602,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
windex--, boffset -= BITSET_WORD_BITS,
bcount = BITSET_WORD_BITS - 1)
{
word =
bitset_word word =
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
for (; word; bcount--)
@@ -664,19 +640,16 @@ static bitset_bindex
lbitset_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_windex windex;
bitset_bindex count;
lbitset_elt *elt;
lbitset_elt *head;
bitset_word word;
head = LBITSET_HEAD (bset);
lbitset_elt *head = LBITSET_HEAD (bset);
if (!head)
return 0;
bitno = *next;
count = 0;
bitset_windex windex;
lbitset_elt *elt;
bitset_word word;
bitset_bindex bitno = *next;
bitset_bindex count = 0;
if (!bitno)
{
@@ -746,7 +719,6 @@ lbitset_list (bitset bset, bitset_bindex *list,
while (elt)
{
int i;
bitset_word *srcp = elt->words;
if ((count + LBITSET_ELT_BITS) < num)
@@ -795,7 +767,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
windex++;
bitno = windex * BITSET_WORD_BITS;
#else
for (i = 0; i < LBITSET_ELT_WORDS; i++)
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
{
word = srcp[i];
if (word)
@@ -827,7 +799,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
/* Tread more carefully since we need to check
if array overflows. */
for (i = 0; i < LBITSET_ELT_WORDS; i++)
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
{
for (word = srcp[i]; word; bitno++)
{
@@ -911,21 +883,18 @@ lbitset_unused_clear (bitset dst)
static void
lbitset_ones (bitset dst)
{
bitset_windex i;
bitset_windex windex;
lbitset_elt *elt;
/* This is a decidedly unfriendly operation for a linked list
bitset! It makes a sparse bitset become dense. An alternative
is to have a flag that indicates that the bitset stores the
complement of what it indicates. */
bitset! It makes a sparse bitset become dense. An alternative
is to have a flag that indicates that the bitset stores the
complement of what it indicates. */
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
bitset_windex windex
= (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
for (bitset_windex i = 0; i < windex; i += LBITSET_ELT_WORDS)
{
/* Create new elements if they cannot be found. */
elt = lbitset_elt_find (dst, i, LBITSET_CREATE);
lbitset_elt *elt = lbitset_elt_find (dst, i, LBITSET_CREATE);
memset (elt->words, -1, sizeof (elt->words));
}
@@ -936,22 +905,17 @@ lbitset_ones (bitset dst)
static void
lbitset_not (bitset dst, bitset src)
{
lbitset_elt *selt;
lbitset_elt *delt;
bitset_windex i;
unsigned j;
bitset_windex windex;
bitset_windex windex
= (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
for (bitset_windex i = 0; i < windex; i += LBITSET_ELT_WORDS)
{
/* Create new elements for dst if they cannot be found
or substitute zero elements if src elements not found. */
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
lbitset_elt *selt = lbitset_elt_find (src, i, LBITSET_SUBST);
lbitset_elt *delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
for (j = 0; j < LBITSET_ELT_WORDS; j++)
for (unsigned j = 0; j < LBITSET_ELT_WORDS; j++)
delt->words[j] = ~selt->words[j];
}
lbitset_unused_clear (dst);
@@ -964,11 +928,7 @@ lbitset_not (bitset dst, bitset src)
static bool
lbitset_subset_p (bitset dst, bitset src)
{
lbitset_elt *selt;
lbitset_elt *delt;
unsigned j;
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
for (lbitset_elt *selt = LBITSET_HEAD (src), *delt = LBITSET_HEAD (dst);
selt || delt; selt = selt->next, delt = delt->next)
{
if (!selt)
@@ -989,7 +949,7 @@ lbitset_subset_p (bitset dst, bitset src)
}
}
for (j = 0; j < LBITSET_ELT_WORDS; j++)
for (unsigned j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != (selt->words[j] | delt->words[j]))
return false;
}
@@ -1001,11 +961,7 @@ lbitset_subset_p (bitset dst, bitset src)
static bool
lbitset_disjoint_p (bitset dst, bitset src)
{
lbitset_elt *selt;
lbitset_elt *delt;
unsigned j;
for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst);
for (lbitset_elt *selt = LBITSET_HEAD (src), *delt = LBITSET_HEAD (dst);
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
@@ -1025,7 +981,7 @@ lbitset_disjoint_p (bitset dst, bitset src)
continue;
}
for (j = 0; j < LBITSET_ELT_WORDS; j++)
for (unsigned j = 0; j < LBITSET_ELT_WORDS; j++)
if (selt->words[j] & delt->words[j])
return false;
}
@@ -1039,8 +995,6 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2);
lbitset_elt *delt = LBITSET_HEAD (dst);
bitset_windex windex1;
bitset_windex windex2;
bitset_windex windex;
lbitset_elt *stmp1;
lbitset_elt *stmp2;
@@ -1049,13 +1003,12 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
bitset_word *srcp2;
bitset_word *dstp;
bool changed = false;
unsigned i;
LBITSET_HEAD (dst) = 0;
dst->b.csize = 0;
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
bitset_windex windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
bitset_windex windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
while (selt1 || selt2)
{
@@ -1116,7 +1069,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
abort ();
case BITSET_OP_OR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ | *srcp2++;
@@ -1129,7 +1082,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
case BITSET_OP_AND:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & *srcp2++;
@@ -1142,7 +1095,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
case BITSET_OP_XOR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ ^ *srcp2++;
@@ -1155,7 +1108,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
case BITSET_OP_ANDN:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & ~(*srcp2++);
@@ -1196,19 +1149,18 @@ lbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2);
bool changed;
if (!selt2)
{
lbitset_weed (dst);
changed = !LBITSET_HEAD (dst);
bool changed = !LBITSET_HEAD (dst);
lbitset_zero (dst);
return changed;
}
else if (!selt1)
{
lbitset_weed (dst);
changed = !LBITSET_HEAD (dst);
bool changed = !LBITSET_HEAD (dst);
lbitset_zero (dst);
return changed;
}
@@ -1228,7 +1180,6 @@ lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2);
bool changed;
if (!selt2)
{
@@ -1237,7 +1188,7 @@ lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
else if (!selt1)
{
lbitset_weed (dst);
changed = !LBITSET_HEAD (dst);
bool changed = !LBITSET_HEAD (dst);
lbitset_zero (dst);
return changed;
}
@@ -1375,24 +1326,18 @@ lbitset_release_memory (void)
void
debug_lbitset (bitset bset)
{
lbitset_elt *elt;
unsigned i;
if (!bset)
return;
for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt; elt = elt->next)
{
fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
for (i = 0; i < LBITSET_ELT_WORDS; i++)
for (unsigned i = 0; i < LBITSET_ELT_WORDS; i++)
{
unsigned j;
bitset_word word;
word = elt->words[i];
bitset_word word = elt->words[i];
fprintf (stderr, " Word %u:", i);
for (j = 0; j < LBITSET_WORD_BITS; j++)
for (unsigned j = 0; j < LBITSET_WORD_BITS; j++)
if ((word & ((bitset_word) 1 << j)))
fprintf (stderr, " %u", j);
fprintf (stderr, "\n");
+3 -3
View File
@@ -23,10 +23,10 @@
#include "bitset.h"
extern size_t lbitset_bytes (bitset_bindex);
size_t lbitset_bytes (bitset_bindex);
extern bitset lbitset_init (bitset, bitset_bindex);
bitset lbitset_init (bitset, bitset_bindex);
extern void lbitset_release_memory (void);
void lbitset_release_memory (void);
#endif
+3 -7
View File
@@ -39,16 +39,12 @@ lib_libbison_a_SOURCES += \
lib/bitsetv-print.h \
lib/bitsetv-print.c
# timevars, stolen from GCC.
lib_libbison_a_SOURCES += \
lib/timevar.h \
lib/timevar.c \
lib/timevar.def
# Non-gnulib sources in Bison's internal library.
lib_libbison_a_SOURCES += \
lib/get-errno.h \
lib/get-errno.c
lib/get-errno.c \
lib/path-join.h \
lib/path-join.c
# The Yacc compatibility library.
if ENABLE_YACC
+37
View File
@@ -0,0 +1,37 @@
/* Concatenate path components.
Copyright (C) 2018 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 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/>. */
/* Written by Akim Demaille <[email protected]>. */
#include <config.h>
/* Specification. */
#include "path-join.h"
#include <concat-filename.h> /* xconcatenated_filename */
#include <filename.h> /* IS_ABSOLUTE_PATH */
#include <xalloc.h> /* xstrdup */
char *
xpath_join (const char *path1, const char *path2)
{
if (!path2 || !*path2)
return xstrdup (path1);
else if (IS_ABSOLUTE_PATH (path2))
return xstrdup (path2);
else
return xconcatenated_filename (path1, path2, NULL);
}
+38
View File
@@ -0,0 +1,38 @@
/* Concatenate path components.
Copyright (C) 2018 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 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/>. */
/* Written by Akim Demaille <[email protected]>. */
#ifndef _PATH_JOIN_H
# define _PATH_JOIN_H
# ifdef __cplusplus
extern "C" {
# endif
/* Concatenate two paths together. PATH2 may be null, or empty, or
absolute: do what is right. Return a freshly allocated
filename. */
char *
xpath_join (const char *path1, const char *path2);
# ifdef __cplusplus
}
# endif
#endif /* _PATH_JOIN_H */
-565
View File
@@ -1,565 +0,0 @@
/* Timing variables for measuring compiler performance.
Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018 Free Software
Foundation, Inc.
Contributed by Alex Samuel <samuel@codesourcery.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#if IN_GCC
#include "system.h"
#include "intl.h"
#include "rtl.h"
#else
/* This source file is taken from the GCC source code, with slight
modifications that are under control of the IN_GCC preprocessor
variable. The !IN_GCC part of this file is specific to Bison. */
# include "../src/system.h"
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# endif
int timevar_report = 0;
#endif
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifndef HAVE_CLOCK_T
typedef int clock_t;
#endif
#ifndef HAVE_STRUCT_TMS
struct tms
{
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
};
#endif
#if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
extern int getrusage (int, struct rusage *);
#endif
#if defined HAVE_DECL_TIMES && !HAVE_DECL_TIMES
extern clock_t times (struct tms *);
#endif
#if defined HAVE_DECL_CLOCK && !HAVE_DECL_CLOCK
extern clock_t clock (void);
#endif
#ifndef RUSAGE_SELF
# define RUSAGE_SELF 0
#endif
/* Calculation of scale factor to convert ticks to microseconds.
We mustn't use CLOCKS_PER_SEC except with clock(). */
#if HAVE_SYSCONF && defined _SC_CLK_TCK
# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
#else
# ifdef CLK_TCK
# define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
# else
# ifdef HZ
# define TICKS_PER_SECOND HZ /* traditional UNIX */
# else
# define TICKS_PER_SECOND 100 /* often the correct value */
# endif
# endif
#endif
/* Prefer times to getrusage to clock (each gives successively less
information). */
#ifdef HAVE_TIMES
# define USE_TIMES
# define HAVE_USER_TIME
# define HAVE_SYS_TIME
# define HAVE_WALL_TIME
#else
#ifdef HAVE_GETRUSAGE
# define USE_GETRUSAGE
# define HAVE_USER_TIME
# define HAVE_SYS_TIME
#else
#ifdef HAVE_CLOCK
# define USE_CLOCK
# define HAVE_USER_TIME
#endif
#endif
#endif
/* libc is very likely to have snuck a call to sysconf() into one of
the underlying constants, and that can be very slow, so we have to
precompute them. Whose wonderful idea was it to make all those
_constants_ variable at run time, anyway? */
#ifdef USE_TIMES
static float ticks_to_msec;
#define TICKS_TO_MSEC (1.0 / TICKS_PER_SECOND)
#endif
#ifdef USE_CLOCK
static float clocks_to_msec;
#define CLOCKS_TO_MSEC (1.0 / CLOCKS_PER_SEC)
#endif
#if IN_GCC
#include "flags.h"
#endif
#include "timevar.h"
/* See timevar.h for an explanation of timing variables. */
/* This macro evaluates to nonzero if timing variables are enabled. */
#define TIMEVAR_ENABLE (timevar_report)
/* A timing variable. */
struct timevar_def
{
/* Elapsed time for this variable. */
struct timevar_time_def elapsed;
/* If this variable is timed independently of the timing stack,
using timevar_start, this contains the start time. */
struct timevar_time_def start_time;
/* The name of this timing variable. */
const char *name;
/* Non-zero if this timing variable is running as a standalone
timer. */
unsigned standalone : 1;
/* Non-zero if this timing variable was ever started or pushed onto
the timing stack. */
unsigned used : 1;
};
/* An element on the timing stack. Elapsed time is attributed to the
topmost timing variable on the stack. */
struct timevar_stack_def
{
/* The timing variable at this stack level. */
struct timevar_def *timevar;
/* The next lower timing variable context in the stack. */
struct timevar_stack_def *next;
};
/* Declared timing variables. Constructed from the contents of
timevar.def. */
static struct timevar_def timevars[TIMEVAR_LAST];
/* The top of the timing stack. */
static struct timevar_stack_def *stack;
/* A list of unused (i.e. allocated and subsequently popped)
timevar_stack_def instances. */
static struct timevar_stack_def *unused_stack_instances;
/* The time at which the topmost element on the timing stack was
pushed. Time elapsed since then is attributed to the topmost
element. */
static struct timevar_time_def start_time;
static void get_time (struct timevar_time_def *);
static void timevar_accumulate (struct timevar_time_def *,
struct timevar_time_def *,
struct timevar_time_def *);
/* Fill the current times into TIME. The definition of this function
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
HAVE_WALL_TIME macros. */
static void
get_time (now)
struct timevar_time_def *now;
{
now->user = 0;
now->sys = 0;
now->wall = 0;
if (!TIMEVAR_ENABLE)
return;
{
#ifdef USE_TIMES
struct tms tms;
now->wall = times (&tms) * ticks_to_msec;
#if IN_GCC
now->user = tms.tms_utime * ticks_to_msec;
now->sys = tms.tms_stime * ticks_to_msec;
#else
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
#endif
#endif
#ifdef USE_GETRUSAGE
struct rusage rusage;
#if IN_GCC
getrusage (RUSAGE_SELF, &rusage);
#else
getrusage (RUSAGE_CHILDREN, &rusage);
#endif
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
#endif
#ifdef USE_CLOCK
now->user = clock () * clocks_to_msec;
#endif
}
}
/* Add the difference between STOP and START to TIMER. */
static void
timevar_accumulate (timer, start, stop)
struct timevar_time_def *timer;
struct timevar_time_def *start;
struct timevar_time_def *stop;
{
timer->user += stop->user - start->user;
timer->sys += stop->sys - start->sys;
timer->wall += stop->wall - start->wall;
}
/* Initialize timing variables. */
void
init_timevar ()
{
if (!TIMEVAR_ENABLE)
return;
/* Zero all elapsed times. */
memset ((void *) timevars, 0, sizeof (timevars));
/* Initialize the names of timing variables. */
#define DEFTIMEVAR(identifier__, name__) \
timevars[identifier__].name = name__;
#include "timevar.def"
#undef DEFTIMEVAR
#ifdef USE_TIMES
ticks_to_msec = TICKS_TO_MSEC;
#endif
#ifdef USE_CLOCK
clocks_to_msec = CLOCKS_TO_MSEC;
#endif
}
/* Push TIMEVAR onto the timing stack. No further elapsed time is
attributed to the previous topmost timing variable on the stack;
subsequent elapsed time is attributed to TIMEVAR, until it is
popped or another element is pushed on top.
TIMEVAR cannot be running as a standalone timer. */
void
timevar_push (timevar)
timevar_id_t timevar;
{
struct timevar_def *tv = &timevars[timevar];
struct timevar_stack_def *context;
struct timevar_time_def now;
if (!TIMEVAR_ENABLE)
return;
/* Mark this timing variable as used. */
tv->used = 1;
/* Can't push a standalone timer. */
if (tv->standalone)
abort ();
/* What time is it? */
get_time (&now);
/* If the stack isn't empty, attribute the current elapsed time to
the old topmost element. */
if (stack)
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
/* Reset the start time; from now on, time is attributed to
TIMEVAR. */
start_time = now;
/* See if we have a previously-allocated stack instance. If so,
take it off the list. If not, malloc a new one. */
if (unused_stack_instances != NULL)
{
context = unused_stack_instances;
unused_stack_instances = unused_stack_instances->next;
}
else
context = (struct timevar_stack_def *)
xmalloc (sizeof (struct timevar_stack_def));
/* Fill it in and put it on the stack. */
context->timevar = tv;
context->next = stack;
stack = context;
}
/* Pop the topmost timing variable element off the timing stack. The
popped variable must be TIMEVAR. Elapsed time since the that
element was pushed on, or since it was last exposed on top of the
stack when the element above it was popped off, is credited to that
timing variable. */
void
timevar_pop (timevar)
timevar_id_t timevar;
{
struct timevar_time_def now;
struct timevar_stack_def *popped = stack;
if (!TIMEVAR_ENABLE)
return;
if (&timevars[timevar] != stack->timevar)
abort ();
/* What time is it? */
get_time (&now);
/* Attribute the elapsed time to the element we're popping. */
timevar_accumulate (&popped->timevar->elapsed, &start_time, &now);
/* Reset the start time; from now on, time is attributed to the
element just exposed on the stack. */
start_time = now;
/* Take the item off the stack. */
stack = stack->next;
/* Don't delete the stack element; instead, add it to the list of
unused elements for later use. */
popped->next = unused_stack_instances;
unused_stack_instances = popped;
}
/* Start timing TIMEVAR independently of the timing stack. Elapsed
time until timevar_stop is called for the same timing variable is
attributed to TIMEVAR. */
void
timevar_start (timevar)
timevar_id_t timevar;
{
struct timevar_def *tv = &timevars[timevar];
if (!TIMEVAR_ENABLE)
return;
/* Mark this timing variable as used. */
tv->used = 1;
/* Don't allow the same timing variable to be started more than
once. */
if (tv->standalone)
abort ();
tv->standalone = 1;
get_time (&tv->start_time);
}
/* Stop timing TIMEVAR. Time elapsed since timevar_start was called
is attributed to it. */
void
timevar_stop (timevar)
timevar_id_t timevar;
{
struct timevar_def *tv = &timevars[timevar];
struct timevar_time_def now;
if (!TIMEVAR_ENABLE)
return;
/* TIMEVAR must have been started via timevar_start. */
if (!tv->standalone)
abort ();
get_time (&now);
timevar_accumulate (&tv->elapsed, &tv->start_time, &now);
}
/* Fill the elapsed time for TIMEVAR into ELAPSED. Returns
update-to-date information even if TIMEVAR is currently running. */
void
timevar_get (timevar, elapsed)
timevar_id_t timevar;
struct timevar_time_def *elapsed;
{
struct timevar_def *tv = &timevars[timevar];
struct timevar_time_def now;
*elapsed = tv->elapsed;
/* Is TIMEVAR currently running as a standalone timer? */
if (tv->standalone)
{
get_time (&now);
timevar_accumulate (elapsed, &tv->start_time, &now);
}
/* Or is TIMEVAR at the top of the timer stack? */
else if (stack->timevar == tv)
{
get_time (&now);
timevar_accumulate (elapsed, &start_time, &now);
}
}
/* Summarize timing variables to FP. The timing variable TV_TOTAL has
a special meaning -- it's considered to be the total elapsed time,
for normalizing the others, and is displayed last. */
void
timevar_print (fp)
FILE *fp;
{
/* Only print stuff if we have some sort of time information. */
#if defined HAVE_USER_TIME || defined HAVE_SYS_TIME || defined HAVE_WALL_TIME
unsigned /* timevar_id_t */ id;
struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed;
struct timevar_time_def now;
if (!TIMEVAR_ENABLE)
return;
/* Update timing information in case we're calling this from GDB. */
if (fp == 0)
fp = stderr;
/* What time is it? */
get_time (&now);
/* If the stack isn't empty, attribute the current elapsed time to
the old topmost element. */
if (stack)
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
/* Reset the start time; from now on, time is attributed to
TIMEVAR. */
start_time = now;
fputs (_("\nExecution times (seconds)\n"), fp);
for (id = 0; id < (unsigned) TIMEVAR_LAST; ++id)
{
struct timevar_def *tv = &timevars[(timevar_id_t) id];
const float tiny = 5e-3;
/* Don't print the total execution time here; that goes at the
end. */
if ((timevar_id_t) id == TV_TOTAL)
continue;
/* Don't print timing variables that were never used. */
if (!tv->used)
continue;
/* Don't print timing variables if we're going to get a row of
zeroes. */
if (tv->elapsed.user < tiny
&& tv->elapsed.sys < tiny
&& tv->elapsed.wall < tiny)
continue;
/* The timing variable name. */
fprintf (fp, " %-22s:", tv->name);
#ifdef HAVE_USER_TIME
/* Print user-mode time for this process. */
fprintf (fp, "%7.2f (%2.0f%%) usr",
tv->elapsed.user,
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
#endif /* HAVE_USER_TIME */
#ifdef HAVE_SYS_TIME
/* Print system-mode time for this process. */
fprintf (fp, "%7.2f (%2.0f%%) sys",
tv->elapsed.sys,
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
#endif /* HAVE_SYS_TIME */
#ifdef HAVE_WALL_TIME
/* Print wall clock time elapsed. */
fprintf (fp, "%7.2f (%2.0f%%) wall",
tv->elapsed.wall,
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
#endif /* HAVE_WALL_TIME */
putc ('\n', fp);
}
/* Print total time. */
fputs (_(" TOTAL :"), fp);
#ifdef HAVE_USER_TIME
fprintf (fp, "%7.2f ", total->user);
#endif
#ifdef HAVE_SYS_TIME
fprintf (fp, "%7.2f ", total->sys);
#endif
#ifdef HAVE_WALL_TIME
fprintf (fp, "%7.2f\n", total->wall);
#endif
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|| defined (HAVE_WALL_TIME) */
}
/* Returns time (user + system) used so far by the compiler process,
in microseconds. */
long
get_run_time ()
{
struct timevar_time_def total_elapsed;
timevar_get (TV_TOTAL, &total_elapsed);
return total_elapsed.user + total_elapsed.sys;
}
/* Prints a message to stderr stating that time elapsed in STR is
TOTAL (given in microseconds). */
void
print_time (str, total)
const char *str;
long total;
{
long all_time = get_run_time ();
fprintf (stderr,
_("time in %s: %ld.%06ld (%ld%%)\n"),
str, total / 1000000, total % 1000000,
all_time == 0 ? 0
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
}
+22 -22
View File
@@ -28,35 +28,35 @@
DEFTIMEVAR (id, name)
where ID is the enumeral value used to identify the timing
where ID is the enum value used to identify the timing
variable, and NAME is a character string describing its purpose. */
/* The total execution time. */
DEFTIMEVAR (TV_TOTAL , "total time")
DEFTIMEVAR (tv_total , "total time")
/* Time spent in the reader. */
DEFTIMEVAR (TV_READER , "reader")
DEFTIMEVAR (TV_SCANNING , "scanner")
DEFTIMEVAR (TV_PARSING , "parser")
DEFTIMEVAR (tv_reader , "reader")
DEFTIMEVAR (tv_scanning , "scanner")
DEFTIMEVAR (tv_parsing , "parser")
/* Time spent handling the grammar. */
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
DEFTIMEVAR (TV_SETS , "computing the sets")
DEFTIMEVAR (TV_LR0 , "LR(0)")
DEFTIMEVAR (TV_LALR , "LALR(1)")
DEFTIMEVAR (TV_IELR_PHASE1 , "IELR(1) Phase 1")
DEFTIMEVAR (TV_IELR_PHASE2 , "IELR(1) Phase 2")
DEFTIMEVAR (TV_IELR_PHASE3 , "IELR(1) Phase 3")
DEFTIMEVAR (TV_IELR_PHASE4 , "IELR(1) Phase 4")
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
DEFTIMEVAR (tv_reduce , "reducing the grammar")
DEFTIMEVAR (tv_sets , "computing the sets")
DEFTIMEVAR (tv_lr0 , "LR(0)")
DEFTIMEVAR (tv_lalr , "LALR(1)")
DEFTIMEVAR (tv_ielr_phase1 , "IELR(1) Phase 1")
DEFTIMEVAR (tv_ielr_phase2 , "IELR(1) Phase 2")
DEFTIMEVAR (tv_ielr_phase3 , "IELR(1) Phase 3")
DEFTIMEVAR (tv_ielr_phase4 , "IELR(1) Phase 4")
DEFTIMEVAR (tv_conflicts , "conflicts")
/* Time spent outputing results. */
DEFTIMEVAR (TV_REPORT , "outputing report")
DEFTIMEVAR (TV_GRAPH , "outputing graph")
DEFTIMEVAR (TV_XML , "outputing xml")
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
DEFTIMEVAR (TV_PARSER , "outputing parser")
DEFTIMEVAR (TV_M4 , "running m4")
/* Time spent outputting results. */
DEFTIMEVAR (tv_report , "outputting report")
DEFTIMEVAR (tv_graph , "outputting graph")
DEFTIMEVAR (tv_xml , "outputting xml")
DEFTIMEVAR (tv_actions , "parser action tables")
DEFTIMEVAR (tv_parser , "outputting parser")
DEFTIMEVAR (tv_m4 , "running m4")
/* Time spent by freeing the memory :). */
DEFTIMEVAR (TV_FREE , "freeing")
DEFTIMEVAR (tv_free , "freeing")
-92
View File
@@ -1,92 +0,0 @@
/* Timing variables for measuring compiler performance.
Copyright (C) 2000, 2002, 2004, 2009-2015, 2018 Free Software
Foundation, Inc.
Contributed by Alex Samuel <samuel@codesourcery.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef GCC_TIMEVAR_H
#define GCC_TIMEVAR_H
/* Timing variables are used to measure elapsed time in various
portions of the compiler. Each measures elapsed user, system, and
wall-clock time, as appropriate to and supported by the host
system.
Timing variables are defined using the DEFTIMEVAR macro in
timevar.def. Each has an enumeral identifier, used when referring
to the timing variable in code, and a character string name.
Timing variables can be used in two ways:
- On the timing stack, using timevar_push and timevar_pop.
Timing variables may be pushed onto the stack; elapsed time is
attributed to the topmost timing variable on the stack. When
another variable is pushed on, the previous topmost variable is
'paused' until the pushed variable is popped back off.
- As a standalone timer, using timevar_start and timevar_stop.
All time elapsed between the two calls is attributed to the
variable.
*/
/* This structure stores the various varieties of time that can be
measured. Times are stored in seconds. The time may be an
absolute time or a time difference; in the former case, the time
base is undefined, except that the difference between two times
produces a valid time difference. */
struct timevar_time_def
{
/* User time in this process. */
float user;
/* System time (if applicable for this host platform) in this
process. */
float sys;
/* Wall clock time. */
float wall;
};
/* An enumeration of timing variable identifiers. Constructed from
the contents of timevar.def. */
#define DEFTIMEVAR(identifier__, name__) \
identifier__,
typedef enum
{
#include "timevar.def"
TIMEVAR_LAST
}
timevar_id_t;
#undef DEFTIMEVAR
extern void init_timevar (void);
extern void timevar_push (timevar_id_t);
extern void timevar_pop (timevar_id_t);
extern void timevar_start (timevar_id_t);
extern void timevar_stop (timevar_id_t);
extern void timevar_get (timevar_id_t, struct timevar_time_def *);
extern void timevar_print (FILE *);
/* Provided for backward compatibility. */
extern long get_run_time (void);
extern void print_time (const char *, long);
extern int timevar_report;
#endif /* ! GCC_TIMEVAR_H */
+121 -236
View File
@@ -56,19 +56,14 @@ static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
static bitset_bindex
vbitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
if (n_bits == BITSET_NBITS_ (src))
return n_bits;
oldsize = VBITSET_SIZE (src);
newsize = VBITSET_N_WORDS (n_bits);
bitset_windex oldsize = VBITSET_SIZE (src);
bitset_windex newsize = VBITSET_N_WORDS (n_bits);
if (oldsize < newsize)
{
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
if (newsize > VBITSET_ASIZE (src))
@@ -78,6 +73,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
grow the bitset 25% larger than requested to reduce
number of reallocations. */
bitset_windex size;
if (oldsize == 0)
size = newsize;
else
@@ -115,9 +111,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
/* Set bit BITNO in bitset DST. */
static void
vbitset_set (dst, bitno)
bitset dst;
bitset_bindex bitno;
vbitset_set (bitset dst, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
@@ -134,9 +128,7 @@ vbitset_set (dst, bitno)
/* Reset bit BITNO in bitset DST. */
static void
vbitset_reset (dst, bitno)
bitset dst ATTRIBUTE_UNUSED;
bitset_bindex bitno ATTRIBUTE_UNUSED;
vbitset_reset (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* We must be accessing outside the cache so the bit is
zero anyway. */
@@ -145,9 +137,8 @@ vbitset_reset (dst, bitno)
/* Test bit BITNO in bitset SRC. */
static bool
vbitset_test (src, bitno)
bitset src ATTRIBUTE_UNUSED;
bitset_bindex bitno ATTRIBUTE_UNUSED;
vbitset_test (bitset src ATTRIBUTE_UNUSED,
bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* We must be accessing outside the cache so the bit is
zero anyway. */
@@ -160,22 +151,13 @@ vbitset_test (src, bitno)
actual number of bits found and with *NEXT indicating where search
stopped. */
static bitset_bindex
vbitset_list_reverse (src, list, num, next)
bitset src;
bitset_bindex *list;
bitset_bindex num;
bitset_bindex *next;
vbitset_list_reverse (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex rbitno;
bitset_bindex count;
bitset_windex windex;
unsigned bitcnt;
bitset_bindex bitoff;
bitset_word *srcp = VBITSET_WORDS (src);
bitset_bindex n_bits = BITSET_SIZE_ (src);
rbitno = *next;
bitset_bindex rbitno = *next;
/* If num is 1, we could speed things up with a binary search
of the word of interest. */
@@ -183,19 +165,17 @@ vbitset_list_reverse (src, list, num, next)
if (rbitno >= n_bits)
return 0;
count = 0;
bitset_bindex count = 0;
bitno = n_bits - (rbitno + 1);
bitset_bindex bitno = n_bits - (rbitno + 1);
windex = bitno / BITSET_WORD_BITS;
bitcnt = bitno % BITSET_WORD_BITS;
bitoff = windex * BITSET_WORD_BITS;
bitset_windex windex = bitno / BITSET_WORD_BITS;
unsigned bitcnt = bitno % BITSET_WORD_BITS;
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
do
{
bitset_word word;
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
for (; word; bitcnt--)
{
if (word & BITSET_MSB)
@@ -220,26 +200,21 @@ vbitset_list_reverse (src, list, num, next)
/* Find list of up to NUM bits set in BSET starting from and including
*NEXT and store in array LIST. Return with actual number of bits
found and with *NEXT indicating where search stopped. */
*NEXT and store in array LIST. Return with actual number of bits
found and with *NEXT indicating where search stopped. */
static bitset_bindex
vbitset_list (src, list, num, next)
bitset src;
bitset_bindex *list;
bitset_bindex num;
bitset_bindex *next;
vbitset_list (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
bitset_windex windex;
bitset_bindex bitoff;
bitset_windex size = VBITSET_SIZE (src);
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word word;
bitno = *next;
bitset_bindex bitno = *next;
count = 0;
bitset_bindex count = 0;
if (!bitno)
{
/* Many bitsets are zero, so make this common case fast. */
@@ -327,12 +302,9 @@ vbitset_list (src, list, num, next)
/* Ensure that any unused bits within the last word are clear. */
static inline void
vbitset_unused_clear (dst)
bitset dst;
vbitset_unused_clear (bitset dst)
{
unsigned last_bit;
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
if (last_bit)
VBITSET_WORDS (dst)[VBITSET_SIZE (dst) - 1] &=
((bitset_word) 1 << last_bit) - 1;
@@ -343,9 +315,7 @@ static void
vbitset_ones (bitset dst)
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned bytes;
bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
unsigned bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
memset (dstp, -1, bytes);
vbitset_unused_clear (dst);
@@ -356,9 +326,7 @@ static void
vbitset_zero (bitset dst)
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned bytes;
bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
unsigned bytes = sizeof (bitset_word) * VBITSET_SIZE (dst);
memset (dstp, 0, bytes);
}
@@ -367,10 +335,9 @@ vbitset_zero (bitset dst)
static bool
vbitset_empty_p (bitset dst)
{
unsigned i;
bitset_word *dstp = VBITSET_WORDS (dst);
for (i = 0; i < VBITSET_SIZE (dst); i++)
for (unsigned i = 0; i < VBITSET_SIZE (dst); i++)
if (dstp[i])
return 0;
@@ -381,20 +348,15 @@ vbitset_empty_p (bitset dst)
static void
vbitset_copy1 (bitset dst, bitset src)
{
bitset_word *srcp;
bitset_word *dstp;
bitset_windex ssize;
bitset_windex dsize;
if (src == dst)
return;
vbitset_resize (dst, BITSET_SIZE_ (src));
srcp = VBITSET_WORDS (src);
dstp = VBITSET_WORDS (dst);
ssize = VBITSET_SIZE (src);
dsize = VBITSET_SIZE (dst);
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex ssize = VBITSET_SIZE (src);
bitset_windex dsize = VBITSET_SIZE (dst);
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
@@ -406,21 +368,15 @@ vbitset_copy1 (bitset dst, bitset src)
static void
vbitset_not (bitset dst, bitset src)
{
unsigned i;
bitset_word *srcp;
bitset_word *dstp;
bitset_windex ssize;
bitset_windex dsize;
vbitset_resize (dst, BITSET_SIZE_ (src));
srcp = VBITSET_WORDS (src);
dstp = VBITSET_WORDS (dst);
ssize = VBITSET_SIZE (src);
dsize = VBITSET_SIZE (dst);
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex ssize = VBITSET_SIZE (src);
bitset_windex dsize = VBITSET_SIZE (dst);
for (i = 0; i < ssize; i++)
*dstp++ = ~(*srcp++);
for (unsigned i = 0; i < ssize; i++)
*dstp++ = ~(*srcp++);
vbitset_unused_clear (dst);
memset (dstp + sizeof (bitset_word) * ssize, 0,
@@ -431,15 +387,15 @@ vbitset_not (bitset dst, bitset src)
static bool
vbitset_equal_p (bitset dst, bitset src)
{
unsigned i;
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex ssize = VBITSET_SIZE (src);
bitset_windex dsize = VBITSET_SIZE (dst);
unsigned i;
for (i = 0; i < min (ssize, dsize); i++)
if (*srcp++ != *dstp++)
return 0;
if (*srcp++ != *dstp++)
return 0;
if (ssize > dsize)
{
@@ -461,15 +417,15 @@ vbitset_equal_p (bitset dst, bitset src)
static bool
vbitset_subset_p (bitset dst, bitset src)
{
unsigned i;
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex ssize = VBITSET_SIZE (src);
bitset_windex dsize = VBITSET_SIZE (dst);
unsigned i;
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return 0;
if (*dstp != (*srcp | *dstp))
return 0;
if (ssize > dsize)
{
@@ -485,15 +441,14 @@ vbitset_subset_p (bitset dst, bitset src)
static bool
vbitset_disjoint_p (bitset dst, bitset src)
{
unsigned i;
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex ssize = VBITSET_SIZE (src);
bitset_windex dsize = VBITSET_SIZE (dst);
for (i = 0; i < min (ssize, dsize); i++)
if (*srcp++ & *dstp++)
return 0;
for (unsigned i = 0; i < min (ssize, dsize); i++)
if (*srcp++ & *dstp++)
return 0;
return 1;
}
@@ -502,25 +457,17 @@ vbitset_disjoint_p (bitset dst, bitset src)
static void
vbitset_and (bitset dst, bitset src1, bitset src2)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ & *src2p++;
for (unsigned i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ & *src2p++;
memset (dstp, 0, sizeof (bitset_word) * (dsize - min (ssize1, ssize2)));
}
@@ -529,24 +476,17 @@ vbitset_and (bitset dst, bitset src1, bitset src2)
static bool
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned i;
int changed = 0;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ & *src2p++;
@@ -582,25 +522,18 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_andn (bitset dst, bitset src1, bitset src2)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ & ~(*src2p++);
*dstp++ = *src1p++ & ~(*src2p++);
if (ssize2 > ssize1)
{
@@ -622,24 +555,17 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
static bool
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned i;
int changed = 0;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ & ~(*src2p++);
@@ -687,25 +613,18 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_or (bitset dst, bitset src1, bitset src2)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ | *src2p++;
*dstp++ = *src1p++ | *src2p++;
if (ssize2 > ssize1)
{
@@ -723,24 +642,18 @@ vbitset_or (bitset dst, bitset src1, bitset src2)
static bool
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned i;
int changed = 0;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ | *src2p++;
@@ -778,25 +691,18 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_xor (bitset dst, bitset src1, bitset src2)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ ^ *src2p++;
*dstp++ = *src1p++ ^ *src2p++;
if (ssize2 > ssize1)
{
@@ -814,24 +720,17 @@ vbitset_xor (bitset dst, bitset src1, bitset src2)
static bool
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned i;
int changed = 0;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *dstp;
bitset_windex ssize1;
bitset_windex ssize2;
bitset_windex dsize;
vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
dsize = VBITSET_SIZE (dst);
ssize1 = VBITSET_SIZE (src1);
ssize2 = VBITSET_SIZE (src2);
dstp = VBITSET_WORDS (dst);
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
bitset_windex dsize = VBITSET_SIZE (dst);
bitset_windex ssize1 = VBITSET_SIZE (src1);
bitset_windex ssize2 = VBITSET_SIZE (src2);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
unsigned i;
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ ^ *src2p++;
@@ -872,7 +771,6 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *src3p;
@@ -894,15 +792,14 @@ vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
for (unsigned i = 0; i < size; i++)
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
}
static bool
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned i;
int changed = 0;
bitset_word *src1p;
bitset_word *src2p;
@@ -922,7 +819,7 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++, dstp++)
for (unsigned i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
@@ -939,7 +836,6 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *src3p;
@@ -961,15 +857,14 @@ vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
for (unsigned i = 0; i < size; i++)
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
}
static bool
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned i;
int changed = 0;
bitset_word *src1p;
bitset_word *src2p;
@@ -989,7 +884,7 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++, dstp++)
for (unsigned i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
@@ -1006,13 +901,6 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned i;
bitset_word *src1p;
bitset_word *src2p;
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
{
@@ -1022,14 +910,14 @@ vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_resize (dst, BITSET_NBITS_ (src1));
src1p = VBITSET_WORDS (src1);
src2p = VBITSET_WORDS (src2);
src3p = VBITSET_WORDS (src3);
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
bitset_word *src1p = VBITSET_WORDS (src1);
bitset_word *src2p = VBITSET_WORDS (src2);
bitset_word *src3p = VBITSET_WORDS (src3);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
for (unsigned i = 0; i < size; i++)
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
}
@@ -1119,17 +1007,14 @@ struct bitset_vtable vbitset_vtable = {
size_t
vbitset_bytes (n_bits)
bitset_bindex n_bits ATTRIBUTE_UNUSED;
vbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED)
{
return sizeof (struct vbitset_struct);
}
bitset
vbitset_init (bset, n_bits)
bitset bset;
bitset_bindex n_bits;
vbitset_init (bitset bset, bitset_bindex n_bits)
{
bset->b.vtable = &vbitset_vtable;
+2 -2
View File
@@ -23,8 +23,8 @@
#include "bitset.h"
extern size_t vbitset_bytes (bitset_bindex);
size_t vbitset_bytes (bitset_bindex);
extern bitset vbitset_init (bitset, bitset_bindex);
bitset vbitset_init (bitset, bitset_bindex);
#endif
+11
View File
@@ -179,3 +179,14 @@
/xstrndup.m4
/host-cpu-c-abi.m4
/stat-time.m4
/sys_time_h.m4
/sys_times_h.m4
/sh-filename.m4
/clock_time.m4
/gethrxtime.m4
/getrusage.m4
/gettime.m4
/gettimeofday.m4
/localtime-buffer.m4
/sys_resource_h.m4
/timespec.m4
+45
View File
@@ -0,0 +1,45 @@
# bison-check-compile-flag.m4
# serial 1
# Copyright (C) 2018 Free Software Foundation, # Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# BISON_CHECK_COMPILER_FLAG(FLAG,
# [ACTION-SUCCESS], [ACTION-FAILURE],
# [EXTRA-FLAGS])
# -------------------------------------------------------------
# Based on Autoconf Macro Archive's AX_CHECK_COMPILE_FLAG, but using
# AC_LINK_IFELSE, not just AC_COMPILE_IFELSE to capture failures such
# as:
#
# ./c++.at:401: $PREPARSER ./list
# stderr:
# ./list: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
#
# because we thought '-stdlib=c++' works, as it passes with AC_COMPILE_IFELSE.
#
# Not using AX_CHECK_LINK_FLAG, because its message is inappropriate:
#
# checking whether the linker accepts -std=c++11... yes
# checking whether the linker accepts -std=c++14... yes
# checking whether the linker accepts -std=c++17... no
AC_DEFUN([BISON_CHECK_COMPILER_FLAG],
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_LINK_IFELSE([m4_default([$5], [AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [$2], [$3])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl BISON_CHECK_COMPILER_FLAGS
+161
View File
@@ -0,0 +1,161 @@
# bison-cxx-std.m4 serial 1
# Copyright (C) 2018 Free Software Foundation, # Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
m4_define([_BISON_CXXSTD_98_snippet],
[#include <vector>
typedef std::vector<int> ints;
])
m4_define([_BISON_CXXSTD_03_snippet],
[])
m4_define([_BISON_CXXSTD_11_snippet],
[#include <algorithm>
#include <memory>
#include <set>
#include <sstream>
#include <string>
// C++11
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
using right_angle_brackets = check<check<bool>>;
auto f = std::make_shared<std::string>("shared_ptr");
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
// Some versions of libstdc++ do not support std::set::emplace.
void foo()
{
std::set<int> is;
is.emplace(42);
}
// Clang++ 3.5, for a while, was unable to process properly
// the for-loop because its variable, r, is a typedef...
// It failed as follows:
//
// error: unexpected ':' in nested name specifier; did you mean '::'?
// for (auto r: std::set<int>{1, 2})
// ^
// ::
using r = std::set<int>;
void bar()
{
for (int r: std::set<int>{1, 2})
continue;
}
])
m4_define([_BISON_CXXSTD_14_snippet],
[ // C++14
void mismatch()
{
using ints = std::vector<int>;
auto v1 = ints{1, 2, 3};
auto v2 = ints{1, 2};
std::mismatch(std::begin(v1), std::end(v1),
std::begin(v2), std::end(v2));
}
])
m4_define([_BISON_CXXSTD_17_snippet],
[ // C++17
namespace ns1::ns2::ns3 {}
#include <optional>
auto opt_string = std::optional<std::string>{};
auto out = std::ostringstream{};
])
m4_define([_BISON_CXXSTD_2A_snippet],
[ // C++2A
])
m4_define([_BISON_CXXSTD_testbody(98)],
[AC_LANG_PROGRAM([
_BISON_CXXSTD_98_snippet
])])
m4_define([_BISON_CXXSTD_testbody(03)],
[AC_LANG_PROGRAM([
_BISON_CXXSTD_98_snippet
_BISON_CXXSTD_03_snippet
])])
m4_define([_BISON_CXXSTD_testbody(11)],
[AC_LANG_PROGRAM([
_BISON_CXXSTD_98_snippet
_BISON_CXXSTD_03_snippet
_BISON_CXXSTD_11_snippet
])])
m4_define([_BISON_CXXSTD_testbody(14)],
[AC_LANG_PROGRAM([
_BISON_CXXSTD_98_snippet
_BISON_CXXSTD_03_snippet
_BISON_CXXSTD_11_snippet
_BISON_CXXSTD_14_snippet
])])
m4_define([_BISON_CXXSTD_testbody(17)],
[AC_LANG_PROGRAM([
_BISON_CXXSTD_98_snippet
_BISON_CXXSTD_03_snippet
_BISON_CXXSTD_11_snippet
_BISON_CXXSTD_14_snippet
_BISON_CXXSTD_17_snippet
])])
m4_define([_BISON_CXXSTD_testbody(2a)],
[AC_LANG_PROGRAM([
_BISON_CXXSTD_98_snippet
_BISON_CXXSTD_03_snippet
_BISON_CXXSTD_11_snippet
_BISON_CXXSTD_14_snippet
_BISON_CXXSTD_17_snippet
_BISON_CXXSTD_2A_snippet
])])
m4_define([_BISON_CXXSTD_testbody],
[m4_ifdef([$0($1)],
[m4_indir([$0($1)], m4_shift2($@))],
[m4_fatal([$0: unknown C++ standard: $1])])])
# BISON_CXXSTD(STD)
# -----------------
# Check whether the C++ compiler support STD (11, 98, 2a, etc.).
# If it does, AC_SUBST 'CXX<STD>_CXXFLAGS' to the corresponding flags.
AC_DEFUN([BISON_CXXSTD],
[AC_REQUIRE([AC_PROG_CXX])
AC_LANG_PUSH([C++])
for f in '-std=c++$1' '-std=c++$1 -stdlib=libc++'
do
BISON_CHECK_COMPILER_FLAG([$f],
[AC_SUBST(m4_toupper([CXX$1_CXXFLAGS]), [$f]) break],
[], [],
[_BISON_CXXSTD_testbody($1)])
done
AC_LANG_POP([C++])
])
-60
View File
@@ -1,60 +0,0 @@
# -*- Autoconf -*-
# Checks required to run `timevar', a time tracker.
#
# Copyright (C) 2002-2003, 2009-2015, 2018 Free Software Foundation,
# Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# serial 2
AC_DEFUN([BISON_PREREQ_TIMEVAR],
[AC_CHECK_HEADERS([sys/time.h sys/times.h])
AC_CHECK_HEADERS([sys/resource.h],,,
[$ac_includes_default
#if HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
])
AC_CHECK_FUNCS([times])
AC_CHECK_DECLS([getrusage, times, clock, sysconf], [], [],
[$ac_includes_default
#if HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#if HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
#if HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
])
AC_CHECK_TYPES([clock_t, struct tms], [], [],
[$ac_includes_default
#if HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#if HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
#if HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
])
])
+14 -26
View File
@@ -89,10 +89,6 @@ static item_number *kernel_items;
static void
allocate_itemsets (void)
{
symbol_number i;
rule_number r;
item_number *rhsp;
/* Count the number of occurrences of all the symbols in RITEMS.
Note that useless productions (hence useless nonterminals) are
browsed too, hence we need to allocate room for _all_ the
@@ -101,8 +97,8 @@ allocate_itemsets (void)
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
sizeof *symbol_count);
for (r = 0; r < nrules; ++r)
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
for (rule_number r = 0; r < nrules; ++r)
for (item_number *rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
{
count++;
symbol_count[*rhsp]++;
@@ -118,7 +114,7 @@ allocate_itemsets (void)
kernel_items = xnmalloc (count, sizeof *kernel_items);
count = 0;
for (i = 0; i < nsyms; i++)
for (symbol_number i = 0; i < nsyms; i++)
{
kernel_base[i] = kernel_items + count;
count += symbol_count[i];
@@ -174,8 +170,6 @@ free_storage (void)
static void
new_itemsets (state *s)
{
size_t i;
if (trace_flag & trace_automaton)
fprintf (stderr, "Entering new_itemsets, state = %d\n", s->number);
@@ -183,7 +177,7 @@ new_itemsets (state *s)
nshifts = 0;
for (i = 0; i < nitemset; ++i)
for (size_t i = 0; i < nitemset; ++i)
if (item_number_is_symbol_number (ritem[itemset[i]]))
{
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
@@ -209,13 +203,11 @@ new_itemsets (state *s)
static state *
get_state (symbol_number sym, size_t core_size, item_number *core)
{
state *s;
if (trace_flag & trace_automaton)
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
sym, symbols[sym]->tag);
s = state_hash_lookup (core_size, core);
state *s = state_hash_lookup (core_size, core);
if (!s)
s = state_list_append (sym, core_size, core);
@@ -235,25 +227,23 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
static void
append_states (state *s)
{
int i;
if (trace_flag & trace_automaton)
fprintf (stderr, "Entering append_states, state = %d\n", s->number);
/* First sort shift_symbol into increasing order. */
for (i = 1; i < nshifts; i++)
for (int i = 1; i < nshifts; i++)
{
symbol_number sym = shift_symbol[i];
int j;
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
const symbol_number sym = shift_symbol[i];
int j = i;
for (; 0 < j && sym < shift_symbol[j - 1]; j--)
shift_symbol[j] = shift_symbol[j - 1];
shift_symbol[j] = sym;
}
for (i = 0; i < nshifts; i++)
for (int i = 0; i < nshifts; i++)
{
symbol_number sym = shift_symbol[i];
const symbol_number sym = shift_symbol[i];
shiftset[i] = get_state (sym, kernel_size[sym], kernel_base[sym]);
}
}
@@ -269,10 +259,9 @@ static void
save_reductions (state *s)
{
int count = 0;
size_t i;
/* Find and count the active items that represent ends of rules. */
for (i = 0; i < nitemset; ++i)
for (size_t i = 0; i < nitemset; ++i)
{
item_number item = ritem[itemset[i]];
if (item_number_is_rule_number (item))
@@ -334,17 +323,16 @@ set_states (void)
void
generate_states (void)
{
item_number initial_core = 0;
state_list *list = NULL;
allocate_storage ();
new_closure (nritems);
/* Create the initial state. The 0 at the lhs is the index of the
item of this initial rule. */
item_number initial_core = 0;
state_list_append (0, 1, &initial_core);
/* States are queued when they are created; process them all. */
for (list = first_state; list; list = list->next)
for (state_list *list = first_state; list; list = list->next)
{
state *s = list->state;
if (trace_flag & trace_automaton)
+6 -11
View File
@@ -83,7 +83,7 @@ static const char * const warnings_args[] =
0
};
static const int warnings_types[] =
static const warnings warnings_types[] =
{
Wnone,
Wmidrule_values,
@@ -114,8 +114,7 @@ warning_argmatch (char const *arg, size_t no, size_t err)
no = !no;
}
size_t b;
for (b = 0; b < warnings_size; ++b)
for (size_t b = 0; b < warnings_size; ++b)
if (value & 1 << b)
{
if (err && no)
@@ -176,8 +175,7 @@ complain_init (void)
warnings warnings_default =
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
size_t b;
for (b = 0; b < warnings_size; ++b)
for (size_t b = 0; b < warnings_size; ++b)
{
warnings_flag[b] = (1 << b & warnings_default
? severity_warning
@@ -204,8 +202,7 @@ warning_severity (warnings flags)
{
/* Diagnostics about warnings. */
severity res = severity_disabled;
size_t b;
for (b = 0; b < warnings_size; ++b)
for (size_t b = 0; b < warnings_size; ++b)
if (flags & 1 << b)
{
res = res < warnings_flag[b] ? warnings_flag[b] : res;
@@ -225,8 +222,7 @@ warning_severity (warnings flags)
bool
warning_is_unset (warnings flags)
{
size_t b;
for (b = 0; b < warnings_size; ++b)
for (size_t b = 0; b < warnings_size; ++b)
if (flags & 1 << b && warnings_flag[b] != severity_unset)
return false;
return true;
@@ -238,8 +234,7 @@ static void
warnings_print_categories (warnings warn_flags, FILE *f)
{
/* Display only the first match, the second is "-Wall". */
size_t i;
for (i = 0; warnings_args[i]; ++i)
for (size_t i = 0; warnings_args[i]; ++i)
if (warn_flags & warnings_types[i])
{
severity s = warning_severity (warnings_types[i]);
+1 -1
View File
@@ -184,7 +184,7 @@ static void
compute_exts_from_src (const char *ext)
{
/* We use this function when the user specifies `-o' or `--output',
so the extenions must be computed unconditionally from the file name
so the extensions must be computed unconditionally from the file name
given by this option. */
src_extension = xstrdup (ext);
header_extension = xstrdup (ext);
+26 -14
View File
@@ -27,6 +27,32 @@
+ (YY_FLEX_MINOR_VERSION) * 1000 \
+ (YY_FLEX_SUBMINOR_VERSION))
// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC
// 6.4.0 and 7.3.0).
//
// ./src/scan-skel.c: In function 'skel_restart':
// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference]
// b->yy_fill_buffer = 1;
// ~~~~~~~~~~~~~~~~~~^~~
// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference]
// b->yy_input_file = file;
// ~~~~~~~~~~~~~~~~~^~~~~~
#if defined __GNUC__ && ! defined __clang__ && 6 <= __GNUC__
# pragma GCC diagnostic ignored "-Wnull-dereference"
#endif
// Old versions of Flex (2.5.35) generate an incomplete documentation comment.
//
// In file included from src/scan-code-c.c:3:
// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command
// [-Werror,-Wdocumentation]
// * @param line_number
// ~~~~~~~~~~~~~~~~~^
// 1 error generated.
#if FLEX_VERSION <= 20060000 && defined __clang__
# pragma clang diagnostic ignored "-Wdocumentation"
#endif
/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
#if FLEX_VERSION <= 2005031
int FLEX_PREFIX (get_lineno) (void);
@@ -44,20 +70,6 @@ int FLEX_PREFIX (lex_destroy) (void);
#define last_string FLEX_PREFIX (last_string)
// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC
// 7.3.0).
//
// ./src/scan-skel.c: In function 'skel_restart':
// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference]
// b->yy_fill_buffer = 1;
// ~~~~~~~~~~~~~~~~~~^~~
// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference]
// b->yy_input_file = file;
// ~~~~~~~~~~~~~~~~~^~~~~~
#if defined __GNUC__ && 7 <= __GNUC__
# pragma GCC diagnostic ignored "-Wnull-dereference"
#endif
/* It seems to be a nice "feature" of Flex that one cannot use yytext,
yyleng etc. when a prefix is given, since there is no longer a
#define, but rather the token is actually changed in the output.
+9 -6
View File
@@ -51,8 +51,9 @@ int report_flag = report_none;
int trace_flag = trace_none;
static struct bison_language const valid_languages[] = {
{ "c", "c-skel.m4", ".c", ".h", true },
{ "c++", "c++-skel.m4", ".cc", ".hh", true },
/* lang, skeleton, ext, hdr, add_tab */
{ "c", "c-skel.m4", ".c", ".h", true },
{ "c++", "c++-skel.m4", ".cc", ".hh", true },
{ "java", "java-skel.m4", ".java", ".java", false },
{ "", "", "", "", false }
};
@@ -127,7 +128,7 @@ flags_argmatch (const char *opt,
/** Decode a set of sub arguments.
*
* \param FlagName the flag familly to update.
* \param FlagName the flag family to update.
* \param Args the effective sub arguments to decode.
* \param All the "all" value.
*
@@ -360,6 +361,8 @@ FEATURE is a list of comma separated words that can include:\n\
fputs (_("General help using GNU software: "
"<http://www.gnu.org/gethelp/>.\n"),
stdout);
#if (defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__
/* Don't output this redundant message for English locales.
Note we still output for 'C' so that it gets included in the
man page. */
@@ -372,6 +375,7 @@ FEATURE is a list of comma separated words that can include:\n\
email address. */
fputs (_("Report translation bugs to "
"<http://translationproject.org/team/>.\n"), stdout);
#endif
fputs (_("For complete documentation, run: info bison.\n"), stdout);
}
@@ -429,8 +433,7 @@ language_argmatch (char const *arg, int prio, location loc)
if (prio < language_prio)
{
int i;
for (i = 0; valid_languages[i].language[0]; i++)
for (int i = 0; valid_languages[i].language[0]; ++i)
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
{
language_prio = prio;
@@ -721,7 +724,7 @@ getargs (int argc, char *argv[])
if (argc - optind != 1)
{
if (argc - optind < 1)
error (0, 0, _("%s: missing operand"), quotearg_colon (argv[argc - 1]));
error (0, 0, _("missing operand"));
else
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
+25 -39
View File
@@ -46,6 +46,8 @@ symbol_number *token_translations = NULL;
int max_user_token_number = 256;
int required_version = 0;
bool
rule_useful_in_grammar_p (rule const *r)
{
@@ -84,8 +86,7 @@ size_t
rule_rhs_length (rule const *r)
{
size_t res = 0;
item_number *rhsp;
for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
for (item_number *rhsp = r->rhs; *rhsp >= 0; ++rhsp)
++res;
return res;
}
@@ -94,11 +95,8 @@ void
rule_rhs_print (rule const *r, FILE *out)
{
if (0 <= *r->rhs)
{
item_number *rp;
for (rp = r->rhs; *rp >= 0; rp++)
fprintf (out, " %s", symbols[*rp]->tag);
}
for (item_number *rp = r->rhs; *rp >= 0; rp++)
fprintf (out, " %s", symbols[*rp]->tag);
else
fputs (" %empty", out);
}
@@ -108,9 +106,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
{
if (*r->rhs >= 0)
{
item_number *rp;
xml_puts (out, level, "<rhs>");
for (rp = r->rhs; *rp >= 0; rp++)
for (item_number *rp = r->rhs; *rp >= 0; rp++)
xml_printf (out, level + 1, "<symbol>%s</symbol>",
xml_escape (symbols[*rp]->tag));
xml_puts (out, level, "</rhs>");
@@ -126,9 +123,8 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level)
void
ritem_print (FILE *out)
{
unsigned i;
fputs ("RITEM\n", out);
for (i = 0; i < nritems; ++i)
for (unsigned i = 0; i < nritems; ++i)
if (ritem[i] >= 0)
fprintf (out, " %s", symbols[ritem[i]]->tag);
else
@@ -140,9 +136,7 @@ size_t
ritem_longest_rhs (void)
{
int max = 0;
rule_number r;
for (r = 0; r < nrules; ++r)
for (rule_number r = 0; r < nrules; ++r)
{
int length = rule_rhs_length (&rules[r]);
if (length > max)
@@ -156,12 +150,11 @@ void
grammar_rules_partial_print (FILE *out, const char *title,
rule_filter filter)
{
rule_number r;
bool first = true;
sym_content *previous_lhs = NULL;
/* rule # : LHS -> RHS */
for (r = 0; r < nrules + nuseless_productions; r++)
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
{
if (filter && !filter (&rules[r]))
continue;
@@ -188,10 +181,9 @@ grammar_rules_print (FILE *out)
void
grammar_rules_print_xml (FILE *out, int level)
{
rule_number r;
bool first = true;
for (r = 0; r < nrules + nuseless_productions; r++)
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
{
if (first)
xml_puts (out, level + 1, "<rules>");
@@ -233,10 +225,9 @@ grammar_dump (FILE *out, const char *title)
fprintf (out, "Variables\n---------\n\n");
{
symbol_number i;
fprintf (out, "Value Sprec Sassoc Tag\n");
for (i = ntokens; i < nsyms; i++)
for (symbol_number i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n",
i,
symbols[i]->content->prec, symbols[i]->content->assoc,
@@ -246,18 +237,16 @@ grammar_dump (FILE *out, const char *title)
fprintf (out, "Rules\n-----\n\n");
{
rule_number i;
fprintf (out,
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
" -> Rhs (Ritem range) [Num]\n");
for (i = 0; i < nrules + nuseless_productions; i++)
for (rule_number i = 0; i < nrules + nuseless_productions; i++)
{
rule const *rule_i = &rules[i];
item_number *rp = NULL;
unsigned rhs_itemno = rule_i->rhs - ritem;
unsigned rhs_count = 0;
unsigned const rhs_itemno = rule_i->rhs - ritem;
/* Find the last RHS index in ritems. */
for (rp = rule_i->rhs; *rp >= 0; ++rp)
unsigned rhs_count = 0;
for (item_number *rp = rule_i->rhs; *rp >= 0; ++rp)
++rhs_count;
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
i,
@@ -268,31 +257,28 @@ grammar_dump (FILE *out, const char *title)
rhs_itemno + rhs_count - 1,
rule_i->lhs->number);
/* Dumped the RHS. */
for (rp = rule_i->rhs; *rp >= 0; rp++)
for (item_number *rp = rule_i->rhs; *rp >= 0; ++rp)
fprintf (out, " %3d", *rp);
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
fprintf (out, " [%d]\n",
item_number_as_rule_number (rule_i->rhs[rhs_count+1]));
}
}
fprintf (out, "\n\n");
fprintf (out, "Rules interpreted\n-----------------\n\n");
{
rule_number r;
for (r = 0; r < nrules + nuseless_productions; r++)
{
fprintf (out, "%-5d %s:", r, rules[r].lhs->symbol->tag);
rule_rhs_print (&rules[r], out);
fprintf (out, "\n");
}
}
for (rule_number r = 0; r < nrules + nuseless_productions; r++)
{
fprintf (out, "%-5d %s:", r, rules[r].lhs->symbol->tag);
rule_rhs_print (&rules[r], out);
fprintf (out, "\n");
}
fprintf (out, "\n\n");
}
void
grammar_rules_useless_report (const char *message)
{
rule_number r;
for (r = 0; r < nrules ; ++r)
for (rule_number r = 0; r < nrules ; ++r)
/* Don't complain about rules whose LHS is useless, we already
complained about it. */
if (!reduce_nonterminal_useless_in_grammar (rules[r].lhs)
+4
View File
@@ -271,4 +271,8 @@ void grammar_rules_useless_report (const char *message);
/* Free the packed grammar. */
void grammar_free (void);
/* The version %required by the grammar file, as an int (100 * major +
minor). 0 if unspecified. */
extern int required_version;
#endif /* !GRAM_H_ */
+31 -36
View File
@@ -87,12 +87,14 @@ escape (char const *name)
static void
no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
{
int n;
*no_reduce_set = bitset_create (ntokens, BITSET_FIXED);
bitset_zero (*no_reduce_set);
FOR_EACH_SHIFT (s->transitions, n)
bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n));
for (n = 0; n < s->errs->num; ++n)
{
int n;
FOR_EACH_SHIFT (s->transitions, n)
bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n));
}
for (int n = 0; n < s->errs->num; ++n)
if (s->errs->symbols[n])
bitset_set (*no_reduce_set, s->errs->symbols[n]->content->number);
}
@@ -145,11 +147,9 @@ conclude_red (struct obstack *out, int source, rule_number ruleno,
static bool
print_token (struct obstack *out, bool first, char const *tok)
{
char const *q = escape (tok);
if (! first)
obstack_sgrow (out, ", ");
obstack_sgrow (out, q);
obstack_sgrow (out, escape (tok));
return false;
}
@@ -157,8 +157,7 @@ void
output_red (state const *s, reductions const *reds, FILE *fout)
{
bitset no_reduce_set;
int j;
int source = s->number;
no_reduce_bitset_init (s, &no_reduce_set);
/* Two obstacks are needed: one for the enabled reductions, and one
for the disabled reductions, because in the end we want two
@@ -166,42 +165,38 @@ output_red (state const *s, reductions const *reds, FILE *fout)
be printed. */
struct obstack dout;
struct obstack eout;
no_reduce_bitset_init (s, &no_reduce_set);
obstack_init (&dout);
obstack_init (&eout);
for (j = 0; j < reds->num; ++j)
const int source = s->number;
for (int j = 0; j < reds->num; ++j)
{
bool defaulted = false;
rule *default_reduction =
yydefact[s->number]
? &rules[yydefact[s->number] - 1]
: NULL;
bool defaulted = default_reduction && default_reduction == reds->rules[j];
/* Build the lookahead tokens lists, one for enabled transitions
and one for disabled transitions. */
bool firstd = true;
bool firste = true;
rule_number ruleno = reds->rules[j]->number;
rule *default_reduction = NULL;
if (yydefact[s->number] != 0)
default_reduction = &rules[yydefact[s->number] - 1];
/* Build the lookahead tokens lists, one for enabled transitions and one
for disabled transistions. */
if (default_reduction && default_reduction == reds->rules[j])
defaulted = true;
if (reds->lookahead_tokens)
{
int i;
for (i = 0; i < ntokens; i++)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (bitset_test (no_reduce_set, i))
firstd = print_token (&dout, firstd, symbols[i]->tag);
else
{
if (! defaulted)
firste = print_token (&eout, firste, symbols[i]->tag);
bitset_set (no_reduce_set, i);
}
}
}
for (int i = 0; i < ntokens; i++)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (bitset_test (no_reduce_set, i))
firstd = print_token (&dout, firstd, symbols[i]->tag);
else
{
if (! defaulted)
firste = print_token (&eout, firste, symbols[i]->tag);
bitset_set (no_reduce_set, i);
}
}
/* Do the actual output. */
conclude_red (&dout, source, ruleno, false, firstd, fout);
+14 -14
View File
@@ -929,7 +929,7 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows,
* compatibility or, if <tt>annotation_lists = NULL</tt>, the canonical
* LR(1) state compatibility test was used.
* - If <tt>annotation_lists = NULL</tt>, reduction lookahead sets were
* computed in all states. TV_IELR_PHASE4 was pushed while they were
* computed in all states. tv_ielr_phase4 was pushed while they were
* computed from item lookahead sets.
*/
static void
@@ -1004,7 +1004,7 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows,
lookahead sets. */
if (!annotation_lists)
{
timevar_push (TV_IELR_PHASE4);
timevar_push (tv_ielr_phase4);
initialize_LA ();
for (state_list *node = first_state; node; node = node->next)
if (!node->state->consistent)
@@ -1037,7 +1037,7 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows,
}
}
}
timevar_pop (TV_IELR_PHASE4);
timevar_pop (tv_ielr_phase4);
}
/* Free state list. */
@@ -1080,7 +1080,7 @@ ielr (void)
}
/* Phase 0: LALR(1). */
timevar_push (TV_LALR);
timevar_push (tv_lalr);
if (lr_type == LR_TYPE__CANONICAL_LR)
set_goto_map ();
else
@@ -1088,10 +1088,10 @@ ielr (void)
if (lr_type == LR_TYPE__LALR)
{
bitsetv_free (goto_follows);
timevar_pop (TV_LALR);
timevar_pop (tv_lalr);
return;
}
timevar_pop (TV_LALR);
timevar_pop (tv_lalr);
{
bitsetv follow_kernel_items;
@@ -1104,14 +1104,14 @@ ielr (void)
{
/* Phase 1: Compute Auxiliary Tables. */
state ***predecessors;
timevar_push (TV_IELR_PHASE1);
timevar_push (tv_ielr_phase1);
ielr_compute_auxiliary_tables (
&follow_kernel_items, &always_follows,
lr_type == LR_TYPE__CANONICAL_LR ? NULL : &predecessors);
timevar_pop (TV_IELR_PHASE1);
timevar_pop (tv_ielr_phase1);
/* Phase 2: Compute Annotations. */
timevar_push (TV_IELR_PHASE2);
timevar_push (tv_ielr_phase2);
if (lr_type != LR_TYPE__CANONICAL_LR)
{
obstack_init (&annotations_obstack);
@@ -1125,11 +1125,11 @@ ielr (void)
bitsetv_free (goto_follows);
lalr_free ();
}
timevar_pop (TV_IELR_PHASE2);
timevar_pop (tv_ielr_phase2);
}
/* Phase 3: Split States. */
timevar_push (TV_IELR_PHASE3);
timevar_push (tv_ielr_phase3);
{
state_number nstates_lr0 = nstates;
ielr_split_states (follow_kernel_items, always_follows,
@@ -1144,11 +1144,11 @@ ielr (void)
free (annotation_lists);
bitsetv_free (follow_kernel_items);
bitsetv_free (always_follows);
timevar_pop (TV_IELR_PHASE3);
timevar_pop (tv_ielr_phase3);
}
/* Phase 4: Compute Reduction Lookaheads. */
timevar_push (TV_IELR_PHASE4);
timevar_push (tv_ielr_phase4);
free (goto_map);
free (from_state);
free (to_state);
@@ -1163,5 +1163,5 @@ ielr (void)
lalr ();
bitsetv_free (goto_follows);
}
timevar_pop (TV_IELR_PHASE4);
timevar_pop (tv_ielr_phase4);
}
+10 -1
View File
@@ -13,7 +13,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
LDADD = lib/libbison.a $(LIBINTL)
LDADD = \
$(ISNAND_LIBM) \
$(ISNANF_LIBM) \
$(ISNANL_LIBM) \
$(LDEXPL_LIBM) \
$(LDEXP_LIBM) \
$(LIBINTL) \
$(LIBTHREAD) \
lib/libbison.a
bin_PROGRAMS = src/bison
# Prettify Automake-computed names of compiled objects.
@@ -116,6 +124,7 @@ bin_SCRIPTS = src/yacc
endif
EXTRA_SCRIPTS = src/yacc
MOSTLYCLEANFILES += src/yacc
CLEANDIRS += %D%/*.dSYM
src/yacc:
$(AM_V_GEN)rm -f $@ $@.tmp
+1 -1
View File
@@ -137,7 +137,7 @@ location_print (location loc, FILE *out)
}
/* Persistant data used by location_caret to avoid reopening and rereading the
/* Persistent data used by location_caret to avoid reopening and rereading the
same file all over for each error. */
struct caret_info
{
+1 -1
View File
@@ -107,7 +107,7 @@ void location_compute (location *loc,
Warning: uses quotearg's slot 3. */
unsigned location_print (location loc, FILE *out);
/* Free any allocated ressources and close any open file handles that are
/* Free any allocated resources and close any open file handles that are
left-over by the usage of location_caret. */
void cleanup_caret (void);
+28 -28
View File
@@ -80,9 +80,9 @@ main (int argc, char *argv[])
getargs (argc, argv);
timevar_report = trace_flag & trace_time;
init_timevar ();
timevar_start (TV_TOTAL);
timevar_enabled = trace_flag & trace_time;
timevar_init ();
timevar_start (tv_total);
if (trace_flag & trace_bitsets)
bitset_stats_enable ();
@@ -91,29 +91,29 @@ main (int argc, char *argv[])
and FATTRS. In file reader.c. The other parts are recorded in
the grammar; see gram.h. */
timevar_push (TV_READER);
timevar_push (tv_reader);
reader ();
timevar_pop (TV_READER);
timevar_pop (tv_reader);
if (complaint_status == status_complaint)
goto finish;
/* Find useless nonterminals and productions and reduce the grammar. */
timevar_push (TV_REDUCE);
timevar_push (tv_reduce);
reduce_grammar ();
timevar_pop (TV_REDUCE);
timevar_pop (tv_reduce);
/* Record other info about the grammar. In files derives and
nullable. */
timevar_push (TV_SETS);
timevar_push (tv_sets);
derives_compute ();
nullable_compute ();
timevar_pop (TV_SETS);
timevar_pop (tv_sets);
/* Compute LR(0) parser states. See state.h for more info. */
timevar_push (TV_LR0);
timevar_push (tv_lr0);
generate_states ();
timevar_pop (TV_LR0);
timevar_pop (tv_lr0);
/* Add lookahead sets to parser states. Except when LALR(1) is
requested, split states to eliminate LR(1)-relative
@@ -124,7 +124,7 @@ main (int argc, char *argv[])
lookahead is not enough to disambiguate the parsing. In file
conflicts. Also resolve s/r conflicts based on precedence
declarations. */
timevar_push (TV_CONFLICTS);
timevar_push (tv_conflicts);
conflicts_solve ();
if (!muscle_percent_define_flag_if ("lr.keep-unreachable-state"))
{
@@ -136,12 +136,12 @@ main (int argc, char *argv[])
free (old_to_new);
}
conflicts_print ();
timevar_pop (TV_CONFLICTS);
timevar_pop (tv_conflicts);
/* Compute the parser tables. */
timevar_push (TV_ACTIONS);
timevar_push (tv_actions);
tables_generate ();
timevar_pop (TV_ACTIONS);
timevar_pop (tv_actions);
grammar_rules_useless_report (_("rule useless in parser due to conflicts"));
@@ -153,25 +153,25 @@ main (int argc, char *argv[])
/* Output the detailed report on the grammar. */
if (report_flag)
{
timevar_push (TV_REPORT);
timevar_push (tv_report);
print_results ();
timevar_pop (TV_REPORT);
timevar_pop (tv_report);
}
/* Output the graph. */
if (graph_flag)
{
timevar_push (TV_GRAPH);
timevar_push (tv_graph);
print_graph ();
timevar_pop (TV_GRAPH);
timevar_pop (tv_graph);
}
/* Output xml. */
if (xml_flag)
{
timevar_push (TV_XML);
timevar_push (tv_xml);
print_xml ();
timevar_pop (TV_XML);
timevar_pop (tv_xml);
}
/* Stop if there were errors, to avoid trashing previous output
@@ -180,16 +180,16 @@ main (int argc, char *argv[])
goto finish;
/* Lookahead tokens are no longer needed. */
timevar_push (TV_FREE);
timevar_push (tv_free);
lalr_free ();
timevar_pop (TV_FREE);
timevar_pop (tv_free);
/* Output the tables and the parser to ftable. In file output. */
timevar_push (TV_PARSER);
timevar_push (tv_parser);
output ();
timevar_pop (TV_PARSER);
timevar_pop (tv_parser);
timevar_push (TV_FREE);
timevar_push (tv_free);
nullable_free ();
derives_free ();
tables_free ();
@@ -207,7 +207,7 @@ main (int argc, char *argv[])
code_scanner_free ();
skel_scanner_free ();
quotearg_free ();
timevar_pop (TV_FREE);
timevar_pop (tv_free);
if (trace_flag & trace_bitsets)
bitset_stats_dump (stderr);
@@ -215,7 +215,7 @@ main (int argc, char *argv[])
finish:
/* Stop timing and print the times. */
timevar_stop (TV_TOTAL);
timevar_stop (tv_total);
timevar_print (stderr);
cleanup_caret ();
+57 -73
View File
@@ -175,9 +175,6 @@ muscle_grow (const char *key, const char *val,
const char *separator, const char *terminator)
{
muscle_entry *entry = muscle_lookup (key);
size_t vals = strlen (val);
size_t terms = strlen (terminator);
if (entry)
{
obstack_sgrow (&muscle_obstack, entry->value);
@@ -189,12 +186,14 @@ muscle_grow (const char *key, const char *val,
obstack_sgrow (&muscle_obstack, val);
size_t vals = strlen (val);
size_t terms = strlen (terminator);
if (terms <= vals
&& STRNEQ (val + vals - terms, terminator))
obstack_sgrow (&muscle_obstack, terminator);
{
char *new_val = obstack_finish0 (&muscle_obstack);
char const *new_val = obstack_finish0 (&muscle_obstack);
entry->value = entry->storage = xstrdup (new_val);
obstack_free (&muscle_obstack, new_val);
}
@@ -208,12 +207,11 @@ muscle_grow (const char *key, const char *val,
static void
muscle_syncline_grow (char const *key, location loc)
{
char *extension = NULL;
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
obstack_quote (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, ")[");
extension = obstack_finish0 (&muscle_obstack);
char const *extension = obstack_finish0 (&muscle_obstack);
muscle_grow (key, extension, "", "");
obstack_free (&muscle_obstack, extension);
}
@@ -236,13 +234,12 @@ void
muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2)
{
char *pair;
obstack_sgrow (&muscle_obstack, "[");
obstack_quote (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, ", ");
obstack_quote (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]");
pair = obstack_finish0 (&muscle_obstack);
char const *pair = obstack_finish0 (&muscle_obstack);
muscle_grow (muscle, pair, ",\n", "");
obstack_free (&muscle_obstack, pair);
}
@@ -275,11 +272,10 @@ muscle_find (char const *key)
static void
muscle_boundary_grow (char const *key, boundary bound)
{
char *extension;
obstack_sgrow (&muscle_obstack, "[[");
obstack_escape (&muscle_obstack, bound.file);
obstack_printf (&muscle_obstack, ":%d.%d]]", bound.line, bound.column);
extension = obstack_finish0 (&muscle_obstack);
char const *extension = obstack_finish0 (&muscle_obstack);
muscle_grow (key, extension, "", "");
obstack_free (&muscle_obstack, extension);
}
@@ -322,9 +318,6 @@ static char *
string_decode (char const *key)
{
char const *value = muscle_find_const (key);
char *value_decoded;
char *result;
if (!value)
return NULL;
do {
@@ -337,20 +330,20 @@ string_decode (char const *key)
break;
}
} while (*value++);
value_decoded = obstack_finish (&muscle_obstack);
result = xstrdup (value_decoded);
char const *value_decoded = obstack_finish (&muscle_obstack);
char *res = xstrdup (value_decoded);
obstack_free (&muscle_obstack, value_decoded);
return result;
return res;
}
/* Reverse of muscle_location_grow. */
static location
location_decode (char const *value)
{
location loc;
aver (value);
aver (*value == '[');
++value; aver (*value == '[');
location loc;
while (*++value)
switch (*value)
{
@@ -359,29 +352,26 @@ location_decode (char const *value)
aver (false);
break;
case ']':
{
char *boundary_str;
++value; aver (*value == ']');
boundary_str = obstack_finish0 (&muscle_obstack);
switch (*++value)
{
case ',':
boundary_set_from_string (&loc.start, boundary_str);
obstack_free (&muscle_obstack, boundary_str);
++value; aver (*value == ' ');
++value; aver (*value == '[');
++value; aver (*value == '[');
break;
case '\0':
boundary_set_from_string (&loc.end, boundary_str);
obstack_free (&muscle_obstack, boundary_str);
return loc;
break;
default:
aver (false);
break;
}
}
++value; aver (*value == ']');
char *boundary_str = obstack_finish0 (&muscle_obstack);
switch (*++value)
{
case ',':
boundary_set_from_string (&loc.start, boundary_str);
obstack_free (&muscle_obstack, boundary_str);
++value; aver (*value == ' ');
++value; aver (*value == '[');
++value; aver (*value == '[');
break;
case '\0':
boundary_set_from_string (&loc.end, boundary_str);
obstack_free (&muscle_obstack, boundary_str);
return loc;
break;
default:
aver (false);
break;
}
break;
}
aver (false);
@@ -446,21 +436,21 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
} conversion_type;
const conversion_type conversion[] =
{
{ "api.push_pull", "api.push-pull", },
{ "api.tokens.prefix", "api.token.prefix", },
{ "lex_symbol", "api.token.constructor", },
{ "location_type", "api.location.type", },
{ "lr.default-reductions", "lr.default-reduction", },
{ "api.push_pull", "api.push-pull", },
{ "api.tokens.prefix", "api.token.prefix", },
{ "lex_symbol", "api.token.constructor", },
{ "location_type", "api.location.type", },
{ "lr.default-reductions", "lr.default-reduction", },
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
{ "namespace", "api.namespace", },
{ "stype", "api.value.type", },
{ "variant=", "api.value.type=variant", },
{ "variant=true", "api.value.type=variant", },
{ "namespace", "api.namespace", },
{ "stype", "api.value.type", },
{ "variant=", "api.value.type=variant", },
{ "variant=true", "api.value.type=variant", },
{ NULL, NULL, }
};
conversion_type const *c;
for (c = conversion; c->obsolete; ++c)
for (conversion_type const *c = conversion; c->obsolete; ++c)
{
char const *eq = strchr (c->obsolete, '=');
if (eq
@@ -474,14 +464,12 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
free (old);
free (upd);
char *res = xstrdup (c->updated);
{
char *eq2 = strchr (res, '=');
if (eq2)
{
*eq2 = '\0';
*value = eq2 + 1;
}
}
char *eq2 = strchr (res, '=');
if (eq2)
{
*eq2 = '\0';
*value = eq2 + 1;
}
return res;
}
}
@@ -507,9 +495,9 @@ muscle_percent_define_insert (char const *var, location variable_loc,
&& muscle_find_const (name))
{
muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
unsigned i = 0;
if (how_old == MUSCLE_PERCENT_DEFINE_F)
goto end;
unsigned i = 0;
complain_indent (&variable_loc, complaint, &i,
_("%%define variable %s redefined"),
quote (variable));
@@ -645,16 +633,16 @@ bool
muscle_percent_define_flag_if (char const *variable)
{
uniqstr invalid_boolean_name = muscle_name (variable, "invalid_boolean");
bool result = false;
bool res = false;
if (muscle_percent_define_ifdef (variable))
{
char *value = muscle_percent_define_get (variable);
muscle_percent_define_check_kind (variable, muscle_keyword);
if (value[0] == '\0' || STREQ (value, "true"))
result = true;
res = true;
else if (STREQ (value, "false"))
result = false;
res = false;
else if (!muscle_find_const (invalid_boolean_name))
{
muscle_insert (invalid_boolean_name, "");
@@ -669,7 +657,7 @@ muscle_percent_define_flag_if (char const *variable)
complain (NULL, fatal, _("%s: undefined %%define variable %s"),
"muscle_percent_define_flag", quote (variable));
return result;
return res;
}
void
@@ -705,14 +693,12 @@ muscle_percent_define_check_values (char const * const *values)
if (value)
{
for (++values; *values; ++values)
{
if (STREQ (value, *values))
break;
}
if (STREQ (value, *values))
break;
if (!*values)
{
unsigned i = 0;
location loc = muscle_percent_define_get_loc (*variablep);
unsigned i = 0;
complain_indent (&loc, complaint, &i,
_("invalid value for %%define variable %s: %s"),
quote (*variablep), quote_n (1, value));
@@ -722,10 +708,8 @@ muscle_percent_define_check_values (char const * const *values)
_("accepted value: %s"), quote (*values));
}
else
{
while (*values)
++values;
}
while (*values)
++values;
free (value);
}
else
+1 -1
View File
@@ -158,7 +158,7 @@ char *muscle_percent_define_get (char const *variable);
/* Mimic muscle_percent_define_get_loc in ../data/bison.m4 exactly. That is,
if the %define variable VARIABLE is undefined, complain fatally since that's
a Bison error. Otherwise, return its definition location in a form
approriate for the first argument of warn_at, complain_at, or fatal_at.
appropriate for the first argument of warn_at, complain_at, or fatal_at.
Don't record this as a Bison usage of VARIABLE as there's no reason to
suspect that the user-supplied value has yet influenced the output. */
location muscle_percent_define_get_loc (char const *variable);
+9 -7
View File
@@ -21,10 +21,10 @@
#include <config.h>
#include "system.h"
#include <concat-filename.h>
#include <configmake.h>
#include <filename.h>
#include <filename.h> /* IS_PATH_WITH_DIR */
#include <get-errno.h>
#include <path-join.h>
#include <quotearg.h>
#include <spawn-pipe.h>
#include <timevar.h>
@@ -531,11 +531,11 @@ output_skeleton (void)
/* Compute the names of the package data dir and skeleton files. */
char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
char const *datadir = pkgdatadir ();
char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4");
char *m4bison = xpath_join (datadir, "bison.m4");
char *skel = (IS_PATH_WITH_DIR (skeleton)
? xstrdup (skeleton)
: xconcatenated_filename (datadir, skeleton, NULL));
: xpath_join (datadir, skeleton));
/* Test whether m4sugar.m4 is readable, to check for proper
installation. A faulty installation can cause deadlock, so a
@@ -603,7 +603,7 @@ output_skeleton (void)
}
/* Read and process m4's output. */
timevar_push (TV_M4);
timevar_push (tv_m4);
{
FILE *in = xfdopen (filter_fd[0], "r");
scan_skel (in);
@@ -614,7 +614,7 @@ output_skeleton (void)
xfclose (in);
}
wait_subprocess (pid, "m4", false, false, true, true, NULL);
timevar_pop (TV_M4);
timevar_pop (tv_m4);
}
static void
@@ -625,6 +625,8 @@ prepare (void)
char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
MUSCLE_INSERT_INT ("required_version", required_version);
/* Flags. */
MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
+299 -267
View File
File diff suppressed because it is too large Load Diff
+14 -14
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.0.5.75-d835. */
/* A Bison parser, made by GNU Bison 3.1.222-4227c. */
/* Bison interface for Yacc-like parsers in C
@@ -52,7 +52,7 @@ extern int gram_debug;
#include "symlist.h"
#include "symtab.h"
#line 221 "src/parse-gram.y" /* yacc.c:1913 */
#line 222 "src/parse-gram.y" /* yacc.c:1913 */
typedef enum
{
@@ -61,7 +61,7 @@ extern int gram_debug;
param_parse = 1 << 1,
param_both = param_lex | param_parse
} param_type;
#line 644 "src/parse-gram.y" /* yacc.c:1913 */
#line 645 "src/parse-gram.y" /* yacc.c:1913 */
#include "muscle-tab.h"
#line 68 "src/parse-gram.h" /* yacc.c:1913 */
@@ -135,27 +135,27 @@ extern int gram_debug;
union GRAM_STYPE
{
#line 182 "src/parse-gram.y" /* yacc.c:1913 */
#line 183 "src/parse-gram.y" /* yacc.c:1913 */
unsigned char character;
#line 186 "src/parse-gram.y" /* yacc.c:1913 */
#line 187 "src/parse-gram.y" /* yacc.c:1913 */
char *code;
#line 191 "src/parse-gram.y" /* yacc.c:1913 */
#line 192 "src/parse-gram.y" /* yacc.c:1913 */
uniqstr uniqstr;
#line 199 "src/parse-gram.y" /* yacc.c:1913 */
#line 200 "src/parse-gram.y" /* yacc.c:1913 */
int integer;
#line 203 "src/parse-gram.y" /* yacc.c:1913 */
#line 204 "src/parse-gram.y" /* yacc.c:1913 */
symbol *symbol;
#line 208 "src/parse-gram.y" /* yacc.c:1913 */
#line 209 "src/parse-gram.y" /* yacc.c:1913 */
assoc assoc;
#line 211 "src/parse-gram.y" /* yacc.c:1913 */
#line 212 "src/parse-gram.y" /* yacc.c:1913 */
symbol_list *list;
#line 214 "src/parse-gram.y" /* yacc.c:1913 */
#line 215 "src/parse-gram.y" /* yacc.c:1913 */
named_ref *named_ref;
#line 241 "src/parse-gram.y" /* yacc.c:1913 */
#line 242 "src/parse-gram.y" /* yacc.c:1913 */
param_type param;
#line 408 "src/parse-gram.y" /* yacc.c:1913 */
#line 409 "src/parse-gram.y" /* yacc.c:1913 */
code_props_type code_type;
#line 646 "src/parse-gram.y" /* yacc.c:1913 */
#line 647 "src/parse-gram.y" /* yacc.c:1913 */
struct
{
+31 -3
View File
@@ -32,6 +32,7 @@
%code
{
#include "system.h"
#include <errno.h>
#include "c-ctype.h"
#include "complain.h"
@@ -822,10 +823,37 @@ add_param (param_type type, char *decl, location loc)
static void
version_check (location const *loc, char const *version)
{
if (strverscmp (version, PACKAGE_VERSION) > 0)
/* Changes of behavior are only on minor version changes, so "3.0.5"
is the same as "3.0". */
errno = 0;
char* cp = NULL;
unsigned long major = strtoul (version, &cp, 10);
if (errno || *cp != '.')
{
complain (loc, complaint, "require bison %s, but have %s",
version, PACKAGE_VERSION);
complain (loc, complaint, _("invalid version requirement: %s"),
version);
return;
}
++cp;
unsigned long minor = strtoul (cp, NULL, 10);
if (errno)
{
complain (loc, complaint, _("invalid version requirement: %s"),
version);
return;
}
required_version = major * 100 + minor;
/* Pretend to be at least 3.2, even if we are only 3.1-211, as it
allows us to check features published in 3.2 while developping
3.2. */
const char* api_version = "3.2";
const char* package_version =
strverscmp (api_version, PACKAGE_VERSION) > 0
? api_version : PACKAGE_VERSION;
if (strverscmp (version, package_version) > 0)
{
complain (loc, complaint, _("require bison %s, but have %s"),
version, package_version);
exit (EX_MISMATCH);
}
}
+6 -10
View File
@@ -48,7 +48,6 @@ print_core (struct obstack *oout, state *s)
{
item_number const *sitems = s->items;
sym_content *previous_lhs = NULL;
size_t i;
size_t snritems = s->nitems;
/* Output all the items of a state, not just its kernel. */
@@ -61,16 +60,15 @@ print_core (struct obstack *oout, state *s)
obstack_printf (oout, _("State %d"), s->number);
obstack_sgrow (oout, "\\n\\l");
for (i = 0; i < snritems; i++)
for (size_t i = 0; i < snritems; ++i)
{
item_number const *sp1 = ritem + sitems[i];
item_number const *sp = sp1;
rule *r;
while (0 <= *sp)
sp++;
r = &rules[item_number_as_rule_number (*sp)];
rule *r = &rules[item_number_as_rule_number (*sp)];
obstack_printf (oout, "%3d ", r->number);
if (previous_lhs && UNIQSTR_EQ (previous_lhs->symbol->tag,
@@ -130,16 +128,15 @@ static void
print_actions (state const *s, FILE *fgraph)
{
transitions const *trans = s->transitions;
int i;
if (!trans->num && !s->reductions)
return;
for (i = 0; i < trans->num; i++)
for (int i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i))
{
state *s1 = trans->states[i];
symbol_number sym = s1->accessing_symbol;
const state *s1 = trans->states[i];
const symbol_number sym = s1->accessing_symbol;
/* Shifts are solid, gotos are dashed, and error is dotted. */
char const *style =
@@ -183,13 +180,12 @@ print_state (state *s, FILE *fgraph)
void
print_graph (void)
{
state_number i;
FILE *fgraph = xfopen (spec_graph_file, "w");
start_graph (fgraph);
/* Output nodes and edges. */
new_closure (nritems);
for (i = 0; i < nstates; i++)
for (int i = 0; i < nstates; i++)
print_state (states[i], fgraph);
free_closure ();
+71 -50
View File
@@ -253,8 +253,8 @@ grammar_current_rule_begin (symbol *lhs, location loc,
/*----------------------------------------------------------------------.
| A symbol should be used if either: |
| 1. It has a destructor. |
| 2. The symbol is a mid-rule symbol (i.e., the generated LHS |
| replacing a mid-rule action) that was assigned to or used, as in |
| 2. The symbol is a midrule symbol (i.e., the generated LHS |
| replacing a midrule action) that was assigned to or used, as in |
| "exp: { $$ = 1; } { $$ = $1; }". |
`----------------------------------------------------------------------*/
@@ -275,13 +275,14 @@ symbol_should_be_used (symbol_list const *s, bool *midrule_warning)
return false;
}
/*----------------------------------------------------------------.
| Check that the rule R is properly defined. For instance, there |
| should be no type clash on the default action. |
`----------------------------------------------------------------*/
/*-----------------------------------------------------------------.
| Check that the rule R is properly defined. For instance, there |
| should be no type clash on the default action. Possibly install |
| the default action. |
`-----------------------------------------------------------------*/
static void
grammar_rule_check (const symbol_list *r)
grammar_rule_check_and_complete (symbol_list *r)
{
/* Type check.
@@ -303,6 +304,23 @@ grammar_rule_check (const symbol_list *r)
complain (&r->location, Wother,
_("type clash on default action: <%s> != <%s>"),
lhs_type, rhs_type);
else
{
/* Install the default action only for C++. */
bool is_cxx =
skeleton
? STREQ (skeleton, "glr.cc") || STREQ (skeleton, "lalr1.cc")
: STREQ (language->language, "c++");
if (is_cxx)
{
code_props_rule_action_init (&r->action_props, "{ $$ = $1; }",
r->location, r,
/* name */ NULL,
/* type */ NULL,
/* is_predicate */ false);
code_props_translate_code (&r->action_props);
}
}
}
/* Warn if there is no default for $$ but we need one. */
else
@@ -373,9 +391,9 @@ grammar_current_rule_end (location loc)
/*-------------------------------------------------------------------.
| The previous action turns out to be a mid-rule action. Attach it |
| The previous action turns out to be a midrule action. Attach it |
| to the current rule, i.e., create a dummy symbol, attach it this |
| mid-rule action, and append this dummy nonterminal to the current |
| midrule action, and append this dummy nonterminal to the current |
| rule. |
`-------------------------------------------------------------------*/
@@ -439,14 +457,14 @@ grammar_current_rule_prec_set (symbol *precsym, location loc)
{
/* POSIX says that any identifier is a nonterminal if it does not
appear on the LHS of a grammar rule and is not defined by %token
or by one of the directives that assigns precedence to a token. We
ignore this here because the only kind of identifier that POSIX
allows to follow a %prec is a token and because assuming it's a
token now can produce more logical error messages. Nevertheless,
grammar_rule_check does obey what we believe is the real intent of
POSIX here: that an error be reported for any identifier that
appears after %prec but that is not defined separately as a
token. */
or by one of the directives that assigns precedence to a token.
We ignore this here because the only kind of identifier that
POSIX allows to follow a %prec is a token and because assuming
it's a token now can produce more logical error messages.
Nevertheless, grammar_rule_check_and_complete does obey what we
believe is the real intent of POSIX here: that an error be
reported for any identifier that appears after %prec but that is
not defined separately as a token. */
symbol_class_set (precsym, token_sym, loc, false);
if (current_rule->ruleprec)
duplicate_directive ("%prec",
@@ -512,7 +530,7 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
}
/* Attach SYM to the current rule. If needed, move the previous
action as a mid-rule action. */
action as a midrule action. */
void
grammar_current_rule_symbol_append (symbol *sym, location loc,
@@ -576,39 +594,40 @@ packgram (void)
for (symbol_list *p = grammar; p; p = p->next)
{
symbol *ruleprec = p->ruleprec;
record_merge_function_type (p->merger, p->content.sym->content->type_name,
p->merger_declaration_location);
rules[ruleno].user_number = ruleno;
rules[ruleno].number = ruleno;
rules[ruleno].lhs = p->content.sym->content;
rules[ruleno].rhs = ritem + itemno;
rules[ruleno].prec = NULL;
rules[ruleno].dprec = p->dprec;
rules[ruleno].merger = p->merger;
rules[ruleno].precsym = NULL;
rules[ruleno].location = p->location;
rules[ruleno].useful = true;
rules[ruleno].action = p->action_props.code;
rules[ruleno].action_location = p->action_props.location;
rules[ruleno].is_predicate = p->action_props.is_predicate;
symbol_list *lhs = p;
record_merge_function_type (lhs->merger, lhs->content.sym->content->type_name,
lhs->merger_declaration_location);
/* 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. */
if (p->midrule_parent_rule
&& (p->action_props.is_value_used
|| (symbol_list_n_get (p->midrule_parent_rule,
p->midrule_parent_rhs_index)
if (lhs->midrule_parent_rule
&& (lhs->action_props.is_value_used
|| (symbol_list_n_get (lhs->midrule_parent_rule,
lhs->midrule_parent_rhs_index)
->action_props.is_value_used)))
p->content.sym->tag += 1;
lhs->content.sym->tag += 1;
/* Don't check the generated rule 0. It has no action, so some rhs
symbols may appear unused, but the parsing algorithm ensures that
%destructor's are invoked appropriately. */
if (p != grammar)
grammar_rule_check (p);
grammar_rule_check_and_complete (p);
rules[ruleno].user_number = ruleno;
rules[ruleno].number = ruleno;
rules[ruleno].lhs = lhs->content.sym->content;
rules[ruleno].rhs = ritem + itemno;
rules[ruleno].prec = NULL;
rules[ruleno].dprec = lhs->dprec;
rules[ruleno].merger = lhs->merger;
rules[ruleno].precsym = NULL;
rules[ruleno].location = lhs->location;
rules[ruleno].useful = true;
rules[ruleno].action = lhs->action_props.code;
rules[ruleno].action_location = lhs->action_props.location;
rules[ruleno].is_predicate = lhs->action_props.is_predicate;
/* Traverse the rhs. */
{
size_t rule_length = 0;
for (p = p->next; p->content.sym; p = p->next)
@@ -633,11 +652,12 @@ packgram (void)
/* If this rule has a %prec,
the specified symbol's precedence replaces the default. */
if (ruleprec)
if (lhs->ruleprec)
{
rules[ruleno].precsym = ruleprec->content;
rules[ruleno].prec = ruleprec->content;
rules[ruleno].precsym = lhs->ruleprec->content;
rules[ruleno].prec = lhs->ruleprec->content;
}
/* An item ends by the rule number (negated). */
ritem[itemno++] = rule_number_as_item_number (ruleno);
aver (itemno < ITEM_NUMBER_MAX);
@@ -797,12 +817,13 @@ check_and_convert_grammar (void)
symbols_pack above) so that token types are set correctly before the rule
action type checking.
Before invoking grammar_rule_check (in packgram below) on any rule, make
sure all actions have already been scanned in order to set 'used' flags.
Otherwise, checking that a midrule's $$ should be set will not always work
properly because the check must forward-reference the midrule's parent
rule. For the same reason, all the 'used' flags must be set before
checking whether to remove '$' from any midrule symbol name (also in
Before invoking grammar_rule_check_and_complete (in packgram
below) on any rule, make sure all actions have already been
scanned in order to set 'used' flags. Otherwise, checking that a
midrule's $$ should be set will not always work properly because
the check must forward-reference the midrule's parent rule. For
the same reason, all the 'used' flags must be set before checking
whether to remove '$' from any midrule symbol name (also in
packgram). */
for (symbol_list *sym = grammar; sym; sym = sym->next)
code_props_translate_code (&sym->action_props);
+30 -57
View File
@@ -52,9 +52,7 @@ static bitset V;
'useless', but no warning should be issued). */
static bitset V1;
static unsigned nuseful_productions;
unsigned nuseless_productions;
static unsigned nuseful_nonterminals;
unsigned nuseless_nonterminals;
#define bitset_swap(Lhs, Rhs) \
@@ -73,12 +71,10 @@ unsigned nuseless_nonterminals;
static bool
useful_production (rule_number r, bitset N0)
{
item_number *rhsp;
/* A production is useful if all of the nonterminals in its appear
in the set of useful nonterminals. */
for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
if (ISVAR (*rhsp) && !bitset_test (N0, *rhsp - ntokens))
return false;
return true;
@@ -115,9 +111,8 @@ useless_nonterminals (void)
while (1)
{
rule_number r;
bitset_copy (Np, N);
for (r = 0; r < nrules; ++r)
for (rule_number r = 0; r < nrules; ++r)
if (!bitset_test (P, r)
&& useful_production (r, N))
{
@@ -169,15 +164,13 @@ inaccessable_symbols (void)
while (1)
{
rule_number r;
bitset_copy (Vp, V);
for (r = 0; r < nrules; ++r)
for (rule_number r = 0; r < nrules; ++r)
if (!bitset_test (Pp, r)
&& bitset_test (P, r)
&& bitset_test (V, rules[r].lhs->number))
{
item_number *rhsp;
for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
bitset_set (Vp, *rhsp);
bitset_set (Pp, r);
@@ -200,24 +193,18 @@ inaccessable_symbols (void)
bitset_free (P);
P = Pp;
nuseful_productions = bitset_count (P);
unsigned nuseful_productions = bitset_count (P);
nuseless_productions = nrules - nuseful_productions;
nuseful_nonterminals = 0;
{
symbol_number i;
for (i = ntokens; i < nsyms; ++i)
nuseful_nonterminals += bitset_test (V, i);
}
unsigned nuseful_nonterminals = 0;
for (symbol_number i = ntokens; i < nsyms; ++i)
nuseful_nonterminals += bitset_test (V, i);
nuseless_nonterminals = nvars - nuseful_nonterminals;
/* A token that was used in %prec should not be warned about. */
{
rule_number r;
for (r = 0; r < nrules; ++r)
if (rules[r].precsym != 0)
bitset_set (V1, rules[r].precsym->number);
}
for (rule_number r = 0; r < nrules; ++r)
if (rules[r].precsym != 0)
bitset_set (V1, rules[r].precsym->number);
}
@@ -231,8 +218,7 @@ reduce_grammar_tables (void)
{
/* Report and flag useless productions. */
{
rule_number r;
for (r = 0; r < nrules; ++r)
for (rule_number r = 0; r < nrules; ++r)
rules[r].useful = bitset_test (P, r);
grammar_rules_useless_report (_("rule useless in grammar"));
}
@@ -243,14 +229,13 @@ reduce_grammar_tables (void)
int useful = 0;
int useless = nrules - nuseless_productions;
rule *rules_sorted = xnmalloc (nrules, sizeof *rules_sorted);
rule_number r;
for (r = 0; r < nrules; ++r)
for (rule_number r = 0; r < nrules; ++r)
rules_sorted[rules[r].useful ? useful++ : useless++] = rules[r];
free (rules);
rules = rules_sorted;
/* Renumber the rules markers in RITEMS. */
for (r = 0; r < nrules; ++r)
for (rule_number r = 0; r < nrules; ++r)
{
item_number *rhsp = rules[r].rhs;
for (/* Nothing. */; 0 <= *rhsp; ++rhsp)
@@ -262,14 +247,10 @@ reduce_grammar_tables (void)
}
/* Adjust NRITEMS. */
{
rule_number r;
int length;
for (r = nrules; r < nrules + nuseless_productions; ++r)
{
length = rule_rhs_length (&rules[r]);
nritems -= length + 1;
}
for (rule_number r = nrules; r < nrules + nuseless_productions; ++r)
{
int length = rule_rhs_length (&rules[r]);
nritems -= length + 1;
}
}
@@ -287,11 +268,10 @@ nonterminals_reduce (void)
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
{
symbol_number n = ntokens;
symbol_number i;
for (i = ntokens; i < nsyms; ++i)
for (symbol_number i = ntokens; i < nsyms; ++i)
if (bitset_test (V, i))
nontermmap[i - ntokens] = n++;
for (i = ntokens; i < nsyms; ++i)
for (symbol_number i = ntokens; i < nsyms; ++i)
if (!bitset_test (V, i))
{
nontermmap[i - ntokens] = n++;
@@ -306,26 +286,21 @@ nonterminals_reduce (void)
/* Shuffle elements of tables indexed by symbol number. */
{
symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted);
symbol_number i;
for (i = ntokens; i < nsyms; ++i)
for (symbol_number i = ntokens; i < nsyms; ++i)
symbols[i]->content->number = nontermmap[i - ntokens];
for (i = ntokens; i < nsyms; ++i)
for (symbol_number i = ntokens; i < nsyms; ++i)
symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i];
for (i = ntokens; i < nsyms; ++i)
for (symbol_number i = ntokens; i < nsyms; ++i)
symbols[i] = symbols_sorted[i - ntokens];
free (symbols_sorted);
}
{
rule_number r;
for (r = 0; r < nrules; ++r)
{
item_number *rhsp;
for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
- ntokens]);
}
for (rule_number r = 0; r < nrules; ++r)
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
- ntokens]);
accept->content->number = nontermmap[accept->content->number - ntokens];
}
@@ -345,17 +320,15 @@ reduce_output (FILE *out)
{
if (nuseless_nonterminals)
{
int i;
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
for (i = 0; i < nuseless_nonterminals; ++i)
for (int i = 0; i < nuseless_nonterminals; ++i)
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
fputs ("\n\n", out);
}
{
bool b = false;
int i;
for (i = 0; i < ntokens; ++i)
for (int i = 0; i < ntokens; ++i)
if (reduce_token_unused_in_grammar (i))
{
if (!b)
+1 -1
View File
@@ -85,7 +85,7 @@ typedef struct code_props {
/** Named reference. */
named_ref *named_ref;
/** Type, for mid-rule actions. */
/** Type, for midrule actions. */
uniqstr type;
} code_props;
+36 -58
View File
@@ -215,10 +215,7 @@ is_dot_or_dash (char ch)
static inline bool
contains_dot_or_dash (const char* p)
{
for (; *p; ++p)
if (is_dot_or_dash (*p))
return true;
return false;
return strpbrk(p, ".-");
}
/* Defines a variant of a symbolic name resolution. */
@@ -277,26 +274,21 @@ variant_table_free (void)
variant_table_size = variant_count = 0;
}
static char *
find_prefix_end (const char *prefix, char *begin, char *end)
static char const *
find_prefix_end (char const *prefix, char const *cp, char const *end)
{
char *ptr = begin;
for (; *prefix && cp != end; ++prefix, ++cp)
if (*prefix != *cp)
return NULL;
for (; *prefix && ptr != end; ++prefix, ++ptr)
if (*prefix != *ptr)
return 0;
if (*prefix)
return 0;
return ptr;
return *prefix ? NULL : cp;
}
static variant *
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
char *cp, char *cp_end, bool explicit_bracketing)
char const *cp, char const *cp_end, bool explicit_bracketing)
{
char *prefix_end = find_prefix_end (id, cp, cp_end);
char const *prefix_end = find_prefix_end (id, cp, cp_end);
if (prefix_end &&
(prefix_end == cp_end ||
(!explicit_bracketing && is_dot_or_dash (*prefix_end))))
@@ -379,7 +371,7 @@ show_sub_message (warnings warning,
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
obstack_printf (&msg_buf,
_(", cannot be accessed from mid-rule action at $%d"),
_(", cannot be accessed from midrule action at $%d"),
midrule_rhs_index);
complain_indent (&id_loc, warning, &indent, "%s",
@@ -433,35 +425,14 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
}
}
char *cp_end;
bool explicit_bracketing;
bool const explicit_bracketing = *cp == '[';
if ('[' == *cp)
{
/* Ignore the brackets. */
char *p;
for (p = ++cp; *p != ']'; ++p)
continue;
cp_end = p;
explicit_bracketing = true;
}
if (explicit_bracketing)
++cp;
else
{
/* Take all characters of the name. */
char* p;
for (p = cp; *p; ++p)
if (is_dot_or_dash (*p))
{
ref_tail_fields = p;
break;
}
for (p = cp; *p; ++p)
continue;
cp_end = p;
ref_tail_fields = strpbrk (cp, ".-");
explicit_bracketing = false;
}
char const *cp_end = strchr (cp, explicit_bracketing ? ']' : '\0');
/* Add all relevant variants. */
{
@@ -494,7 +465,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
variant *var = &variant_table[i];
unsigned symbol_index = var->symbol_index;
/* Check visibility from mid-rule actions. */
/* Check visibility from midrule actions. */
if (midrule_rhs_index != 0
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
@@ -705,8 +676,15 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
if (0 < n)
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
true;
{
symbol_list *sym = symbol_list_n_get (effective_rule, n);
if (muscle_percent_define_ifdef ("api.value.automove")
&& sym->action_props.is_value_used)
complain (&dollar_loc, Wother,
_("multiple occurrences of $%d with api.value.automove"),
n);
sym->action_props.is_value_used = true;
}
break;
}
}
@@ -834,17 +812,17 @@ code_props_translate_code (code_props *self)
{
switch (self->kind)
{
case CODE_PROPS_NONE:
break;
case CODE_PROPS_PLAIN:
self->code = translate_action (self, INITIAL);
break;
case CODE_PROPS_SYMBOL_ACTION:
self->code = translate_action (self, SC_SYMBOL_ACTION);
break;
case CODE_PROPS_RULE_ACTION:
self->code = translate_action (self, SC_RULE_ACTION);
break;
case CODE_PROPS_NONE:
break;
case CODE_PROPS_PLAIN:
self->code = translate_action (self, INITIAL);
break;
case CODE_PROPS_SYMBOL_ACTION:
self->code = translate_action (self, SC_SYMBOL_ACTION);
break;
case CODE_PROPS_RULE_ACTION:
self->code = translate_action (self, SC_RULE_ACTION);
break;
}
}
+1 -1
View File
@@ -707,7 +707,7 @@ eqopt ([[:space:]]*=)?
"{"|"<"{splice}"%" STRING_GROW; nesting++;
"%"{splice}">" STRING_GROW; nesting--;
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrrectly
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrectly
(as '<' '<%'). */
"<"{splice}"<" STRING_GROW;
+4 -3
View File
@@ -29,8 +29,9 @@
#define FLEX_PREFIX(Id) skel_ ## Id
#include <src/flex-scanner.h>
#include <dirname.h>
#include <error.h>
#include <dirname.h>
#include <path-join.h>
#include <quotearg.h>
#include <src/complain.h>
@@ -236,14 +237,14 @@ at_complain (int argc, char *argv[], char **out_namep, int *out_linenop)
static void
at_output (int argc, char *argv[], char **out_namep, int *out_linenop)
{
if (2 < argc)
if (3 < argc)
fail_for_at_directive_too_many_args (argv[0]);
if (*out_namep)
{
free (*out_namep);
xfclose (yyout);
}
*out_namep = xstrdup (argv[1]);
*out_namep = xpath_join (argv[1], 2 < argc ? argv[2] : NULL);
output_file_name_check (out_namep, true);
/* If there were errors, do not generate the output. */
yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w");

Some files were not shown because too many files have changed in this diff Show More