Compare commits

...
318 Commits
Author SHA1 Message Date
Akim Demaille 0accf65570 version 3.2.1.0
* NEWS: Record release date.
2018-11-09 06:31:50 +01:00
Akim Demaille 05e70adf22 build: fix issues in the generated tarball
Reported by Andre da Costa Barros.
https://savannah.gnu.org/patch/?9716

* examples/calc++/local.mk: We no longer generate position.hh and
stack.hh.  Leaving them here triggers their concurrent generation,
which fails.
(%C%_calc___CPPFLAGS): Fix the extracted headers in the source tree.
* examples/mfcalc/local.mk (%C%_mfcalc_CPPFLAGS): Ditto.
2018-11-08 08:33:16 +01:00
Akim Demaille 7efe0b5da3 build: fix typo
Reported by Horst Von Brand.
https://savannah.gnu.org/support/?109580

* examples/local.mk (.PHOMY): Rename as...
(.PHONY): this.
2018-11-07 21:51:27 +01:00
Akim Demaille 351e3630bb NEWS: update 2018-11-06 13:26:41 +01:00
Akim Demaille 4fd1fc70e0 examples: ship them
Currently, the examples are extracted on the user's side.
Unfortunately, that requires that the user has Perl, which is
otherwise not needed for Bison.  Let's ship the examples instead.

The examples were handled this way so that we could depend on
configure flags: if --enable-gcc-warnings is passed, it is understood
as "I'm a maintainer", so the examples are generated with `#line`s.
Regular users should not see them, so they are now unconditionally
removed when rolling a tarball.

Reported by Mike Frysinger.
https://lists.gnu.org/archive/html/bison-patches/2015-04/msg00000.html

* examples/local.mk: Ship all the extracted files.
(examples-unline): New.
Make sure that the generated tarballs do not contain the #lines.
2018-11-06 13:23:13 +01:00
Akim Demaille e02ce4c7f0 build: minor fixes in doc/
* doc/local.mk: Consistently use *.tmp for temporary files.
Fix comments.
2018-11-06 07:26:01 +01:00
Akim Demaille 7cab285eda CI: maximize chances of errors sooner
* .travis.yml: Try clang and icc soon, so that we don't have to wait
for the end of the run to know that they fail.
2018-11-05 06:32:27 +01:00
Akim Demaille 86efe28222 c++: improve the generated documentation
* data/lalr1.cc, data/location.cc: Improve documenting comments.
* tests/c++.at (Doxygen Documentation): Fix AT_BISON_OPTION_PUSHDEFS,
so that the generated yyerror is correct.
* tests/c++.at, tests/headers.at: Prefer %empty.
2018-11-04 17:56:09 +01:00
Akim Demaille cf1446dc9e tests: don't fail if the C++ compiler does not work
Also, make sure that `make dist` generates a correct tarball even if
the C++ compiler does not work.

Reported by Nelson H. F. Beebe.

* m4/cxx.m4 (BISON_CXX_WORKS): Define to true/false instead of
true/exit 77.  The latter is too dangerous to use (it directly quits).
(ENABLE_CXX): New name for the Automake conditional, for consistency
with ENABLE_CXX11 etc.
* tests/local.at (AT_COMPILE, AT_COMPILE_CXX): Adjust to the new
semantics of BISON_CXX_WORKS.
* examples/c++/local.mk: Skip the variant test if C++ does not work.
* examples/calc++/local.mk: Likewise.
2018-11-04 17:56:09 +01:00
Akim Demaille e93c40b33d tests: don't disable C++ warnings in C files
This triggers error with GCC.
See eff6739124.

* tests/testsuite.h: Disable -Wzero-as-null-pointer-constant only for
C++.
2018-11-04 17:56:09 +01:00
Akim Demaille eff6739124 c++: workaround portability issue
On some systems (x86_64-pc-solaris2.11), with Developer Studio 12.5's
CC, we get:

    ".../include/CC/Cstd/vector.cc", line 127: Error: Cannot assign const yy::parser::stack_symbol_type to yy::parser::stack_symbol_type without "yy::parser::stack_symbol_type::operator=(const yy::parser::stack_symbol_type&)";.
    ".../include/CC/Cstd/vector", line 475:     Where: While instantiating "std::vector<yy::parser::stack_symbol_type>::__insert_aux(yy::parser::stack_symbol_type*, const yy::parser::stack_symbol_type&)".
    ".../include/CC/Cstd/vector", line 475:     Where: Instantiated from non-template code.
    1 Error(s) detected.

Don't expect __cplusplus to be always defined.  If it's not, consider
this is C++98.

Reported by Nelson H. F. Beebe.

* data/c++.m4, data/lalr1.cc, examples/c++/variant.yy, tests/local.at,
* tests/testsuite.h:
An undefined __cplusplus means pre C++11.
2018-11-04 08:00:01 +01:00
Akim Demaille 5a0d7802f4 tests: work around getopt portability issues
On some systems, we don't use our getopt.  As a consequence the error
messages vary:

    $ bison --skeleton
    bison: option requires an argument -- skeleton
    Try 'bison --help' for more information.

instead of

    bison: option '--skeleton' requires an argument
    Try 'bison --help' for more information.

Reported by Jannick and Nelson H. F. Beebe.
https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00140.html

* tests/input.at (Invalid number of arguments): work around getopt
portability issues.
2018-11-03 08:02:15 +01:00
Akim Demaille f1e0839c9e doc: -Wzero-as-null-pointer-constant was added to GCC 4.7
It is not supported by previous versions.
See https://www.gnu.org/software/gcc/gcc-4.7/changes.html
Reported by Nelson H. F. Beebe.

* doc/bison.texi (Calc++ Scanner): here.
2018-11-03 07:23:10 +01:00
Adam SampsonandAkim Demaille 3bf429aed8 examples: #include <cstring> in calc++
strerror is defined by <string.h>, and recent versions of GNU libstdc++
no longer include this automatically from <string>.
2018-11-02 10:20:30 +01:00
Akim Demaille f8cadc731b c: provide a definition of _Noreturn that works for C++
On Solaris, GCC 7.3 defines:

                      -std=c++14  -std=c++17
    __cplusplus       201402L       201703L
    __STDC_VERSION__  199901L       201112L

So the current #definition of _Noreturn sees that 201112 <=
__STDC_VERSION__, i.e., that C11 is supported, so it expects _Noreturn
to be supported.  Apparently it is not.

This is only for C++, the test suite works for C.  However, the test
suite does not try several C standards, maybe we should...

http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00064.html

* data/c.m4 (b4_attribute_define): Define _Noreturn as [[noreturn]] in
modern C++.
2018-10-31 12:06:24 +01:00
Akim Demaille bd7aebb8b0 c: update the definition of _Noreturn
Does not work on Solaris 11.3 x86/64:

    479. c++.at:1293: testing C++ GLR parser identifier shadowing ...
    ======== Testing with C++ standard flags: '-std=c++17'
    ./c++.at:1332: $BISON_CXX_WORKS
    stderr:
    stdout:
    ./c++.at:1332: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o input input.cc $LIBS
    stderr:
    input.cc:837:8: error: '_Noreturn' does not name a type
     static _Noreturn void
            ^~~~~~~~~
    input.cc:845:8: error: '_Noreturn' does not name a type
     static _Noreturn void
            ^~~~~~~~~

Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00051.html

* data/c.m4 (b4_attribute_define): Use the snippet which is currently
in gnulib's m4/gnulib-common.m4 (which seems a little more advanced
than lib/_Noreturn.h).
2018-10-30 19:44:31 +01:00
Akim Demaille ca8039e612 tests: don't expect the shell to support 'local'
It doesn't work on Solaris 11.3 x86/64.
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00051.html

* examples/test: Don't use 'local'.
2018-10-30 19:13:38 +01:00
Akim Demaille 5d07f4f726 bitset: fix warning
Reported by Hans Åberg.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00047.html

* lib/bitset.c (bitset_count_): here.
2018-10-30 07:01:57 +01:00
Akim Demaille e605ad9679 build: fix use of gnulib Make variables
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00048.html

* lib/local.mk (lib_libbison_a_LIBADD): Merge into...
* src/local.mk (src_bison_LDADD): here.
2018-10-30 07:01:21 +01:00
Akim Demaille 50fac71d46 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-10-29 21:15:10 +01:00
Akim Demaille a8455b072a version 3.2
* NEWS: Record release date.
2018-10-29 20:37:13 +01:00
Akim Demaille a9d6e16e0a build: don't depend on the libc to generate bison.help
The "Report translation bugs to..." part of --help is issued only on
glibc systems.  So if the tarball is not wrapped on such a system, and
used on such a system (or the converse), then bison.help will differ
on the user's system, and help2man will be called to update bison.1.

But help2man should not be a requirement.

Reported by Alexandre Duret-Lutz.

* doc/local.mk (doc/bison.help): Remove the possible doc about
translation bugs.
Pass LC_ALL=C, as reported in src/getargs.c's usage().
(doc/cross-options.texi): Use bison.help instead of calling bison
--help.
2018-10-29 20:24:30 +01:00
Akim Demaille bd0cf11e00 c++: always issue the "generated by" message
Some users rely on this sentence to know that the file can be ignored.
Reported by Alexandre Duret-Lutz.

* data/bison.m4 (b4_generated_by): New.
(b4_copyright): Use it.
* data/location.cc, data/stack.hh: Use it too, for the stub files
(position.hh and stack.hh).
2018-10-29 20:07:21 +01:00
Akim Demaille c8512e09e7 cfg.mk: remove exceptions for timevar
They appear to be no longer needed.

* cfg.mk: here.
2018-10-28 18:02:50 +01:00
Akim Demaille 96f503e197 style: clean up src/AnnotationList.c
* src/AnnotationList.c: Reduce scopes.
2018-10-28 17:56:22 +01:00
Akim Demaille 9912dd28ca style: clean up print.c
* src/print.c: Reduce scopes.
2018-10-28 16:32:12 +01:00
Akim Demaille 22aaad0c45 bitset: clean up bbitset.h
* lib/libiberty.h: Inline in...
* lib/bbitset.h: here.
* lib/local.mk: Adjust.
2018-10-27 19:27:41 +02:00
Akim Demaille a45ed4ecc1 bitset: clean up bitset.h
* lib/bitset.h: Fix include order.
2018-10-27 19:27:41 +02:00
Akim Demaille fef272bdf3 bitset: clean up vbitset.c
* lib/vbitset.c: Reduce scopes, etc.
2018-10-27 19:27:41 +02:00
Akim Demaille d1f57a4ae5 bitset: clean up lbitset.c
* lib/lbitset.c: Reduce scopes, etc.
2018-10-27 19:27:41 +02:00
Akim Demaille 5d5f12fb0d bitset: clean up ebitset.c
* lib/ebitset.c: Reduce scopes, etc.
2018-10-27 19:09:08 +02:00
Akim Demaille 9f6013a0fd bitset: clean up bitset_stats.c
* lib/bitset_stats.c: Reduce scopes, etc.
2018-10-27 19:09:08 +02:00
Akim Demaille fad0f9231b bitset: clean up bitset.c
* lib/bitset.c: Reduce scopes, etc.
2018-10-27 19:09:08 +02:00
Akim Demaille 81df326649 bitset: clean up abitset.c
* lib/abitset.c: Reduce scopes, etc.
2018-10-27 18:46:01 +02:00
JannickandAkim Demaille 01c5b6ab0f xml2dot.xsl: fix typos in comments 2018-10-27 16:43:27 +02:00
Akim Demaille c45f86d286 doc: fix distcheck
The extracted example, simple.yy, does not use %require "3.2", so it
generates a stack.hh, which breaks distcheck.

* doc/bison.texi: Fix it.
2018-10-27 08:53:30 +02:00
Akim Demaille 1664d1c5ed NEWS: prepare for 3.2 2018-10-27 08:30:50 +02:00
Akim Demaille 71758d854a tests: beware of Windows file name constraints
Don't expect to be able to build a file named '"\"".y' (6 characters)
on Windows.

Reported by Jannick.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00042.html

* tests/synclines.at (syncline escapes): Skip if we failed to create
the file.
2018-10-26 18:59:01 +02:00
Akim Demaille 3751d50e70 tests: fix invocation of m4_map
* tests/actions.at, tests/synclines.at: m4_map takes a list of
arguments in $2, m4_map_args takes arguments in $2, $3, etc.
2018-10-26 18:59:01 +02:00
Akim Demaille 3f5e6905da doc: spell check
* README, doc/bison.texi, examples/README, examples/c++/README: here.
2018-10-26 08:40:07 +02:00
Akim Demaille 719782e6ba examples: add a Makefile for C++ short examples
* examples/c++/Makefile: New.
* examples/c++/local.mk, examples/c++/README: Adjust.
2018-10-26 08:35:10 +02:00
Akim Demaille ee175dfd00 doc: some improvements
* doc/bison.texi (Calc++ Scanner): Show how exception can be thrown
from auxiliary functions.
Clarify the meaning of the various flex %options we use.
Get rid of a warning.
(Calc++ Parsing Driver): Use the parser as a functor.
2018-10-26 07:42:28 +02:00
Akim Demaille f3110c9b9a examples: check the errors
* examples/test (run): Check stderr, unless -noerr is passed.
* examples/calc++/calc++.test, examples/mfcalc/mfcalc.test: Check
errors.
2018-10-26 07:42:28 +02:00
Akim Demaille 18743948b5 doc: minor fixes
* doc/bison.texi: Simplify wording.
Fix Texinfo error.
(Complete Symbols): Handle the token EOF.
(Calc++ Parser): In the modern C++ world, prefer assignment to swap.
(Strings are Destroyed): Prefer an explicit 'continue' to a comment.
2018-10-25 07:03:15 +02:00
Akim Demaille 849d91bc02 configure: quit on trying to get ICC and Flex be friends
The CI is using Flex 2.5.35.  And ICC is too picky for it.  Let's stop
making these warnings errors.  I wish I could disable them in the
source files using the ICC version and the Flex version, but ICC's
pragma support is unclear, and I'm tired of fighting it.

* configure.ac (FLEX_SCANNER_CXXFLAGS): Make warnings warnings.
* examples/c++/local.mk: Comment changes.
2018-10-24 21:53:21 +02:00
Akim Demaille 73a822e636 doc: mention earlier how to disable the generation of location.hh
Suggested by Victor Khomenko.

* doc/bison.texi (C++ Bison Interface): Here.
2018-10-24 18:57:15 +02:00
Akim Demaille 5b879c8980 c++: std::to_string is available in C++11
Reported by Victor Khomenko.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00033.html

* doc/bison.texi, examples/c++/variant-11.yy: Use std::to_string
instead of ours.
2018-10-24 18:49:04 +02:00
Akim Demaille 8fd5f0d5a5 examples: move the variant examples into the C++ directory
* examples/variant-11.test examples/variant-11.yy,
* examples/variant.test examples/variant.yy:
Move into examples/c++/.
* examples/c++/README: New.
* examples/README, examples/c++/local.mk, examples/local.mk:
Adjust.
2018-10-24 07:20:08 +02:00
Akim Demaille a4dce889a4 doc: an introductory example for C++
Suggested by Victor Khomenko.
http://lists.gnu.org/archive/html/bug-bison/2018-08/msg00037.html

* doc/bison.texi (A Simple C++ Example): New.
* examples/c++/local.mk, examples/c++/simple.test: New.
Extract, check, and install this new example.
* examples/local.mk: Adjust.
* examples/test: Adjust to the case where the dirname differs
from the test name.
2018-10-24 06:18:57 +02:00
Akim Demaille 7c4b40de61 build: remove a few copies of the Copyright from the generated Makefile
* build-aux/local.mk, cfg.mk, examples/calc++/local.mk,
* examples/local.mk, examples/mfcalc/local.mk,
* examples/rpcalc/local.mk, lib/local.mk, src/local.mk,
* tests/local.mk:
Use Automake comments so that we don't get a copy of each in the
generated Makefile.
2018-10-24 06:18:57 +02:00
Akim Demaille f9bba892bd c++: make operator() an alias to the parse function
* data/glr.cc, data/lalr1.cc (operator()): New.
* doc/bison.texi: Update.
2018-10-24 06:18:57 +02:00
Akim Demaille facfd9c406 build: enable more warnings during tests
Prompted by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00018.html

* configure.ac: here.
2018-10-23 09:08:57 +02:00
Akim Demaille 0308dfb039 regen 2018-10-23 09:08:57 +02:00
Akim Demaille 9d8fc7fd3e yacc.c: work around strange typing issues
On the CI, both GCC and Clang report:

    src/parse-gram.c: In function 'yy_lac':
    src/parse-gram.c:1479:29: error: format '%hd' expects argument of type 'int',
       but argument 3 has type 'yytype_int16 {aka long int}' [-Werror=format=]
             YYDPRINTF ((stderr, " G%hd", yystate));
                                 ^

Although yytype_int16 is supposed to be a short int, not a long int.
This must be explored.

* data/yacc.c (yy_lac): Work around typing issue.
2018-10-23 09:08:57 +02:00
Akim Demaille b5515215c1 yacc.c: don't define _Noreturn uselessly
Clang warns:

     aux/x.h:97:11: error: macro name is a reserved identifier
           [-Werror,-Wreserved-id-macro]
     #  define _Noreturn YY_ATTRIBUTE ((__noreturn__))

Reported by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00024.html

* data/c.m4 (b4_attribute_define): Don't define _Noreturn unconditionally.
* data/glr.c: Ask for _Noreturn.
2018-10-23 09:08:57 +02:00
Akim Demaille ab3dc5415c pacify ICC 16.0.3 20160415
Found on the CI.

yacc.c:

    error #2259: non-pointer conversion from "int" to "yytype_int16={short}" may lose significant bits
        yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
                ^

glr.c:

    error #2259: non-pointer conversion from "int" to "yybool={unsigned char}" may lose significant bits
      yybool yynormal YY_ATTRIBUTE_UNUSED = (yystackp->yysplitPoint == YY_NULLPTR);
                                          ^

    error #2259: non-pointer conversion from "int" to "yybool={unsigned char}" may lose significant bits
      return yypact_value_is_default (yypact[yystate]);
             ^

    error #2259: non-pointer conversion from "int" to "yybool={unsigned char}" may lose significant bits
      return 0 < yyaction;
             ^

    error #2259: non-pointer conversion from "int" to "yybool={unsigned char}" may lose significant bits
      return yyaction == 0;
             ^

    error #2259: non-pointer conversion from "int" to "yybool={unsigned char}" may lose significant bits
      yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
                                                     ^

* data/glr.c, data/yacc.c: Avoid these warnings.
2018-10-23 09:08:57 +02:00
Akim Demaille 06f3245fa4 flex: work around more warnings
* doc/bison.texi: here.
2018-10-23 09:08:57 +02:00
Akim Demaille 05d702422a examples: clang 5 defines nullptr as a macro
* examples/variant.yy: So don't do it.
* examples/variant-11.yy: Fix comment.
2018-10-23 09:08:57 +02:00
Akim Demaille 121da2cbdb glr.c: be strict about types
* data/glr.c: Don't use `foo |= bar` with foo and bar being yybool:
the result appears to be an int, not a yybool.
Use yybool where appropriate.
Add casts where needed.
2018-10-23 09:08:57 +02:00
Akim Demaille 7a45fc35bf yacc.c: fix warnings about integral types
Reported by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00018.html

Rather than adding casts, we should be more careful with types.  For
instance yystate should be a yytype_int16.  But currently we can't: it
is also used sometimes for storing other things that state numbers.

* data/yacc.c (yyparse): Add missing casts.
2018-10-23 09:08:57 +02:00
Akim Demaille ae1e65a285 yacc.c: clarify the computation of yystate
The yacc.c skeleton is old, and was using many tricks to save
registers.  Today's register allocators can do this themselves.  Let's
keep the code simpler to read and let compilers do their job.

* data/yacc.c: Avoid using yystate for different types of content.
An inline function would be better, but doing this portably will be
a problem.
2018-10-22 17:49:08 +02:00
Akim Demaille ba9db64745 printf returns a signed int
* tests/local.at: Adjust location_print's signature.
2018-10-22 17:49:08 +02:00
Akim Demaille b4b8666e4a tests: be strict about types
* tests/actions.at, tests/c++.at, tests/cxx-type.at,
* tests/glr-regression.at, tests/local.at, tests/torture.at,
* tests/types.at:
Pay stricter attention to types to avoid warnings.
2018-10-22 17:49:06 +02:00
Akim Demaille 0021bc3e28 c++: fix signedness issues
* data/lalr1.cc, data/stack.hh: The callers of stack use int, while
stack is based on size_type.  Add overloads to avoid warnings.
2018-10-22 08:40:39 +02:00
Akim Demaille 4b0efdeb28 c++: minor changes
* data/lalr1.cc: Fix oldish comment.
* data/stack.hh: Prefer typename for type names.
Use size() instead of duplicating it.
* examples/variant-11.yy, examples/variant.yy (yylex): Use int,
as this is the type of the semantic value.
2018-10-22 08:40:39 +02:00
Akim Demaille 73917e9e6f all: display a clear warning about private macros
* data/bison.m4 (b4_disclaimer): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
2018-10-22 07:28:54 +02:00
Akim Demaille ba29791773 c++: minor simplification
* data/stack.hh: Prefer a default argument value to two constructors.
2018-10-21 19:09:53 +02:00
Akim Demaille a7842d1bc0 regen 2018-10-21 09:58:44 +02:00
Akim Demaille 81a9580622 all: avoid useless comments and #lines
Currently we emit useless code for places where we might issue user
content, but there is none.  This commit avoids this.  Besides, some
of the comments looked like implementation details ("Copy the first
part of user declarations"), rather than made for the reader of the
result ("First part of user prologue").

On Bison's parse-gram.c we get:

    @@ -76,10 +76,6 @@
     #define yynerrs         gram_nerrs

    -/* Copy the first part of user declarations.  */
    -
    -#line 82 "src/parse-gram.c" /* yacc.c:339  */
    -

* data/bison.m4 (b4_define_user_code): Accept a comment to document
the section.
Do not emit any code if the content is empty.
Adjust callers to not emit the comment.
Do not
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java, data/yacc.c:
Adjust.
2018-10-21 09:58:44 +02:00
Akim Demaille 85f7c08036 tests: refactor
* tests/actions.at, tests/synclines.at: Prefer iteration to
copy-paste.
2018-10-21 08:28:50 +02:00
Akim Demaille 098f5084a0 tests: rename AT_SKEL_CC_IF/AT_SKEL_JAVA_IF as AT_CXX_IF/AT_JAVA_IF
The previous name is too obscure, and the other macros for C++ use
CXX, not CC.

* tests/local.at (AT_SKEL_CC_IF, AT_SKEL_JAVA_IF): Rename as...
(AT_CXX_IF, AT_JAVA_IF): these.
Adjust callers.
2018-10-21 08:28:47 +02:00
Akim Demaille 07a4b32f4d c++: check that emplace for rvalues works
See the previous commit.

* tests/local.at (AT_REQUIRE_CXX_VERSION): New.
* tests/types.at (api.value.type): Check emplace in C++14.
2018-10-21 08:02:52 +02:00
Akim Demaille 3ead69b1c1 c++: prefer a perfect forwarding version of variant's emplace
* data/variant.hh (emplace): In modern C++, use only a perfect
forwarding version.
And use it.
* doc/bison.texi: Document it.
2018-10-20 19:03:01 +02:00
Akim Demaille 42f0b949ec c++: prefer 'emplace' to 'build'
When we introduced variants in Bison, C++ did not have the 'emplace'
functions, and we chose 'build'.  Let's align with modern C++ and
promote 'emplace' rather than 'build'.

* data/lalr1.cc, data/variant.hh (emplace): New.
(build): Deprecate in favor of emplace.
* doc/bison.texi: Adjust.
2018-10-20 19:03:01 +02:00
Akim Demaille e7b709ab0b %printer: promote yyo rather than yyoutput
* doc/bison.texi: Promote yyo rather than yyoutput.

* data/c.m4, data/glr.cc, tests/types.at, tests/calc.at,
tests/regression.at: Adjust.
2018-10-20 19:03:01 +02:00
Akim Demaille 35068fbe66 doc: improve the C++ section
* doc/bison.texi (C++ Parser): file.hh and location.hh are no longer
mandatory.
Various minor fixes.
2018-10-20 14:13:07 +02:00
Akim Demaille 16d34d8036 doc: reorder C++ sections
* doc/bison.texi (C++ Parser Interface): Document before semantic_type
and location_type.
2018-10-20 14:13:07 +02:00
Akim Demaille bfbd73f3e0 git: don't ignore auxiliary Texinfo files
As a matter of fact, I think it is wrong to gitignore generated files
that belong to the build tree.  There should be the strict minimum,
and it's up to people that build in place to adjust their own
~/.gitignore.

* doc/.gitignore: here.
Remove files we no longer produce (thanks to texi2dvi).
2018-10-20 14:12:08 +02:00
Akim Demaille 602f8e2a77 c++: do not exhibit private macros
* examples/variant-11.yy: here.
2018-10-20 13:56:40 +02:00
Akim Demaille ace93397c1 c++: don't obfuscate std::move when not needed
* data/lalr1.cc, data/variant.hh: Avoid macros that depend on the
version of C++ when not needed.
2018-10-20 09:18:40 +02:00
Akim Demaille d2192653db build: add missing gnulib libs
Reported by Denis Excoffier.

* lib/local.mk, src/local.mk: here.
2018-10-20 09:11:22 +02:00
Akim Demaille 83a832618d maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-10-18 13:33:28 +02:00
Akim Demaille 0e0d7d2975 version 3.1.91
* NEWS: Record release date.
2018-10-18 12:54:37 +02:00
Akim Demaille 5abbc66fe4 NEWS: update 2018-10-18 12:54:08 +02:00
Akim Demaille bf338b7cd2 examples: force stack resizing with unique_ptr
In the previous commit we fixed a problem when the C++ stack was
resized.  The test was using ints.  Let's add a test with someone
quite touchy: unique_ptr

* examples/variant-11.yy: Accept an argument, which is the number of
numbers to send to the parser.
* examples/variant-11.test: Check with many numbers.
2018-10-18 08:51:08 +02:00
Akim Demaille 3967e46a2d lalr1.cc: fix stack symbol move
In some casing, once we moved a stack symbol, we forget to mark the
source stack symbol as emptied.  As a consequence, it may be destroyed
a second time.

This happens when the stack has to be resized.

* data/lalr1.cc (stack_symbol_type::stack_symbol_type): Record that
the source was emptied.
(stack_symbol_type::operator=): Likewise.
* tests/c++.at (C++ Variant-based Symbols Unit Tests): Force the stack
to be resized.  Check its content.
2018-10-18 07:15:30 +02:00
Akim Demaille b994c3bf78 doc: improve the doc of the examples
* examples/README: here.
2018-10-17 19:00:29 +02:00
Akim Demaille 03a13ce793 reader: recognize C++ even when it's not lalr1.cc or glr.cc
* src/reader.c (grammar_rule_check_and_complete): If a user uses her
own skeleton but sets the language to C++, recognize it as C++.
2018-10-17 17:53:51 +02:00
Akim Demaille f5fc21240f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-10-17 07:11:56 +02:00
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
143 changed files with 5892 additions and 4529 deletions
+1 -1
View File
@@ -1 +1 @@
3.0.5
3.2
+300
View File
@@ -0,0 +1,300 @@
# 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:
## ------- ##
## First. ##
## ------- ##
# Start with three completely different environments, to get
# errors asap.
- 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: "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: "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='
## ----- ##
## 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 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 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++'
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
+191 -15
View File
@@ -1,5 +1,178 @@
GNU Bison NEWS
* Noteworthy changes in release 3.2.1.0 (2018-11-09) [stable]
** Bug fixes
Several portability issues have been fixed in the build system, in the
test suite, and in the generated parsers in C++.
* Noteworthy changes in release 3.2 (2018-10-29) [stable]
** 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.
** Changes
%printers should use yyo rather than yyoutput to denote the output stream.
Variant-based symbols in C++ should use emplace() rather than build().
In C++ parsers, parser::operator() is now a synonym for the parser::parse.
** Documentation
A new section, "A Simple C++ Example", is a tutorial for parsers in C++.
A comment in the generated code now emphasizes that users should not
depend upon non-documented implementation details, such as macros starting
with YY_.
** 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/c++/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 +871,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 +1194,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 +2190,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 +2225,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 +2403,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 +2678,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 +2820,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 +3131,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
+9 -5
View File
@@ -10,7 +10,7 @@ Bison requires GNU m4 1.4.6 or later. See:
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
** Internationalization
Bison supports two catalogues: one for Bison itself (i.e., for the
Bison supports two catalogs: one for Bison itself (i.e., for the
maintainer-side parser generation), and one for the generated parsers
(i.e., for the user-side parser execution). The requirements between
both differ: bison needs ngettext, the generated parsers do not. To
@@ -29,9 +29,9 @@ If you have questions about using Bison and the documentation does
not answer them, please send mail to <[email protected]>.
* Bug reports
Please send bug reports to <[email protected]>. Please include the
version number from 'bison --version', and a complete, self-contained
test case in each bug report.
Please send bug reports to <[email protected]>. Be sure to include the
version number from 'bison --version', and a complete, self-contained test
case in each bug report.
* Copyright statements
For any copyright year range specified as YYYY-ZZZZ in this package,
@@ -42,12 +42,13 @@ note that the range specifies every single year in that closed interval.
Local Variables:
mode: outline
fill-column: 76
ispell-dictionary: "american"
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
@@ -61,3 +62,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
# LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
# LocalWords: MERCHANTABILITY
+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.
+9
View File
@@ -3,11 +3,13 @@ it is today without the invaluable help of these people:
Aaro Koskinen [email protected]
Аскар Сафин [email protected]
Adam Sampson [email protected]
Airy Andre [email protected]
Akim Demaille [email protected]
Albert Chin-A-Young [email protected]
Alexander Belopolsky [email protected]
Alexandre Duret-Lutz [email protected]
Andre da Costa Barros [email protected]
Andreas Schwab [email protected]
Andrew Suffield [email protected]
Angelo Borsotti [email protected]
@@ -42,6 +44,7 @@ David J. MacKenzie [email protected]
David Kastrup [email protected]
David Michael [email protected]
Dengke Du [email protected]
Denis Excoffier [email protected]
Dennis Clarke [email protected]
Derek Clegg [email protected]
Derek M. Jones [email protected]
@@ -51,6 +54,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]
@@ -66,6 +70,7 @@ Goran Uddeborg [email protected]
Guido Trentalancia [email protected]
H. Merijn Brand [email protected]
Hans Åberg [email protected]
Horst Von Brand [email protected]
Jan Nieuwenhuizen [email protected]
Jannick [email protected]
Jerry Quinn [email protected]
@@ -77,10 +82,12 @@ 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]
Ken Moffat [email protected]
Kiyoshi Kanazawa [email protected]
Laurent Mascherpa [email protected]
Lie Yan [email protected]
Magnus Fromreide [email protected]
@@ -101,6 +108,7 @@ Michel d'Hooge [email protected]
Michiel De Wilde [email protected]
Mickael Labau [email protected]
Mike Castle [email protected]
Mike Frysinger [email protected]
Mike Sullivan [email protected]
Nate Guerin [email protected]
Neil Booth [email protected]
@@ -145,6 +153,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]
+46
View File
@@ -1,4 +1,20 @@
* Short term
** yacc.c
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
than duplicating it.
** C++
Move to int everywhere instead of unsigned? stack_size, etc. The parser
itself uses int (for yylen for instance), yet stack is based on size_t.
Maybe locations should also move to ints.
** C
Introduce state_type rather than spreading yytype_int16 everywhere?
** glr.c
yyspaceLeft should probably be a pointer diff.
** Graphviz display code thoughts
The code for the --graph option is over two files: print_graph, and
graphviz. This is because Bison used to also produce VCG graphs, but since
@@ -196,6 +212,31 @@ 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.
See also
https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
and https://research.swtch.com/yyerror.
** %include
This is a popular demand. We already made many changes in the parser that
should make this reasonably easy to implement.
Bruce Mardle <[email protected]>
https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
** 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 +272,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 +410,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
+14 -14
View File
@@ -1,17 +1,17 @@
# Copyright (C) 2000-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/>.
## Copyright (C) 2000-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/>.
EXTRA_DIST += \
build-aux/Darwin.valgrind \
+32 -35
View File
@@ -1,18 +1,18 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2008-2015, 2018 Free Software Foundation, Inc.
## Customize maint.mk -*- makefile -*-
## 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 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.
## 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/>.
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
# Update version, then recompile so that tests/bison --version be
# up-to-date, then compile our parser again with our up-to-date bison.
@@ -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,21 @@ 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+=?|^src/(parse-gram.c|system.h)$$ \
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
prohibit_always_true_header_tests=^djgpp/subpipe.h$$ \
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$$) \
)
+28 -13
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,18 @@ 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])
AM_CONDITIONAL([ENABLE_CXX14], [test x"$CXX14_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 +94,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'
@@ -94,7 +108,9 @@ if test "$enable_gcc_warnings" = yes; then
# -Wno-keyword-macro: We use the "#define private public" dirty
# trick in the test suite to check some private implementation
# details for lalr1.cc.
warn_tests='-Wundef -pedantic -Wdeprecated -Wsign-compare -fno-color-diagnostics
warn_tests='-Wundef -pedantic -Wconversion
-Wdeprecated -Wsign-compare -Wsign-conversion
-fno-color-diagnostics
-Wno-keyword-macro'
AC_LANG_PUSH([C])
@@ -124,7 +140,7 @@ if test "$enable_gcc_warnings" = yes; then
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
# Warnings for the test suite only.
for i in $warn_tests;
for i in $warn_tests -Wincompatible-pointer-types;
do
gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
done
@@ -146,17 +162,15 @@ if test "$enable_gcc_warnings" = yes; then
do
gl_WARN_ADD([$i], [WARN_CXXFLAGS_TEST])
done
# Clang++ 3.2+ reject C code generated by Flex.
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.
gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
# Too many compilers complain about Flex generated code.
gl_WARN_ADD([-Wno-error], [FLEX_SCANNER_CXXFLAGS])
# Clang++ deprecates compiling C.
gl_WARN_ADD([-Wno-deprecated], [WNO_DEPRECATED_CXXFLAGS])
CXXFLAGS=$save_CXXFLAGS
gl_WARN_ADD([-fno-exceptions], [CXXFLAGS_NO_EXCEPTIONS])
AC_LANG_POP([C++])
fi
BISON_TEST_FOR_WORKING_C_COMPILER
BISON_C_COMPILER_POSIXLY_CORRECT
BISON_TEST_FOR_WORKING_CXX_COMPILER
@@ -204,7 +218,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 +256,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 +266,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
+103 -42
View File
@@ -22,12 +22,17 @@
## Identification. ##
## ---------------- ##
# b4_generated_by
# ---------------
m4_define([b4_generated_by],
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
])
# b4_copyright(TITLE, [YEARS])
# ----------------------------
# If YEARS are not defined, use b4_copyright_years.
m4_define([b4_copyright],
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
[b4_generated_by
b4_comment([$1
]m4_dquote(m4_text_wrap([Copyright (C)
@@ -58,26 +63,49 @@ Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison.])])
version 2.2 of Bison.])
])
# b4_disclaimer
# -------------
# Issue a warning about private implementation details.
m4_define([b4_disclaimer],
[b4_comment([Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them.])
])
# 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 +417,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 +432,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 +471,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 +506,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 +564,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])]);
@@ -601,13 +629,15 @@ m4_define([b4_user_code],
b4_syncline([@oline@], [@ofile@])])
# b4_define_user_code(MACRO)
# --------------------------
# From b4_MACRO, build b4_user_MACRO that includes the synclines.
# b4_define_user_code(MACRO, COMMENT)
# -----------------------------------
# From b4_MACRO, if defined, build b4_user_MACRO that includes the synclines.
m4_define([b4_define_user_code],
[m4_define([b4_user_$1],
[b4_user_code([b4_$1])])])
[m4_ifdef([b4_$1],
[m4_ifval([$2],
[b4_comment([$2])
])b4_user_code([b4_$1])])])])
# b4_user_actions
# b4_user_initial_action
@@ -617,9 +647,9 @@ m4_define([b4_define_user_code],
# ----------------------
# Macros that issue user code, ending with synclines.
b4_define_user_code([actions])
b4_define_user_code([initial_action])
b4_define_user_code([post_prologue])
b4_define_user_code([pre_prologue])
b4_define_user_code([initial_action], [User initialization code.])
b4_define_user_code([post_prologue], [Second part of user prologue.])
b4_define_user_code([pre_prologue], [First part of user prologue.])
b4_define_user_code([union_members])
@@ -701,7 +731,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 +740,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 +785,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 +809,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 +887,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 +902,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 +947,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 +1009,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])
@@ -1011,8 +1074,6 @@ b4_check_user_names_wrap([[code]], [[qualifier]])
## ---------------- ##
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
m4_define_default([b4_pre_prologue], [])
m4_define_default([b4_post_prologue], [])
m4_define_default([b4_epilogue], [])
m4_define_default([b4_parse_param], [])
+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],
+55 -39
View File
@@ -204,11 +204,12 @@ m4_define([b4_table_value_equals],
## Compiler issues. ##
## ----------------- ##
# b4_attribute_define
# -------------------
# Provide portable compiler "attributes".
# b4_attribute_define([noreturn])
# -------------------------------
# Provide portable compiler "attributes". If "noreturn" is passed, define
# _Noreturn.
m4_define([b4_attribute_define],
[#ifndef YY_ATTRIBUTE
[[#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
@@ -226,16 +227,23 @@ m4_define([b4_attribute_define],
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
#if ! defined _Noreturn
# if defined __cplusplus && 201103L <= __cplusplus
# define _Noreturn [[noreturn]]
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn
# endif
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
]])[/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
@@ -260,24 +268,26 @@ m4_define([b4_attribute_define],
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
])
## ---------##
## 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 +298,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 +377,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]))])
@@ -498,54 +514,54 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
# Define the "yy_symbol_print" function.
m4_define_default([b4_yy_symbol_print_define],
[[
/*----------------------------------------.
| Print this symbol's value on YYOUTPUT. |
`----------------------------------------*/
/*-----------------------------------.
| Print this symbol's value on YYO. |
`-----------------------------------*/
]b4_function_define([yy_symbol_value_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[FILE *yyo], [yyo]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
FILE *yyo = yyoutput;
]b4_parse_param_use([yyo], [yylocationp])dnl
FILE *yyoutput = yyo;
]b4_parse_param_use([yyoutput], [yylocationp])dnl
[ if (!yyvaluep)
return;]
dnl glr.c does not feature yytoknum.
m4_if(b4_skeleton, ["yacc.c"],
[[# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
]])dnl
b4_symbol_actions([printer])[
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
/*---------------------------.
| Print this symbol on YYO. |
`---------------------------*/
]b4_function_define([yy_symbol_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[FILE *yyo], [yyo]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
YYFPRINTF (yyoutput, "%s %s (",
YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
YYFPRINTF (yyoutput, ": ");
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
YYFPRINTF (yyo, ": ");
])dnl
[ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl
[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
b4_locations_if([, yylocationp])[]b4_user_args[);
YYFPRINTF (yyoutput, ")");
YYFPRINTF (yyo, ")");
}]dnl
])
@@ -807,11 +823,11 @@ m4_define([b4_yy_location_print_define],
YY_ATTRIBUTE_UNUSED
]b4_function_define([yy_location_print_],
[static unsigned],
[static int],
[[FILE *yyo], [yyo]],
[[YYLTYPE const * const yylocp], [yylocp]])[
{
unsigned res = 0;
int res = 0;
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
if (0 <= yylocp->first_line)
{
+45 -42
View File
@@ -199,11 +199,10 @@ m4_if(b4_skeleton, ["glr.c"],
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2015, 2018])[
]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
])])
@@ -214,12 +213,12 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C],
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
[2002-2015, 2018])[
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
]b4_disclaimer[
]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([[
@@ -236,7 +235,6 @@ b4_percent_code_get([[top]])[
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])]))[
/* First part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
@@ -259,9 +257,8 @@ b4_percent_code_get([[top]])[
static YYSTYPE yyval_default;]b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default;])[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
]b4_user_post_prologue[
]b4_percent_code_get[]dnl
[#include <stdio.h>
#include <stdlib.h>
@@ -292,22 +289,29 @@ 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;
/* When we move to stdbool, get rid of the various casts to 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[
]b4_attribute_define([noreturn])[
#ifndef YYASSERT
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
@@ -597,7 +601,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return strlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
return (size_t) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -776,11 +780,11 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
* yyerr for YYERROR, yyabort for YYABORT. */
static YYRESULTTAG
yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
yyGLRStack* yystackp,
YYSTYPE* yyvalp]b4_locuser_formals[)
{
yybool yynormal YY_ATTRIBUTE_UNUSED = (yystackp->yysplitPoint == YY_NULLPTR);
yybool yynormal YY_ATTRIBUTE_UNUSED = (yybool) (yystackp->yysplitPoint == YY_NULLPTR);
int yylow;
]b4_parse_param_use([yyvalp], [yylocp])dnl
[ YYUSE (yyrhslen);
@@ -797,7 +801,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
# undef yyclearin
# define yyclearin (yychar = YYEMPTY)
# undef YYFILL
# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
# define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
# undef YYBACKUP
# define YYBACKUP(Token, Value) \
return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
@@ -814,7 +818,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
]])[
switch (yyn)
{
]b4_user_actions[
]b4_user_actions[
default: break;
}
@@ -900,7 +904,7 @@ yylhsNonterm (yyRuleNum yyrule)
static inline yybool
yyisDefaultedState (yyStateNum yystate)
{
return yypact_value_is_default (yypact[yystate]);
return (yybool) yypact_value_is_default (yypact[yystate]);
}
/** The default reduction for YYSTATE, assuming it has one. */
@@ -926,7 +930,7 @@ yygetLRActions (yyStateNum yystate, int yytoken,
int* yyaction, const short** yyconflicts)
{
int yyindex = yypact[yystate] + yytoken;
if (yypact_value_is_default (yypact[yystate])
if (yyisDefaultedState (yystate)
|| yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
{
*yyaction = -yydefact[yystate];
@@ -961,13 +965,13 @@ yyLRgotoState (yyStateNum yystate, yySymbol yysym)
static inline yybool
yyisShiftAction (int yyaction)
{
return 0 < yyaction;
return (yybool) (0 < yyaction);
}
static inline yybool
yyisErrorAction (int yyaction)
{
return yyaction == 0;
return (yybool) (yyaction == 0);
}
/* GLRStates */
@@ -1077,7 +1081,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
yyGLRStackItem* yyp0, *yyp1;
size_t yynewSize;
size_t yyn;
size_t yysize = yystackp->yynextFree - yystackp->yyitems;
size_t yysize = (size_t) (yystackp->yynextFree - yystackp->yyitems);
if (YYMAXDEPTH - YYHEADROOM < yysize)
yyMemoryExhausted (yystackp);
yynewSize = 2*yysize;
@@ -1260,7 +1264,7 @@ do { \
`----------------------------------------------------------------------*/
static inline void
yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
yyRuleNum yyrule]b4_user_formals[)
{
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
@@ -1277,8 +1281,8 @@ yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval]b4_locations_if([,
&]b4_rhs_location(yynrhs, yyi + 1))[]dnl
b4_user_args[);
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
YYFPRINTF (stderr, " (unresolved)");
@@ -1305,9 +1309,9 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
YYASSERT (yyk == 0);
yystackp->yynextFree -= yynrhs;
yystackp->yyspaceLeft += yynrhs;
yystackp->yyspaceLeft += (size_t) yynrhs;
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
YY_REDUCE_PRINT ((yytrue, yyrhs, yyk, yyrule]b4_user_args[));
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
yyvalp]b4_locuser_args[);
}
@@ -1328,7 +1332,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
}
yyupdateSplit (yystackp, yys);
yystackp->yytops.yystates[yyk] = yys;
YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
YY_REDUCE_PRINT ((yyfalse, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
yystackp, yyvalp]b4_locuser_args[);
}
@@ -1424,11 +1428,9 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
}
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
{
yyGLRState** yynewStates;
yyGLRState** yynewStates = YY_NULLPTR;
yybool* yynewLookaheadNeeds;
yynewStates = YY_NULLPTR;
if (yystackp->yytops.yycapacity
> (YYSIZEMAX / (2 * sizeof yynewStates[0])))
yyMemoryExhausted (yystackp);
@@ -1856,9 +1858,9 @@ yycompressStack (yyGLRStack* yystackp)
yyr = yyp, yyp = yyq, yyq = yyp->yypred)
yyp->yypred = yyr;
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
yystackp->yyspaceLeft += (size_t) (yystackp->yynextFree - yystackp->yyitems);
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
yystackp->yyspaceLeft -= (size_t) (yystackp->yynextFree - yystackp->yyitems);
yystackp->yysplitPoint = YY_NULLPTR;
yystackp->yylastDeleted = YY_NULLPTR;
@@ -2062,7 +2064,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyarg[yycount++] = yytokenName (yyx);
{
size_t yysz = yysize + yytnamerr (YY_NULLPTR, yytokenName (yyx));
yysize_overflow |= yysz < yysize;
if (yysz < yysize)
yysize_overflow = yytrue;
yysize = yysz;
}
}
@@ -2087,7 +2090,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
size_t yysz = yysize + strlen (yyformat);
yysize_overflow |= yysz < yysize;
if (yysz < yysize)
yysize_overflow = yytrue;
yysize = yysz;
}
@@ -2260,7 +2264,6 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[
@@ -2352,7 +2355,7 @@ b4_dollar_popdef])[]dnl
size_t yys;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
yystackp->yytops.yylookaheadNeeds[yys] = (yybool) (yychar != YYEMPTY);
/* yyprocessOneStack returns one of three things:
@@ -2573,4 +2576,4 @@ m4_if(b4_prefix, [yy], [],
#define yylloc ]b4_prefix[lloc]])])[
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
+29 -16
View File
@@ -44,7 +44,7 @@
# filename member).
# We require a pure interface.
m4_define([b4_pure_flag], [1])
m4_define([b4_pure_flag], [1])
m4_include(b4_pkgdatadir/[c++.m4])
b4_bison_locations_if([m4_include(b4_pkgdatadir/[location.cc])])
@@ -166,6 +166,12 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
{
}
int
]b4_parser_class_name[::operator() ()
{
return parse ();
}
int
]b4_parser_class_name[::parse ()
{
@@ -184,9 +190,9 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
{]b4_locations_if([[
YYUSE (yylocationp);]])[
YYUSE (yyvaluep);
std::ostream& yyoutput = debug_stream ();
std::ostream& yyo = yyoutput;
YYUSE (yyo);
std::ostream& yyo = debug_stream ();
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
]b4_symbol_actions([printer])[
}
@@ -234,25 +240,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[
@@ -264,6 +273,10 @@ b4_location_define])])[
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
/// Parse. An alias for parse ().
/// \returns 0 iff parsing succeeded.
int operator() ();
/// Parse.
/// \returns 0 iff parsing succeeded.
virtual int parse ();
@@ -330,13 +343,13 @@ b4_defines_if(
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2015, 2018])[
// C++ GLR parser skeleton written by Akim Demaille.
]b4_disclaimer[
]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.
+100 -63
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,10 +185,15 @@ 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[ ();
/// Parse. An alias for parse ().
/// \returns 0 iff parsing succeeded.
int operator() ();
/// Parse.
/// \returns 0 iff parsing succeeded.
virtual int parse ();
@@ -206,6 +220,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[&);
@@ -256,8 +272,9 @@ b4_location_define])])[
/// Print the state stack on the debug stream.
virtual void yystack_print_ ();
// Debugging.
/// Debugging level.
int yydebug_;
/// Debug stream.
std::ostream* yycdebug_;
/// \brief Display a symbol type, value and location.
@@ -315,12 +332,15 @@ 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.
/// Moves the contents of that.
stack_symbol_type& operator= (stack_symbol_type& that);
#endif
};
/// Stack type.
@@ -332,20 +352,20 @@ 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);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
/// Constants.
enum
@@ -377,6 +397,10 @@ b4_location_define])])[
]b4_percent_code_get([[provides]])[
]])
## -------------- ##
## Output files. ##
## -------------- ##
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
@@ -388,30 +412,28 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
// C++ LALR(1) parser skeleton written by Akim Demaille.
]b4_disclaimer[
]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
])
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
b4_percent_code_get([[top]])[]dnl
b4_output_begin([b4_parser_file_name])[
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])[
]b4_disclaimer[
]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])])[
// User implementation prologue.
]b4_user_post_prologue[
]b4_percent_code_get[
@@ -585,34 +607,40 @@ 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)])])[
#if defined __cplusplus && 201103L <= __cplusplus
// that is emptied.
that.state = empty_state;
#endif
}
]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= (stack_symbol_type& that)
{
state = that.state;
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [copy], [that.value])],
[value], [move], [that.value])],
[[value = that.value;]])[]b4_locations_if([
location = that.location;])[
// that is emptied.
that.state = empty_state;
return *this;
}
#endif
template <typename Base>
void
@@ -647,22 +675,26 @@ m4_if(b4_prefix, [yy], [],
#endif
void
]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym)
{
stack_symbol_type t (s, sym);
yypush_ (m, t);
}
void
]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
]b4_parser_class_name[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
{
if (m)
YY_SYMBOL_PRINT (m, s);
yystack_.push (s);
YY_SYMBOL_PRINT (m, sym);
yystack_.push (YY_MOVE (sym));
}
void
]b4_parser_class_name[::yypop_ (unsigned n)
]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
{
#if defined __cplusplus && 201103L <= __cplusplus
yypush_ (m, stack_symbol_type (s, std::move (sym)));
#else
stack_symbol_type ss (s, sym);
yypush_ (m, ss);
#endif
}
void
]b4_parser_class_name[::yypop_ (int n)
{
yystack_.pop (n);
}
@@ -716,6 +748,12 @@ m4_if(b4_prefix, [yy], [],
return yyvalue == yytable_ninf_;
}
int
]b4_parser_class_name[::operator() ()
{
return parse ();
}
int
]b4_parser_class_name[::parse ()
{
@@ -745,7 +783,6 @@ m4_if(b4_prefix, [yy], [],
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
// User initialization code.
b4_user_initial_action
b4_dollar_popdef])[]dnl
@@ -754,7 +791,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 +853,7 @@ b4_dollar_popdef])[]dnl
--yyerrstatus_;
// Shift the lookahead token.
yypush_ ("Shifting", yyn, yyla);
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate;
/*-----------------------------------------------------------.
@@ -839,7 +876,7 @@ b4_dollar_popdef])[]dnl
/* Variants are always initialized to an empty instance of the
correct type. The default '$$ = $1' action is NOT applied
when using variants. */
b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])], [
b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [emplace])], [
/* If YYLEN is nonzero, implement the default value of the
action: '$$ = $1'. Otherwise, use the top of the stack.
@@ -885,7 +922,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 +1011,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 +1217,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
+9 -12
View File
@@ -82,15 +82,14 @@ m4_define([b4_define_state],[[
]b4_yystype[ yylval = null;
]])
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2015, 2018])
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
])[/* First part of user declarations. */
]b4_user_pre_prologue
b4_user_post_prologue
b4_percent_code_get([[imports]])
b4_output_begin([b4_parser_file_name])[
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2015, 2018])[
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
]])[
]b4_user_pre_prologue[
]b4_user_post_prologue[
]b4_percent_code_get([[imports]])
[/**
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
*
@@ -586,7 +585,6 @@ b4_define_state])[
yystack.push (yystate, yylval ]b4_locations_if([, yylloc])[);
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef[]dnl
])[
@@ -597,7 +595,6 @@ b4_dollar_popdef[]dnl
push_parse_initialize ();
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef[]dnl
])[
@@ -1068,4 +1065,4 @@ b4_percent_code_get[]dnl
}
b4_epilogue[]dnl
b4_output_end()
b4_output_end
+69 -40
View File
@@ -18,11 +18,48 @@
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],
[[ /// Abstract a position.
# Define the position and location classes.
m4_define([b4_location_define],
[[ /// A point in a source file.
class position
{
public:]m4_ifdef([b4_location_constructors], [[
@@ -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.
/// Two points in a source file.
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])[
]b4_generated_by[
// 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])
+48 -42
View File
@@ -15,14 +15,19 @@
# 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
# ---------------
m4_define([b4_stack_define],
[[ /// A stack with random access from its top.
template <class T, class S = std::vector<T> >
template <typename T, typename S = std::vector<T> >
class stack
{
public:
@@ -31,12 +36,7 @@ m4_define([b4_stack_define],
typedef typename S::const_reverse_iterator const_iterator;
typedef typename S::size_type size_type;
stack ()
{
seq_.reserve (200);
}
stack (size_type n)
stack (size_type n = 200)
: seq_ (n)
{}
@@ -46,7 +46,16 @@ m4_define([b4_stack_define],
T&
operator[] (size_type i)
{
return seq_[seq_.size () - 1 - i];
return seq_[size () - 1 - i];
}
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (int i)
{
return operator[] (size_type (i));
}
/// Random access.
@@ -55,23 +64,32 @@ m4_define([b4_stack_define],
const T&
operator[] (size_type i) const
{
return seq_[seq_.size () - 1 - i];
return seq_[size () - 1 - i];
}
/// Random access.
///
/// Index 0 returns the topmost element.
const T&
operator[] (int i) const
{
return operator[] (size_type (i));
}
/// Steal the contents of \a t.
///
/// 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);
}
void
pop (size_type n = 1)
pop (int n = 1)
{
for (; n; --n)
for (; 0 < n; --n)
seq_.pop_back ();
}
@@ -107,47 +125,35 @@ m4_define([b4_stack_define],
};
/// Present a slice of the top of a stack.
template <class T, class S = stack<T> >
template <typename T, typename S = stack<T> >
class slice
{
public:
typedef typename S::size_type size_type;
slice (const S& stack, size_type range)
slice (const S& stack, int range)
: stack_ (stack)
, range_ (range)
{}
const T&
operator[] (size_type i) const
operator[] (int i) const
{
return stack_[range_ - i];
}
private:
const S& stack_;
size_type range_;
int range_;
};
]])
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])[
]b4_generated_by[
// 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[
]])
+85 -39
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.
@@ -117,7 +117,7 @@ m4_define([b4_variant_define],
/// Instantiate an empty \a T in here.
template <typename T>
T&
build ()
emplace ()
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
@@ -125,16 +125,47 @@ m4_define([b4_variant_define],
return *new (yyas_<T> ()) T ();
}
# if defined __cplusplus && 201103L <= __cplusplus
/// Instantiate a \a T in here from \a t.
template <typename T, typename U>
T&
emplace (U&& u)
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (std::forward <U>(u));
}
# else
/// Instantiate a \a T in here from \a t.
template <typename T>
T&
build (const T& t)
emplace (const T& t)
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (t);
}
# endif
/// Instantiate an empty \a T in here.
/// Obsolete, use emplace.
template <typename T>
T&
build ()
{
return emplace<T> ();
}
/// Instantiate a \a T in here from \a t.
/// Obsolete, use emplace.
template <typename T>
T&
build (const T& t)
{
return emplace<T> (t);
}
/// Accessor to a built \a T.
template <typename T>
@@ -163,7 +194,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>
@@ -182,17 +213,32 @@ m4_define([b4_variant_define],
void
move (self_type& other)
{
build<T> ();
# if defined __cplusplus && 201103L <= __cplusplus
emplace<T> (std::move (other.as<T> ()));
# else
emplace<T> ();
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)
{
emplace<T> (std::move (other.as<T> ()));
other.destroy<T> ();
}
#endif
/// Copy the content of \a other to this.
template <typename T>
void
copy (const self_type& other)
{
build<T> (other.as<T> ());
emplace<T> (other.as<T> ());
}
/// Destroy the stored \a T.
@@ -206,7 +252,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 +301,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 +329,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 +351,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 +379,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 +406,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])])
+2 -2
View File
@@ -83,7 +83,7 @@
<xsl:param name="staten"/>
<xsl:for-each select='reduction'>
<!-- These variables are needed because the current context can't be
refered to directly in XPath expressions. -->
referred to directly in XPath expressions. -->
<xsl:variable name="rul">
<xsl:value-of select="@rule"/>
</xsl:variable>
@@ -95,7 +95,7 @@
<xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
<xsl:variable name="rule">
<xsl:choose>
<!-- The acceptation state is refered to as 'accept' in the XML, but
<!-- The acceptation state is referred to as 'accept' in the XML, but
just as '0' in the DOT. -->
<xsl:when test="@rule='accept'">
<xsl:text>0</xsl:text>
+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>
+42 -49
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
])
@@ -299,9 +299,8 @@ m4_define([b4_shared_declarations],
## Output files. ##
## -------------- ##
b4_output_begin([b4_parser_file_name])
b4_copyright([Bison implementation for Yacc-like parsers in C])[
b4_output_begin([b4_parser_file_name])[
]b4_copyright([Bison implementation for Yacc-like parsers in C])[
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
@@ -312,8 +311,9 @@ b4_copyright([Bison implementation for Yacc-like parsers in C])[
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
]b4_identification
b4_percent_code_get([[top]])[]dnl
]b4_disclaimer[
]b4_identification[
]b4_percent_code_get([[top]])[]dnl
m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
@@ -335,9 +335,7 @@ m4_if(b4_api_prefix, [yy], [],
#define yychar ]b4_prefix[char]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])]))[
/* Copy the first part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
/* Enabling verbose error messages. */
@@ -354,9 +352,8 @@ m4_if(b4_api_prefix, [yy], [],
]])dnl
b4_shared_declarations[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
]b4_user_post_prologue[
]b4_percent_code_get[]dnl
[#ifdef short
# undef short
@@ -791,7 +788,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
yytype_int16 **yytop, yytype_int16 *yytop_empty)
{
YYSIZE_T yysize_old =
*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
(YYSIZE_T) (*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1);
YYSIZE_T yysize_new = yysize_old + yyadd;
if (*yycapacity < yysize_new)
{
@@ -957,7 +954,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
YYDPRINTF ((stderr, " R%d", yyrule - 1));
if (yyesp != yyes_prev)
{
YYSIZE_T yysize = yyesp - *yyes + 1;
YYSIZE_T yysize = (YYSIZE_T) (yyesp - *yyes + 1);
if (yylen < yysize)
{
yyesp -= yylen;
@@ -973,15 +970,14 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
yyesp = yyes_prev -= yylen;
}
{
int yystate;
yytype_int16 yystate;
{
int yylhs = yyr1[yyrule] - YYNTOKENS;
yystate = yypgoto[yylhs] + *yyesp;
if (yystate < 0 || YYLAST < yystate
|| yycheck[yystate] != *yyesp)
yystate = yydefgoto[yylhs];
else
yystate = yytable[yystate];
const int yylhs = yyr1[yyrule] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyesp;
yystate = ((yytype_int16)
(0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
? yytable[yyi]
: yydefgoto[yylhs]));
}
if (yyesp == yyes_prev)
{
@@ -1001,7 +997,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
}
*++yyesp = yystate;
}
YYDPRINTF ((stderr, " G%d", yystate));
YYDPRINTF ((stderr, " G%d", (int) yystate));
}
}
}]])[
@@ -1089,7 +1085,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -1433,7 +1429,6 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
[b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef[]dnl
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
@@ -1451,12 +1446,12 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
yyssp++;
yysetstate:
*yyssp = yystate;
*yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
#ifdef yyoverflow
{
@@ -1476,10 +1471,9 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
&yyls1, yysize * sizeof (*yylsp),])[
&yystacksize);
]b4_locations_if([
yyls = yyls1;])[
yyss = yyss1;
yyvs = yyvs1;
yyvs = yyvs1;]b4_locations_if([
yyls = yyls1;])[
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
@@ -1653,7 +1647,7 @@ yyreduce:
int yychar_backup = yychar;
switch (yyn)
{
]b4_user_actions[
]b4_user_actions[
default: break;
}
if (yychar_backup != yychar)
@@ -1687,14 +1681,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
{
const int yylhs = yyr1[yyn] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyssp;
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
? yytable[yyi]
: yydefgoto[yylhs]);
}
goto yynewstate;
@@ -1908,12 +1901,12 @@ yypushreturn:]])[
return yyresult;
}
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])[
b4_defines_if([[
]b4_output_begin([b4_spec_defines_file])[
]b4_copyright([Bison interface for Yacc-like parsers in C])[
]b4_disclaimer[
]b4_shared_declarations[
]b4_output_end()
])# b4_defines_if
]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
+12 -10
View File
@@ -1,25 +1,28 @@
# Do not ignore these. The release procedure (web-manual-update)
# works in the src tree (even when run from the build tree) and leaves
# these files around. Since they take precedence over the files in
# the build tree, locally built manuals use obsolete auxiliary files.
#
# So don't hide them, give the maintainer a chance to clean them.
#/bison.aux
#/bison.cp
#/bison.cps
#/bison.toc
/*~
/.dirstamp
/bison.1
/bison.aux
/bison.cp
/bison.cps
/bison.dvi
/bison.fn
/bison.help
/bison.html
/bison.info
/bison.ky
/bison.log
/bison.pdf
/bison.pg
/bison.ps
/bison.toc
/bison.tp
/bison.vr
/cross-options.texi
/fdl.texi
/gendocs_template
/gendocs_template_min
/gpl-3.0.texi
/refcard.dvi
/refcard.log
@@ -27,4 +30,3 @@
/stamp-vti
/version.texi
/yacc.1
/gendocs_template_min
+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.
#
+825 -340
View File
File diff suppressed because it is too large Load Diff
+19 -18
View File
@@ -30,11 +30,9 @@ $(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
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.tmp
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
@@ -44,8 +42,8 @@ $(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
# diff in the next run. Note that $@ might not exist yet.
$(AM_V_GEN){ test ! -f $@ || cat $@; } >$@~
$(AM_V_at)test ! -f $@.tmp || rm -f $@.tmp
$(AM_V_at)src/bison$(EXEEXT) --help | \
$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
$(AM_V_at)$(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l \
<$(top_srcdir)/doc/bison.help >$@.tmp
$(AM_V_at)diff -u $@~ $@.tmp || true
$(AM_V_at)mv $@.tmp $@
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
@@ -66,9 +64,9 @@ doc/refcard.pdf: doc/refcard.tex
## doc/bison.help. ##
## ---------------- ##
# Some of our targets (cross-option.texi, bison.1) use "bison --help".
# Some of our targets (cross-options.texi, bison.1) use "bison --help".
# Since we want to ship the generated file to avoid additional
# requirements over the user environment, we used not depend on
# requirements over the user environment, we used to not depend on
# src/bison itself, but on src/getargs.c and other files. Yet, we
# need "bison --help" to work to make help2man happy, so we used to
# include "make src/bison" in the commands. Then we may have a
@@ -82,15 +80,18 @@ doc/refcard.pdf: doc/refcard.tex
# bison.help, which contains --version then --help. This file can
# depend on bison, which ensures its correctness. But update it
# *only* if needed (content changes). This way, we avoid useless
# compilations of cross-option.texi and bison.1. At the cost of
# compilations of cross-options.texi and bison.1. At the cost of
# repeated builds of bison.help.
EXTRA_DIST += $(top_srcdir)/doc/bison.help
if ! CROSS_COMPILING
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
$(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp
$(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp
$(AM_V_GEN)LC_ALL=C src/bison$(EXEEXT) --version >doc/bison.help.tmp
$(AM_V_at) LC_ALL=C src/bison$(EXEEXT) --help | \
## Avoid variations in the output depending on whether we are
## on a glibc system.
sed '/translation bugs/d' >>doc/bison.help.tmp
$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@
endif ! CROSS_COMPILING
@@ -116,14 +117,14 @@ endif
$(top_srcdir)/doc/bison.1: $(MAN_DEPS)
$(AM_V_GEN)$(HELP2MAN) \
--include=$(top_srcdir)/doc/bison.x \
--output=$@.t src/bison$(EXEEXT)
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
touch $@; \
else \
mv $@.t $@; \
--output=$@.tmp src/bison$(EXEEXT)
$(AM_V_at)if $(remove_time_stamp) $@ >$@a.tmp 2>/dev/null && \
$(remove_time_stamp) $@.tmp | cmp $@a.tmp - >/dev/null 2>&1; then \
touch $@; \
else \
mv $@.tmp $@; \
fi
$(AM_V_at)rm -f $@*.t
$(AM_V_at)rm -f $@*.tmp
if ENABLE_YACC
nodist_man_MANS = doc/yacc.1
+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
+38 -24
View File
@@ -1,40 +1,54 @@
This directory contains examples of Bison grammar files.
* mfcalc
A C example of a multi-function calculator. Extracted from the
documentation.
Most of them come from the documentation, which should be installed together
with Bison. The URLs are provided for convenience.
* calc++
A C++ version of the canonical example for parsers: a calculator. Also uses
Flex for the scanner. Extracted from the documentation.
* variant.yy
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).
* Examples in C
** rpcalc - Reverse Polish Notation Calculator
The first example is that of a simple double-precision Reverse Polish
Notation calculator (a calculator using postfix operators). This example
provides a good starting point, since operator precedence is not an issue.
Extracted from the documentation: "Reverse Polish Notation Calculator"
https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
** mfcalc - Multi-Function Calculator
A more complete C example: a multi-function calculator.
Extracted from the documentation: "Multi-Function Calculator: mfcalc".
https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
* Examples in C++
** c++ - A directory of simple C++ examples
** calc++ - A Complete C++ Example
A fully featured C++ version of the canonical example for parsers: a
calculator. Also uses Flex for the scanner.
Extracted from the documentation: "A Complete C++ Example".
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
-----
Local Variables:
mode: outline
fill-column: 76
ispell-dictionary: "american"
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
+21
View File
@@ -0,0 +1,21 @@
# This Makefile is designed to be simple and readable. It does not
# aim at portability. It requires GNU Make.
BISON = bison
CXX = g++
CXXFLAGS =
PROGS = simple variant variant-11
simple: CXXFLAGS = -std=c++14
variant-11: CXXFLAGS = -std=c++11
all: $(PROGS)
%.cc %.hh: %.yy
$(BISON) $(BISONFLAGS) -o $*.cc $<
%: %.cc
$(CXX) $(CXXFLAGS) -o$@ $<
clean:
rm -f $(PROGS:=.cc) $(PROGS)
+47
View File
@@ -0,0 +1,47 @@
This directory contains examples of Bison grammar files in C++.
* Examples in C++
You can run `make` to compile these examples. And `make clean` to tidy
afterwards.
** simple.yy - Simple example in C++14
A very simple example in C++, based on variants and symbol constructors.
Variants allow to use any C++ type as semantic value type, and symbol
constructors ensure consistency between declared token type and effective
semantic value.
Run as `./simple`.
Extracted from the documentation: "A Simple C++ Example".
https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html
** variant.yy - Self-contained example in C++98
A variation of simple.yy, in C++98.
Run as `./variant`.
** variant-11.yy - Self-contained example in modern C++
Another variation of simple.yy, closely related to the previous one, but
exhibiting support for C++11's move semantics.
Run as `./variant` or `./variant NUMBER`.
-----
Local Variables:
mode: outline
fill-column: 76
ispell-dictionary: "american"
End:
Copyright (C) 2018 Free Software Foundation, Inc.
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 ispell american
+70
View File
@@ -0,0 +1,70 @@
## 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/>.
cxxdir = $(examplesdir)/c++
## -------- ##
## Simple. ##
## -------- ##
BUILT_SOURCES += $(simple_sources)
CLEANFILES += %D%/simple.[ch] %D%/simple.output
CLEANDIRS += %D%/*.dSYM
cxx_DATA = $(simple_extracted)
simple_extracted = %D%/simple.yy
simple_sources = $(simple_extracted)
extracted += $(simple_extracted)
if ENABLE_CXX14
check_PROGRAMS += %D%/simple
nodist_%C%_simple_SOURCES = $(simple_sources)
%C%_simple_CXXFLAGS = $(CXX11_CXXFLAGS)
# Don't use gnulib's system headers.
%C%_simple_CPPFLAGS = -I$(top_builddir)
TESTS += %D%/simple.test
%D%/simple.cc: $(BISON_IN) $(dist_pkgdata_DATA)
endif
EXTRA_DIST += %D%/simple.test
## ---------- ##
## Variants. ##
## ---------- ##
if ENABLE_CXX
check_PROGRAMS += %D%/variant
nodist_%C%_variant_SOURCES = %D%/variant.yy
# Don't use gnulib's system headers.
%C%_variant_CPPFLAGS = -I$(top_builddir)
TESTS += %D%/variant.test
%D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
endif
EXTRA_DIST += %D%/variant.test
if ENABLE_CXX11
check_PROGRAMS += %D%/variant-11
nodist_%C%_variant_11_SOURCES = %D%/variant-11.yy
%C%_variant_11_CXXFLAGS = $(CXX11_CXXFLAGS)
# Don't use gnulib's system headers.
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
TESTS += %D%/variant-11.test
%D%/variant-11.cc: $(BISON_IN) $(dist_pkgdata_DATA)
endif
EXTRA_DIST += %D%/variant-11.test
dist_cxx_DATA = %D%/README %D%/Makefile %D%/variant.yy %D%/variant-11.yy
CLEANFILES += %D%/simple.output %D%/variant.output %D%/variant-11.output
+4
View File
@@ -0,0 +1,4 @@
#! /bin/sh
: >input
run 0 "{I have three numbers for you., 1, 2, 3, And that's all!}"
+21
View File
@@ -0,0 +1,21 @@
#! /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 numbers for you., 1, 2, 3, And that's all!}" 4
run 0 "{I have numbers for you., 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, And that's all!}" 1000
+152
View File
@@ -0,0 +1,152 @@
/*
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)...});
}
}
%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 (std::to_string ($1)); }
;
%%
// The last number return by the scanner is max - 1.
int max = 4;
namespace yy
{
// The yylex function providing subsequent tokens:
// TEXT "I have three numbers for you."
// NUMBER 1
// NUMBER 2
// NUMBER ...
// NUMBER max - 1
// TEXT "And that's all!"
// END_OF_FILE
static
parser::symbol_type
yylex ()
{
static int count = 0;
const int stage = count;
++count;
auto loc = parser::location_type{nullptr, unsigned (stage + 1), unsigned (stage + 1)};
if (stage == 0)
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
else if (stage < max)
return parser::make_NUMBER (stage, std::move (loc));
else if (stage == max)
return parser::make_TEXT (make_string_uptr ("And that's all!"), std::move (loc));
else
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 (int argc, const char *argv[])
{
if (2 <= argc && isdigit (*argv[1]))
max = strtol (argv[1], nullptr, 10);
auto&& p = yy::parser{};
p.set_debug_level (!!getenv ("YYDEBUG"));
return p.parse ();
}
// Local Variables:
// mode: C++
// End:
+20 -15
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,13 +90,20 @@ list:
;
item:
TEXT { std::swap ($$, $1); }
| NUMBER { $$ = string_cast ($1); }
TEXT
| NUMBER { $$ = to_string ($1); }
;
%%
namespace yy
{
// Use nullptr with pre-C++11.
#if !defined __cplusplus || __cplusplus < 201103L
# define NULLPTR 0
#else
# define NULLPTR nullptr
#endif
// The yylex function providing subsequent tokens:
// TEXT "I have three numbers for you."
// NUMBER 1
@@ -112,9 +116,10 @@ namespace yy
parser::symbol_type
yylex ()
{
static int stage = -1;
++stage;
parser::location_type loc(YY_NULLPTR, stage + 1, stage + 1);
static int count = 0;
const int stage = count;
++count;
parser::location_type loc (NULLPTR, unsigned (stage + 1), unsigned (stage + 1));
switch (stage)
{
case 0:
+2 -1
View File
@@ -29,6 +29,7 @@ the scanner's.
Local Variables:
mode: outline
fill-column: 76
ispell-dictionary: "american"
End:
Copyright (C) 2018 Free Software Foundation, Inc.
@@ -48,4 +49,4 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
# LocalWords: mfcalc calc parsers yy MERCHANTABILITY
# LocalWords: mfcalc calc parsers yy MERCHANTABILITY Ctrl ispell american
+11 -3
View File
@@ -19,7 +19,8 @@ cat >input <<EOF
toto := 1
toto
EOF
run 0 1 -s
run 0 1
run -noerr 0 1 -s
cat >input <<EOF
@@ -30,7 +31,7 @@ d := a + b * c
d
EOF
run 0 7
run 0 7 -p
run -noerr 0 7 -p
cat >input <<EOF
@@ -47,4 +48,11 @@ cat >input <<EOF
a := 1
d := a + b * c
EOF
run 1 ''
run 1 'err: -:3.1: syntax error, unexpected end of file, expecting ( or identifier or number'
cat >input <<EOF
a := 072101108108111044032119111114108100033
a
EOF
run 1 'err: -:1.6-44: integer is out of range: 072101108108111044032119111114108100033'
+26 -28
View File
@@ -1,18 +1,18 @@
# Copyright (C) 2005-2006, 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/>.
## Copyright (C) 2005-2006, 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/>.
## ------------------- ##
## Parser generation. ##
@@ -36,7 +36,7 @@ CLEANFILES += \
%D%/parser.output \
%D%/parser.stamp \
%D%/scanner.cc
CLEANDIRS += %D%/*.dSYM
## -------------------- ##
## Building & testing. ##
@@ -57,24 +57,22 @@ extracted += $(calcxx_extracted)
calcxx_sources_generated = \
%D%/parser.cc \
%D%/parser.hh \
%D%/location.hh \
%D%/position.hh \
%D%/stack.hh
%D%/location.hh
calcxx_sources = \
$(calcxx_sources_extracted) \
$(calcxx_sources_generated)
if FLEX_CXX_WORKS
check_PROGRAMS += %D%/calc++
nodist_%C%_calc___SOURCES = \
$(calcxx_sources)
%C%_calc___CPPFLAGS = -I$(top_builddir)/%D%
%C%_calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
dist_TESTS += %D%/calc++.test
else
if ENABLE_CXX
check_PROGRAMS += %D%/calc++
nodist_%C%_calc___SOURCES = $(calcxx_sources)
# Don't use gnulib's system headers.
%C%_calc___CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
TESTS += %D%/calc++.test
endif ENABLE_CXX
endif FLEX_CXX_WORKS
EXTRA_DIST += %D%/calc++.test
endif
## ------------ ##
+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}{$_}
+43 -21
View File
@@ -1,17 +1,17 @@
# Copyright (C) 2005, 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/>.
## Copyright (C) 2005, 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/>.
dist_noinst_SCRIPTS = %D%/extexi %D%/test
TEST_LOG_COMPILER = $(top_srcdir)/%D%/test
@@ -30,9 +30,11 @@ EXTEXIFLAGS = --synclines
endif
extract = VERSION="$(VERSION)" $(PERL) $(extexi) $(EXTEXIFLAGS) $(doc) --
extracted =
CLEANFILES += $(extracted) %D%/extracted.stamp
EXTRA_DIST += $(extracted)
MAINTAINERCLEANFILES += $(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 $@
@@ -41,19 +43,39 @@ $(extracted): %D%/extracted.stamp
@test -f $@ || rm -f %D%/extracted.stamp
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/extracted.stamp
## ------ ##
## Dist. ##
## ------ ##
# Ship the stamp file, otherwise it will be recreated, which is what
# we want to avoid.
EXTRA_DIST += %D%/extracted.stamp
# Suppress the #lines from the examples when rolling the tarball, so
# that regular users have readable examples even before installing
# Bison.
dist-hook: examples-unline
.PHONY: examples-unline
examples-unline:
for e in $(extracted); \
do \
e=$(distdir)/$$e; \
sed -e '/#line/d' $$e >$$e.tmp; \
mv -f $$e.tmp $$e; \
done
## ---------- ##
## Examples. ##
## ---------- ##
examplesdir = $(docdir)/examples
dist_examples_DATA = %D%/README %D%/variant.yy
check_PROGRAMS += %D%/variant
nodist_%C%_variant_SOURCES = %D%/variant.yy
%C%_variant_CPPFLAGS = -I$(top_builddir)
dist_TESTS += %D%/variant.test
dist_examples_DATA = %D%/README
CLEANDIRS += %D%/*.dSYM
include %D%/calc++/local.mk
include %D%/c++/local.mk
include %D%/mfcalc/local.mk
include %D%/rpcalc/local.mk
+18 -16
View File
@@ -1,18 +1,18 @@
# Copyright (C) 2005-2006, 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/>.
## Copyright (C) 2005-2006, 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/>.
## -------------------- ##
## Building & testing. ##
@@ -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)
@@ -27,7 +28,8 @@ extracted += $(mfcalc_extracted)
check_PROGRAMS += %D%/mfcalc
nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
%C%_mfcalc_CPPFLAGS = -I$(top_builddir)/%D%
# Don't use gnulib's system headers.
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_mfcalc_LDADD = -lm
dist_TESTS += %D%/mfcalc.test
+1 -1
View File
@@ -24,4 +24,4 @@ cat >input <<EOF
(1+2) * 3
EOF
run 0 9
run 0 9 -p
run -noerr 0 9 -p
+17 -15
View File
@@ -1,18 +1,18 @@
# Copyright (C) 2005-2006, 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/>.
## Copyright (C) 2005-2006, 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/>.
## -------------------- ##
## Building & testing. ##
@@ -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)
@@ -27,6 +28,7 @@ extracted += $(rpcalc_extracted)
check_PROGRAMS += %D%/rpcalc
nodist_%C%_rpcalc_SOURCES = $(rpcalc_sources)
# Don't use gnulib's system headers.
%C%_rpcalc_CPPFLAGS = -I$(top_builddir)/%D%
%C%_rpcalc_LDADD = -lm
+21 -14
View File
@@ -15,7 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
me=`basename $1 .test`
me=$(basename "$1" .test)
medir=$(basename "$(dirname "$1")")
# Number of the current test.
number=1
@@ -23,11 +24,11 @@ number=1
# Exit status of this script.
exit=true
# top_buiddir.
cwd=`pwd`
# top_builddir.
cwd=$(pwd)
# The exercised program.
for p in $cwd/examples/$me/$me $cwd/examples/$me
for p in "$cwd/examples/$medir/$me" "$cwd/examples/$me"
do
if test -x "$p"; then
prog=$p
@@ -44,7 +45,7 @@ fi
# -------
cleanup ()
{
local status=$?
status=$?
if test -z "$DEBUG"; then
cd $cwd
rm -rf $$.dir
@@ -55,21 +56,27 @@ trap cleanup 0 1 2 13 15
mkdir $$.dir
cd $$.dir
# run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
# ---------------------------------------------------------
# run [-noerr] EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
# ------------------------------------------------------------------
# -noerr: ignore stderr, otherwise merge it into effective output.
run ()
{
noerr=false
case $1 in
(-noerr) noerr=true; shift;;
esac
# Expected exit status.
local sta_exp=$1
sta_exp=$1
shift
# Expected output.
local out_exp=$1
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`
sta_eff=0
$prog "$@" - <input >out_eff 2>err_eff || sta_eff=$?
# Combine effective output and error streams.
out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff)
if test $sta_eff -eq $sta_exp; then
if test "$out_eff" = "$out_exp"; then
echo "$me: PASS: $number"
@@ -81,7 +88,7 @@ run ()
echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)"
exit=false
fi
number=`expr $number + 1`
number=$(expr $number + 1)
}
# We have cd'd one level deeper.
+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
+68 -124
View File
@@ -35,33 +35,28 @@
static bitset_bindex
abitset_resize (bitset src, bitset_bindex size)
{
/* These bitsets have a fixed size. */
if (BITSET_SIZE_ (src) != size)
abort ();
/* These bitsets have a fixed size. */
if (BITSET_SIZE_ (src) != size)
abort ();
return size;
return size;
}
/* 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_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,36 +138,27 @@ 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_bindex rbitno = *next;
bitset_word *srcp = ABITSET_WORDS (src);
bitset_bindex n_bits = BITSET_SIZE_ (src);
rbitno = *next;
/* If num is 1, we could speed things up with a binary search
of the word of interest. */
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 +183,20 @@ 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. */
@@ -242,7 +226,7 @@ abitset_list (bitset src, bitset_bindex *list,
on the previous call to this function. */
bitoff = windex * BITSET_WORD_BITS;
word = srcp[windex] >> bitno;
bitset_word word = srcp[windex] >> bitno;
for (bitno = bitoff + bitno; word; bitno++)
{
if (word & 1)
@@ -263,7 +247,8 @@ abitset_list (bitset src, bitset_bindex *list,
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
bitset_word word = srcp[windex];
if (!word)
continue;
if ((count + BITSET_WORD_BITS) < num)
@@ -302,9 +287,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 +298,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 +309,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,13 +318,11 @@ 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;
return true;
}
@@ -355,10 +332,9 @@ abitset_copy1 (bitset dst, bitset src)
{
bitset_word *srcp = ABITSET_WORDS (src);
bitset_word *dstp = ABITSET_WORDS (dst);
bitset_windex size = dst->b.csize;
if (srcp == dstp)
return;
return;
bitset_windex size = dst->b.csize;
memcpy (dstp, srcp, sizeof (bitset_word) * size);
}
@@ -366,13 +342,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 +355,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 +369,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,15 +383,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,31 +397,28 @@ 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++;
if (*dstp != tmp)
{
changed = true;
@@ -464,31 +432,28 @@ 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++);
if (*dstp != tmp)
{
changed = true;
@@ -502,28 +467,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,28 +503,26 @@ 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++)
*dstp++ = *src1p++ ^ *src2p++;
for (bitset_windex i = 0; i < size; i++)
*dstp++ = *src1p++ ^ *src2p++;
}
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 +539,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,10 +560,9 @@ 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++;
if (*dstp != tmp)
{
changed = true;
@@ -618,22 +576,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,10 +597,9 @@ 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++;
if (*dstp != tmp)
{
changed = true;
@@ -658,22 +613,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,10 +634,9 @@ 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++;
if (*dstp != tmp)
{
changed = true;
@@ -699,9 +651,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 +736,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,19 +758,13 @@ 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.
There is probably little merit if using caching since
the small bitset will always fit in the cache. */
if (size == 1)
bset->b.vtable = &abitset_small_vtable;
else
bset->b.vtable = &abitset_vtable;
bset->b.vtable = size == 1 ? &abitset_small_vtable : &abitset_vtable;
bset->b.cindex = 0;
bset->b.csize = size;
bset->b.cdata = ABITSET_WORDS (bset);
+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
+21 -13
View File
@@ -21,12 +21,20 @@
#ifndef _BBITSET_H
#define _BBITSET_H
#include "libiberty.h"
#include <stdbool.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include "xalloc.h"
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x)
# endif
#endif
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
/* Currently we support five flavours of bitsets:
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
Memory for bit array and bitset structure allocated
@@ -281,24 +289,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 */
+33 -57
View File
@@ -24,12 +24,14 @@
#include <stdlib.h>
#include <string.h>
#include "obstack.h"
#include "abitset.h"
#include "lbitset.h"
#include "ebitset.h"
#include "vbitset.h"
#include "bitset_stats.h"
#include "obstack.h"
const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
@@ -39,8 +41,6 @@ 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 ();
@@ -50,23 +50,17 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
abort ();
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
break;
return abitset_bytes (n_bits);
case BITSET_LIST:
bytes = lbitset_bytes (n_bits);
break;
return lbitset_bytes (n_bits);
case BITSET_TABLE:
bytes = ebitset_bytes (n_bits);
break;
return ebitset_bytes (n_bits);
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
break;
return vbitset_bytes (n_bits);
}
return bytes;
}
@@ -134,12 +128,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 +145,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 +159,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,11 +186,9 @@ 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;
return type;
return bitset_stats_type_get (bset);
}
@@ -214,9 +198,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];
}
@@ -227,9 +209,8 @@ bitset_type_name_get (bitset bset)
bitset_bindex
bitset_next (bitset src, bitset_bindex bitno)
{
bitset_bindex val;
bitset_bindex next = bitno;
bitset_bindex val;
if (!bitset_list (src, &val, 1, &next))
return BITSET_BINDEX_MAX;
return val;
@@ -240,7 +221,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);
}
@@ -249,9 +230,8 @@ bitset_compatible_p (bitset bset1, bitset bset2)
bitset_bindex
bitset_prev (bitset src, bitset_bindex bitno)
{
bitset_bindex val;
bitset_bindex next = bitno;
bitset_bindex val;
if (!bitset_list_reverse (src, &val, 1, &next))
return BITSET_BINDEX_MAX;
return val;
@@ -291,15 +271,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)
@@ -310,7 +288,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
fprintf (file, "%lu ", (unsigned long) i);
pos += 1 + (i >= 10) + (i >= 100);
};
}
if (verbose)
fprintf (file, "}\n");
@@ -357,7 +335,7 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
bitset_bindex
bitset_size_ (bitset src)
{
return BITSET_NBITS_ (src);
return BITSET_NBITS_ (src);
}
@@ -366,18 +344,18 @@ bitset_bindex
bitset_count_ (bitset src)
{
bitset_bindex list[BITSET_LIST_SIZE];
bitset_bindex next;
bitset_bindex num;
bitset_bindex count;
bitset_bindex count = 0;
/* This could be greatly sped up by adding a count method for each
bitset implementation that uses a direct technique (based on
masks) for counting the number of bits set in a word. */
next = 0;
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
count += num)
continue;
{
bitset_bindex next = 0;
bitset_bindex num;
while ((num = bitset_list (src, list, BITSET_LIST_SIZE, &next)))
count += num;
}
return count;
}
@@ -398,7 +376,7 @@ bitset_copy_ (bitset dst, bitset src)
BITSET_FOR_EACH (iter, src, i, 0)
{
bitset_set (dst, i);
};
}
return true;
}
@@ -411,13 +389,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)
+30 -35
View File
@@ -24,14 +24,14 @@
/* This file is the public interface to the bitset abstract data type.
Only use the functions and macros defined in this file. */
#include "bbitset.h"
#include "obstack.h"
#include <stdio.h>
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
#include "bbitset.h"
#include "obstack.h"
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
BITSET_VARIABLE = 2, /* Bitset size variable. */
@@ -83,7 +83,6 @@ union bitset_union
struct bbitset_struct b;
bitset_windex size; /* Allocated size of array. */
} v;
};
@@ -99,37 +98,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 +180,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 +280,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
@@ -309,9 +308,7 @@ extern void bitset_dump (FILE *, bitset);
bitset_iterator iter;
BITSET_FOR_EACH (iter, src, i, 0)
{
printf ("%lu ", (unsigned long) i);
};
printf ("%lu ", (unsigned long) i);
*/
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
@@ -331,9 +328,7 @@ extern void bitset_dump (FILE *, bitset);
bitset_iterator iter;
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
{
printf ("%lu ", (unsigned long) i);
};
printf ("%lu ", (unsigned long) i);
*/
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
@@ -368,13 +363,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 +378,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 */
+84 -82
View File
@@ -29,18 +29,19 @@
#include "bitset_stats.h"
#include "bbitset.h"
#include "abitset.h"
#include "ebitset.h"
#include "lbitset.h"
#include "vbitset.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gettext.h"
#define _(Msgid) gettext (Msgid)
#include "abitset.h"
#include "bbitset.h"
#include "ebitset.h"
#include "lbitset.h"
#include "vbitset.h"
/* Configuration macros. */
#define BITSET_STATS_FILE "bitset.dat"
#define BITSET_LOG_COUNT_BINS 10
@@ -108,18 +109,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 +130,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 +205,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 +213,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 +240,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 +268,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 +346,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);
}
@@ -378,7 +372,7 @@ bitset_stats_test (bitset src, bitset_bindex bitno)
static bitset_bindex
bitset_stats_resize (bitset src, bitset_bindex size)
{
return BITSET_RESIZE_ (src->s.bset, size);
return BITSET_RESIZE_ (src->s.bset, size);
}
@@ -573,35 +567,40 @@ static bitset_bindex
bitset_stats_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex count;
bitset_bindex tmp;
bitset_bindex size;
bitset_bindex i;
count = BITSET_LIST_ (bset->s.bset, list, num, next);
bitset_bindex 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;
if (i >= BITSET_LOG_COUNT_BINS)
i = BITSET_LOG_COUNT_BINS - 1;
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
{
bitset_bindex i;
bitset_bindex tmp;
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
continue;
if (i >= BITSET_LOG_COUNT_BINS)
i = BITSET_LOG_COUNT_BINS - 1;
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
}
/* Log histogram of number of bits in set. */
size = BITSET_SIZE_ (bset->s.bset);
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
continue;
if (i >= BITSET_LOG_SIZE_BINS)
i = BITSET_LOG_SIZE_BINS - 1;
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
bitset_bindex size = BITSET_SIZE_ (bset->s.bset);
{
bitset_bindex i;
bitset_bindex tmp;
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
continue;
if (i >= BITSET_LOG_SIZE_BINS)
i = BITSET_LOG_SIZE_BINS - 1;
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
}
/* Histogram of fraction of bits set. */
i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
if (i >= BITSET_DENSITY_BINS)
i = BITSET_DENSITY_BINS - 1;
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
{
bitset_bindex i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
if (i >= BITSET_DENSITY_BINS)
i = BITSET_DENSITY_BINS - 1;
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
}
return count;
}
@@ -663,7 +662,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 +676,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. */
@@ -697,32 +693,38 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
abort ();
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
abitset_init (sbset, n_bits);
{
size_t bytes = abitset_bytes (n_bits);
bset->s.bset = xcalloc (1, bytes);
abitset_init (bset->s.bset, n_bits);
}
break;
case BITSET_LIST:
bytes = lbitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
lbitset_init (sbset, n_bits);
{
size_t bytes = lbitset_bytes (n_bits);
bset->s.bset = xcalloc (1, bytes);
lbitset_init (bset->s.bset, n_bits);
}
break;
case BITSET_TABLE:
bytes = ebitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
ebitset_init (sbset, n_bits);
{
size_t bytes = ebitset_bytes (n_bits);
bset->s.bset = xcalloc (1, bytes);
ebitset_init (bset->s.bset, n_bits);
}
break;
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
vbitset_init (sbset, n_bits);
{
size_t bytes = vbitset_bytes (n_bits);
bset->s.bset = xcalloc (1, bytes);
vbitset_init (bset->s.bset, n_bits);
}
break;
}
bset->s.bset = sbset;
BITSET_STATS_ALLOCS_INC (type);
return bset;
+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 */
+121 -254
View File
@@ -22,10 +22,11 @@
#include "ebitset.h"
#include "obstack.h"
#include <stdlib.h>
#include <string.h>
#include "obstack.h"
/* This file implements expandable bitsets. These bitsets can be of
arbitrary length and are more efficient than arrays of bits for
large sparse sets.
@@ -73,7 +74,7 @@ typedef ebitset_elt *ebitset_elts;
/* Number of elements to initially allocate. */
#ifndef EBITSET_INITIAL_SIZE
#define EBITSET_INITIAL_SIZE 2
# define EBITSET_INITIAL_SIZE 2
#endif
@@ -123,19 +124,14 @@ 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)
{
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
if (newsize > EBITSET_ASIZE (src))
@@ -145,11 +141,7 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
grow the bitset 25% larger than requested to reduce
number of reallocations. */
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4;
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = size;
@@ -234,9 +226,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 +244,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 +256,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,12 +266,9 @@ 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;
return true;
}
@@ -296,24 +277,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 +308,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 +325,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,17 +365,13 @@ 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];
if (elt)
ebitset_elt_remove (bset, j);
}
@@ -415,10 +385,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 +394,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 +407,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 +419,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 +427,14 @@ 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 +525,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 +595,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 +648,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 +703,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 +735,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 +765,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 +794,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 +810,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 +837,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 +860,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 +879,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 +892,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 +918,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 +959,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 +981,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 +994,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 +1007,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 +1033,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 +1048,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 +1076,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 +1083,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 +1146,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
+107 -181
View File
@@ -22,12 +22,13 @@
#include "lbitset.h"
#include "obstack.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "obstack.h"
/* This file implements linked-list bitsets. These bitsets can be of
arbitrary length and are more efficient than arrays of bits for
large sparse sets.
@@ -108,21 +109,21 @@ lbitset_elt_alloc (void)
/* Let particular systems override the size of a chunk. */
#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 0
# define OBSTACK_CHUNK_SIZE 0
#endif
/* Let them override the alloc and free routines too. */
#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
# define OBSTACK_CHUNK_ALLOC xmalloc
#endif
#ifndef OBSTACK_CHUNK_FREE
#define OBSTACK_CHUNK_FREE free
# define OBSTACK_CHUNK_FREE free
#endif
#if ! defined __GNUC__ || __GNUC__ < 2
#define __alignof__(type) 0
# define __alignof__(type) 0
#endif
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
@@ -145,9 +146,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 +209,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 +227,7 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
bset->b.csize = 0;
}
lbitset_elt *next;
for (; elt; elt = next)
{
next = elt->next;
@@ -242,12 +240,9 @@ 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;
return true;
}
@@ -257,13 +252,8 @@ static inline void
lbitset_elt_link (bitset bset, lbitset_elt *elt)
{
bitset_windex windex = elt->index;
lbitset_elt *ptr;
lbitset_elt *current;
if (bset->b.csize)
current = LBITSET_CURRENT (bset);
else
current = LBITSET_HEAD (bset);
lbitset_elt *current = bset->b.csize ? LBITSET_CURRENT (bset) : LBITSET_HEAD (bset);
/* If this is the first and only element, add it in. */
if (LBITSET_HEAD (bset) == 0)
@@ -277,6 +267,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 +285,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 +311,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 +327,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
if (current)
{
lbitset_elt *elt;
if (windex < bset->b.cindex)
{
for (elt = current;
@@ -371,8 +363,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 +378,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 +392,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 +405,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 +430,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 +488,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 +550,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 +571,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 +584,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 +598,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--)
@@ -658,25 +630,21 @@ lbitset_list_reverse (bitset bset, 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
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_bindex bitno = *next;
bitset_bindex count = 0;
if (!bitno)
{
@@ -713,7 +681,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
{
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
bitset_word word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
for (; word; bitno++)
{
@@ -746,7 +714,6 @@ lbitset_list (bitset bset, bitset_bindex *list,
while (elt)
{
int i;
bitset_word *srcp = elt->words;
if ((count + LBITSET_ELT_BITS) < num)
@@ -754,7 +721,7 @@ lbitset_list (bitset bset, bitset_bindex *list,
/* The coast is clear, plant boot! */
#if LBITSET_ELT_WORDS == 2
word = srcp[0];
bitset_word word = srcp[0];
if (word)
{
if (!(word & 0xffff))
@@ -795,9 +762,9 @@ 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];
bitset_word word = srcp[i];
if (word)
{
if (!(word & 0xffff))
@@ -827,9 +794,9 @@ 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++)
for (bitset_word word = srcp[i]; word; bitno++)
{
if (word & 1)
{
@@ -870,12 +837,12 @@ lbitset_empty_p (bitset dst)
{
next = elt->next;
if (!lbitset_elt_zero_p (elt))
return 0;
return false;
/* Weed as we go. */
lbitset_elt_unlink (dst, elt);
}
return 1;
return true;
}
@@ -883,21 +850,14 @@ lbitset_empty_p (bitset dst)
static inline void
lbitset_unused_clear (bitset dst)
{
unsigned last_bit;
bitset_bindex n_bits;
n_bits = BITSET_SIZE_ (dst);
last_bit = n_bits % LBITSET_ELT_BITS;
bitset_bindex n_bits = BITSET_SIZE_ (dst);
unsigned last_bit = n_bits % LBITSET_ELT_BITS;
if (last_bit)
{
lbitset_elt *elt;
bitset_windex windex;
bitset_word *srcp;
elt = LBITSET_TAIL (dst);
srcp = elt->words;
windex = n_bits / BITSET_WORD_BITS;
lbitset_elt *elt = LBITSET_TAIL (dst);
bitset_word *srcp = elt->words;
bitset_windex windex = n_bits / BITSET_WORD_BITS;
srcp[windex - elt->index] &= ((bitset_word) 1 << last_bit) - 1;
windex++;
@@ -911,21 +871,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,27 +893,21 @@ 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);
lbitset_weed (dst);
return;
}
@@ -964,11 +915,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 +936,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 +948,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 +968,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,26 +982,20 @@ 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;
lbitset_elt *dtmp;
bitset_word *srcp1;
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)
{
bitset_windex windex;
lbitset_elt *stmp1;
lbitset_elt *stmp2;
/* Figure out whether we need to substitute zero elements for
missing links. */
if (windex1 == windex2)
@@ -1090,6 +1027,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
/* Find the appropriate element from DST. Begin by discarding
elements that we've skipped. */
lbitset_elt *dtmp;
while (delt && delt->index < windex)
{
changed = true;
@@ -1107,16 +1045,16 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
/* Do the operation, and if any bits are set, link it into the
linked list. */
srcp1 = stmp1->words;
srcp2 = stmp2->words;
dstp = dtmp->words;
bitset_word *srcp1 = stmp1->words;
bitset_word *srcp2 = stmp2->words;
bitset_word *dstp = dtmp->words;
switch (op)
{
default:
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 +1067,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 +1080,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 +1093,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,23 +1134,23 @@ 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;
}
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
else
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
}
@@ -1228,7 +1166,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,11 +1174,12 @@ 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;
}
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
else
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
}
@@ -1259,14 +1197,11 @@ lbitset_or_cmp (bitset dst, bitset src1, bitset src2)
lbitset_elt *selt2 = LBITSET_HEAD (src2);
if (!selt2)
{
return lbitset_copy_cmp (dst, src1);
}
return lbitset_copy_cmp (dst, src1);
else if (!selt1)
{
return lbitset_copy_cmp (dst, src2);
}
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
return lbitset_copy_cmp (dst, src2);
else
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
}
@@ -1284,14 +1219,11 @@ lbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
lbitset_elt *selt2 = LBITSET_HEAD (src2);
if (!selt2)
{
return lbitset_copy_cmp (dst, src1);
}
return lbitset_copy_cmp (dst, src1);
else if (!selt1)
{
return lbitset_copy_cmp (dst, src2);
}
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
return lbitset_copy_cmp (dst, src2);
else
return lbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
}
@@ -1375,24 +1307,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
-37
View File
@@ -1,37 +0,0 @@
/* Fake libiberty.h for Bison.
Copyright (C) 2002-2004, 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/>. */
/* Bison depends on libiberty's implementation of bitsets, which
requires a 'libiberty.h' file. This file provides the minimum
services. */
#ifndef BISON_LIBIBERTY_H_
# define BISON_LIBIBERTY_H_ 1
# ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x)
# endif
# endif
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# include "xalloc.h"
#endif /* ! BISON_LIBIBERTY_H_ */
+20 -25
View File
@@ -1,17 +1,17 @@
# Copyright (C) 2001-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/>.
## Copyright (C) 2001-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/>.
include lib/gnulib.mk
@@ -30,7 +30,6 @@ lib_libbison_a_SOURCES += \
lib/ebitset.h \
lib/lbitset.c \
lib/lbitset.h \
lib/libiberty.h \
lib/vbitset.c \
lib/vbitset.h
@@ -39,20 +38,16 @@ 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
lib_LIBRARIES = lib/liby.a
EXTRA_LIBRARIES = lib/liby.a
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c
lib_LIBRARIES = lib/liby.a
EXTRA_LIBRARIES = lib/liby.a
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c
endif
+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 */
+181 -334
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,11 +73,7 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
grow the bitset 25% larger than requested to reduce
number of reallocations. */
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4;
VBITSET_WORDS (src)
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
VBITSET_ASIZE (src) = size;
@@ -115,9 +106,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 +123,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,13 +132,12 @@ 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. */
return 0;
return false;
}
@@ -160,22 +146,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 +160,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 +195,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_bindex bitno = *next;
bitset_bindex count = 0;
bitset_windex windex;
bitset_bindex bitoff;
bitset_word word;
bitno = *next;
count = 0;
if (!bitno)
{
/* Many bitsets are zero, so make this common case fast. */
@@ -327,12 +297,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 +310,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 +321,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,34 +330,27 @@ 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;
return 1;
return false;
return true;
}
static void
vbitset_copy1 (bitset dst, bitset src)
{
bitset_word *srcp;
bitset_word *dstp;
bitset_windex ssize;
bitset_windex dsize;
if (src == dst)
return;
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 +362,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,96 +381,87 @@ 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 false;
if (ssize > dsize)
{
for (; i < ssize; i++)
if (*srcp++)
return 0;
return false;
}
else
{
for (; i < dsize; i++)
if (*dstp++)
return 0;
return false;
}
return 1;
return true;
}
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)
{
for (; i < ssize; i++)
if (*srcp++)
return 0;
return false;
}
return 1;
return true;
}
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 false;
return 1;
return true;
}
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,31 +470,24 @@ 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;
bool changed = false;
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++;
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -568,7 +502,7 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
if (*dstp != 0)
{
changed = 1;
changed = true;
*dstp = 0;
}
}
@@ -582,25 +516,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,31 +549,24 @@ 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;
bool changed = false;
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++);
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -657,7 +577,7 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
if (*dstp != 0)
{
changed = 1;
changed = true;
*dstp = 0;
}
}
@@ -672,7 +592,7 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -687,25 +607,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,31 +636,25 @@ 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;
bool changed = false;
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++;
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -764,7 +671,7 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -778,25 +685,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,31 +714,24 @@ 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;
bool changed = false;
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++;
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -855,7 +748,7 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -872,13 +765,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;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
{
@@ -888,47 +774,40 @@ vbitset_and_or (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++;
}
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;
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
return bitset_and_or_cmp_ (dst, src1, src2, 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++)
bool changed = false;
for (unsigned i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -939,13 +818,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;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
{
@@ -955,47 +827,40 @@ vbitset_andn_or (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++;
}
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;
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
return bitset_andn_or_cmp_ (dst, src1, src2, 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++)
bool changed = false;
for (unsigned i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1006,13 +871,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,47 +880,41 @@ 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++;
}
static bool
vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned i;
int changed = 0;
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))
return bitset_or_and_cmp_ (dst, src1, src2, 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);
unsigned i;
bool changed = false;
for (i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1074,9 +926,9 @@ static void
vbitset_copy (bitset dst, bitset src)
{
if (BITSET_COMPATIBLE_ (dst, src))
vbitset_copy1 (dst, src);
vbitset_copy1 (dst, src);
else
bitset_copy_ (dst, src);
bitset_copy_ (dst, src);
}
@@ -1119,22 +971,17 @@ 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;
bset->b.cindex = 0;
VBITSET_SIZE (bset) = 0;
vbitset_resize (bset, n_bits);
return bset;
+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++])
])
+3 -5
View File
@@ -50,14 +50,12 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
AC_LANG_POP([C++])])
case $bison_cv_cxx_works in
yes)
BISON_CXX_WORKS=':';;
no | cross)
BISON_CXX_WORKS='exit 77';;
yes) BISON_CXX_WORKS=':';;
no | cross) BISON_CXX_WORKS='false';;
esac
AC_SUBST([BISON_CXX_WORKS])
AM_CONDITIONAL(BISON_CXX_WORKS, test $bison_cv_cxx_works = yes)
AM_CONDITIONAL([ENABLE_CXX], [test $bison_cv_cxx_works = yes])
])
# BISON_CXX_COMPILER_POSIXLY_CORRECT
-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
])
])
+60 -85
View File
@@ -168,10 +168,9 @@ AnnotationList__compute_conflicted_tokens (bitset shift_tokens,
bitset conflicted_tokens = bitset_create (ntokens, BITSET_FIXED);
bitset conflicted_tokens_rule = bitset_create (ntokens, BITSET_FIXED);
bitset tokens = bitset_create (ntokens, BITSET_FIXED);
int i;
bitset_copy (tokens, shift_tokens);
for (i = 0; i < reds->num; ++i)
for (int i = 0; i < reds->num; ++i)
{
bitset_and (conflicted_tokens_rule, tokens, reds->lookahead_tokens[i]);
bitset_or (conflicted_tokens,
@@ -215,20 +214,17 @@ AnnotationList__compute_lhs_contributions (state *s, rule *the_rule,
}
static void
AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
bitsetv follow_kernel_items,
bitsetv always_follows,
state ***predecessors,
bitset **item_lookahead_sets,
AnnotationList
**annotation_lists,
AnnotationIndex
*annotation_counts,
struct obstack
*annotations_obstackp)
AnnotationList__computePredecessorAnnotations (
AnnotationList *self, state *s,
bitsetv follow_kernel_items,
bitsetv always_follows,
state ***predecessors,
bitset **item_lookahead_sets,
AnnotationList **annotation_lists,
AnnotationIndex *annotation_counts,
struct obstack *annotations_obstackp)
{
state **predecessor;
for (predecessor = predecessors[s->number]; *predecessor; ++predecessor)
for (state **predecessor = predecessors[s->number]; *predecessor; ++predecessor)
{
AnnotationList *annotation_node =
AnnotationList__alloc_on_obstack (
@@ -237,8 +233,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
bool potential_contribution = false;
bitset *lookaheads = NULL;
{
ContributionIndex ci;
for (ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
{
symbol_number contribution_token =
InadequacyList__getContributionToken (self->inadequacyNode, ci)
@@ -274,12 +269,12 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
if (item_number_is_rule_number (ritem[s->items[self_item]
- 2]))
{
Sbitset items;
unsigned rulei;
for (rulei = s->items[self_item];
!item_number_is_rule_number (ritem[rulei]);
++rulei)
;
continue;
Sbitset items;
if (AnnotationList__compute_lhs_contributions (
*predecessor,
&rules[item_number_as_rule_number (ritem[rulei])],
@@ -334,10 +329,9 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
potential_contribution = true;
if (!lookaheads)
{
size_t j;
lookaheads = xnmalloc ((*predecessor)->nitems,
sizeof *lookaheads);
for (j = 0; j < (*predecessor)->nitems; ++j)
for (size_t j = 0; j < (*predecessor)->nitems; ++j)
lookaheads[j] = NULL;
}
if (!lookaheads[i])
@@ -377,8 +371,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s,
annotation_node = NULL;
}
{
size_t i;
for (i = 0; i < (*predecessor)->nitems; ++i)
for (size_t i = 0; i < (*predecessor)->nitems; ++i)
if (lookaheads[i])
bitset_free (lookaheads[i]);
free (lookaheads);
@@ -416,23 +409,19 @@ AnnotationList__compute_from_inadequacies (
struct obstack *annotations_obstackp,
InadequacyListNodeCount *inadequacy_list_node_count)
{
bitsetv all_lookaheads;
bitset shift_tokens;
bitset conflicted_tokens;
bitset_iterator biter_conflict;
bitset_bindex conflicted_token;
/* Return an empty list if s->lookahead_tokens = NULL. */
if (s->consistent)
return;
all_lookaheads = bitsetv_create (s->nitems, ntokens, BITSET_FIXED);
bitsetv all_lookaheads = bitsetv_create (s->nitems, ntokens, BITSET_FIXED);
bitsetv_ones (all_lookaheads);
shift_tokens = AnnotationList__compute_shift_tokens (s->transitions);
conflicted_tokens =
bitset shift_tokens = AnnotationList__compute_shift_tokens (s->transitions);
bitset conflicted_tokens =
AnnotationList__compute_conflicted_tokens (shift_tokens, s->reductions);
/* Add an inadequacy annotation for each conflicted_token. */
bitset_iterator biter_conflict;
bitset_bindex conflicted_token;
BITSET_FOR_EACH (biter_conflict, conflicted_tokens, conflicted_token, 0)
{
AnnotationList *annotation_node;
@@ -444,8 +433,7 @@ AnnotationList__compute_from_inadequacies (
/* Allocate the annotation node. */
{
int rule_i;
for (rule_i = 0; rule_i < s->reductions->num; ++rule_i)
for (int rule_i = 0; rule_i < s->reductions->num; ++rule_i)
if (bitset_test (s->reductions->lookahead_tokens[rule_i],
conflicted_token))
++contribution_count;
@@ -461,8 +449,7 @@ AnnotationList__compute_from_inadequacies (
{
ContributionIndex ci = 0;
int item_i = 0;
int rule_i;
for (rule_i = 0; rule_i < s->reductions->num; ++rule_i)
for (int rule_i = 0; rule_i < s->reductions->num; ++rule_i)
{
rule *the_rule = s->reductions->rules[rule_i];
if (bitset_test (s->reductions->lookahead_tokens[rule_i],
@@ -584,27 +571,20 @@ AnnotationList__debug (AnnotationList const *self, size_t nitems, int spaces)
AnnotationIndex ai;
for (a = self, ai = 0; a; a = a->next, ++ai)
{
{
int j;
for (j = 0; j < spaces; ++j)
putc (' ', stderr);
}
for (int j = 0; j < spaces; ++j)
putc (' ', stderr);
fprintf (stderr, "Annotation %d (manifesting state %d):\n",
ai, a->inadequacyNode->manifestingState->number);
{
ContributionIndex ci;
bitset_bindex rulei = 0; /* init suppresses compiler warning */
rulei = bitset_first (a->inadequacyNode->inadequacy.conflict.actions);
for (ci = 0; ci < a->inadequacyNode->contributionCount; ++ci)
bitset_bindex rulei
= bitset_first (a->inadequacyNode->inadequacy.conflict.actions);
for (ContributionIndex ci = 0; ci < a->inadequacyNode->contributionCount; ++ci)
{
symbol_number token =
InadequacyList__getContributionToken (a->inadequacyNode, ci)
->content->number;
{
int j;
for (j = 0; j < spaces+2; ++j)
putc (' ', stderr);
}
for (int j = 0; j < spaces+2; ++j)
putc (' ', stderr);
if (ci == InadequacyList__getShiftContributionIndex (
a->inadequacyNode))
fprintf (stderr, "Contributes shift of token %d.\n", token);
@@ -639,20 +619,17 @@ AnnotationList__computeLookaheadFilter (AnnotationList const *self,
{
bitsetv_zero (lookahead_filter);
for (; self; self = self->next)
{
ContributionIndex ci;
for (ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
if (!AnnotationList__isContributionAlways (self, ci))
{
Sbitset__Index item;
Sbitset biter;
symbol_number token =
InadequacyList__getContributionToken (self->inadequacyNode, ci)
->content->number;
SBITSET__FOR_EACH (self->contributions[ci], nitems, biter, item)
bitset_set (lookahead_filter[item], token);
}
}
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
if (!AnnotationList__isContributionAlways (self, ci))
{
symbol_number token =
InadequacyList__getContributionToken (self->inadequacyNode, ci)
->content->number;
Sbitset__Index item;
Sbitset biter;
SBITSET__FOR_EACH (self->contributions[ci], nitems, biter, item)
bitset_set (lookahead_filter[item], token);
}
}
/**
@@ -699,11 +676,10 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
size_t nitems, bitset *lookaheads,
bool require_split_stable)
{
symbol *token;
ContributionIndex const ci_shift =
InadequacyList__getShiftContributionIndex (self->inadequacyNode);
token = self->inadequacyNode->inadequacy.conflict.token;
symbol *token = self->inadequacyNode->inadequacy.conflict.token;
/* S/R conflict. */
if (ci_shift != ContributionIndex__none)
@@ -711,9 +687,6 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
bool find_stable_domination_over_shift = false;
bool find_stable_error_action_domination = false;
{
ContributionIndex ci;
int actioni;
ContributionIndex ci_rr_dominator = ContributionIndex__none;
int shift_precedence = token->content->prec;
/* If the token has no precedence set, shift is always chosen. */
@@ -723,11 +696,16 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
/* Figure out which reductions contribute, which of those would
dominate in a R/R comparison, and whether any reduction dominates
the shift so that the R/R comparison is actually needed. */
for (ci = 0, actioni = bitset_first (self->inadequacyNode->inadequacy
.conflict.actions);
ContributionIndex ci_rr_dominator = ContributionIndex__none;
int actioni;
ContributionIndex ci;
for (ci = 0,
actioni = bitset_first (self->inadequacyNode->inadequacy
.conflict.actions);
ci < self->inadequacyNode->contributionCount;
++ci, actioni = bitset_next (self->inadequacyNode->inadequacy
.conflict.actions, actioni+1))
++ci,
actioni = bitset_next (self->inadequacyNode->inadequacy
.conflict.actions, actioni+1))
{
int reduce_precedence = 0;
if (ci == ci_shift)
@@ -796,17 +774,14 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
/* R/R conflict, so the reduction with the lowest rule number dominates.
Fortunately, contributions are sorted by rule number. */
{
ContributionIndex ci;
for (ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
if (AnnotationList__stateMakesContribution (self, nitems, ci,
lookaheads))
{
if (require_split_stable
&& !AnnotationList__isContributionAlways (self, ci))
return ContributionIndex__none;
return ci;
}
}
for (ContributionIndex ci = 0; ci < self->inadequacyNode->contributionCount; ++ci)
if (AnnotationList__stateMakesContribution (self, nitems, ci,
lookaheads))
{
if (require_split_stable
&& !AnnotationList__isContributionAlways (self, ci))
return ContributionIndex__none;
return ci;
}
return ContributionIndex__none;
}
+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);
}
+33 -17
View File
@@ -1,19 +1,17 @@
# Copyright (C) 2001-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/>.
LDADD = lib/libbison.a $(LIBINTL)
## Copyright (C) 2001-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/>.
bin_PROGRAMS = src/bison
# Prettify Automake-computed names of compiled objects.
@@ -106,16 +104,34 @@ BUILT_SOURCES += \
src/scan-gram.c \
src/scan-skel.c
# Although conceptually most of these guys would make more sense in the
# definition of libbison, beware that they might expand as flags such as
# `-lm`. Keep them here. Or use a Libtool convenience library.
src_bison_LDADD = \
$(ISNAND_LIBM) \
$(ISNANF_LIBM) \
$(ISNANL_LIBM) \
$(LDEXPL_LIBM) \
$(LDEXP_LIBM) \
$(LIBINTL) \
$(LIBTHREAD) \
$(LIB_CLOCK_GETTIME) \
$(LIB_GETHRXTIME) \
lib/libbison.a
## ------ ##
## yacc. ##
## ------ ##
if ENABLE_YACC
bin_SCRIPTS = src/yacc
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);

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