Compare commits

...
567 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
Akim Demaille 2caaeba496 version 3.1
* NEWS: Record release date.
2018-08-27 21:52:23 +02:00
Akim Demaille 95a65a3215 build: tabs are ok in a Makefile
* cfg.mk: TABs are ok in examples/calc++/Makefile.
2018-08-27 21:11:12 +02:00
Akim Demaille 33e523878b C++: make sure the generated header is self container
See the previous commit.

* data/lalr1.cc: Be sure to define YY_NULLPTR.
* tests/headers.at: Check the case that was failing.
2018-08-26 18:54:42 +02:00
Akim Demaille 2360e39906 tests: check that headers are sane
The header generated for variants with assertions but without
locations, is not self-contained.  Prepare a check for this.

* tests/headers.at (Sane headers): New, extracted from...
(Several parsers): here.
2018-08-26 18:51:11 +02:00
Akim Demaille 10082ac068 "C++: restore copy-constructor for stack_symbol_type
Benchmarks show that it is more efficient to keep this copy
constructor, rather than forcing the use of the default constructor
and then assignment.

This reverts commit 7ab25ad020.
2018-08-25 11:05:53 +02:00
Akim Demaille de64159e7f examples: calc++: a Makefile and a README
* examples/calc++/Makefile, examples/calc++/README: New.
* examples/calc++/local.mk: Ship and install them.
* doc/bison.texi: Formatting changes.
2018-08-25 08:49:26 +02:00
Akim Demaille 280c40a350 gnulib: update 2018-08-25 07:47:25 +02:00
Jiahao LiandAkim Demaille c1cf82f9c8 variant: fix uninitialized memory access in variant<>
Currently, in bison's C++ parser template (`lalr.cc`), the `variant<>`
struct's `build()` method uses placement-new in the form `new (...) T`
to initialize a variant type.  However, for POD variant types, this
will leave the memory space uninitialized.  If we subsequently tries
to `::move` into a variant object in such state, the call can trigger
clang's undefined behavior sanitizer due to accessing the
uninitialized memory.

https://lists.gnu.org/archive/html/bison-patches/2018-08/msg00098.html

* data/variant.hh (build): Always initialize the stored value.

Signed-off-by: Akim Demaille <[email protected]>
2018-08-25 07:25:05 +02:00
Akim Demaille 55947367c6 NEWS: update 2018-08-24 19:48:19 +02:00
Akim Demaille b4e9eaefd5 examples: calc++: minor improvements
* doc/bison.texi (A Complete C++ Example): Prefer throw exceptions
from the scanner.
Show the invalid characters.
Since the scanner sends exceptions, it no longer needs to report
errors, so we can get rid of the driver's routine to report error,
do it in yyerror.
Use @group/@end group to improve rendering.
2018-08-24 19:40:36 +02:00
Akim Demaille 1a968edcb8 examples: calc++: make sure the file name in location is set
Reported by Hans Åberg.
http://lists.gnu.org/archive/html/bug-bison/2018-08/msg00039.html

* doc/bison.texi (A Complete C++ Example): Move the token's location
from the scanner to the driver.
2018-08-24 19:24:37 +02:00
Akim Demaille 82fa282a1b examples: calc++: remove prefixes
This example uses the calcxx_ prefix for each class.  That's uselessly
heavy.

* doc/bison.texi (A Complete C++ Example): Simplify the class names.
Since now 'driver' denotes the class, use 'drv' for the values.
Formatting changes.
2018-08-24 19:24:34 +02:00
Akim Demaille e504c843c1 examples: fix the leading empty line
* examples/extexi: Really avoid the first empty line.
Remove useless `next`.
2018-08-23 19:16:11 +02:00
Akim Demaille 3fda8335bf examples: shorten the name of the calc++ files
* doc/bison.texi: Turn the calc++- prefix into calc++/.
* examples/extexi (%file_wanted): Replace with
(&file_wanted): this.
* examples/calc++/local.mk: Adjust.
2018-08-23 13:37:52 +02:00
Akim Demaille 9645a2b20e tests: disable -Wmaybe-uninitialized in some tests
On these tests, at -O2 and above, GCC 8 complains that yylval may be
uninitialized.  But it seems wrong: it is initialized.  Rather than
turning off the warning in the skeleton (hence possibility hiding
relevant warnings of user parsers), let's turn it off in the tests
only.

    163: parse.error=verbose and consistent errors:      FAILED (conflicts.at:625)
    165: parse.error=verbose and consistent errors: lr.default-reduction=consistent FAILED (conflicts.at:635)
    166: parse.error=verbose and consistent errors: lr.default-reduction=accepting FAILED (conflicts.at:641)
    167: parse.error=verbose and consistent errors: lr.type=canonical-lr FAILED (conflicts.at:645)
    168: parse.error=verbose and consistent errors: parse.lac=full FAILED (conflicts.at:650)
    169: parse.error=verbose and consistent errors: parse.lac=full lr.default-reduction=accepting FAILED (conflicts.at:655)

We get:

    input.c: In function 'yyparse':
    input.c:980:9: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
             ^~~~~~
    cc1: all warnings being treated as errors

See https://lists.gnu.org/archive/html/bison-patches/2018-08/msg00063.html.

* tests/conflicts.at (AT_CONSISTENT_ERRORS_CHECK): Disable
-Wmaybe-uninitialized.
2018-08-23 13:36:19 +02:00
Akim Demaille 7ff6b7bbca doc: clarify that the push parser object can be reused
Suggested by Rici Lake.
https://lists.gnu.org/archive/html/bug-bison/2018-08/msg00033.html

* doc/bison.texi: Complete description of the first node in the main
@menu.
(Push Decl): Remove the 'experimental' warnings about push parser.
Clarify that the push parser object can be reused in several parses.
2018-08-19 21:02:17 +02:00
Akim Demaille 44e76d801f lalr1.cc: support compilation with disabled support for exceptions
Reported by Brooks Moses <[email protected]>
http://lists.gnu.org/archive/html/bison-patches/2018-02/msg00000.html

* data/lalr1.cc (YY_EXCEPTIONS): New.
Use it to disable try/catch clauses.

* doc/bison.texi (C++ Parser Interface): Document it.

* configure.ac (CXXFLAGS_NO_EXCEPTIONS): New.
* tests/atlocal.in: Receive it.
* tests/local.at (AT_FULL_COMPILE, AT_LANG_COMPILE):
Accept a new argument, extra compiler flags.
* tests/calc.at: Run the C++ calculator with exception support disabled.
2018-08-19 17:47:59 +02:00
Akim Demaille 32e0fd1a99 examples: add empty lines
Currently the examples are too dense, let's put empty lines where
'#line' would be issued.  And also remove some spurious empty
lines (remains from @group, @end group, etc.).

* examples/extexi: Do that.
* examples/local.mk (extexiFLAGS): Rename as...
(EXTEXIFLAGS): this.
2018-08-19 17:47:59 +02:00
Akim Demaille b610f43f25 examples: check the variant example
* examples/mfcalc/local.mk, examples/rpcalc/local.mk: Define the
programs in a more natural order, source, preproc, then linker.

* examples/test: Be ready to work on programs that are not in
a subdir.
* examples/variant.test: New.
* examples/local.mk: Use it.
* examples/variant.yy: Don't use 0 for nullptr.
Use a more natural output for a list of string.
2018-08-19 17:47:59 +02:00
Akim Demaille f348522005 C++: fix portability issue with MSVC 2017
Visual Studio issues a C4146 warning on '-static_cast<unsigned>(rhs)'.
The code is weird, probably to cope with INT_MIN.  Let's go back to
using std::max (whose header is still included in position.hh...) like
originally, but with the needed casts.

Reported by 長田偉伸, and with help from Rici Lake.

See also
http://lists.gnu.org/archive/html/bug-bison/2013-02/msg00000.html
and commit 75ae829984.

* data/location.cc (position::add_): Take min as an int.
Use std::max.
While here, get rid of a couple of useless inlines.
2018-08-18 18:07:43 +02:00
Akim Demaille e866c476fd build: fix concurrent build failure
Reported by Dengke Du and Robert Yang.
https://lists.gnu.org/archive/html/bison-patches/2017-07/msg00000.html

* src/local.mk (src/yacc): Make sure the directory exists.
2018-08-18 15:37:14 +02:00
Akim Demaille 72252aaa97 lalr1.cc: remove debug comment
* data/lalr1.cc: Remove a comment about indentation.
I'm not sure it would be nice to indent even more, it's already quite
of the right.
2018-08-18 14:46:17 +02:00
Akim Demaille a1513c265b doc: fix the name of the GFDL section
Reported by dine <[email protected]>.
http://lists.gnu.org/archive/html/bug-bison/2016-10/msg00000.html

I mirrored what the Coreutils do.

* doc/bison.texi (Copying This Manual): Rename as...
(GNU Free Documentation License): this, since that the name we
used in the preamble.
2018-08-18 14:33:06 +02:00
Akim Demaille 425044a936 doc: clarify the destructor selection example
Reported by Gary L Peskin.
http://lists.gnu.org/archive/html/help-bison/2016-02/msg00000.html

* doc/bison.texi (Destructor Decl): here.
2018-08-18 14:15:21 +02:00
Akim Demaille 5010af94d0 portability: don't use _Pragma with ICC
ICC defines __GNUC__ [1], but does not support GCC's _Pragma for
diagnostics.  As a matter of fact, I believe it does not support
_Pragma at all (only #pragma) [2].

Reported by Maxim Prohorenko.
https://savannah.gnu.org/support/index.php?108339

[1] https://software.intel.com/en-us/cpp-compiler-18.0-developer-guide-and-reference-gcc-compatibility-and-interoperability
[2] https://software.intel.com/en-us/cpp-compiler-18.0-developer-guide-and-reference-pragmas

* data/c.m4 (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN): Exclude ICC from
the club.
2018-08-18 14:15:13 +02:00
Akim Demaille 005ea24cbb doc: typed mid-rule actions
* doc/bison.texi (Mid-Rule Actions): Restructure to insert...
(Typed Mid-Rule Actions): this new section.
Move the manual translation of mid-rule actions into regular actions
to...
(Mid-Rule Action Translation): here.
2018-08-18 10:42:35 +02:00
Akim Demaille adf0425d11 escape properly the file names in #line for printer/destructor
Reported by Jannick.
http://lists.gnu.org/archive/html/bug-bison/2017-05/msg00001.html

"Amusingly" enough, we have the same problem with %defines when the
parser file name has backslashes or quotes: we generate #includes with
an incorrect C string.

* src/output.c (prepare_symbol_definitions): Escape properly the file
names before passing them to M4.
* data/bison.m4, data/lalr1.cc: Don't simply put the file name between
two quotes (that should have been strong enough a smell...), expect
the string to be properly quoted.
* tests/synclines.at: New tests to check this.
2018-08-18 10:04:50 +02:00
Akim Demaille cb4e7ecefa tests: fix title and improve quoting
* tests/synclines.at: here.
Also, prefer '%code' to ;%{...%}' for yylex/yyerror prototypes.
2018-08-18 10:00:21 +02:00
Akim Demaille 2e9ad04cdb style: reduce scopes
* src/output.c: here.
2018-08-18 09:53:29 +02:00
Akim Demaille 28cde9c128 style: reduce scopes
* src/scan-code.l: here.
2018-08-18 09:53:29 +02:00
Akim Demaille d288047e9b regen 2018-08-18 07:42:07 +02:00
Akim Demaille d135a16792 style: reduce scopes
* src/parse-gram.y: Declare iterator within the for-loop.
2018-08-18 07:42:07 +02:00
Akim Demaille 75417c1c1c tests: style changes
* tests/c++.at, tests/local.at: Formatting and title changes.
2018-08-18 07:28:04 +02:00
Akim Demaille 8bc4348cc7 reader: simplify the search of the start symbol
Suggested by Paul Eggert.

* src/reader.c (find_start_symbol): Don't check 'res', we know it is
not null.  That suffices to avoid the GCC warnings.
* bootstrap.conf: We don't need 'assume', which doesn't exist anyway.
2018-08-17 06:22:47 +02:00
Akim Demaille 1113522acb c++: fix GCC8 warnings about uninitialized values
In 0931d14728 I removed too many
initializations from some ctors: some were not about base ctors, but
about member variables.  In fact, more of them were missing to please
GCC 8.

While at it, generate more natural code for C++ without variant:
instead of

    template <typename Base>
    parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
      : Base (other)
      , value ()
    {
      value = other.value
    }

generate

    template <typename Base>
    parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
      : Base (other)
      , value (other.value)
    {}

* data/c++.m4 (basic_symbol::basic_symbol): Always initialize 'value',
it might be a POD without a ctor.
* data/lalr1.cc (stack_symbol_type::stack_symbol_type): Likewise.
* data/variant.hh (variant::variant): Default initialize the buffer too.
2018-08-15 20:24:16 +02:00
Akim Demaille 45b9d97b54 tests: style: use %empty
* tests/conflicts.at: here.
2018-08-15 19:40:19 +02:00
Akim Demaille b01b80836d tests: fix warnings in push mode
Fix warning with GCC 8, -DNDEBUG.

    422. push.at:83: testing Multiple impure instances ...
    input.y: In function 'main':
    input.c:1022:12: error: potential null pointer dereference [-Werror=null-dereference]
       if (!yyps->yynew && yyps->yyss != yyps->yyssa)
            ~~~~^~~~~~~

* data/yacc.c (pstate_delete): Do nothing if called on null pointer.
2018-08-15 19:40:15 +02:00
Akim Demaille bd07c76b0a c++: avoid GCC 8 warnings
GCC 8 issues warnings whose root cause was a bit hard to find.

    calc.cc: In member function 'virtual int yy::parser::parse()':
    calc.cc:810:18: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
         , location (l)
                      ^
    calc.cc: In member function 'void yy::parser::yypush_(const char*, yy::parser::stack_symbol_type&)':
    calc.cc:810:18: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
         , location (l)
                      ^
    calc.cc: In member function 'void yy::parser::yypush_(const char*, yy::parser::state_type, yy::parser::symbol_type&)':
    calc.cc:810:18: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
         , location (l)
                      ^

The problem is with locations that don't have a constructor, such as
Span (in calc.cc) which is POD.  It is POD on purpose: so that we can
use that structure to test glr.cc which cannot use non POD in its
(C) stacks.

* data/c++.m4 (basic_symbol): Also ensure that 'location' is
initialized.
2018-08-15 19:23:00 +02:00
Akim Demaille 45ca5043ce tests: avoid compiler warnings
* tests/calc.at (AT_CALC_MAIN): Declare yyparse and operator<< in an
unnamed namespace to avoid "not declared" warnings (clang
-Weverything).
Remove useless prototypes.
2018-08-15 19:21:17 +02:00
Akim Demaille ef98967ada build: work around GCC warnings on Flex code
With GCC 7.3.0 and Flex 2.6.4, we get warnings on all the generated
scanners:

    examples/calc++/calc++-scanner.cc: In function 'void yyrestart(FILE*)':
    examples/calc++/calc++-scanner.cc:1611:20: error: potential null pointer dereference [-Werror=null-dereference]
     /* %endif */
      ~~~~~~~~~~~       ^
    examples/calc++/calc++-scanner.cc:1607:19: error: potential null pointer dereference [-Werror=null-dereference]
     /* %if-c-only */
      ~~~~~~~~~~~~~~~  ^
    examples/calc++/calc++-scanner.cc:1611:20: error: potential null pointer dereference [-Werror=null-dereference]
     /* %endif */
      ~~~~~~~~~~~       ^
    examples/calc++/calc++-scanner.cc:1607:19: error: potential null pointer dereference [-Werror=null-dereference]
     /* %if-c-only */
      ~~~~~~~~~~~~~~~  ^
    cc1plus: all warnings being treated as errors

Obviously the lines are incorrect, and the warnings are emitted twice.
Still, let's get rid of these warnings.

* doc/bison.texi, src/flex-scanner.h: Disable these warnings in code
generated by Flex.
2018-08-15 14:42:09 +02:00
Akim Demaille 7783ba2d4f fix incorrect C code
Commit 3df32101e7 introduced invalid C
code.  Caught by GCC 7.3.0.

* bootstrap.conf (gnulib_modules): We need assume.
* src/reader.c (find_start_symbol): Fix the signature (too much C++,
sorry...).
Prefer 'assume' to 'assert', so that we don't have these warnings even
when NDEBUG is defined.
2018-08-15 14:39:46 +02:00
Akim Demaille bbd17b68fb examples: fix Englishoes
* examples/README: Fix my mistakes.
2018-08-14 13:40:54 +02:00
Akim Demaille 30c179fee8 examples: ship and install variant.yy
This file was meant to be shown as an example.  Install it.

* README, data/README: Put Emacs metadata in the final section.
* examples/README: New.
* examples/variant.yy: Use %empty.
* examples/local.mk: Install both these files.
2018-08-14 13:36:47 +02:00
Akim Demaille 7ab25ad020 C++: remove useless copy-constructor
We currently generate copy constructors such as the following
one (taken from examples/variant.yy):

    parser::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
      : super_type (that.state, that.location)
    {
      switch (that.type_get ())
      {
        case 3: // TEXT
        case 8: // item
          value.copy< ::std::string > (that.value);
          break;

        case 7: // list
          value.copy< ::std::vector<std::string> > (that.value);
          break;

        case 4: // NUMBER
          value.copy< int > (that.value);
          break;

        default:
          break;
      }
    }

they are actually useless: we never need it.

* data/lalr1.cc: Don't generate the stack_symbol_type copy ctor.
2018-08-14 06:17:21 +02:00
Akim Demaille e555fb5e55 C++: symbol constructors: add a missing reference
Fix a typo so that instead of

    basic_symbol::basic_symbol (typename Base::kind_type t, const int v)

we now generate

    basic_symbol::basic_symbol (typename Base::kind_type t, const int& v)

* data/variant.hh (b4_basic_symbol_constructor_declare)
(b4_basic_symbol_constructor_define): Add missing reference.
2018-08-14 06:17:21 +02:00
Akim Demaille 0931d14728 C++: remove useless calls to the base default constructor
* data/c++.m4, data/stack.hh, data/variant.hh: here.
2018-08-14 06:17:21 +02:00
Akim Demaille e76245fcd9 C++: prefer size_type to unsigned for indexes
* data/stack.hh (size_type): New, based on the container type.
2018-08-14 06:17:21 +02:00
Akim Demaille c2de9dafd1 regen 2018-08-14 06:15:42 +02:00
Akim Demaille f7de571ff1 style: m4: remove useless reference to 'int' in integral types
* m4/cxx.m4: Prefer 'unsigned' to 'unsigned int'.
2018-08-14 06:15:42 +02:00
Akim Demaille c226d4ed48 style: doc: remove useless reference to 'int' in integral types
* doc/bison.texi: Prefer 'unsigned' to 'unsigned int'.  Likewise for
long and short.
2018-08-14 06:15:41 +02:00
Akim Demaille 9df53e7288 style: lib: remove useless reference to 'int' in integral types
* lib/abitset.c, lib/bbitset.h, lib/bitset.c, lib/bitset.h,
* lib/bitset_stats.c, lib/bitsetv-print.c, lib/bitsetv.c,
* lib/bitsetv.h, lib/ebitset.c, lib/lbitset.c, lib/timevar.c,
* lib/vbitset.c:
Prefer 'unsigned' to 'unsigned int'.  Likewise for long and short.
2018-08-14 06:15:41 +02:00
Akim Demaille 9a5c688ae4 style: src: remove useless reference to 'int' in integral types
* src/AnnotationList.c, src/AnnotationList.h, src/InadequacyList.h,
* src/closure.c, src/closure.h, src/gram.c, src/gram.h, src/ielr.c,
* src/location.c, src/output.c, src/reader.c, src/relation.c,
* src/scan-code.l, src/scan-gram.l, src/tables.c, src/tables.h:
Prefer 'unsigned' to 'unsigned int'.  Likewise for long and short.
2018-08-14 06:15:41 +02:00
Akim Demaille e3b7c01820 style: tests: remove useless reference to 'int' in integral types
* tests/actions.at, tests/cxx-type.at: Prefer 'unsigned' to 'unsigned
int'.  Likewise for long and short.
2018-08-14 06:15:41 +02:00
Akim Demaille 5cc5703239 style: data: remove useless reference to 'int' in integral types
* data/c.m4, data/glr.c, data/yacc.c: Prefer 'unsigned' to 'unsigned
int'.  Likewise for long and short.
2018-08-14 06:15:41 +02:00
Akim Demaille c8dc9a8f51 gnulib: update
* bootstrap.conf: gnulib_mk is defined again by bootstrap.
2018-08-12 11:23:38 +02:00
Akim Demaille f9a6b34147 doc: avoid type aliases
* doc/bison.texi (C++ Location Values): Use 'unsigned' instead of
'uint'.
2018-08-12 09:40:32 +02:00
Akim Demaille 48828e779f doc: remove the "experimental" warning for some features
Several features were flagged 'experimental' and waiting for user
feedback to 'stabilize', but i. AFAIK, no user ever reported anything
about them, ii. they'be been here long enough to prove they don't do
harm.

* doc/bison.texi: No longer experimental: default %printer and
%destructor (typed: <*> and untyped: <>), %define api.value.type union
and variant, Java parsers, XML output, LR family (lr, ielr, lalr),
semantic predicates (%?).
2018-08-12 09:15:01 +02:00
Akim Demaille 4ad0ed3425 tests: check variants and typed mid-rule actions
See
http://lists.gnu.org/archive/html/bison-patches/2018-08/msg00013.html

* tests/c++.at (Variants and Typed Mid-rule Actions): New.
2018-08-12 09:04:04 +02:00
Akim Demaille ad42f96053 tests: fix minor issues
* tests/actions.at: Fix some log messages.
Prefer #error to fprintf: it fixes the invalid use of yyoutput in
%destructor, and it is an even stronger check: that the code is not
even emitted.  The portability of #error is not really a problem here,
since the point is anyway to have the compilation fail.
2018-08-12 08:44:32 +02:00
Akim Demaille 4410084223 c++: variant: add more assertions
* data/variant.hh (variant::as): Check yytypeid_ before
checking *yytypeid_.
2018-08-11 18:27:10 +02:00
Akim Demaille ccc759e81a doc: -fcaret is enabled by default
* doc/bison.texi (Mid-Rule Action Translation): So no need to pass it.
2018-08-11 18:27:09 +02:00
Akim Demaille e19e088e66 style: reduce scopes
* src/closure.c, src/conflicts.c: here.
2018-08-11 18:27:09 +02:00
Akim Demaille 9c80fa286e NEWS: update 2018-08-11 18:09:29 +02:00
Akim Demaille da8f4a2f5f rule actions cannot be typed
Make sure that we cannot apply a type to the (main) action of a rule.

* src/reader.c (grammar_rule_check): Issue the warning.
* tests/input.at (Cannot type action): Check the warning.
2018-08-11 18:09:29 +02:00
Akim Demaille f18f71cfb0 warn about typed mid-rule actions in Yacc mode
* src/reader.c (grammar_current_rule_action_append): Warn.
* tests/input.at (AT_CHECK_UNUSED_VALUES): Check.
2018-08-11 18:09:29 +02:00
Akim Demaille 11548b8e68 tests: check typed mid-rule actions
* tests/input.at (_AT_UNUSED_VALUES_DECLARATIONS): Check
typed mid-rule actions.
* tests/report.at (Reports): Check that types of typed mid-rule
actions are reported.
* tests/actions.at (Typed mid-rule actions): Check that
the values of typed mid-rule actions are correct.
2018-08-11 18:09:29 +02:00
Akim Demaille b79b889de5 regen 2018-08-11 18:09:29 +02:00
Akim Demaille 7b24c424b5 add support for typed mid-rule actions
Prompted on Piotr Marcińczyk's message:
http://lists.gnu.org/archive/html/bug-bison/2017-06/msg00000.html.
See also http://lists.gnu.org/archive/html/bug-bison/2018-06/msg00001.html.

Because their type is unknown to Bison, the values of midrule actions are
not treated like the others: they don't have %printer and %destructor
support.  In addition, in C++, (Bison) variants cannot work properly.

Typed midrule actions address these issues.  Instead of:

    exp: { $<ival>$ = 1; } { $<ival>$ = 2; }   { $$ = $<ival>1 + $<ival>2; }

write:

    exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; }   { $$ = $1 + $2; }

* src/scan-code.h, src/scan-code.l (code_props): Add a `type` field to
record the declared type of an action.
(code_props_rule_action_init): Add a type argument.
* src/parse-gram.y: Accept an optional type tag for actions.
* src/reader.h, src/reader.c (grammar_current_rule_action_append): Add
a type argument.
(grammar_midrule_action): When a mid-rule is typed, pass its type to
the defined dummy non terminal symbol.
2018-08-11 18:09:29 +02:00
Akim Demaille 0d06a966f8 tests: make room for more cases
* tests/input.at (AT_CHECK_UNUSED_VALUES): Add an empty line
to allow more symbols, and adjust line numbers.
Use a more consistent m4 quoting scheme.
2018-08-05 20:25:59 +02:00
Akim Demaille 3df32101e7 warnings: address -Wnull-dereference in reader.c
Based on a patch by David Michael.
http://lists.gnu.org/archive/html/bison-patches/2018-07/msg00000.html

* src/reader.c (find_start): New, extracted from...
(check_and_convert_grammar): here.
2018-08-05 20:25:58 +02:00
Akim Demaille c699078246 style: ielr: reduce scopes
* src/ielr.c: Use modern C to reduce the scopes of some variables.
2018-08-05 20:17:25 +02:00
Akim Demaille 4c7377f499 style: move to C99 to reduce scopes
* src/symtab.c, src/reader.c: Freely mix statements and variable
definitions.  And use for-loops with initializers.
2018-07-26 20:18:32 +02:00
Akim Demaille 9502b2ab48 style: split a function in two
grammar_current_rule_action_append was used in two different places:
for actual action (`{...}`), and for predicates (`%?{...}`).  Let's
split this in two different functions.

* src/reader.h, src/reader.c (grammar_current_rule_predicate_append): New.
Extracted from...
(grammar_current_rule_action_append): here.
Remove arguments that don't apply.
Adjust dependencies.
2018-07-26 20:18:32 +02:00
Akim Demaille a0f33a28e9 tests: fix typo
* tests/actions.at: Remove (harmless) stray character.
2018-07-26 20:13:05 +02:00
Akim Demaille 0def17c3d1 print: remove unused function
This function was unused since 1991's original import by
rms (e06f0c3442).

* src/print.c (print_token): Remove.
2018-07-26 20:10:38 +02:00
Akim Demaille d2e7bc1613 doc: fix Texinfo syntax error
* doc/bison.texi (Understanding): here.
2018-06-23 09:12:06 +02:00
Akim Demaille 70875b4873 doc: we now show the type of the symbols
* doc/bison.texi (Understanding Your Parser): Update the output
from Bison.
Use types in the example, and show them in the report.
* NEWS: Update.
2018-06-22 09:51:32 +02:00
Akim Demaille 34d1773990 tests: check the typed symbols in the reports
* tests/report.at: New.
* tests/local.mk, tests/testsuite.at: Use it.
2018-06-18 08:53:27 +02:00
Akim Demaille 27767290da report: display the type of the symbols
* src/print.c (print_nonterminal_symbols, print_terminal_symbols):
Also should the type of the symbols.
2018-06-18 07:18:14 +02:00
Akim Demaille 2efaa8e96a style: reduce scopes
* src/print.c (print_terminal_symbols, print_nonterminal_symbols): Here.
2018-06-18 07:16:03 +02:00
Akim Demaille 4cdcb6f243 style: split large function
* src/print.c (print_grammar): Split into...
(print_terminal_symbols, print_nonterminal_symbols): these.
Adjust dependencies.
2018-06-18 07:15:56 +02:00
Akim Demaille 7f42eb0a5e style: reduce scopes
* src/print.c (print_grammar): Shorten scopes.
2018-06-18 07:15:48 +02:00
Akim Demaille d03ad8b686 gnulib: update
Fixes the `make install-pdf` problem reported by Hans Åberg in
http://lists.gnu.org/archive/html/bug-bison/2018-06/msg00000.html
that had already been fixed by Joel E. Denny in
http://lists.gnu.org/archive/html/bug-bison/2012-04/msg00011.html
Final fix in
http://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00019.html
2018-06-18 07:13:28 +02:00
Akim Demaille f462a08572 Merge maint into master
* upstream/maint: (48 commits)
  THANKS: update an address
  tests: adjust syncline tests to GCC 7
  glr: fix improperly placed synclines
  bison: be git grep friendly
  Replace ftp with https
  maint: post-release administrivia
  version 3.0.5
  bison: style: indentation fixes
  regen
  bison: please address sanitizer
  C++: style: fix indentation
  NEWS: update
  C++: style: prefer `unsigned` to `unsigned int`
  C++: style: space before paren
  C++: fix -Wdeprecated warnings
  tests: fix -Wdeprecated warning
  maint: update syntax-check exclusions
  autoconf: update
  regen
  Update copyright years
  ...
2018-06-17 18:43:59 +02:00
Akim Demaille 0ac08d2d6c THANKS: update an address 2018-05-30 19:18:04 +02:00
Akim Demaille 6053dcae59 tests: adjust syncline tests to GCC 7
GCC 7 also underlines the error.

    syncline.c:4:2: error: #error "4"
     #error "4"
      ^~~~~

* tests/synclines.at (_AT_SYNCLINES_COMPILE): Remove tildas from GCC 7.
2018-05-30 19:17:06 +02:00
Akim Demaille 5952fe5abf glr: fix improperly placed synclines
Predicates with GLR are issued with synclines in the middle of C code:

          case 2:
      if (! (#line 6 "sempred.y" /* glr.c:816  */
      new_syntax)) YYERROR;
    #line 793 "sempred.tab.c" /* glr.c:816  */
      break;

Reported by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2018-05/msg00033.html

* data/c.m4 (b4_predicate_case): Be sure to start on column 0.
It would be nicer if b4_syncline could ensure this by itself
(that would avoid ugly code when synclines are disabled), but that's
way more work.
* tests/glr-regression.at (Predicates): Be a real end-to-end test.
This would have caught this error years ago...
2018-05-29 09:02:21 +02:00
Akim Demaille d0447d949b bison: be git grep friendly
* src/output.c (user_actions_output): Make calls to b4_case and
b4_predicate_case explicit.
2018-05-29 09:02:12 +02:00
Akim Demaille f3bd6a25bf Replace ftp with https
Reported by Hans Åberg.

* README, cfg.mk, doc/bison.texi: here.
2018-05-29 07:28:02 +02:00
Akim Demaille 38d91ccd96 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-05-27 14:42:55 +02:00
Akim Demaille 0dfa650f59 version 3.0.5
* NEWS: Record release date.
2018-05-27 11:53:43 +02:00
Akim Demaille 1e7a8315f6 bison: style: indentation fixes
* src/parse-gram.y: here.
2018-05-27 10:58:29 +02:00
Akim Demaille 4eeec4e41f regen 2018-05-27 10:46:31 +02:00
Akim Demaille 6fd3372db4 bison: please address sanitizer
* src/parse-gram.y (add_param): Asan does not like that the second
argument of strspn is not 0-terminated.
2018-05-27 10:44:41 +02:00
Akim Demaille f24afe4435 C++: style: fix indentation
* data/variant.hh (b4_symbol_variant): De-indent, as the callers are
indented.
2018-05-27 10:43:16 +02:00
Akim Demaille 1047f3c095 NEWS: update 2018-05-27 10:04:11 +02:00
Akim Demaille 928a817418 C++: style: prefer unsigned to unsigned int
* data/c++.m4: here.
2018-05-27 10:04:11 +02:00
Akim Demaille ae8d777ad6 C++: style: space before paren
* data/c++.m4, data/lalr1.cc: here.
2018-05-27 10:04:11 +02:00
Akim Demaille d17dc9a8b5 C++: fix -Wdeprecated warnings
For instance on test 99:

    In file included from @@.cc:56:
    @@.hh:409:26: error: definition of implicit copy constructor for
                         'stack_symbol_type' is deprecated because it
                         has a user-declared copy assignment operator
                         [-Werror,-Wdeprecated]
          stack_symbol_type& operator= (const stack_symbol_type& that);
                         ^

Reported by Derek Clegg.
https://lists.gnu.org/archive/html/bison-patches/2018-05/msg00036.html

* configure.ac (warn_tests): Add -Wdeprecated.
* data/lalr1.cc (stack_symbol_type): Add an explicit copy ctor.
We cannot rely on the explicit default implementation (`= default`)
as we support C++ 98.
2018-05-27 10:03:57 +02:00
Akim Demaille 7bb478bd19 tests: fix -Wdeprecated warning
With recent compilers:

    input.yy:49:5: error: definition of implicit copy assignment
                          operator for 'Object' is deprecated because
                          it has a user-declared destructor
                          [-Werror,-Wdeprecated]
        ~Object ()
        ^
    input.yy:130:35: note: in implicit copy assignment operator for
                           'Object' first required here
        { yylhs.value.as< Object > () = yystack_[0].value.as< Object > (); }

* tests/c++.at (Object): Add missing assignment operator.
2018-05-27 09:32:16 +02:00
Akim Demaille 9c29c52fce maint: update syntax-check exclusions
sc_two_space_separator_in_usage complains about bootstrap:

    two_space_separator_in_usage
    /Users/akim/src/gnu/bison/bootstrap:905:   --aux-dir $build_aux\
    /Users/akim/src/gnu/bison/bootstrap:906:   --doc-base $doc_base\
    /Users/akim/src/gnu/bison/bootstrap:907:   --lib $gnulib_name\
    /Users/akim/src/gnu/bison/bootstrap:908:   --m4-base $m4_base/\
    /Users/akim/src/gnu/bison/bootstrap:909:   --source-base $source_base/\
    /Users/akim/src/gnu/bison/bootstrap:910:   --tests-base $tests_base\
    /Users/akim/src/gnu/bison/bootstrap:911:   --local-dir $local_gl_dir\
    maint.mk: help2man requires at least two spaces between an option and its description

* cfg.mk: Exclude bootstrap from this check.
2018-05-19 15:24:01 +02:00
Akim Demaille 2a11380460 autoconf: update
* submodules/autoconf: Update to latest master.
No difference on the M4 files we use.
2018-05-19 15:17:28 +02:00
Akim Demaille 77a0e35143 regen 2018-05-19 15:14:46 +02:00
Akim Demaille 2e9e591889 Update copyright years
Run `make update-copyright`.
2018-05-12 18:18:41 +02:00
Nate GuerinandAkim Demaille a6ec9ca2f1 Add a missing word in the documentation
Small patch adds the word 'to' to the documentation.
2018-05-12 18:13:37 +02:00
Akim Demaille 370a302f34 Examples: improve C++ style
* examples/variant.yy: Prefer vector to list.
Remove useless inline.
2018-05-12 14:04:04 +02:00
Akim Demaille 2b5a27ba3d Avoid compiler warnings
At least GCC 7.3, with -O1 or -O2 (but not -O0 or -O3) generates
warnings with -Wnull-dereference when using yyformat: it fails to see
yyformat cannot be null.

Reported by Frank Heckenbach, https://savannah.gnu.org/patch/?9620.

* configure.ac: Use -Wnull-dereference if supported.
* data/glr.c, data/lalr1.cc, data/yacc.c: Define yyformat in such
a way that GCC cannot not see that yyformat is defined.
Using `default: abort();` also addresses the issue, but forces
the inclusion of `stdlib.h`, which we avoid.
2018-05-12 13:29:14 +02:00
Akim Demaille d132c2d545 C++: fix uses of inline
Sometimes `inline` would be used in *.cc files on symbols that are not
exported (useless but harmless), and sometimes on exported symbols
such as the constructor of syntax_error (harmful: linking fails).

Reported several times, including:

- by Dennis T
  http://lists.gnu.org/archive/html/bug-bison/2016-03/msg00002.html
- by Frank Heckenbach
  https://savannah.gnu.org/patch/?9616

* data/c++.m4 (b4_inline): New: expands to `inline` or nothing.
Use it where appropriate.
* data/lalr1.cc: Use it where appropriate.

* tests/c++.at (Syntax error as exception): Put the scanner in another
compilation unit to exercise the constructor of syntax_error.
2018-05-10 17:33:18 +02:00
Akim Demaille bb45005671 C++: remove useless inline in CC files
* data/glr.cc, data/lalr1.cc: Remove `inline` from implementations
that are not in headers.
2018-05-10 16:57:51 +02:00
Akim Demaille 0afeaa2ab7 C++: remove useless inline on templates
Templates are implicitly `inline`.

* data/c++.m4, data/lalr1.cc: Remove `inline` from templates.
2018-05-10 16:11:58 +02:00
Akim Demaille dbd1609311 style: don't use std::endl
* data/lalr1.cc, doc/bison.texi, etc/bench.pl.in, examples/variant.yy,
* tests/actions.at, tests/atlocal.in, tests/c++.at, tests/headers.at,
* tests/local.at, tests/types.at:
Don't use std::endl, it flushes uselessly, and is considered bad
style.
2018-05-08 12:35:06 +02:00
Akim Demaille ad9500f3fd doc: wrap
* README-hacking: Refill paragraphs.
2018-05-08 12:35:06 +02:00
Akim Demaille 76bd8a6b4a gnulib: update
* README-hacking: Commit before bootstrapping.
* bootstrap.conf: gnulib_mk is no longer defined by bootstrap.
* bootstrap, gnulib, lib/.gitignore, m4/.gitignore: Update/regen.
2018-05-08 12:35:06 +02:00
Akim Demaille 7e6bd4bb33 tests: we might need to find gnulib headers
315. calc.at:596: testing Calculator  ...
    ++ cat
    ++ test x = x1
    ++ set +x
    bison/tests/calc.at:596: bison -fno-caret -o calc.c calc.y
    ++ bison -fno-caret -o calc.c calc.y
    ++ set +x
    bison/tests/calc.at:596: $BISON_C_WORKS
    stderr:
    stdout:
    ++ set +x
    bison/tests/calc.at:596: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS
    ++ ccache clang-mp-6.0 -Qunused-arguments -O3 -g -Wall -Wextra -Wno-sign-compare -Wcast-align -Wdocumentation -Wformat -Wpointer-arith -Wwrite-strings -Wbad-function-cast -Wshadow -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wmissing-declarations -Wmissing-prototypes -Wundef -pedantic -Wsign-compare -fno-color-diagnostics -Wno-keyword-macro -Werror -Ibison/_build/6s/lib -DNDEBUG -isystem /opt/local/include -I/opt/local/include -L/opt/local/lib -o calc calc.c bison/_build/6s/lib/libbison.a -lintl -Wl,-framework -Wl,CoreFoundation
    stderr:
    In file included from calc.y:198:
    bison/_build/6s/lib/unistd.h:592:11: fatal error: 'getopt-pfx-core.h' file not found
    # include <getopt-pfx-core.h>
              ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    stdout:
    bison/tests/calc.at:596: exit code was 1, expected 0
    315. calc.at:596: 315. Calculator  (calc.at:596): FAILED (calc.at:596)

* tests/atlocal.in (CPPFLAGS): Find gnulib's headers.
2018-05-08 12:35:06 +02:00
Akim Demaille e1dd2807e6 getargs: rename argument to avoid gnulib's renaming
With Clang 6.0:

      CC       src/bison-getargs.o
    bison/src/getargs.c:67:12: error: parameter 'option' not found in the
                               function declaration [-Werror,-Wdocumentation]
     *  \param option   option being decoded.
               ^~~~~~
    bison/src/getargs.c:67:12: note: did you mean 'rpl_option'?

* src/getargs.c: Don't use `option` as a documentation argument.
2018-05-08 12:06:05 +02:00
Paul Eggert 96748b2bf8 Capitalize "Polish" when it's a proper adjective 2017-09-22 09:10:04 -07:00
Paul Eggert 4b314bdb6d Adjust to recent Gnulib changes 2017-09-16 21:58:07 -07:00
Paul Eggert d855f6c806 autoconf: update 2017-09-16 21:58:07 -07:00
Paul Eggert 1ee41a50d9 gnulib: update 2017-09-16 21:58:07 -07:00
Akim Demaille 8bf276d820 gnulib: update 2015-08-12 13:56:07 +02:00
Akim Demaille 476c1cca59 lalr1, yacc: use the default location as initial error location
Currently lalr1.cc makes an out-of-bound access when trying to read @1
in rules with an empty rhs (i.e., when there is no @1) that raises an
error (YYERROR).

glr.c already gracefully handles this by using @$ as initial location
for the errors.  Let's do that in yacc.c and lalr1.cc.

* data/lalr1.cc, data/yacc.c: Use @$ to initialize the error location.
* tests/actions.at: Check that case.
2015-08-12 13:56:07 +02:00
Akim Demaille 55fb68aabf style: formatting and comment changes
* data/glr.c: Avoid empty lines.
* data/lalr1.cc: Use the same comments as in glr.c and yacc.c.
2015-08-12 13:56:07 +02:00
Akim Demaille 0d40b36417 c++: style: use "unsigned", not "unsigned int"
This style appears to be more traditional, at least in C++.
For instance in the standard, [facets.examples].
There are occurrences using "unsigned int" too though.

* data/lalr1.cc, data/location.cc, data/stack.hh: here.
2015-08-12 13:56:06 +02:00
Akim Demaille b809770efb c++: style: remove useless "inline" and fix space issues
* data/lalr1.cc, data/c++.m4: Formatting changes.
* data/stack.hh: Remove useless "inline".
Add documentation.
* data/location.cc: Prefer {} for empty bodies.
2015-08-12 13:56:06 +02:00
Akim Demaille 009285d20a tests: beware of additional warnings from GCC 5
* tests/synclines.at (AT_SYNCLINES_COMPILE): Avoid warnings about
unused functions.
2015-08-12 13:56:06 +02:00
Akim Demaille 3e8d1bd053 tests: beware that clang warns about "#define private public"
We use this trick to write some test about internal details.  But
since we use -Werror, clang++ 3.6 dies issueing a warning about it.

* configure.ac (warn_tests): Disable this warning.
2015-08-12 13:56:06 +02:00
Akim Demaille 32ea6125e3 tests: update our Valgrind suppression files
* build-aux/linux-gnu.valgrind, build-aux/darwin11.4.0.valgrind: Rename as...
* build-aux/Linux.valgrind, build-aux/Darwin.valgrind: these.
* build-aux/Linux.valgrind: Add suppression clause.
* configure.ac: Update.
* tests/local.mk: Use it.
2015-08-12 13:56:06 +02:00
Akim Demaille baa423bd59 doc: improve html and pdf rendering
* doc/bison.texi: Help html conversion to understand where the
function names end.
Beware of PDF width.
2015-03-03 16:58:13 +01:00
Akim Demaille 75fbe357c8 doc: fixes in the C++ part
Reported by Askar Safin.

http://lists.gnu.org/archive/html/bug-bison/2015-02/msg00018.html
http://lists.gnu.org/archive/html/bug-bison/2015-02/msg00019.html

* doc/bison.texi (Split Symbols): Fix access to token types.
yylval is a pointer, so use ->.
Fix coding style issues: space before paren.
2015-03-03 16:31:31 +01:00
Akim Demaille a668f48631 tests: be robust to platforms that support UTF-8 even with LC_ALL=C
Because musl supports UTF-8 with LC_ALL=C, gcc produces:

  input.y: In function ‘yyparse’:

instead of:

  input.y: In function 'yyparse':

Reported by Ferdinand Thiessen.
http://lists.gnu.org/archive/html/bug-bison/2015-02/msg00001.html

* tests/synclines.at (AT_SYNCLINES_COMPILE): Skip syncline tests when
we can't trust error messages issued about a function body.
2015-02-10 14:56:30 +01:00
Akim Demaille 3d75e7de1e tests: java: avoid recent Java features
Tests 463 and 464 fail with Java 1.4 compilers.

Reported by Michael Felt.
<http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00091.html>

* tests/javapush.at: Use StringBuffer instead of StringBuilder.
2015-02-10 14:56:12 +01:00
Akim Demaille 9524161147 tests: c++: fix symbol lookup issue
Sun C 5.13 SunOS_sparc 2014/10/20 reports errors on tests 430-432.

Reported by Dennis Clarke.
<http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00087.html>

* tests/c++.at (Variants): Be sure to emit operator<< before using it:
use "%code top" rather than "%code".
Prefer std::vector to std::list.
Do not define anything in std::, to avoid undefined behavior.
2015-01-26 18:44:38 +01:00
Akim Demaille d6445ec10b Merge remote-tracking branch 'origin/maint'
* origin/maint:
  maint: post-release administrivia
  version 3.0.4
  gnulib: update
  build: re-enable compiler warnings, and fix them
  tests: c++: fix a C++03 conformance issue
  tests: fix a title
  c++: reserve 200 slots in the parser's stack
  tests: be more robust to unrecognized synclines, and try to recognize xlc
  tests: fix C++ conformance
  build: fix some warnings
  build: avoid infinite recursions on include_next
2015-01-23 15:17:35 +01:00
Akim Demaille 7ca7a3abf3 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2015-01-23 14:13:40 +01:00
Akim Demaille c4e686a1ab version 3.0.4
* NEWS: Record release date.
2015-01-23 13:53:53 +01:00
Akim Demaille 2646fd012d gnulib: update 2015-01-23 11:27:10 +01:00
Akim Demaille a2c525b34c build: re-enable compiler warnings, and fix them
There are warnings (-Wextra) in generated C++ code:

  ltlparse.cc: In member function 'ltlyy::parser::symbol_number_type
  ltlyy::parser::by_state::type_get() const':
  ltlparse.cc:452:33: warning: enumeral and non-enumeral type in
  conditional expression
      return state == empty_state ? empty_symbol : yystos_[state];

Reported by Alexandre Duret-Lutz.

It turns out that -Wall and -Wextra were disabled because of a stupid
typo.

* configure.ac: Fix the stupid typo.
* data/lalr1.cc, src/AnnotationList.c, src/InadequacyList.c,
* src/ielr.c, src/print.c, src/scan-code.l, src/symlist.c,
* src/symlist.h, src/symtab.c, src/tables.c, tests/actions.at,
* tests/calc.at, tests/cxx-type.at, tests/glr-regression.at,
* tests/named-refs.at, tests/torture.at:
Fix warnings, mostly issues about variables used only with assertions,
which are disabled with -DNDEBUG.
2015-01-23 07:52:50 +01:00
Akim Demaille 658b189348 tests: c++: fix a C++03 conformance issue
This fixes test 241 on xLC:

"input.y", line 42.11: 1540-0274 (S) The name lookup for "report" did not find a declaration.
"input.y", line 42.11: 1540-1292 (I) Static declarations are not considered for a function call if the function is not qualified.

where report is:

  static void
  report (std::ostream& yyo, int ival, float fval)
  {
    yyo << "ival: " << ival << ", fval: " <<  fval;
  }

and line 42 is:

  %printer { report (yyo, $$,       $<fval>$); } <ival>;

It turns out that indeed this function must not be declared static,
<http://stackoverflow.com/a/17662745/1353549>.  Let's put it into an
anonymous namespace.

Reported by Thomas Jahns.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00059.html

* tests/actions.at (Qualified $$ in actions): Don't use "static",
prefer anonymous namespace.
2015-01-22 08:45:44 +01:00
Akim Demaille a06344172a tests: fix a title
* tests/conflicts.at: De-overquote.
2015-01-20 20:47:02 +01:00
Akim Demaille 573654ca9e c++: reserve 200 slots in the parser's stack
This is consistent with what is done with yacc.c and glr.c.  Because
it also avoids that the stack needs to be resized very soon, it should
help keeping tests about destructors more reliable.

Indeed, if the stack is created too small, very soon the C++ library
needs to enlarge it, which means creating a new one, copying the
elements from the initial one onto it, and then destroy the elements
of the initial stack: that would be a spurious call to a destructor.

Reported by Thomas Jahns.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00059.html

* data/stack.hh (stack::stack): Reserve 200 slots.
* tests/c++.at: Remove traces of stack expansions.
2015-01-20 20:45:48 +01:00
Akim Demaille 0b0370ff42 tests: be more robust to unrecognized synclines, and try to recognize xlc
Reported by Thomas Jahns.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00059.html

* tests/synclines.at (AT_SYNCLINES_COMPILE): Rename as...
(_AT_SYNCLINES_COMPILE): this.
Try to recognize xlc locations.
(AT_SYNCLINES_COMPILE): New.  Skips the test if we can't read the
synclines.
2015-01-20 18:16:09 +01:00
Akim Demaille eaa476a7e9 tests: fix C++ conformance
Reported by Thomas Jahns.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00059.html

* tests/c++.at (Exception safety): Add missing include.
Don't use const_iterator for erase.
2015-01-20 18:04:24 +01:00
Akim Demaille 16832bf546 build: fix some warnings
Reported by John Horigan.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00034.html

* src/graphviz.c, src/symtab.h: Address compiler warnings.
2015-01-18 15:41:15 +01:00
Akim Demaille eabb3df7aa Merge remote-tracking branch 'origin/maint' into origin/master
* origin/maint:
  doc: minor fixes
  gnulib: strtoul is considered obsolete and now useless
  c++: avoid warnings when destructors don't use $$
  maint: post-release administrivia
  version 3.0.3
  gnulib: update
2015-01-16 15:14:41 +01:00
Akim Demaille 0ab29b7c20 build: avoid infinite recursions on include_next
On MacOS X 10.5 PPC with Apple's GCC 4.0.1:

  % uname -a
  Darwin aria.cielonegro.org 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:0
  1 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh
  % gcc --version
  powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
  Copyright (C) 2005 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

building in place enters into an infinite recursion on "#include_next":

  % gmake V=1
  [snip]
  depbase=`echo lib/math.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
  gcc -std=gnu99    -I. -Ilib -I. -I./lib   -g -O2 -MT lib/math.o -MD -MP -MF $depbase.Tpo -c -o lib/math.o lib/math.c &&\
  mv -f $depbase.Tpo $depbase.Po
  In file included from lib/math.h:27,
                   from lib/math.h:27,
                   from lib/math.h:27,
                   from lib/math.h:27,
  [snip]
                   from lib/math.h:27,
                   from lib/math.h:27,
                   from lib/math.c:3:
  lib/math.h:27:23: error: #include nested too deeply
  Makefile:3414: recipe for target 'lib/math.o' failed
  gmake[2]: *** [lib/math.o] Error 1

Using -I./lib instead of -Ilib fixes the problem.

Reported by Pho.
<https://lists.gnu.org/archive/html/bison-patches/2014-01/msg00000.html>

* Makefile.am (AM_CPPFLAGS): Use -I./lib instead of -Ilib.
2015-01-16 10:52:17 +01:00
Akim Demaille 559b30881d doc: minor fixes
* doc/bison.texi: Fix warnings about colon in reference names.
* data/bison.m4, src/files.h: Fix comments.
* doc/Doxyfile.in: update.
2015-01-16 10:52:17 +01:00
Akim Demaille 88ffc4b907 gnulib: strtoul is considered obsolete and now useless
* bootstrap.conf: here.
2015-01-15 17:26:32 +01:00
Akim Demaille 3e82dfaa0d c++: avoid warnings when destructors don't use $$
* data/c++.m4: here.
2015-01-15 14:29:22 +01:00
Akim Demaille 11d820174f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2015-01-15 10:24:34 +01:00
Akim Demaille da6f07468a version 3.0.3
* NEWS: Record release date.
2015-01-15 10:04:53 +01:00
Akim Demaille 93ee7a47e7 gnulib: update 2015-01-15 09:36:14 +01:00
Akim Demaille 875ef1b90c symbol: use the first occurrence as an LHS as defining location
Currently on the following grammar:

    %type <foo> foo
    %%
    start: foo | bar | "baz"
    foo: foo
    bar: bar

bison reports:

    warning: 2 nonterminals useless in grammar [-Wother]
    warning: 4 rules useless in grammar [-Wother]
    1.13-15: warning: nonterminal useless in grammar: foo [-Wother]
     %type <foo> foo
                 ^^^
    3.14-16: warning: nonterminal useless in grammar: bar [-Wother]
     start: foo | bar | "baz"
                  ^^^
    [...]

i.e., the location of the first occurrence of a symbol is taken as its
definition point.  In the case of nonterminals, the first occurrence
as a left-hand side of a rule makes more sense:

    warning: 2 nonterminals useless in grammar [-Wother]
    warning: 4 rules useless in grammar [-Wother]
    4.1-3: warning: nonterminal useless in grammar: foo [-Wother]
     foo: foo
     ^^^
    5.1-3: warning: nonterminal useless in grammar: bar [-Wother]
     bar: bar
     ^^^
    [...]

* src/symtab.h, src/symtab.c (symbol::location_of_lhs): New.
(symbol_location_as_lhs_set): New.
* src/parse-gram.y (current_lhs): Use it.
* tests/reduce.at: Update locations.
2015-01-14 17:05:35 +01:00
Akim Demaille 650af77812 reduce: don't complain about rules whose lhs is useless
In the following grammar, the 'exp' nonterminal is trivially useless.
So, of course, its rules are useless too.

    %%
    input: '0' | exp
    exp: exp '+' exp | exp '-' exp | '(' exp ')'

Previously all the useless rules were reported, including those whose
left-hand side is the 'exp' nonterminal:

    warning: 1 nonterminal useless in grammar [-Wother]
    warning: 4 rules useless in grammar [-Wother]
    2.14-16: warning: nonterminal useless in grammar: exp [-Wother]
     input: '0' | exp
                  ^^^
    2.14-16: warning: rule useless in grammar [-Wother]
     input: '0' | exp
                  ^^^
  ! 3.6-16: warning: rule useless in grammar [-Wother]
  !  exp: exp '+' exp | exp '-' exp | '(' exp ')'
  !       ^^^^^^^^^^^
  ! 3.20-30: warning: rule useless in grammar [-Wother]
  !  exp: exp '+' exp | exp '-' exp | '(' exp ')'
  !                     ^^^^^^^^^^^
  ! 3.34-44: warning: rule useless in grammar [-Wother]
  !  exp: exp '+' exp | exp '-' exp | '(' exp ')'
  !                                   ^^^^^^^^^^^

The interest of being so verbose is dubious.  I suspect most of the
time nonterminals are not expected to be useless, so the user wants to
fix the nonterminal, not remove its rules.  And even if the user
wanted to get rid of its rules, the position of these rules probably
does not help more that just having the name of the nonterminal.

This commit discard these messages, marked with '!', and keep the
others.  In particular, we still report:

    2.14-16: warning: rule useless in grammar [-Wother]
     input: '0' | exp
                  ^^^

All the useless rules (including the '!' ones) are still reported in
the reports (xml, text, etc.); only the diagnostics on stderr change.

* src/gram.c (grammar_rules_useless_report): Don't complain about
useless rules whose lhs is useless.
* src/reduce.h, src/reduce.c (reduce_nonterminal_useless_in_grammar):
Take a sym_content as argument.
Adjust callers.
* tests/reduce.at (Useless Rules, Underivable Rules, Reduced Automaton):
Adjust.
2015-01-14 13:59:53 +01:00
Akim Demaille c03a8db0cc style: reduce: use unsigned to count a number of objects
* src/reduce.h, src/reduce.c (nuseful_productions, nuseless_productions)
(nuseful_nonterminals, nuseless_nonterminals): Declare as unsigned.
Simplify "0 <" tests into non-zero tests.
2015-01-14 10:13:49 +01:00
Akim Demaille 8b06c6b871 style: reduce: introduce and use a swap for bitset
* src/reduce.c (bitset_swap): New.
Use it.
2015-01-14 10:13:49 +01:00
Akim Demaille c5da1a2adc style: reduce: reduce scopes and other stylistic changes
* src/reduce.c: Various stylistic changes:
Reduce scopes.
Prefer ++i to i++.
Prefer < to >.
2015-01-14 10:13:30 +01:00
Akim Demaille dfd5b89d01 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  tests: split a large test case into several smaller ones
  package: a bit of trouble shooting indications
  doc: liby's main arms the internationalization
  bison: avoid warnings from static code analysis
  c++: fix the use of destructors when variants are enabled
  style: tests: simplify the handling of some C++ tests
  c++: symbols can be empty, so use it
  c++: variants: don't leak the lookahead in error recovery
  c++: provide a means to clear symbols
  c++: clean up the handling of empty symbols
  c++: comment and style changes
  c++: variants: comparing addresses of typeid.name() is undefined
  c++: locations: complete the API and fix comments
  build: do not clean figure sources in make clean
2015-01-13 14:45:15 +01:00
Akim Demaille ca5a716303 tests: split a large test case into several smaller ones
* tests/conflicts.at (AT_CONSISTENT_ERRORS_CHECK): Move AT_SETUP/AT_CLEANUP
into it, so that we don't skip non Java tests following a test case in Java.
2015-01-13 14:19:02 +01:00
Akim Demaille d72642d691 package: a bit of trouble shooting indications
* README-hacking: here.
2015-01-12 12:11:53 +01:00
Akim Demaille 9a91e7f246 doc: liby's main arms the internationalization
Reported by Nicolas Bedon.
<https://lists.gnu.org/archive/html/bug-bison/2014-11/msg00005.html>

* doc/bison.texi (Yacc Library): Document the call the setlocale.
2015-01-12 11:37:24 +01:00
Akim Demaille 671850a1c3 bison: avoid warnings from static code analysis
A static analysis tool reports that some callers of symbol_list_n_get
might get NULL and not handle it properly.  This is not the case, yet
we can suppress this pattern.

Reported by Mike Sullivan.
<https://lists.gnu.org/archive/html/bug-bison/2013-12/msg00027.html>

* src/symlist.c (symbol_list_n_get): Actually it is never called
to return 0.  Enforce this postcondition via aver.
(symbol_list_n_type_name_get): Simplify accordingly.  In particular,
discards a (translated) useless error message.
* src/symlist.h: Adjust documentation.
* src/scan-code.l: Style change.
2015-01-09 15:27:59 +01:00
Akim Demaille ee028dceff c++: fix the use of destructors when variants are enabled
When using variants, destructors generate invalid code.
<http://lists.gnu.org/archive/html/bug-bison/2014-09/msg00005.html>
Reported by Michael Catanzaro.

* data/c++.m4 (~basic_symbol): b4_symbol_foreach works on yysym:
define it.
* tests/c++.at (Variants): Check it.
2015-01-09 13:54:58 +01:00
Akim Demaille e1d06b5235 style: tests: simplify the handling of some C++ tests
* tests/c++.at: here.
(Doxygen): Pass %define, so that files such as position.hh etc.
are generated, instead of putting everything into input.hh.
2015-01-08 16:08:00 +01:00
Akim Demaille 821394a3c8 c++: symbols can be empty, so use it
The previous patches ensure that symbols (symbol_type and
stack_symbol_type) can be empty, cleared, and their emptiness can be
checked.  Therefore, yyempty, which codes whether yyla is empty or
not, is now useless.

In C skeletons (e.g., yacc.c), the fact that the lookahead is empty is
coded by "yychar = YYEMPTY", which is exactly what this patch
restores, since yychar/yytoken corresponds to yyla.type.

* data/lalr1.cc (yyempty): Remove.
Rather, depend on yyla.empty ().
2015-01-08 16:07:59 +01:00
Akim Demaille 00cebd11d4 c++: variants: don't leak the lookahead in error recovery
During error recovery, when discarding the lookeahead, we don't
destroy it, which is caught by parse.assert assertions.

Reported by Antonio Silva Correia.
With an analysis and suggested patch from Michel d'Hooge.
<http://savannah.gnu.org/support/?108481>

* tests/c++.at (Variants): Strengthen the test to try syntax errors
with discarded lookahead.
2015-01-08 16:07:59 +01:00
Akim Demaille ee2f433512 c++: provide a means to clear symbols
The symbol destructor is currently the only means to clear a symbol.
Unfortunately during error recovery we might have to clear the
lookahead, which is a local variable (yyla) that has not yet reached
its end of scope.

Rather that duplicating the code to destroy a symbol, or rather than
destroying and recreating yyla, let's provide a means to clear a
symbol.

Reported by Antonio Silva Correia, with an analysis from Michel d'Hooge.
<http://savannah.gnu.org/support/?108481>

* data/c++.m4, data/lalr1.cc (basis_symbol::clear, by_state::clear)
(by_type::clear): New.
(basic_symbol::~basic_symbol): Use clear.
2015-01-08 16:07:59 +01:00
Akim Demaille 5422471cbb c++: clean up the handling of empty symbols
* data/c++.m4, data/lalr1.cc (yyempty_): Remove, replaced by...
(empty_symbol, by_state::empty_state): these.
(basic_symbol::empty): New.
2015-01-08 14:45:42 +01:00
Akim Demaille 8a4ec3595b c++: comment and style changes
* data/c++.m4, data/lalr1.cc: More documentation.
Tidy.
* tests/c++.at (string_cast): Rename as...
(to_string): this C++11 name.
2015-01-08 11:25:07 +01:00
Akim Demaille 7cf84b13a0 c++: variants: comparing addresses of typeid.name() is undefined
Instead of storing and comparing pointers to names of types, store
pointers to the typeids, and compares the typeids.
Reported by Thomas Jahns.
<http://lists.gnu.org/archive/html/bug-bison/2014-03/msg00001.html>

* data/variant.hh (yytname_): Replace with...
(yytypeid_): this.
2015-01-07 10:34:07 +01:00
Akim Demaille 56351d4c7b c++: locations: complete the API and fix comments
There are no support for += between locations, and some comments are wrong.
Reported by Alexandre Duret-Lutz.

* data/location.cc: Fix.
* doc/bison.texi: Document.
* tests/c++.at: Check.
2015-01-05 18:32:23 +01:00
Akim Demaille 478c4a8f49 build: do not clean figure sources in make clean
"make clean && make" fails in in-tree builds.

* doc/local.mk (CLEANDIRS): Replace with...
(CLEANFILES): this safer list of files to clean.
2015-01-05 14:41:46 +01:00
Akim Demaille 13e294ee55 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  build: don't try to generate docs when cross-compiling
  package: fix a reporter's name
  %union: fix the support for named %union
  package: bump to 2015
  flex: don't trust YY_USER_INIT
  yacc.c: fix broken union when api.value.type=union and %defines are used
  doc: fix missing xref
  gnulib: update
  location: remove some ugly debugging code traces
  build: use abort to pacify compiler errors
  package: bump to 2014
  doc: specify documentation encoding
2015-01-05 13:51:30 +01:00
Akim Demaille a16074bb09 build: don't try to generate docs when cross-compiling
When cross-compiling don't run the generated bison to update the docs.
Reported by Aaro Koskinen.
<http://lists.gnu.org/archive/html/bison-patches/2014-03/msg00000.html>

* configure.ac (CROSS_COMPILING): New.
* doc/local.mk: Use it.
2015-01-05 12:27:27 +01:00
Akim Demaille 8386f6ef28 package: fix a reporter's name
* THANKS, build-aux/git-log-fix: s/Bernd Edligner/Bernd Edlinger/.
2015-01-04 18:00:51 +01:00
Akim Demaille 827bc59ca1 %union: fix the support for named %union
Bison supports a union tag, for obscure reasons.  But it does a poor
job at it, especially since Bison 3.0.
Reported by Stephen Cameron and Tobias Frost.

It did not ensure that the name was not given several times.  An easy
way to do this is to make the %union tag be handled as a %define
variable, as they cannot be defined several times.

Since Bison 3.0, the synclines were wrongly placed, resulting in
invalid code.  Addressing this issue, because of the way the union tag
was stored (as a code muscle), would have been tedious.  Unless we
rather define the %union tag as a %percent variable, whose synclines
are easier to manipulate.

So replace the b4_union_name muscle by the api.value.union.name
%define variable, document, and check.

* data/bison.m4: Make sure that api.value.union.name has a keyword value.
* data/c++.m4: Make sure that api.value.union.name is not defined.
* data/c.m4 (b4_union_name): No longer use it, use api.value.union.name.
* doc/bison.texi (%define Summary): Document it.
* src/parse-gram.y (union_name): No longer define b4_uion_name, but
api.value.union.name.
* tests/input.at (Redefined %union name): New.
* tests/synclines.at (%union name syncline): New.
* tests/types.at: Check named %unions.
2015-01-04 18:00:51 +01:00
Akim Demaille 3209eb1c4c package: bump to 2015
Which also requires:

* gnulib: Update.
2015-01-04 17:49:13 +01:00
Akim Demaille 975bb56431 flex: don't trust YY_USER_INIT
Reported by Bernd Edligner and others.

* src/scan-gram.l: here.
2014-12-31 14:54:43 +01:00
Akim Demaille 8d4dc896cb yacc.c: fix broken union when api.value.type=union and %defines are used
Reported by Rich Wilson.

* data/c.m4 (b4_symbol_type_register): Append to b4_union_members,
not b4_user_union_members.
The latter invokes the former, but it is the former which is reinitialized
to empty by b4_value_type_setup_union.
* tests/types.at: Check it.

This reveals another bug, this time in the case of glr.c parsers.

* data/glr.c: Generate the header file before the implementation file,
to be sure that the setup is run before what depends on it.
2014-12-31 14:39:05 +01:00
Akim Demaille a3c3c6f242 doc: fix missing xref
Reported by xolodho.

* doc/bison.texi (Printer Decl): here.
2014-12-31 12:49:39 +01:00
Akim Demaille 179b2419ba gnulib: update 2014-12-29 16:13:57 +01:00
Akim Demaille b702ec61ab location: remove some ugly debugging code traces
* data/location.cc: here.
2014-02-03 15:27:03 +01:00
Akim Demaille ab96bb2457 build: use abort to pacify compiler errors
clang, with -DNDEBUG and -Werror fails on some functions that might
lack a return.  This is because aver is just another assert, discarded
with -DNDEBUG.  So use abort.

* src/muscle-tab.c, src/scan-skel.l: here.
2014-02-03 15:27:02 +01:00
Akim Demaille fc51acddb4 package: bump to 2014
* AUTHORS, ChangeLog-2012, Makefile.am, NEWS, PACKAGING, README,
* README-alpha, README-hacking, THANKS, TODO, bootstrap.conf,
* build-aux/darwin11.4.0.valgrind, build-aux/local.mk,
* build-aux/update-b4-copyright,
* build-aux/update-package-copyright-year, cfg.mk, configure.ac,
* data/README, data/bison.m4, data/c++-skel.m4, data/c++.m4,
* data/c-like.m4, data/c-skel.m4, data/c.m4, data/glr.c, data/glr.cc,
* data/java-skel.m4, data/java.m4, data/lalr1.cc, data/lalr1.java,
* data/local.mk, data/location.cc, data/stack.hh, data/variant.hh,
* data/xslt/bison.xsl, data/xslt/xml2dot.xsl, data/xslt/xml2text.xsl,
* data/xslt/xml2xhtml.xsl, data/yacc.c, djgpp/Makefile.maint,
* djgpp/README.in, djgpp/config.bat, djgpp/config.sed,
* djgpp/config.site, djgpp/config_h.sed, djgpp/djunpack.bat,
* djgpp/local.mk, djgpp/subpipe.c, djgpp/subpipe.h,
* djgpp/testsuite.sed, doc/bison.texi, doc/local.mk, doc/refcard.tex,
* etc/README, etc/bench.pl.in, etc/local.mk,
* examples/calc++/calc++.test, examples/calc++/local.mk,
* examples/extexi, examples/local.mk, examples/mfcalc/local.mk,
* examples/mfcalc/mfcalc.test, examples/rpcalc/local.mk,
* examples/rpcalc/rpcalc.test, examples/test, examples/variant.yy,
* lib/abitset.c, lib/abitset.h, lib/bbitset.h, lib/bitset.c,
* lib/bitset.h, lib/bitset_stats.c, lib/bitset_stats.h,
* lib/bitsetv-print.c, lib/bitsetv-print.h, lib/bitsetv.c,
* lib/bitsetv.h, lib/ebitset.c, lib/ebitset.h, lib/get-errno.c,
* lib/get-errno.h, lib/lbitset.c, lib/lbitset.h, lib/libiberty.h,
* lib/local.mk, lib/main.c, lib/timevar.c, lib/timevar.def,
* lib/timevar.h, lib/vbitset.c, lib/vbitset.h, lib/yyerror.c,
* m4/bison-i18n.m4, m4/c-working.m4, m4/cxx.m4, m4/flex.m4,
* m4/timevar.m4, src/AnnotationList.c, src/AnnotationList.h,
* src/InadequacyList.c, src/InadequacyList.h, src/LR0.c, src/LR0.h,
* src/Sbitset.c, src/Sbitset.h, src/assoc.c, src/assoc.h,
* src/closure.c, src/closure.h, src/complain.c, src/complain.h,
* src/conflicts.c, src/conflicts.h, src/derives.c, src/derives.h,
* src/files.c, src/files.h, src/flex-scanner.h, src/getargs.c,
* src/getargs.h, src/gram.c, src/gram.h, src/graphviz.c,
* src/graphviz.h, src/ielr.c, src/ielr.h, src/lalr.c, src/lalr.h,
* src/local.mk, src/location.c, src/location.h, src/main.c,
* src/muscle-tab.c, src/muscle-tab.h, src/named-ref.c,
* src/named-ref.h, src/nullable.c, src/nullable.h, src/output.c,
* src/output.h, src/parse-gram.c, src/parse-gram.y, src/print-xml.c,
* src/print-xml.h, src/print.c, src/print.h, src/print_graph.c,
* src/print_graph.h, src/reader.c, src/reader.h, src/reduce.c,
* src/reduce.h, src/relation.c, src/relation.h, src/scan-code.h,
* src/scan-code.l, src/scan-gram.h, src/scan-gram.l, src/scan-skel.h,
* src/scan-skel.l, src/state.c, src/state.h, src/symlist.c,
* src/symlist.h, src/symtab.c, src/symtab.h, src/system.h,
* src/tables.c, src/tables.h, src/uniqstr.c, src/uniqstr.h,
* tests/actions.at, tests/atlocal.in, tests/bison.in, tests/c++.at,
* tests/calc.at, tests/conflicts.at, tests/cxx-type.at,
* tests/existing.at, tests/glr-regression.at, tests/headers.at,
* tests/input.at, tests/java.at, tests/javapush.at, tests/local.at,
* tests/local.mk, tests/named-refs.at, tests/output.at, tests/push.at,
* tests/reduce.at, tests/regression.at, tests/sets.at,
* tests/skeletons.at, tests/synclines.at, tests/testsuite.at,
* tests/torture.at, tests/types.at:
here.
2014-02-03 15:27:02 +01:00
Paul Eggert 957255b82c doc: specify documentation encoding
* doc/bison.texi: Add '@documentencoding UTF-8'; needed since the
manual contains UTF-8 characters.  This will cause the .info files
to contain UTF-8 quotes and the like, which should be OK nowadays.
Add @documentlanguage while we're at it.
2014-01-03 11:08:50 -08:00
Akim Demaille 8044fda634 symbols: properly fuse the properties of two symbol aliases
This completes and fixes a728075710.
Reported by Valentin Tolmer.

Before it Bison used to put the properties of the symbols
(associativity, printer, etc.) in the 'symbol' structure.  An
identifier-named token (FOO) and its string-named alias ("foo")
duplicated these properties, and symbol_check_alias_consistency()
checked that both had compatible properties and fused them, at the end
of the parsing of the grammar.

The commit a728075710 introduces a
sym_content structure that keeps all these properties, and ensures
that both aliases point to the same sym_content (instead of
duplicating).  However, it removed symbol_check_alias_consistency,
which resulted in the non-fusion of *existing* properties:

  %token FOO "foo"
  %left FOO %left "foo"

was properly diagnosed as a redeclaration, but

  %left FOO %left "foo"
  %token FOO "foo"

was not, as the properties of FOO and "foo" were not checked before
fusion.  It certainly also means that

  %left "foo"
  %token FOO "foo"

did not transfer properly the associativity to FOO.

The fix is simple: reintroduce symbol_check_alias_consistency (under a
better name, symbol_merge_properties) and call it where appropriate.

Also, that commit made USER_NUMBER_HAS_STRING_ALIAS useless, but left
it.

* src/symtab.h (USER_NUMBER_HAS_STRING_ALIAS): Remove, unused.
Adjust dependencies.
* src/symtab.c (symbol_merge_properties): New, based on the former
symbol_check_alias_consistency.
* tests/input.at: Re-enable tests that we now pass.
2013-12-10 09:43:33 +01:00
Akim Demaille b7d4c48e55 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  package: install the examples
  package: install README and the like in docdir
  diagnostics: fix the order of multiple declarations reports
  symbol: provide an easy means to compare them in source order

Conflicts:
  src/symtab.c
  tests/input.at

* tests/input.at: Comment out a test that master currently does not
pass (because of a728075710).
2013-12-10 08:53:07 +01:00
Akim Demaille b167e7ba0d package: install the examples
Currently, we do not install the various examples extracted from the
documentation.  Let's do it, as they are useful starting points.

* configure.ac: When --enable-gcc-warnings is set, enable ENABLE_GCC_WARNINGS.
* examples/extexi: No longer issue synclines by default.
* examples/local.mk: Except if ENABLE_GCC_WARNINGS.
* examples/calc++/local.mk, examples/mfcalc/local.mk,
* examples/rpcalc/local.mk: Install the example files.
2013-12-09 16:53:14 +01:00
Akim Demaille 85d57e27d2 package: install README and the like in docdir
* Makefile.am: here.
2013-12-09 16:53:14 +01:00
Akim Demaille 461f1516f8 diagnostics: fix the order of multiple declarations reports
On

  %token FOO "foo"
  %printer {} "foo"
  %printer {} FOO

we report

  /tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO
   %printer {} "foo"
            ^^
  /tmp/foo.yy:3.10-11:     previous declaration
   %printer {} FOO
            ^^

* src/symtab.c (locations_sort): New.
Use it.
* tests/input.at (Invalid Aliases): Stress the order of diagnostics.
2013-12-09 16:53:03 +01:00
Akim Demaille 26eb4f0bdc symbol: provide an easy means to compare them in source order
* src/symtab.c (symbols_sort): New.
(user_token_number_redeclaration): Taken from here.
2013-12-09 16:03:03 +01:00
Akim Demaille fc6c85664a Merge remote-tracking branch 'origin/maint'
* origin/maint: (43 commits)
  maint: post-release administrivia
  version 3.0.2
  gnulib: update
  output: do not generate source files when late errors are caught
  output: record what generated files are source or report files
  output: do not generate source files when early errors are caught
  xml: also use "%empty" with html output
  style: formatting changes
  xml: also display %empty for empty right-hand sides
  reports: display %empty in the generated pointed-rules
  news: YYERROR vs variants
  style: scope reduction in lalr.cc
  lalr1.cc: formatting changes
  lalr1.cc: fix the support of YYERROR with variants
  tests: check $$'s destruction with variant, YYERROR, and no error recovery
  tests: simplify useless obfuscation
  skeletons: use better names when computing a "goto"
  maint: post-release administrivia
  version 3.0.1
  aver: it is no longer "protected against NDEBUG"
  ...

Conflicts:
  data/glr.c
2013-12-09 10:43:37 +01:00
Akim Demaille 0bd5ee5f89 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2013-12-05 15:16:28 +01:00
Akim Demaille a3efd13e44 version 3.0.2
* NEWS: Record release date.
2013-12-05 14:58:22 +01:00
Akim Demaille a4122000c6 gnulib: update
* gnulib: here.
2013-12-05 14:42:08 +01:00
Akim Demaille 461983270c output: do not generate source files when late errors are caught
Reported by Alexandre Duret-Lutz as "second problem" in:
http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html

* bootstrap.conf: We need the "unlink" module.
* src/files.h, src/files.c (unlink_generated_sources): New.
* src/output.c: Use it.
* tests/output.at: Check the case of late errors.
2013-12-04 15:53:01 +01:00
Akim Demaille ea99d6e6a0 output: record what generated files are source or report files
* src/files.h, src/files.c (output_file_name_check): Take an additional
argument to record whether a file is a source or report file.
* src/files.c (generated_file): New.
(file_names, file_names_count): Replace with...
(generated_files, generated_files_size): these.
* src/scan-skel.l: Adjust.
2013-12-04 15:53:01 +01:00
Akim Demaille 184b42c85b output: do not generate source files when early errors are caught
Reported by Alexandre Duret-Lutz as "second problem" in:
http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html

One problem is that some errors are caught early, before the
generation of output files, while others can only be detected
afterwards (since, for instance, skeletons can raise errors
themselves).

This will be addressed in two steps: early errors do not generate
source files at all, while later errors will remove the files that
have already been generated.

* src/scan-skel.l (yyout): Open to /dev/null when there are errors.
* tests/output.at (AT_CHECK_FILES): Factored out of...
(AT_CHECK_OUTPUT): this.
Fuse the "SHELLIO" argument in the "FLAGS" one.
Use $5 to denote the expected exit status.
Add a test case for early errors.
2013-12-04 15:53:01 +01:00
Akim Demaille be29c71dd8 xml: also use "%empty" with html output
* data/xslt/xml2xhtml.xsl: No longer issue an Epsilon, display as in
dot and text formats.
2013-11-26 16:28:22 +01:00
Akim Demaille d439985436 style: formatting changes
* src/print-xml.c: here.
2013-11-26 16:20:55 +01:00
Akim Demaille f3d2a1b2ac xml: also display %empty for empty right-hand sides
* data/xslt/xml2dot.xsl, data/xslt/xml2text.xsl: Display %empty where needed.
2013-11-26 16:20:52 +01:00
Akim Demaille 21cf80399f reports: display %empty in the generated pointed-rules
* src/print.c (print_core): Use %empty for empty rules.
* src/print_graph.c (print_core): Ditto.
* tests/conflicts.at, tests/output.at, tests/reduce.at: Adjust
expectations.
2013-11-26 15:31:52 +01:00
Akim Demaille 7b0ca050f7 news: YYERROR vs variants 2013-11-26 15:31:51 +01:00
Akim Demaille a339aef48a style: scope reduction in lalr.cc
* src/lalr.c: Shorten variable scopes.
(lookahead_tokens_print): Use the same variable name in two loops
iterating over the same structure.
2013-11-18 10:29:23 +01:00
Akim Demaille 44186fc4ec lalr1.cc: formatting changes
* data/lalr1.cc: Fix indentation.
2013-11-15 10:14:06 +01:00
Akim Demaille 5c77412162 lalr1.cc: fix the support of YYERROR with variants
When variant are enabled, the yylhs variable (the left-hand side of
the rule being reduced, i.e. $$ and @$) is explicitly destroyed when
YYERROR is called.  This is because before running the user code, $$
is initialized, so that the user can properly use it.

However, when quitting yyparse, yylhs is also reclaimed by the C++
compiler: the variable goes out of scope.

Instead of trying to be too smart, let the compiler do its job: reduce
the scope of yylhs to exactly the reduction.  This way, whatever the
type of scope exit (regular, exception, return, goto...) this variable
will be properly reclaimed.

Reported by Paolo Simone Gasparello.
<http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00003.html>

* data/lalr1.cc (yyparse): Reduce the scope of yylhs.
* tests/c++.at: We now pass this test.
2013-11-15 10:14:05 +01:00
Akim Demaille 5cf6e669af tests: check $$'s destruction with variant, YYERROR, and no error recovery
When variant are enabled, the yylhs variable (the left-hand side of
the rule being reduced, i.e. $$ and @$) is explicitly destroyed when
YYERROR is called.  This is because before running the user code, $$
is initialized, so that the user can properly use it.

However, when quitting yyparse, yylhs is also reclaimed by the C++
compiler: the variable goes out of scope.

This was not detected by the test suite because (i) the Object tracker
was too weak, and (ii) the problem does not show when there is error
recovery.

Reported by Paolo Simone Gasparello.
<http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00003.html>

* tests/c++.at (Exception safety): Improve the objects logger to make
sure that we never destroy twice an object.
Also track copy-constructors.
Use a set instead of a list.
Display the logs before running the function body, this is more
useful in case of failure.
Generalize to track with and without error recovery.
2013-11-15 10:13:47 +01:00
Akim Demaille 16bb9f1647 tests: simplify useless obfuscation
* tests/c++.at: $$ is not special for M4, there is no need to "escape"
it.
2013-11-15 09:38:15 +01:00
Akim Demaille edb2e90531 skeletons: use better names when computing a "goto"
* data/glr.c (yyLRgotoState): Name the symbol argument yysym, instead
of yylhs.
* data/lalr1.cc (yy_lr_goto_state_): Likewise.
* data/lalr1.java (yy_lr_goto_state_): New, modeled after the previous
two routines.
Use it.
2013-11-14 16:26:16 +01:00
Akim Demaille 6d94eebba7 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2013-11-12 18:37:14 +01:00
Akim Demaille c2ecada32b version 3.0.1
* NEWS: Record release date.
2013-11-12 15:55:33 +01:00
Akim Demaille 458171e6df aver: it is no longer "protected against NDEBUG"
Apply the same rules for aver as for assert: no side effects,
especially not important ones.

* src/AnnotationList.c, src/muscle-tab.c: Adjust aver uses to resist
to -DNDEBUG.
2013-11-12 15:49:10 +01:00
Akim Demaille 8d0b7cef7d parsers: rename YY_NULL as YY_NULLPTR to avoid conflicts with Flex
Flex also defines YY_NULL (to 0).  Avoid gratuitous conflicts.

* data/c.m4 (b4_null_define): Rename YY_NULL as YY_NULLPTR.

* data/glr.c, data/lalr1.cc, data/location.cc, data/variant.hh,
* data/yacc.c, src/parse-gram.c, tests/actions.at, tests/c++.at,
* tests/cxx-type.at, tests/glr-regression.at, tests/headers.at,
* tests/push.at, tests/regression.at:
Adjust.
2013-11-08 10:52:15 +01:00
Akim Demaille afc4457605 build: use Automake 1.14's non-recursive Makefile features
* configure.ac: Require Automake 1.14.
* examples/calc++/local.mk, examples/local.mk, examples/mfcalc/local.mk,
* examples/rpcalc/local.mk, tests/local.mk: Use %D% and %C%.
2013-11-05 14:32:20 +01:00
Akim Demaille 60dcc936ce build: restore maintainer-push-check
* tests/local.mk: here.
2013-11-05 14:15:15 +01:00
Akim Demaille ad9d4f9f2e c++: use __attribute__((__pure__)) to avoid warnings
Building C++ parsers with -Wsuggest-attribute=const and
-Wsuggest-attribute=noreturn triggers warning in generated code.

* data/lalr1.cc: Call b4_attribute_define.
(debug_stream, debug_level): Flag as pure.
* tests/headers.at (Several parsers): There are now more YY macros
that "leak".
2013-11-05 10:44:03 +01:00
Akim Demaille 3cc83855d9 skeletons: update the handling of compiler attributes
* data/c.m4 (b4_attribute_define): Instead of defining __attribute__,
define YY_ATTRIBUTE conditionally.
(YY_ATTRIBUTE_PURE, YY_ATTRIBUTE_UNUSED, _Noreturn): New.
Use them.
* data/glr.c: Use them.
2013-11-05 10:44:03 +01:00
Akim Demaille 5407fc7d76 gnulib: update 2013-11-05 10:44:03 +01:00
Akim Demaille 516652b474 style: use /* ... */ comments
* src/complain.c: Here.
2013-10-24 17:22:21 +02:00
Akim Demaille 026816664f tests: skip C++ tests that are too demanding for some compilers
Some tests now fail when compiled with G++ 4.3 or 4.4 on MacPorts.

* tests/local.at (AT_SKIP_IF_EXCEPTION_SUPPORT_IS_POOR): New.
* tests/c++.at (Exception safety): Use it.
2013-10-24 17:22:21 +02:00
Akim Demaille 265640d56e install: do not install yacc.1 when --disable-yacc
* configure.ac (ENABLE_YACC): New conditional.
(YACC_SCRIPT, YACC_LIBRARY): Remove.
* lib/local.mk, src/local.mk: Use the former instead of the latter.
* doc/local.mk: Use ENABLE_YACC to avoid installing yacc.1.
2013-10-22 17:34:22 +02:00
Akim Demaille ee9cdb8595 style: avoid tabs
* src/scan-code.l: here.
2013-10-22 16:43:17 +02:00
Akim Demaille a810712331 c++: fix generated doxygen comments
* configure.ac: Enable -Wdocumentation if supported.
* data/lalr1.cc: Fix comments.
2013-10-22 16:31:57 +02:00
Akim Demaille 1a9646fc91 fix: uniqstr are already pointers
* src/uniqstr.c (uniqstr_assert): Remove incorrect double indirection,
and now useless cast.
2013-10-22 16:29:22 +02:00
Paul Eggert 67411a88a0 bison: pacify Sun C 5.12
* src/scan-code.l (show_sub_message):
Redo initializations to work around a bogus Sun C 5.12 warning.
(parse_ref): Remove unreachable code that Sun C 5.12 complains about.
* src/uniqstr.h (uniqstr_vsprintf): Use
_GL_ATTRIBUTE_FORMAT_PRINTF (...)  instead of __attribute__
((__format__ (__printf__, ...))).  Otherwise, Sun C 5.12
complains about an unknown attribute.
2013-10-21 15:23:43 -07:00
Paul Eggert 0bfe22b6d5 maint: git now ignores rpcalc
* examples/rpcalc/.gitignore: Ignore rpcalc.
2013-10-21 15:23:43 -07:00
Paul Eggert 3a684d611e build: examples/calc++/calc++ requires flex
* configure.ac (FLEX_CXX_WORKS): New AM_CONDITIONAL.
* examples/calc++/local.mk (examples/calc++/calc++):
Build if FLEX_CXX_WORKS, not BISON_CXX_WORKS.
2013-10-21 15:23:42 -07:00
Paul Eggert a9733794bb maint: mention help2man, texinfo, apt-get
* README-hacking: Add help2man, texinfo.
Describe how to add packages if you're using Debian.
2013-10-21 15:23:42 -07:00
Paul Eggert 19fe1aa332 maint: git now ignores .log and .trs files
* .gitignore: Add *.log, *.trs.
2013-10-21 15:23:42 -07:00
Akim Demaille 39bace5da8 tests: fix incorrect object construction
Reported by Ken Moffat.
http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00009.html

* tests/c++.at (Exception safety): Here.
2013-10-21 10:36:53 +02:00
Akim Demaille 071863b3d8 glr: allow spaces between "%?" and "{" in predicates
Reported by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00004.html
http://stackoverflow.com/questions/19330171/

* src/scan-gram.l: Do not try to be too smart when diagnosing invalid
directives.
* tests/glr-regression.at (Predicates): New test.
2013-10-16 15:51:25 +02:00
Akim Demaille e4678430c2 diagnostics: "-Werror -Wno-error=foo" must not emit errors
Currently "-Werror -Wno-error=foo" still turns "foo" warnings into errors.
Reported by Alexandre Duret-Lutz.
See http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html.

* src/complain.c (errority, errority_flag): New.
(complain_init): Initialize the latter.
(warning_argmatch): Extract the loop iterating on the flag's bits.
Set and unset errority_flag here.
(warnings_argmatch): -Wno-error is not the same as -Wno-error=everything:
we must remember if category foo was explicitly turned in an error/warning
via -W(no-)error=foo.
(warning_severity): Use errority_flag.

* tests/input.at (Symbols): Just check --yacc, not -Wyacc, that's the
job of tests on -W.
(-Werror is not affected by -Wnone and -Wall): Rename as...
(-Werror combinations): this.
Tests more combinations of -W, -W(no-)error, and -W(no-)error=foo.
* tests/local.at (AT_BISON_CHECK_WARNINGS): Don't expect -Werror
to turn runs that issue warnings into runs with errors, as the
warnings might be enforced as warnings by -Wno-error=foo, in which
case -Werror does not change anything.

* doc/bison.texi (Bison Options): Try to be clearer about how
-W(no-)error and -W(no-)error=foo interact.
2013-10-16 14:56:09 +02:00
Akim Demaille 2b7fe38c36 comment changes
* src/complain.h, src/complain.c: More documentation, more comments.
2013-10-16 14:45:27 +02:00
Andreas SchwabandAkim Demaille 4c4191cec2 location: fix EOF check
* location.c (location_caret): Use int, not char, for values from
getc.
2013-10-04 14:00:52 +02:00
Akim Demaille ae7cd18c98 style: variant: remove empty line
* data/variant.hh (b4_symbol_constructor_define_): Remove
stray eol.
2013-09-19 16:45:09 +02:00
Akim Demaille 4f3cc9c21b Merge remote-tracking branch 'origin/maint'
* origin/maint:
  glr: more assertions
  glr: shorten scopes
  glr: formatting changes
  glr: better use of tracing macros
  examples: improve the output of the "variant" example
  variant: remove useless assertion
  tests: remove stray debugging traces
  tests: do not use grep -q
  build: don't require flex for ordinary builds
  maint: update .gitignore
  build: port to pre-5.8.7 perl
  tests: minor change to make it easier to test other skeletons
  uniqstr: fix assertion
2013-09-19 16:33:20 +02:00
Akim Demaille 55a2063005 glr: simplify the invocation of YYLLOC_DEFAULT
The commit which introduces yyresolveLocations (commit
8710fc41aa) saves and restores the
look-ahead (type, value and location) for no clear reason.  This
appears to be useless.

* data/glr.c (yyresolveLocations): Don't save/restore the current
look-ahead to call YYLLOC_DEFAULT.
Minor style changes.
2013-09-19 16:14:07 +02:00
Akim Demaille 77482f2783 glr: more assertions
* data/glr.c (yyaddDeferredAction, yyglrShiftDefer, yypdumpstack):
More assertions.
2013-09-19 15:58:00 +02:00
Akim Demaille 5a6e85fb8d glr: shorten scopes
* data/glr.c (yyglrReduce): Define yyflag with its value.
2013-09-19 15:57:59 +02:00
Akim Demaille 9e87ff5472 glr: formatting changes
* data/glr.c: here.
2013-09-19 15:57:59 +02:00
Akim Demaille 3afe18fd1f glr: better use of tracing macros
* data/glr.c (yydestroyGLRState): Use YY_SYMBOL_PRINT instead of
yy_symbol_print.
2013-09-19 15:57:59 +02:00
Akim Demaille b51cf830a6 examples: improve the output of the "variant" example
* examples/variant.yy: Improve the printing of lists.
2013-09-19 15:57:59 +02:00
Akim Demaille 66b03e134f variant: remove useless assertion
* data/variant.hh (move): Remove precondition assertion which is
ensured by the first call of the body (this precondition is also one
of "build").
2013-09-19 15:57:59 +02:00
Akim Demaille 3dc50b3bc2 tests: remove stray debugging traces
* tests/atlocal.in: Remove traces.
Be ready to remove conftest.dSYM generated on OS X.
2013-09-19 15:57:59 +02:00
Akim Demaille 0a244a2269 tests: do not use grep -q
Reported by Daniel Galloway.
http://lists.gnu.org/archive/html/bug-bison/2013-08/msg00020.html

* tests/java.at: Ignore grep's output instead.
2013-09-04 17:26:17 +02:00
Paul Eggert b5e27aa262 build: don't require flex for ordinary builds
* configure.ac (LEX): Don't fail if this is lex, as flex is not
required for ordinary builds.  Instead, issue a warning and
substitute a no-op LEX.  Reported by Michael Felt in
<http://lists.gnu.org/archive/html/bug-bison/2013-08/msg00009.html>.
2013-08-24 18:22:44 -07:00
Paul Eggert 0149d39e6e maint: update .gitignore
* .gitignore: Add *.eps, *.o, *.pdf, *.png, *.stamp, *~,
.deps, .dirstamp.  Needed to suppress unwanted chatter from
'git status' after a bootstrap build.
2013-08-24 18:00:52 -07:00
Paul Eggert 1d91bfdf1c build: port to pre-5.8.7 perl
* examples/local.mk (extract): Omit -f from perl options.
This doesn't work with perl versions before 5.8.7
that are configured without USE_SITECUSTOMIZE.
Reported by Michael Felt in
<http://lists.gnu.org/archive/html/bug-bison/2013-08/msg00006.html>.
2013-08-24 07:55:47 -07:00
Akim Demaille db40c3f869 tests: minor change to make it easier to test other skeletons
* tests/c++.at (Variants): Pass the skeleton as argument.
2013-08-01 16:11:27 +02:00
Valentin TolmerandAkim Demaille b663fd5322 uniqstr: fix assertion
* src/uniqstr.c (uniqstr_assert): Really make sure str is a uniqstr,
not just whether some uniqstr with the same content was registered.
2013-08-01 15:29:21 +02:00
237 changed files with 12216 additions and 8136 deletions
+10 -1
View File
@@ -1,7 +1,16 @@
*.eps
*.log
*.o
*.pdf
*.png
*.stamp
*.trs
*~
.deps
.dirstamp
/*.cache
/*.flc
/*.prj
/*~
/.tarball-version
/.version
/ABOUT-NLS
+1 -1
View File
@@ -1 +1 @@
3.0
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
+1 -1
View File
@@ -24,7 +24,7 @@ and nasty bugs.
-----
Copyright (C) 1998-2013 Free Software Foundation, Inc.
Copyright (C) 1998-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
+45 -45
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]>
@@ -26733,8 +26733,8 @@
-----
Copyright (C) 1987-1988, 1991-2013 Free Software Foundation,
Inc.
Copyright (C) 1987-1988, 1991-2015, 2018 Free Software
Foundation, Inc.
Copying and distribution of this file, with or without
modification, are permitted provided the copyright notice and this
+12 -5
View File
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in.
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# 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
@@ -24,8 +24,10 @@ SUBDIRS = po runtime-po .
aclocaldir = @aclocaldir@
aclocal_DATA = m4/bison-i18n.m4
EXTRA_DIST = .prev-version .version \
cfg.mk ChangeLog-1998 ChangeLog-2012 PACKAGING
EXTRA_DIST = .prev-version .version cfg.mk PACKAGING \
ChangeLog-1998 ChangeLog-2012 ChangeLog
dist_doc_DATA = AUTHORS COPYING NEWS README THANKS TODO
## Running the bison from this tarball. To generate our own parser,
## but also to run the tests. Of course, you ought to keep a sane
@@ -37,9 +39,11 @@ AM_YFLAGS = -d -v -Werror -Wall -Wno-yacc --report=all
# Initialization before completion by local.mk's.
AM_CFLAGS = $(WARN_CFLAGS)
# Find builddir/src/scan-code.c etc.
AM_CPPFLAGS = -I. -Ilib -I$(top_srcdir) -I$(top_srcdir)/lib
# Find builddir/src/scan-code.c etc. For some reason "-I./lib"
# 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)
@@ -61,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
+483 -17
View File
@@ -1,7 +1,470 @@
GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
* 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
Compiling Bison now requires a C99 compiler---as announced during the
release of Bison 3.0, five years ago. Generated parsers do not require a
C99 compiler.
Support for DJGPP, which have been unmaintained and untested for years, is
obsolete. Unless there is activity to revive it, the next release of Bison
will have it removed.
** New features
*** Typed midrule actions
Because their type is unknown to Bison, the values of midrule actions are
not treated like the others: they don't have %printer and %destructor
support. It also prevents C++ (Bison) variants to handle them properly.
Typed midrule actions address these issues. Instead of:
exp: { $<ival>$ = 1; } { $<ival>$ = 2; } { $$ = $<ival>1 + $<ival>2; }
write:
exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; } { $$ = $1 + $2; }
*** Reports include the type of the symbols
The sections about terminal and nonterminal symbols of the '*.output' file
now specify their declared type. For instance, for:
%token <ival> NUM
the report now shows '<ival>':
Terminals, with rules where they appear
NUM <ival> (258) 5
*** Diagnostics about useless rules
In the following grammar, the 'exp' nonterminal is trivially useless. So,
of course, its rules are useless too.
%%
input: '0' | exp
exp: exp '+' exp | exp '-' exp | '(' exp ')'
Previously all the useless rules were reported, including those whose
left-hand side is the 'exp' nonterminal:
warning: 1 nonterminal useless in grammar [-Wother]
warning: 4 rules useless in grammar [-Wother]
2.14-16: warning: nonterminal useless in grammar: exp [-Wother]
input: '0' | exp
^^^
2.14-16: warning: rule useless in grammar [-Wother]
input: '0' | exp
^^^
3.6-16: warning: rule useless in grammar [-Wother]
exp: exp '+' exp | exp '-' exp | '(' exp ')'
^^^^^^^^^^^
3.20-30: warning: rule useless in grammar [-Wother]
exp: exp '+' exp | exp '-' exp | '(' exp ')'
^^^^^^^^^^^
3.34-44: warning: rule useless in grammar [-Wother]
exp: exp '+' exp | exp '-' exp | '(' exp ')'
^^^^^^^^^^^
Now, rules whose left-hand side symbol is useless are no longer reported
as useless. The locations of the errors have also been adjusted to point
to the first use of the nonterminal as a left-hand side of a rule:
warning: 1 nonterminal useless in grammar [-Wother]
warning: 4 rules useless in grammar [-Wother]
3.1-3: warning: nonterminal useless in grammar: exp [-Wother]
exp: exp '+' exp | exp '-' exp | '(' exp ')'
^^^
2.14-16: warning: rule useless in grammar [-Wother]
input: '0' | exp
^^^
*** C++: Generated parsers can be compiled with -fno-exceptions (lalr1.cc)
When compiled with exceptions disabled, the generated parsers no longer
uses try/catch clauses.
Currently only GCC and Clang are supported.
** Documentation
*** A demonstration of variants
A new example was added (installed in .../share/doc/bison/examples),
'variant.yy', which shows how to use (Bison) variants in C++.
The other examples were made nicer to read.
*** Some features are no longer 'experimental'
The following features, mature enough, are no longer flagged as
experimental in the documentation: push parsers, default %printer and
%destructor (typed: <*> and untyped: <>), %define api.value.type union and
variant, Java parsers, XML output, LR family (lr, ielr, lalr), and
semantic predicates (%?).
** Bug fixes
*** GLR: Predicates support broken by #line directives
Predicates (%?) in GLR such as
widget:
%? {new_syntax} 'w' id new_args
| %?{!new_syntax} 'w' id old_args
were issued with #lines in the middle of C code.
*** Printer and destructor with broken #line directives
The #line directives were not properly escaped when emitting the code for
%printer/%destructor, which resulted in compiler errors if there are
backslashes or double-quotes in the grammar file name.
*** Portability on ICC
The Intel compiler claims compatibility with GCC, yet rejects its _Pragma.
Generated parsers now work around this.
*** Various
There were several small fixes in the test suite and in the build system,
many warnings in bison and in the generated parsers were eliminated. The
documentation also received its share of minor improvements.
Useless code was removed from C++ parsers, and some of the generated
constructors are more 'natural'.
* Noteworthy changes in release 3.0.5 (2018-05-27) [stable]
** Bug fixes
*** C++: Fix support of 'syntax_error'
One incorrect 'inline' resulted in linking errors about the constructor of
the syntax_error exception.
*** C++: Fix warnings
GCC 7.3 (with -O1 or -O2 but not -O0 or -O3) issued null-dereference
warnings about yyformat being possibly null. It also warned about the
deprecated implicit definition of copy constructors when there's a
user-defined (copy) assignment operator.
*** Location of errors
In C++ parsers, out-of-bounds errors can happen when a rule with an empty
ride-hand side raises a syntax error. The behavior of the default parser
(yacc.c) in such a condition was undefined.
Now all the parsers match the behavior of glr.c: @$ is used as the
location of the error. This handles gracefully rules with and without
rhs.
*** Portability fixes in the test suite
On some platforms, some Java and/or C++ tests were failing.
* Noteworthy changes in release 3.0.4 (2015-01-23) [stable]
** Bug fixes
*** C++ with Variants (lalr1.cc)
Fix a compiler warning when no %destructor use $$.
*** Test suites
Several portability issues in tests were fixed.
* Noteworthy changes in release 3.0.3 (2015-01-15) [stable]
** Bug fixes
*** C++ with Variants (lalr1.cc)
Problems with %destructor and '%define parse.assert' have been fixed.
*** Named %union support (yacc.c, glr.c)
Bison 3.0 introduced a regression on named %union such as
%union foo { int ival; };
The possibility to use a name was introduced "for Yacc compatibility".
It is however not required by POSIX Yacc, and its usefulness is not clear.
*** %define api.value.type union with %defines (yacc.c, glr.c)
The C parsers were broken when %defines was used together with "%define
api.value.type union".
*** Redeclarations are reported in proper order
On
%token FOO "foo"
%printer {} "foo"
%printer {} FOO
bison used to report:
/tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO
%printer {} "foo"
^^
/tmp/foo.yy:3.10-11: previous declaration
%printer {} FOO
^^
Now, the "previous" declaration is always the first one.
** Documentation
Bison now installs various files in its docdir (which defaults to
'/usr/local/share/doc/bison'), including the three fully blown examples
extracted from the documentation:
- rpcalc
Reverse Polish Calculator, a simple introductory example.
- mfcalc
Multi-function Calc, a calculator with memory and functions and located
error messages.
- calc++
a calculator in C++ using variant support and token constructors.
* Noteworthy changes in release 3.0.2 (2013-12-05) [stable]
** Bug fixes
*** Generated source files when errors are reported
When warnings are issued and -Werror is set, bison would still generate
the source files (*.c, *.h...). As a consequence, some runs of "make"
could fail the first time, but not the second (as the files were generated
anyway).
This is fixed: bison no longer generates this source files, but, of
course, still produces the various reports (*.output, *.xml, etc.).
*** %empty is used in reports
Empty right-hand sides are denoted by '%empty' in all the reports (text,
dot, XML and formats derived from it).
*** YYERROR and variants
When C++ variant support is enabled, an error triggered via YYERROR, but
not caught via error recovery, resulted in a double deletion.
* Noteworthy changes in release 3.0.1 (2013-11-12) [stable]
** Bug fixes
*** Errors in caret diagnostics
On some platforms, some errors could result in endless diagnostics.
*** Fixes of the -Werror option
Options such as "-Werror -Wno-error=foo" were still turning "foo"
diagnostics into errors instead of warnings. This is fixed.
Actually, for consistency with GCC, "-Wno-error=foo -Werror" now also
leaves "foo" diagnostics as warnings. Similarly, with "-Werror=foo
-Wno-error", "foo" diagnostics are now errors.
*** GLR Predicates
As demonstrated in the documentation, one can now leave spaces between
"%?" and its "{".
*** Installation
The yacc.1 man page is no longer installed if --disable-yacc was
specified.
*** Fixes in the test suite
Bugs and portability issues.
* Noteworthy changes in release 3.0 (2013-07-25) [stable]
@@ -408,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'
@@ -731,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]
@@ -1727,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; };
@@ -1762,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
@@ -1940,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 (); };
@@ -2215,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:
@@ -2357,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
%%
@@ -2628,7 +3091,7 @@ Output file does not redefine const for C++.
-----
Copyright (C) 1995-2013 Free Software Foundation, Inc.
Copyright (C) 1995-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Parser Generator.
@@ -2668,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
+1 -1
View File
@@ -36,7 +36,7 @@ to the bison package.
-----
Copyright (C) 2002, 2005, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2002, 2005, 2009-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
+13 -9
View File
@@ -7,10 +7,10 @@ instructions.
Bison requires GNU m4 1.4.6 or later. See:
ftp://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
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,25 +29,26 @@ 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,
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-2013 Free Software
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
+1 -1
View File
@@ -12,7 +12,7 @@ the problems you encounter.
-----
Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, Inc.
This file is part of GNU Bison.
+113 -105
View File
@@ -9,19 +9,19 @@ Everything related to the development of Bison is on Savannah:
* Administrivia
** If you incorporate a change from somebody on the net:
First, if it is a large change, you must make sure they have signed
the appropriate paperwork. Second, be sure to add their name and
email address to THANKS.
First, if it is a large change, you must make sure they have signed the
appropriate paperwork. Second, be sure to add their name and email address
to THANKS.
** If a change fixes a test, mention the test in the commit message.
** Bug reports
If somebody reports a new bug, mention his name in the commit message
and in the test case you write. Put him into THANKS.
If somebody reports a new bug, mention his name in the commit message and in
the test case you write. Put him into THANKS.
The correct response to most actual bugs is to write a new test case
which demonstrates the bug. Then fix the bug, re-run the test suite,
and check everything in.
The correct response to most actual bugs is to write a new test case which
demonstrates the bug. Then fix the bug, re-run the test suite, and check
everything in.
* Hacking
@@ -30,17 +30,17 @@ and check everything in.
Which include serious bug fixes, must be mentioned in NEWS.
** Translations
Only user visible strings are to be translated: error messages, bits
of the .output file etc. This excludes impossible error messages
(comparable to assert/abort), and all the --trace output which is
meant for the maintainers only.
Only user visible strings are to be translated: error messages, bits of the
.output file etc. This excludes impossible error messages (comparable to
assert/abort), and all the --trace output which is meant for the maintainers
only.
** Horizontal tabs
Do not add horizontal tab characters to any file in Bison's repository
except where required. For example, do not use tabs to format C code.
However, make files, ChangeLog, and some regular expressions require
tabs. Also, test cases might need to contain tabs to check that Bison
properly processes tabs in its input.
However, make files, ChangeLog, and some regular expressions require tabs.
Also, test cases might need to contain tabs to check that Bison properly
processes tabs in its input.
* Working from the repository
@@ -62,13 +62,22 @@ tools we depend upon, including:
- Gettext <http://www.gnu.org/software/gettext/>
- Graphviz <http://www.graphviz.org>
- Gzip <http://www.gnu.org/software/gzip/>
- Help2man <http://www.gnu.org/software/help2man/>
- Perl <http://www.cpan.org/>
- Rsync <http://samba.anu.edu.au/rsync/>
- Tar <http://www.gnu.org/software/tar/>
- Texinfo <http://www.gnu.org/software/texinfo/>
Valgrind <http://valgrind.org/> is also highly recommended, if it supports
your architecture.
If you're using a GNU/Linux distribution, the easiest way to install the
above packages depends on your system. The following shell command should
work for Debian-based systems such as Ubuntu:
sudo apt-get install \
autoconf automake autopoint flex graphviz help2man texinfo valgrind
Bison is written using Bison grammars, so there are bootstrapping issues.
The bootstrap script attempts to discover when the C code generated from the
grammars is out of date, and to bootstrap with an out-of-date version of the
@@ -94,15 +103,19 @@ to perform the first checkout of the submodules, run
$ git submodule update --init
Git submodule support is weak before versions 1.6 and later, you
should probably upgrade Git if your version is older.
The next step is to get other files needed to build, which are
extracted from other source packages:
$ ./bootstrap
And there you are! Just
Bootstrapping updates the submodules to the versions registered in the
top-level directory. To change gnulib, first check out the version you want
in `gnulib`, then commit this change in Bison's repository, and finally run
bootstrap.
If it fails with missing symbols (e.g., "error: possibly undefined macro:
AC_PROG_GNU_M4"), you are likely to have forgotten the submodule
initialization part. Otherwise, there you are! Just
$ ./configure
$ make
@@ -126,13 +139,12 @@ explicitly by the user.
*** Updating Bison
If you pull a newer version of a branch, say via "git pull", you might
import requests for updated submodules. A simple "git diff" will
reveal if the current version of the submodule (i.e., the actual
contents of the gnulib directory) and the current request from the
subscriber (i.e., the reference of the version of gnulib that the
Bison repository requests) differ. To upgrade the submodules (i.e.,
to check out the version that is actually requested by the subscriber,
run "git submodule update".
import requests for updated submodules. A simple "git diff" will reveal if
the current version of the submodule (i.e., the actual contents of the
gnulib directory) and the current request from the subscriber (i.e., the
reference of the version of gnulib that the Bison repository requests)
differ. To upgrade the submodules (i.e., to check out the version that is
actually requested by the subscriber, run "git submodule update".
$ git pull
$ git submodule update
@@ -156,8 +168,8 @@ Register your changes.
$ git checkin ...
For a suggestion of what gnulib commit might be stable enough for a
formal release, see the ChangeLog in the latest gnulib snapshot at:
For a suggestion of what gnulib commit might be stable enough for a formal
release, see the ChangeLog in the latest gnulib snapshot at:
http://erislabs.net/ianb/projects/gnulib/
@@ -167,9 +179,9 @@ The Autoconf files we use are currently:
lib/m4sugar/m4sugar.m4
lib/m4sugar/foreach.m4
These files don't change very often in Autoconf, so it should be
relatively straight-forward to examine the differences in order to
decide whether to update.
These files don't change very often in Autoconf, so it should be relatively
straight-forward to examine the differences in order to decide whether to
update.
* Test suite
@@ -178,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:
@@ -194,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.
@@ -232,102 +247,96 @@ suite. So currently, do not try to run valgrind on Mac OS X.
Try to run the test suite with more severe conditions before a
release:
- Configure the package with --enable-gcc-warnings, so that one checks
that 1. Bison compiles cleanly, 2. the parsers it produces compile
cleanly too.
- Configure the package with --enable-gcc-warnings, so that one checks that
1. Bison compiles cleanly, 2. the parsers it produces compile cleanly too.
- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules
that can fix portability issues. See if you really want to pay
attention to its warnings; there's no need to obey blindly to it
- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules that
can fix portability issues. See if you really want to pay attention to
its warnings; there's no need to obey blindly to it
(<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
- Check with "make syntax-check" if there are issues diagnosed by
gnulib.
- Check with "make syntax-check" if there are issues diagnosed by gnulib.
- run "make maintainer-check" which:
- runs "valgrind -q bison" to run Bison under Valgrind.
- 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 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-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 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.
- 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.
- 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.
* Release Procedure
This section needs to be updated to take into account features from
gnulib. In particular, be sure to read README-release.
This section needs to be updated to take into account features from gnulib.
In particular, be sure to read README-release.
** Update the submodules. See above.
** Update maintainer tools, such as Autoconf. See above.
** Try to get the *.pot files to the Translation Project at least one
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 '\<_(' *
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 '\<_(' *.
** Tests
See above.
** Update the foreign files
Running "./bootstrap" in the top level should update them all for you.
This covers PO files too. Sometimes a PO file contains problems that
causes it to be rejected by recent Gettext releases; please report
these to the Translation Project.
Running "./bootstrap" in the top level should update them all for you. This
covers PO files too. Sometimes a PO file contains problems that causes it
to be rejected by recent Gettext releases; please report these to the
Translation Project.
** Update README
Make sure the information in README is current. Most notably, make sure
it recommends a version of GNU M4 that is compatible with the latest
Bison sources.
Make sure the information in README is current. Most notably, make sure it
recommends a version of GNU M4 that is compatible with the latest Bison
sources.
** Check copyright years.
We update years in copyright statements throughout Bison once at the
start of every year by running "make update-copyright". However, before
a release, it's good to verify that it's actually been run. Besides the
copyright statement for each Bison file, check the copyright statements
that the skeletons insert into generated parsers, and check all
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
We update years in copyright statements throughout Bison once at the start
of every year by running "make update-copyright". However, before a
release, it's good to verify that it's actually been run. Besides the
copyright statement for each Bison file, check the copyright statements that
the skeletons insert into generated parsers, and check all occurrences of
PACKAGE_COPYRIGHT_YEAR in configure.ac.
** Update NEWS, commit and tag.
See do-release-commit-and-tag in README-release. For a while, we used
beta names such as "2.6_rc1". Now that we use gnulib in the release
procedure, we must use "2.5.90", which has the additional benefit of
being properly sorted in "git tag -l".
See do-release-commit-and-tag in README-release. For a while, we used beta
names such as "2.6_rc1". Now that we use gnulib in the release procedure,
we must use "2.5.90", which has the additional benefit of being properly
sorted in "git tag -l".
** make alpha, beta, or stable
See README-release.
** Upload
There are two ways to upload the tarballs to the GNU servers: using
gnupload (from gnulib), or by hand. Obviously prefer the former. But
in either case, be sure to read the following paragraph.
There are two ways to upload the tarballs to the GNU servers: using gnupload
(from gnulib), or by hand. Obviously prefer the former. But in either
case, be sure to read the following paragraph.
*** Setup
You need "gnupg".
Make sure your public key has been uploaded at least to
keys.gnupg.net. You can upload it with:
Make sure your public key has been uploaded at least to keys.gnupg.net. You
can upload it with:
gpg --keyserver keys.gnupg.net --send-keys F125BDF3
@@ -336,8 +345,8 @@ where F125BDF3 should be replaced with your key ID.
*** Using gnupload
You need "ncftp".
At the end "make stable" (or alpha/beta) will display the procedure to
run. Just copy and paste it in your shell.
At the end "make stable" (or alpha/beta) will display the procedure to run.
Just copy and paste it in your shell.
*** By hand
@@ -399,9 +408,9 @@ sections that have been removed or renamed):
$ ls -lt
Remove these files and commit their removal to CVS. For each of these
files, add a line to the file .symlinks. This will ensure that
hyperlinks to the removed files will redirect to the entire manual; this
is better than a 404 error.
files, add a line to the file .symlinks. This will ensure that hyperlinks
to the removed files will redirect to the entire manual; this is better than
a 404 error.
There is a problem with 'index.html' being written twice (once for POSIX
function 'index', once for the table of contents); you can ignore this
@@ -420,19 +429,18 @@ Complete/fix the announcement file. The generated list of recipients
([email protected], [email protected], [email protected],
[email protected], and [email protected]) is
appropriate for a stable release or a "serious beta". For any other
release, drop at least [email protected]. For an example of how to
fill out the rest of the template, search the mailing list archives
for the most recent release announcement.
release, drop at least [email protected]. For an example of how to fill out
the rest of the template, search the mailing list archives for the most
recent release announcement.
For a stable release, send the same announcement on the comp.compilers
newsgroup by sending email to [email protected]. Do not make any Cc as
the moderator will throw away anything cross-posted or Cc'ed. It really
needs to be a separate message.
newsgroup by sending email to [email protected]. Do not make any Cc as the
moderator will throw away anything cross-posted or Cc'ed. It really needs
to be a separate message.
** Prepare NEWS
So that developers don't accidentally add new items to the old NEWS
entry, create a new empty entry in line 3 (without the two leading
spaces):
So that developers don't accidentally add new items to the old NEWS entry,
create a new empty entry in line 3 (without the two leading spaces):
* Noteworthy changes in release ?.? (????-??-??) [?]
@@ -440,7 +448,7 @@ Push these changes.
-----
Copyright (C) 2002-2005, 2007-2013 Free Software Foundation, Inc.
Copyright (C) 2002-2005, 2007-2015, 2018 Free Software Foundation, Inc.
This file is part of GNU Bison.
+45 -4
View File
@@ -1,26 +1,33 @@
Bison was originally written by Robert Corbett. It would not be what
it is today without the invaluable help of these people:
Аскар Сафин [email protected]
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]
Anthony Heading [email protected]
Antonio Silva Correia [email protected]
Arnold Robbins [email protected]
Art Haas [email protected]
Askar Safin [email protected]
Baron Schwartz [email protected]
Ben Pfaff [email protected]
Benoit Perrot [email protected]
Bernd Edlinger [email protected]
Bernd Kiefer [email protected]
Bert Deknuydt [email protected]
Bill Allombert [email protected]
Bob Rossi [email protected]
Brandon Lucia [email protected]
Brooks Moses [email protected]
Bruce Lilly [email protected]
Bruno Haible [email protected]
Charles-Henri de Boysson [email protected]
@@ -31,10 +38,15 @@ Cris van Pelt [email protected]
Csaba Raduly [email protected]
Dagobert Michelsen [email protected]
Daniel Frużyński [email protected]
Daniel Galloway [email protected]
Daniel Hagerty [email protected]
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]
Di-an Jan [email protected]
Dick Streefland [email protected]
@@ -42,31 +54,40 @@ 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]
Florian Krohm [email protected]
Frank Heckenbach [email protected]
Frans Englich [email protected]
Gabriel Rassoul [email protected]
Gary L Peskin [email protected]
Georg Sauthoff [email protected]
George Neuner [email protected]
Gilles Espinasse [email protected]
Goran Uddeborg [email protected]
Guido Trentalancia [email protected]
H. Merijn Brand [email protected]
Hans Aberg haberg@matematik.su.se
Hans Åberg haberg[email protected]
Horst Von Brand [email protected]
Jan Nieuwenhuizen [email protected]
Jannick [email protected]
Jerry Quinn [email protected]
Jesse Thilo [email protected]
Jim Kent [email protected]
Jim Meyering [email protected]
Joel E. Denny [email protected]
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]
@@ -78,14 +99,22 @@ Martin Mokrejs [email protected]
Martin Nylin [email protected]
Matt Kraai [email protected]
Matt Rosing [email protected]
Maxim Prohorenko [email protected]
Michael Catanzaro [email protected]
Michael Felt [email protected]
Michael Hayes [email protected]
Michael Raskin [email protected]
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]
Nelson H. F. Beebe [email protected]
Nick Bowler [email protected]
Nicolas Bedon [email protected]
Nicolas Burrus [email protected]
Nicolas Tisserand [email protected]
Noah Friedman [email protected]
@@ -93,6 +122,7 @@ Odd Arild Olsen [email protected]
Oleg Smolsky [email protected]
Oleksii Taran [email protected]
Paolo Bonzini [email protected]
Paolo Simone Gasparello [email protected]
Pascal Bart [email protected]
Paul Eggert [email protected]
Paul Hilfinger [email protected]
@@ -102,30 +132,39 @@ Peter Fales [email protected]
Peter Hamorsky [email protected]
Peter Simons [email protected]
Petr Machata [email protected]
Pho [email protected]
Piotr Gackiewicz [email protected]
Piotr Marcińczyk [email protected]
Quentin Hocquet [email protected]
Quoc Peyrot [email protected]
R Blake [email protected]
Raja R Harinath [email protected]
Ralf Wildenhues [email protected]
Rich Wilson [email protected]
Richard Stallman [email protected]
Rici Lake [email protected]
Rob Conde [email protected]
Rob Vermaas [email protected]
Robert Anisko [email protected]
Rob Conde rob.conde@ai-solutions.com
Robert Yang liezhi.yang@windriver.com
Roland Levillain [email protected]
Satya Kiran Popuri [email protected]
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]
Sum Wu [email protected]
Théophile Ranquet [email protected]
Thiru Ramakrishnan [email protected]
Thomas Jahns [email protected]
Tim Josling [email protected]
Tim Landscheidt [email protected]
Tim Van Holder [email protected]
Tobias Frost [email protected]
Tom Lane [email protected]
Tom Tromey [email protected]
Tommy Nordgren [email protected]
@@ -141,7 +180,9 @@ Wojciech Polak [email protected]
Wolfgang S. Kechel [email protected]
Wolfram Wagner [email protected]
Wwp [email protected]
xolodho [email protected]
Zack Weinberg [email protected]
長田偉伸 [email protected]
Many people are not named here because we lost track of them. We
thank them! Please, help us keeping this list up to date.
@@ -153,7 +194,7 @@ End:
-----
Copyright (C) 2000-2013 Free Software Foundation, Inc.
Copyright (C) 2000-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Parser Generator.
+49 -2
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
@@ -112,7 +128,7 @@ We could (should?) also treat the case of the undef_token, which is
numbered 257 for yylex, and 2 internal. Both appear for instance in
toknum:
const unsigned short int
const unsigned short
parser::yytoken_number_[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
@@ -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,11 +410,13 @@ Here's a proposal for how a new implementation might look:
Local Variables:
mode: outline
coding: utf-8
fill-column: 76
End:
-----
Copyright (C) 2001-2004, 2006, 2008-2013 Free Software Foundation, Inc.
Copyright (C) 2001-2004, 2006, 2008-2015, 2018 Free Software Foundation,
Inc.
This file is part of Bison, the GNU Compiler Compiler.
+246 -172
View File
@@ -1,10 +1,10 @@
#! /bin/sh
# Print a version string.
scriptversion=2013-07-03.20; # UTC
scriptversion=2018-10-13.05; # UTC
# Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
# Copyright (C) 2003-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
@@ -17,7 +17,7 @@ scriptversion=2013-07-03.20; # UTC
# 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/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Originally written by Paul Eggert. The canonical version of this
# script is maintained as build-aux/bootstrap in gnulib, however, to
@@ -42,8 +42,13 @@ export LC_ALL
local_gl_dir=gl
# Honor $PERL, but work even if there is none.
PERL="${PERL-perl}"
me=$0
default_gnulib_url=git://git.sv.gnu.org/gnulib
usage() {
cat <<EOF
Usage: $me [OPTION]...
@@ -73,6 +78,37 @@ contents are read as shell variables to configure the bootstrap.
For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
are honored.
Gnulib sources can be fetched in various ways:
* If this package is in a git repository with a 'gnulib' submodule
configured, then that submodule is initialized and updated and sources
are fetched from there. If \$GNULIB_SRCDIR is set (directly or via
--gnulib-srcdir) and is a git repository, then it is used as a reference.
* Otherwise, if \$GNULIB_SRCDIR is set (directly or via --gnulib-srcdir),
then sources are fetched from that local directory. If it is a git
repository and \$GNULIB_REVISION is set, then that revision is checked
out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated and
sources are fetched from there.
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources are
cloned into that directory using git from \$GNULIB_URL, defaulting to
$default_gnulib_url.
If \$GNULIB_REVISION is set, then that revision is checked out.
* Otherwise, the existing Gnulib sources in the 'gnulib' directory are
used. If it is a git repository and \$GNULIB_REVISION is set, then that
revision is checked out.
If you maintain a package and want to pin a particular revision of the
Gnulib sources that has been tested with your package, then there are two
possible approaches: either configure a 'gnulib' submodule with the
appropriate revision, or set \$GNULIB_REVISION (and if necessary
\$GNULIB_URL) in $me.conf.
Running without arguments will suffice in most cases.
EOF
}
@@ -126,19 +162,12 @@ 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 --delete --exclude '*.s1' -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' \
http://translationproject.org/latest/%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
# fall back to the package name (1st argument with munging)
@@ -167,7 +196,15 @@ source_base=lib
m4_base=m4
doc_base=doc
tests_base=tests
gnulib_extra_files=''
gnulib_extra_files="
build-aux/install-sh
build-aux/mdate-sh
build-aux/texinfo.tex
build-aux/depcomp
build-aux/config.guess
build-aux/config.sub
doc/INSTALL
"
# Additional gnulib-tool options to use. Use "\newline" to break lines.
gnulib_tool_option_extras=
@@ -209,12 +246,26 @@ bootstrap_sync=false
# Use git to update gnulib sources
use_git=true
check_exists() {
if test "$1" = "--verbose"; then
($2 --version </dev/null) >/dev/null 2>&1
if test $? -ge 126; then
# If not found, run with diagnostics as one may be
# presented with env variables to set to find the right version
($2 --version </dev/null)
fi
else
($1 --version </dev/null) >/dev/null 2>&1
fi
test $? -lt 126
}
# find_tool ENVVAR NAMES...
# -------------------------
# Search for a required program. Use the value of ENVVAR, if set,
# otherwise find the first of the NAMES that can be run (i.e.,
# supports --version). If found, set ENVVAR to the program name,
# die otherwise.
# otherwise find the first of the NAMES that can be run.
# If found, set ENVVAR to the program name, die otherwise.
#
# FIXME: code duplication, see also gnu-web-doc-update.
find_tool ()
@@ -224,27 +275,21 @@ find_tool ()
find_tool_names=$@
eval "find_tool_res=\$$find_tool_envvar"
if test x"$find_tool_res" = x; then
for i
do
if ($i --version </dev/null) >/dev/null 2>&1; then
find_tool_res=$i
break
for i; do
if check_exists $i; then
find_tool_res=$i
break
fi
done
else
find_tool_error_prefix="\$$find_tool_envvar: "
fi
test x"$find_tool_res" != x \
|| die "one of these is required: $find_tool_names"
($find_tool_res --version </dev/null) >/dev/null 2>&1 \
|| die "${find_tool_error_prefix}cannot run $find_tool_res --version"
if test x"$find_tool_res" = x; then
warn_ "one of these is required: $find_tool_names;"
die "alternatively set $find_tool_envvar to a compatible tool"
fi
eval "$find_tool_envvar=\$find_tool_res"
eval "export $find_tool_envvar"
}
# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6.
find_tool SHA1SUM sha1sum gsha1sum shasum
# Override the default configuration, if necessary.
# Make sure that bootstrap.conf is sourced from the current directory
# if we were invoked as "sh bootstrap".
@@ -253,24 +298,18 @@ case "$0" in
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
# Extra files from gnulib, which override files from other sources.
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
build-aux/install-sh
build-aux/mdate-sh
build-aux/texinfo.tex
build-aux/depcomp
build-aux/config.guess
build-aux/config.sub
doc/INSTALL
"
if test "$vc_ignore" = auto; then
vc_ignore=
test -d .git && vc_ignore=.gitignore
test -d CVS && vc_ignore="$vc_ignore .cvsignore"
fi
if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
use_gnulib=false
else
use_gnulib=true
fi
# Translate configuration into internal form.
# Parse options.
@@ -326,7 +365,7 @@ insert_if_absent() {
die "Error: Duplicate entries in $file: " $duplicate_entries
fi
linesold=$(gitignore_entries $file | wc -l)
linesnew=$(echo "$str" | gitignore_entries - $file | sort -u | wc -l)
linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
if [ $linesold != $linesnew ] ; then
{ echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
|| die "insert_if_absent $file $str: failed"
@@ -407,28 +446,30 @@ sort_ver() { # sort -V is not generally available
done
}
get_version_sed='
# Move version to start of line.
s/.*[v ]\([0-9]\)/\1/
# Skip lines that do not start with version.
/^[0-9]/!d
# Remove characters after the version.
s/[^.a-z0-9-].*//
# The first component must be digits only.
s/^\([0-9]*\)[a-z-].*/\1/
#the following essentially does s/5.005/5.5/
s/\.0*\([1-9]\)/.\1/g
p
q'
get_version() {
app=$1
$app --version >/dev/null 2>&1 || return 1
$app --version >/dev/null 2>&1 || { $app --version; return 1; }
$app --version 2>&1 |
sed -n '# Move version to start of line.
s/.*[v ]\([0-9]\)/\1/
# Skip lines that do not start with version.
/^[0-9]/!d
# Remove characters after the version.
s/[^.a-z0-9-].*//
# The first component must be digits only.
s/^\([0-9]*\)[a-z-].*/\1/
#the following essentially does s/5.005/5.5/
s/\.0*\([1-9]\)/.\1/g
p
q'
$app --version 2>&1 | sed -n "$get_version_sed"
}
check_versions() {
@@ -448,6 +489,7 @@ check_versions() {
test "$appvar" = TAR && appvar=AMTAR
case $appvar in
GZIP) ;; # Do not use $GZIP: it contains gzip options.
PERL::*) ;; # Keep perl modules as-is
*) eval "app=\${$appvar-$app}" ;;
esac
@@ -465,12 +507,22 @@ check_versions() {
ret=1
continue
} ;;
# Another check is for perl modules. These can be written as
# e.g. perl::XML::XPath in case of XML::XPath module, etc.
perl::*)
# Extract module name
app="${app#perl::}"
if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
warn_ "Error: perl module '$app' not found"
ret=1
fi
continue
;;
esac
if [ "$req_ver" = "-" ]; then
# Merely require app to exist; not all prereq apps are well-behaved
# so we have to rely on $? rather than get_version.
$app --version >/dev/null 2>&1
if [ 126 -le $? ]; then
if ! check_exists --verbose $app; then
warn_ "Error: '$app' not found"
ret=1
fi
@@ -503,6 +555,12 @@ print_versions() {
# can't depend on column -t
}
# Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
# Also find the compatible sha1 utility on the BSDs
if test x"$SKIP_PO" = x; then
find_tool SHA1SUM sha1sum gsha1sum shasum sha1
fi
use_libtool=0
# We'd like to use grep -E, to see if any of LT_INIT,
# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
@@ -548,13 +606,21 @@ if ! printf "$buildreq" | check_versions; then
fi
fi
# Warn the user if autom4te appears to be broken; this causes known
# issues with at least gettext 0.18.3.
probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
if test "x$probe" != xhi; then
warn_ "WARNING: your autom4te wrapper eats stdin;"
warn_ "if bootstrap fails, consider upgrading your autotools"
fi
echo "$0: Bootstrapping from checked-out $package sources..."
# See if we can use gnulib's git-merge-changelog merge driver.
if $use_git && test -d .git && (git --version) >/dev/null 2>/dev/null ; then
if $use_git && test -d .git && check_exists git; then
if git config merge.merge-changelog.driver >/dev/null ; then
:
elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
elif check_exists git-merge-changelog; then
echo "$0: initializing git-merge-changelog driver"
git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
@@ -574,94 +640,101 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@"
}
if $use_git; then
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init || exit $?
git submodule update || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
shallow=
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
cleanup_gnulib
trap - 1 2 13 15
if $use_gnulib; then
if $use_git; then
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Use GNULIB_SRCDIR directly or as a reference.
if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init && git submodule update \
|| exit $?
# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
shallow=
if test -z "$GNULIB_REVISION"; then
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
fi
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
|| cleanup_gnulib
trap - 1 2 13 15
fi
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Use GNULIB_SRCDIR directly or as a reference.
if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update -- "$gnulib_path" || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
fi
fi
GNULIB_SRCDIR=$gnulib_path
fi
;;
esac
if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
&& ! git_modules_config submodule.gnulib.url >/dev/null; then
(cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
fi
;;
esac
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
case $(sh -c 'echo "$1"' -- a) in
a) ignored=--;;
*) ignored=ignored;;
esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
case $(sh -c 'echo "$1"' -- a) in
a) ignored=--;;
*) ignored=ignored;;
esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
fi
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit $?
fi
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit $?
# Get translations.
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 HTTP.
cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
eval "$cmd"
}
@@ -692,11 +765,10 @@ update_po_files() {
cksum_file="$ref_po_dir/$po.s1"
if ! test -f "$cksum_file" ||
! test -f "$po_dir/$po.po" ||
! $SHA1SUM -c --status "$cksum_file" \
< "$new_po" > /dev/null; then
! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
echo "$me: updated $po_dir/$po.po..."
cp "$new_po" "$po_dir/$po.po" \
&& $SHA1SUM < "$new_po" > "$cksum_file"
&& $SHA1SUM < "$new_po" > "$cksum_file" || return
fi
done
}
@@ -752,9 +824,9 @@ symlink_to_dir()
# Leave any existing symlink alone, if it already points to the source,
# so that broken build tools that care about symlink times
# aren't confused into doing unnecessary builds. Conversely, if the
# existing symlink's time stamp is older than the source, make it afresh,
# existing symlink's timestamp is older than the source, make it afresh,
# so that broken tools aren't confused into skipping needed builds. See
# <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
# <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" &&
src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
@@ -860,31 +932,33 @@ fi
# Import from gnulib.
gnulib_tool_options="\
--import\
--no-changelog\
--aux-dir $build_aux\
--doc-base $doc_base\
--lib $gnulib_name\
--m4-base $m4_base/\
--source-base $source_base/\
--tests-base $tests_base\
--local-dir $local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
if $use_gnulib; then
gnulib_tool_options="\
--no-changelog\
--aux-dir=$build_aux\
--doc-base=$doc_base\
--lib=$gnulib_name\
--m4-base=$m4_base/\
--source-base=$source_base/\
--tests-base=$tests_base\
--local-dir=$local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
fi
bootstrap_post_import_hook \
|| die "bootstrap_post_import_hook failed"
@@ -981,9 +1055,9 @@ bootstrap_epilogue
echo "$0: done. Now you can run './configure'."
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
+8 -5
View File
@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2013 Free Software Foundation, Inc.
# Copyright (C) 2006-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
@@ -17,7 +17,8 @@
# gnulib modules used by this package.
gnulib_modules='
argmatch assert calloc-posix close closeout config-h c-strcase
argmatch assert
calloc-posix close closeout config-h c-strcase
configmake
dirname
error extensions fdl fopen-safer
@@ -33,8 +34,10 @@ gnulib_modules='
quote quotearg
readme-release
realloc-posix
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
unistd unistd-safer unlocked-io update-copyright unsetenv verify
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
timevar
unistd unistd-safer unlink unlocked-io
update-copyright unsetenv verify
warnings
xalloc
xalloc-die
@@ -80,7 +83,7 @@ gnulib_tool_option_extras='--symlink --makefile-name=gnulib.mk'
bootstrap_post_import_hook()
{
# Massage lib/gnulib.mk before using it later in the bootstrapping process.
build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
build-aux/prefix-gnulib-mk --lib-name="$gnulib_name" "lib/$gnulib_mk"
# Ensure that ChangeLog exists, for automake.
test -f ChangeLog || touch ChangeLog
+1 -5
View File
@@ -1,6 +1,4 @@
/announce-gen
/arg-nonnull.h
/c++defs.h
/compile
/config.guess
/config.rpath
@@ -16,14 +14,12 @@
/install-sh
/javacomp.sh.in
/javaexec.sh.in
/link-warning.h
/mdate-sh
/missing
/prefix-gnulib-mk
/test-driver
/texinfo.tex
/update-copyright
/useless-if-before-free
/vc-list-files
/warn-on-use.h
/ylwrap
/prefix-gnulib-mk
@@ -1,4 +1,4 @@
# Copyright (C) 2012-2013 Free Software Foundation, Inc.
# Copyright (C) 2012-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
+61
View File
@@ -0,0 +1,61 @@
# Copyright (C) 2012-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/>.
# 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
{
Probably exception handling from G++ 5.1.
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:pool
fun:__static_initialization_and_destruction_0
fun:_GLOBAL__sub_I_eh_alloc.cc
fun:call_init.part.0
fun:_dl_init
obj:/usr/lib/ld-2.21.so
}
# Linux seattle 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012
# x86_64 GNU/Linux
{
index
Memcheck:Cond
fun:index
fun:expand_dynamic_string_token
fun:_dl_map_object
fun:map_doit
fun:_dl_catch_error
fun:do_preload
fun:dl_main
fun:_dl_sysdep_start
fun:_dl_start
obj:/lib/ld-2.11.3.so
}
+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;
+3
View File
@@ -2,6 +2,9 @@
# option. It specifies what changes to make to each given SHA1's commit
# log and metadata, using Perl-eval'able expressions.
975bb564319aa4f4204c48aba265757ba207a80f
s/Edligner/Edlinger/;
0db2648930e3b6c376a539aabe368aade83ee29a
s/--flags/--feature/;
s/flag_flag/feature_flag/;
+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
-16
View File
@@ -1,16 +0,0 @@
# Linux seattle 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012
# x86_64 GNU/Linux
{
index
Memcheck:Cond
fun:index
fun:expand_dynamic_string_token
fun:_dl_map_object
fun:map_doit
fun:_dl_catch_error
fun:do_preload
fun:dl_main
fun:_dl_sysdep_start
fun:_dl_start
obj:/lib/ld-2.11.3.so
}
+20 -20
View File
@@ -1,22 +1,22 @@
# Copyright (C) 2000-2013 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/cross-options.pl \
build-aux/darwin11.4.0.valgrind \
build-aux/linux-gnu.valgrind \
build-aux/move-if-change \
build-aux/prev-version.txt \
EXTRA_DIST += \
build-aux/Darwin.valgrind \
build-aux/Linux.valgrind \
build-aux/cross-options.pl \
build-aux/move-if-change \
build-aux/prev-version.txt \
build-aux/update-b4-copyright
-4
View File
@@ -1,4 +0,0 @@
/_Noreturn.h
/arg-nonnull.h
/c++defs.h
/warn-on-use.h
+1 -1
View File
@@ -3,7 +3,7 @@
# Update b4_copyright invocations or b4_copyright_years definitions to
# include the current year.
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 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
+1 -1
View File
@@ -2,7 +2,7 @@
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
# Copyright (C) 2010-2013 Free Software Foundation, Inc.
# Copyright (C) 2010-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
+33 -35
View File
@@ -1,18 +1,18 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2008-2013 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,15 +26,15 @@ 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 = \
ftp://$(gnu_rel_host)/gnu/bison
https://$(gnu_rel_host)/gnu/bison
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
@@ -158,23 +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 \
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
space_before_open_paren=^(data/|djgpp/) \
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$$) \
)
+59 -39
View File
@@ -1,6 +1,6 @@
# Configure template for GNU Bison. -*-Autoconf-*-
#
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# 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
@@ -21,23 +21,20 @@
# 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]),
[[email protected]])
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2013])
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2018])
AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
[The copyright year for this package])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
# Automake 1.10.3 and 1.11.1 fix a security flaw discussed here:
#
# http://thread.gmane.org/gmane.comp.sysutils.autotools.announce/131
#
# To avoid 1.11, we make 1.11.1 the minimum version.
# We use Automake 1.14's %D% and %C%.
#
# We want gnits strictness only when rolling a stable release. For
# release candidates, we use version strings like 2.4.3_rc1, but gnits
@@ -45,7 +42,7 @@ AC_CONFIG_MACRO_DIR([m4])
# releases, we want to be able run make dist without being required to
# add a bogus NEWS entry. In that case, the version string
# automatically contains a dash, which we also let disable gnits.
AM_INIT_AUTOMAKE([1.11.1 dist-xz nostdinc
AM_INIT_AUTOMAKE([1.14 dist-xz nostdinc
color-tests parallel-tests
silent-rules]
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
@@ -74,16 +71,32 @@ 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)],
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended).
Also, issue synclines from the examples/ to
the corresponding source in the Texinfo doc.],
[case $enable_gcc_warnings in
yes|no) ;;
*) AC_MSG_ERROR([invalid value for --gcc-warnings: $enable_gcc_warnings]);;
esac],
[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
-Wformat -Wpointer-arith -Wwrite-strings'
-fparse-all-comments -Wdocumentation
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
warn_cxx='-Wnoexcept'
# Warnings for the test suite only.
@@ -91,7 +104,14 @@ if test "$enable_gcc_warnings" = yes; then
# -fno-color-diagnostics: Clang's use of colors in the error
# messages is confusing the tests looking at the compiler's output
# (e.g., synclines.at).
warn_tests='-Wundef -pedantic -Wsign-compare -fno-color-diagnostics'
#
# -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 -Wconversion
-Wdeprecated -Wsign-compare -Wsign-conversion
-fno-color-diagnostics
-Wno-keyword-macro'
AC_LANG_PUSH([C])
# Clang supports many of GCC's -W options, but only issues warnings
@@ -120,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
@@ -142,16 +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
AC_LANG_POP([C++])
fi
BISON_TEST_FOR_WORKING_C_COMPILER
BISON_C_COMPILER_POSIXLY_CORRECT
BISON_TEST_FOR_WORKING_CXX_COMPILER
@@ -161,21 +180,17 @@ AC_ARG_ENABLE([yacc],
[AC_HELP_STRING([--disable-yacc],
[do not build a yacc command or an -ly library])],
, [enable_yacc=yes])
case $enable_yacc in
yes)
YACC_SCRIPT=src/yacc
YACC_LIBRARY=lib/liby.a;;
*)
YACC_SCRIPT=
YACC_LIBRARY=;;
esac
AC_SUBST([YACC_SCRIPT])
AC_SUBST([YACC_LIBRARY])
AM_CONDITIONAL([ENABLE_YACC], [test "$enable_yacc" = yes])
# Checks for programs.
AM_MISSING_PROG([DOT], [dot])
AC_PROG_LEX
$LEX_IS_FLEX || AC_MSG_ERROR([Flex is required])
$LEX_IS_FLEX || test "X$LEX" = X: || {
AC_MSG_WARN([bypassing lex because flex is required])
LEX=:
}
AM_CONDITIONAL([FLEX_CXX_WORKS],
[$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
AC_PROG_YACC
AC_PROG_RANLIB
AC_PROG_GNU_M4
@@ -203,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
@@ -225,28 +239,34 @@ AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/atlocal])
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
AC_CHECK_PROGS([VALGRIND], [valgrind])
case $VALGRIND:$host_os in
# Use something simpler that $host_os to select our suppression file.
uname=`uname`
case $VALGRIND:$uname in
'':*) ;;
*:darwin*)
*:Darwin)
# See README-hacking.
# VALGRIND+='-q --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
VALGRIND=;;
*:*)
suppfile=build-aux/$host_os.valgrind
suppfile=build-aux/$uname.valgrind
if test -f "$srcdir/$suppfile"; then
VALGRIND="$VALGRIND --gen-suppressions=all"
VALGRIND="$VALGRIND --suppressions=\$(abs_top_srcdir)/$suppfile"
AC_SUBST([VALGRIND_OPTS_SUPPRESSION],
["--suppressions=\$(abs_top_srcdir)/$suppfile"])
fi
AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"])
;;
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])
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
+5 -3
View File
@@ -1,5 +1,3 @@
-*- outline -*-
This directory contains data needed by Bison.
* Skeletons
@@ -52,7 +50,11 @@ into various formats.
-----
Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc.
Local Variables:
mode: outline
End:
Copyright (C) 2002, 2008-2015, 2018 Free Software Foundation, Inc.
This file is part of GNU Bison.
+108 -45
View File
@@ -2,7 +2,7 @@
# Language-independent M4 Macros for Bison.
# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc.
# Copyright (C) 2002, 2004-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
@@ -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)
@@ -437,15 +465,14 @@ m4_define([b4_symbol_action_location],
# b4_symbol_action(SYMBOL-NUM, KIND)
# ----------------------------------
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
# Same as in C, but using references instead of pointers.
m4_define([b4_symbol_action],
[b4_symbol_if([$1], [has_$2],
[b4_dollar_pushdef([(*yyvaluep)],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[(*yylocationp)])dnl
b4_symbol_case_([$1])[]dnl
b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
_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@])
break;
@@ -479,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])])
])
@@ -537,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])]);
@@ -602,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
@@ -618,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])
@@ -702,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])])
@@ -711,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.
#
@@ -756,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])])
@@ -780,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. ##
## --------- ##
@@ -825,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
@@ -840,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
])
@@ -885,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, [],
@@ -947,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])
@@ -1012,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], [])
@@ -1061,3 +1121,6 @@ b4_percent_define_ifdef([api.value.type],
[['%s' and '%s' cannot be used together]],
[%yacc],
[%define api.value.type "union"])])])])
# api.value.union.name.
b4_percent_define_check_kind([api.value.union.name], [keyword])
+2 -1
View File
@@ -2,7 +2,8 @@
# C++ skeleton dispatching for Bison.
# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 2006-2007, 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
+151 -83
View File
@@ -2,7 +2,7 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -17,20 +17,58 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Sanity checks, before defaults installed by c.m4.
b4_percent_define_ifdef([[api.value.union.name]],
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
[named %union is invalid in C++])])
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// ])])
## -------- ##
## Checks. ##
## -------- ##
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
# b4_inline(hh|cc)
# ----------------
# Expand to `inline\n ` if $1 is hh.
m4_define([b4_inline],
[m4_case([$1],
[cc], [],
[hh], [[inline
]],
[m4_fatal([$0: invalid argument: $1])])])
# 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. ##
@@ -73,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.
@@ -169,16 +207,26 @@ m4_define([b4_public_types_declare],
/// (External) token type, as returned by yylex.
typedef token::yytokentype token_type;
/// Internal symbol number.
/// Symbol type: an internal symbol number.
typedef int symbol_number_type;
/// The symbol type number to denote an empty symbol.
enum { empty_symbol = -2 };
/// 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>
@@ -190,22 +238,30 @@ 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 ();
/// Destroy contents, and record that is empty.
void clear ();
/// Whether empty.
bool empty () const;
/// Destructive move, \a s is emptied into this.
void move (basic_symbol& s);
@@ -216,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.
@@ -235,92 +293,95 @@ m4_define([b4_public_types_declare],
/// Constructor from (external) token numbers.
by_type (kind_type t);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol type from \a that.
void move (by_type& that);
/// The (internal) type number (corresponding to \a type).
/// -1 when this symbol is empty.
/// \a empty when empty.
symbol_number_type type_get () const;
/// The token.
token_type token () const;
enum { empty = 0 };
/// The symbol type.
/// -1 when this symbol is empty.
token_number_type type;
/// \a empty_symbol when empty.
/// An int, not token_number_type, to be able to store empty_symbol.
int type;
};
/// "External" symbols: returned by the scanner.
typedef basic_symbol<by_type> symbol_type;
]b4_symbol_constructor_declare])
]])
# b4_public_types_define
# ----------------------
# b4_public_types_define(hh|cc)
# -----------------------------
# Provide the implementation needed by the public types.
m4_define([b4_public_types_define],
[[ inline
]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
: std::runtime_error (m)]b4_locations_if([
, location (l)])[
{}
// basic_symbol.
template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
: value ()
: value ()]b4_locations_if([
, location ()])[
{}
template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other)
, value ()]b4_locations_if([
, location (other.location)])[
{
]b4_variant_if([b4_symbol_variant([other.type_get ()], [value], [copy],
[other.value])],
[value = other.value;])[
]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], [YY_MOVE_OR_COPY],
[YY_MOVE (other.value)])])[
}
template <typename Base>
inline
]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])], [[
/// Constructor for valueless symbols.
template <typename Base>
inline
]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>
inline
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
{
clear ();
}
template <typename Base>
void
]b4_parser_class_name[::basic_symbol<Base>::clear ()
{]b4_variant_if([[
// User destructor.
symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
@@ -330,53 +391,60 @@ m4_define([b4_public_types_define],
// Type destructor.
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
Base::clear ();
}
template <typename Base>
bool
]b4_parser_class_name[::basic_symbol<Base>::empty () const
{
return Base::type_get () == empty_symbol;
}
template <typename Base>
inline
void
]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s)
{
super_type::move(s);
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.
inline
]b4_parser_class_name[::by_type::by_type ()
: type (empty)
]b4_inline([$1])b4_parser_class_name[::by_type::by_type ()
: type (empty_symbol)
{}
inline
]b4_parser_class_name[::by_type::by_type (const by_type& other)
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other)
: type (other.type)
{}
inline
]b4_parser_class_name[::by_type::by_type (token_type t)
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t)
: type (yytranslate_ (t))
{}
inline
void
]b4_inline([$1])[void
]b4_parser_class_name[::by_type::clear ()
{
type = empty_symbol;
}
]b4_inline([$1])[void
]b4_parser_class_name[::by_type::move (by_type& that)
{
type = that.type;
that.type = empty;
that.clear ();
}
inline
int
]b4_inline([$1])[int
]b4_parser_class_name[::by_type::type_get () const
{
return type;
}
]b4_token_ctor_if([[
inline
]b4_parser_class_name[::token_type
]b4_inline([$1])b4_parser_class_name[::token_type
]b4_parser_class_name[::by_type::token () const
{
// YYTOKNUM[NUM] -- (External) token number corresponding to the
@@ -390,6 +458,7 @@ m4_define([b4_public_types_define],
return static_cast<token_type> (yytoken_number_[type]);
}
]])[]dnl
b4_symbol_constructor_define])
@@ -402,14 +471,13 @@ m4_define([b4_symbol_constructor_declare], [])
m4_define([b4_symbol_constructor_define], [])
# b4_yytranslate_define
# ---------------------
# Define yytranslate_. Sometimes used in the header file,
# b4_yytranslate_define(cc|hh)
# ----------------------------
# Define yytranslate_. Sometimes used in the header file ($1=hh),
# sometimes in the cc file.
m4_define([b4_yytranslate_define],
[[ // Symbol number corresponding to token number t.
inline
]b4_parser_class_name[::token_number_type
]b4_inline([$1])b4_parser_class_name[::token_number_type
]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type],
[int])[ t)
{
@@ -419,12 +487,12 @@ m4_define([b4_yytranslate_define],
{
]b4_translate[
};
const unsigned int user_token_number_max_ = ]b4_user_token_number_max[;
const unsigned user_token_number_max_ = ]b4_user_token_number_max[;
const token_number_type undef_token_ = ]b4_undef_token_number[;
if (static_cast<int>(t) <= yyeof_)
if (static_cast<int> (t) <= yyeof_)
return yyeof_;
else if (static_cast<unsigned int> (t) <= user_token_number_max_)
else if (static_cast<unsigned> (t) <= user_token_number_max_)
return translate_table[t];
else
return undef_token_;
+7 -7
View File
@@ -2,7 +2,7 @@
# Common code for C-like languages (C, C++, Java, etc.)
# Copyright (C) 2012-2013 Free Software Foundation, Inc.
# Copyright (C) 2012-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
@@ -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],
+2 -1
View File
@@ -2,7 +2,8 @@
# C skeleton dispatching for Bison.
# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 2006-2007, 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
+96 -58
View File
@@ -2,7 +2,7 @@
# C M4 Macros for Bison.
# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc.
# Copyright (C) 2002, 2004-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
@@ -97,7 +97,8 @@ m4_define([b4_api_PREFIX],
m4_define_default([b4_prefix], [b4_api_prefix])
# If the %union is not named, its name is YYSTYPE.
m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])
b4_percent_define_default([[api.value.union.name]],
[b4_api_PREFIX[][STYPE]])
## ------------------------ ##
@@ -171,10 +172,10 @@ m4_define([b4_int_type],
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
b4_ints_in($@, [-128], [127]), [1], [signed char],
b4_ints_in($@, [0], [65535]), [1], [unsigned short int],
b4_ints_in($@, [-32768], [32767]), [1], [short int],
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
b4_ints_in($@, [-32768], [32767]), [1], [short],
m4_eval([0 <= $1]), [1], [unsigned int],
m4_eval([0 <= $1]), [1], [unsigned],
[int])])
@@ -203,26 +204,53 @@ m4_define([b4_table_value_equals],
## Compiler issues. ##
## ----------------- ##
# b4_attribute_define
# -------------------
# Provide portability for __attribute__.
# b4_attribute_define([noreturn])
# -------------------------------
# Provide portable compiler "attributes". If "noreturn" is passed, define
# _Noreturn.
m4_define([b4_attribute_define],
[#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if (! defined __GNUC__ || __GNUC__ < 2 \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
# define __attribute__(Spec) /* empty */
[[#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
]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. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -240,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_NULL appropriate for the current
# 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_NULL
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
[# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULL 0
# define YY_NULLPTR ((void*)0)
# endif
# endif[]dnl
])
@@ -266,7 +296,13 @@ m4_define([b4_null_define],
# b4_null
# -------
# Return a null pointer constant.
m4_define([b4_null], [YY_NULL])
m4_define([b4_null], [YY_NULLPTR])
## ---------##
## Values. ##
## ---------##
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
# -------------------------------------------------------------
@@ -341,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]))])
@@ -439,7 +475,8 @@ b4_syncline([@oline@], [@ofile@])
# ------------------------------------
m4_define([b4_predicate_case],
[ case $1:
if (! ($2)) YYERROR;
if (! (
$2)) YYERROR;
b4_syncline([@oline@], [@ofile@])
break;])
@@ -477,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
])
@@ -541,15 +578,15 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
# b4_symbol_type_register(SYMBOL-NUM)
# -----------------------------------
# Symbol SYMBOL-NUM has a type (for variant) instead of a type-tag.
# Extend the definition of %union's body with a field of that type,
# and extend the symbol's "type" field to point to the field name,
# instead of the type name.
# Extend the definition of %union's body (b4_union_members) with a
# field of that type, and extend the symbol's "type" field to point to
# the field name, instead of the type name.
m4_define([b4_symbol_type_register],
[m4_define([b4_symbol($1, type_tag)],
[b4_symbol_if([$1], [has_id],
[b4_symbol([$1], [id])],
[yytype_[]b4_symbol([$1], [number])])])dnl
m4_append([b4_user_union_members],
m4_append([b4_union_members],
m4_expand([
b4_symbol_tag_comment([$1])dnl
b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]))
@@ -589,10 +626,9 @@ m4_copy_force([b4_symbol_value_union], [b4_symbol_value])
])
# ---------------- #
# api.value.type. #
# ---------------- #
# -------------------------- #
# api.value.type = variant. #
# -------------------------- #
# b4_value_type_setup_variant
# ---------------------------
@@ -667,11 +703,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
[union\|union-directive],
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
typedef union ]b4_union_name[ ]b4_api_PREFIX[STYPE;
union ]b4_union_name[
]b4_percent_define_get_syncline([[api.value.union.name]])[
union ]b4_percent_define_get([[api.value.union.name]])[
{
]b4_user_union_members[
};
]b4_percent_define_get_syncline([[api.value.union.name]])[
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
#endif
@@ -783,13 +821,13 @@ m4_define([b4_yy_location_print_define],
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
__attribute__((__unused__))
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)
{
+208 -192
View File
File diff suppressed because it is too large Load Diff
+32 -19
View File
@@ -1,6 +1,6 @@
# C++ GLR skeleton for Bison
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -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 ()
{
@@ -177,16 +183,16 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
| Print this symbol. |
`--------------------*/
inline void
void
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
const semantic_type* yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[)
{]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 ();
@@ -329,14 +342,14 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2013])[
[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.
+1 -1
View File
@@ -2,7 +2,7 @@
# Java skeleton dispatching for Bison.
# Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 2007, 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
+1 -1
View File
@@ -2,7 +2,7 @@
# Java language support for Bison
# Copyright (C) 2007-2013 Free Software Foundation, Inc.
# Copyright (C) 2007-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
+260 -198
View File
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -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,8 +112,8 @@ 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_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
_b4_symbol_case([$1])
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline([@oline@], [@ofile@])
break;
@@ -131,7 +137,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
m4_pushdef([b4_copyright_years],
[2002-2013])
[2002-2015, 2018])
m4_define([b4_parser_class_name],
[b4_percent_define_get([[parser_class_name]])])
@@ -142,29 +148,35 @@ b4_bison_locations_if([# Backward compatibility.
m4_include(b4_pkgdatadir/[stack.hh])
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
# 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],
[b4_percent_code_get([[requires]])[
]b4_parse_assert_if([# include <cassert>])[
# include <vector>
# include <cstdlib> // std::abort
# include <iostream>
# include <stdexcept>
# include <string>]b4_defines_if([[
# include "stack.hh"
]b4_bison_locations_if([[# include "location.hh"]])])[
# include <string>
# 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])[
@@ -173,24 +185,29 @@ 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 ();
#if ]b4_api_PREFIX[DEBUG
/// The current debugging stream.
std::ostream& debug_stream () const;
std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
/// Set the current debugging stream.
void set_debug_stream (std::ostream &);
/// Type for debugging levels.
typedef int debug_level_type;
/// The current debugging level.
debug_level_type debug_level () const;
debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
/// Set the current debugging level.
void set_debug_level (debug_level_type l);
#endif
@@ -203,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[&);
@@ -213,14 +232,14 @@ b4_location_define])])[
/// Generate an error message.
/// \param yystate the state where the error occurred.
/// \param yytoken the lookahead token type, or yyempty_.
/// \param yyla the lookahead token.
virtual std::string yysyntax_error_ (state_type yystate,
symbol_number_type yytoken) const;
const symbol_type& yyla) const;
/// Compute post-reduction state.
/// \param yystate the current state
/// \param yylhs the nonterminal to push on the stack
state_type yy_lr_goto_state_ (state_type yystate, int yylhs);
/// \param yysym the nonterminal to push on the stack
state_type yy_lr_goto_state_ (state_type yystate, int yysym);
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
@@ -253,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.
@@ -267,7 +287,7 @@ b4_location_define])])[
/// \brief Reclaim the memory associated to a symbol.
/// \param yymsg Why this token is reclaimed.
/// If null, print nothing.
/// \param s The symbol.
/// \param yysym The symbol.
template <typename Base>
void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
@@ -287,16 +307,21 @@ b4_location_define])])[
/// Copy constructor.
by_state (const by_state& other);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol type from \a that.
void move (by_state& that);
/// The (internal) type number (corresponding to \a state).
/// "empty" when empty.
/// \a empty_symbol when empty.
symbol_number_type type_get () const;
enum { empty = 0 };
/// The state number used to denote an empty symbol.
enum { empty_state = -1 };
/// The state.
/// \a empty when empty.
state_type state;
};
@@ -307,10 +332,15 @@ b4_location_define])])[
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
/// 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.
@@ -322,39 +352,38 @@ 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 int n = 1);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
// Constants.
/// Constants.
enum
{
yyeof_ = 0,
yylast_ = ]b4_last[, //< Last index in yytable_.
yynnts_ = ]b4_nterms_number[, //< Number of nonterminal symbols.
yyempty_ = -2,
yyfinal_ = ]b4_final_state_number[, //< Termination state number.
yylast_ = ]b4_last[, ///< Last index in yytable_.
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
yyfinal_ = ]b4_final_state_number[, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
yyntokens_ = ]b4_tokens_number[ //< Number of tokens.
yyntokens_ = ]b4_tokens_number[ ///< Number of tokens.
};
]b4_parse_param_vars[
};
]b4_token_ctor_if([b4_yytranslate_define
b4_public_types_define])[
]b4_token_ctor_if([b4_yytranslate_define([$1])[
]b4_public_types_define([$1])])[
]b4_namespace_close[
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
@@ -368,6 +397,10 @@ b4_public_types_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++])
@@ -379,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[
]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])[
[b4_shared_declarations([cc])])[
// User implementation prologue.
]b4_user_post_prologue[
]b4_percent_code_get[
@@ -418,6 +449,15 @@ m4_if(b4_prefix, [yy], [],
# endif
#endif
// Whether we are compiled with exception support.
#ifndef YY_EXCEPTIONS
# if defined __GNUC__ && !defined __EXCEPTIONS
# define YY_EXCEPTIONS 0
# else
# define YY_EXCEPTIONS 1
# endif
#endif
]b4_locations_if([dnl
[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
]b4_yylloc_default_define])[
@@ -437,7 +477,7 @@ m4_if(b4_prefix, [yy], [],
{ \
*yycdebug_ << Title << ' '; \
yy_print_ (*yycdebug_, Symbol); \
*yycdebug_ << std::endl; \
*yycdebug_ << '\n'; \
} \
} while (false)
@@ -456,14 +496,14 @@ m4_if(b4_prefix, [yy], [],
#else // !]b4_api_PREFIX[DEBUG
# define YYCDEBUG if (false) std::cerr
# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
# define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
# define YY_STACK_PRINT() static_cast<void>(0)
# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE (Symbol)
# define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
# define YY_STACK_PRINT() static_cast<void> (0)
#endif // !]b4_api_PREFIX[DEBUG
#define yyerrok (yyerrstatus_ = 0)
#define yyclearin (yyempty = true)
#define yyclearin (yyla.clear ())
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
@@ -527,70 +567,82 @@ m4_if(b4_prefix, [yy], [],
| Symbol types. |
`---------------*/
]b4_token_ctor_if([], [b4_public_types_define])[
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
// by_state.
inline
]b4_parser_class_name[::by_state::by_state ()
: state (empty)
: state (empty_state)
{}
inline
]b4_parser_class_name[::by_state::by_state (const by_state& other)
: state (other.state)
{}
inline
void
]b4_parser_class_name[::by_state::clear ()
{
state = empty_state;
}
void
]b4_parser_class_name[::by_state::move (by_state& that)
{
state = that.state;
that.state = empty;
that.clear ();
}
inline
]b4_parser_class_name[::by_state::by_state (state_type s)
: state (s)
{}
inline
]b4_parser_class_name[::symbol_number_type
]b4_parser_class_name[::by_state::type_get () const
{
return state == empty ? 0 : yystos_[state];
if (state == empty_state)
return empty_symbol;
else
return yystos_[state];
}
inline
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
{}
inline
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
: super_type (s]b4_locations_if([, that.location])[)
{
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [move], [that.value])],
[[value = that.value;]])[
]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], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
#if defined __cplusplus && 201103L <= __cplusplus
// that is emptied.
that.type = empty;
that.state = empty_state;
#endif
}
inline
]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>
inline
void
]b4_parser_class_name[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
{
@@ -610,6 +662,10 @@ m4_if(b4_prefix, [yy], [],
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
symbol_number_type yytype = yysym.type_get ();
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
// below array bounds".
if (yysym.empty ())
std::abort ();
yyo << (yytype < yyntokens_ ? "token" : "nterm")
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
<< yysym.location << ": "])[;
@@ -618,26 +674,27 @@ m4_if(b4_prefix, [yy], [],
}
#endif
inline
void
]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym)
{
stack_symbol_type t (s, sym);
yypush_ (m, t);
}
inline
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));
}
inline
void
]b4_parser_class_name[::yypop_ (unsigned int 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);
}
@@ -669,36 +726,40 @@ m4_if(b4_prefix, [yy], [],
}
#endif // ]b4_api_PREFIX[DEBUG
inline ]b4_parser_class_name[::state_type
]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yylhs)
]b4_parser_class_name[::state_type
]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yysym)
{
int yyr = yypgoto_[yylhs - yyntokens_] + yystate;
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
return yytable_[yyr];
else
return yydefgoto_[yylhs - yyntokens_];
return yydefgoto_[yysym - yyntokens_];
}
inline bool
bool
]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue)
{
return yyvalue == yypact_ninf_;
}
inline bool
bool
]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue)
{
return yyvalue == yytable_ninf_;
}
int
]b4_parser_class_name[::operator() ()
{
return parse ();
}
int
]b4_parser_class_name[::parse ()
{
/// Whether yyla contains a lookahead.
bool yyempty = true;
// State.
int yyn;
/// Length of the RHS of the rule being reduced.
int yylen = 0;
// Error handling.
@@ -711,21 +772,17 @@ m4_if(b4_prefix, [yy], [],
/// The locations where the error started and ended.
stack_symbol_type yyerror_range[3];]])[
/// $$ and @@$.
stack_symbol_type yylhs;
/// The return value of parse ().
int yyresult;
// FIXME: This shoud be completely indented. It is not yet to
// avoid gratuitous conflicts when merging into the master branch.
#if YY_EXCEPTIONS
try
#endif // YY_EXCEPTIONS
{
YYCDEBUG << "Starting parse" << std::endl;
YYCDEBUG << "Starting parse\n";
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
// User initialization code.
b4_user_initial_action
b4_dollar_popdef])[]dnl
@@ -734,11 +791,11 @@ b4_dollar_popdef])[]dnl
location values to have been already stored, initialize these
stacks with a primary value. */
yystack_.clear ();
yypush_ (YY_NULL, 0, yyla);
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
// A new symbol was pushed on the stack.
yynewstate:
YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
// Accept?
if (yystack_[0].state == yyfinal_)
@@ -748,28 +805,30 @@ b4_dollar_popdef])[]dnl
// Backup.
yybackup:
// Try to take a decision without lookahead.
yyn = yypact_[yystack_[0].state];
if (yy_pact_value_is_default_ (yyn))
goto yydefault;
// Read a lookahead token.
if (yyempty)
if (yyla.empty ())
{
YYCDEBUG << "Reading a token: ";
#if YY_EXCEPTIONS
try
#endif // YY_EXCEPTIONS
{]b4_token_ctor_if([[
symbol_type yylookahead (]b4_lex[);
yyla.move (yylookahead);]], [[
yyla.type = yytranslate_ (]b4_lex[);]])[
}
#if YY_EXCEPTIONS
catch (const syntax_error& yyexc)
{
error (yyexc);
goto yyerrlab1;
}
yyempty = false;
#endif // YY_EXCEPTIONS
}
YY_SYMBOL_PRINT ("Next token is", yyla);
@@ -789,15 +848,12 @@ b4_dollar_popdef])[]dnl
goto yyreduce;
}
// Discard the token being shifted.
yyempty = true;
// Count tokens shifted since error; after three, turn off error status.
if (yyerrstatus_)
--yyerrstatus_;
// Shift the lookahead token.
yypush_ ("Shifting", yyn, yyla);
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate;
/*-----------------------------------------------------------.
@@ -814,52 +870,60 @@ b4_dollar_popdef])[]dnl
`-----------------------------*/
yyreduce:
yylen = yyr2_[yyn];
yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([
/* 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])],[
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'. Otherwise, use the top of the stack.
{
stack_symbol_type yylhs;
yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([
/* 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], [emplace])], [
/* If YYLEN is nonzero, implement the default value of the
action: '$$ = $1'. Otherwise, use the top of the stack.
Otherwise, the following line sets YYLHS.VALUE to garbage.
This behavior is undocumented and Bison
users should not rely upon it. */
if (yylen)
yylhs.value = yystack_@{yylen - 1@}.value;
else
yylhs.value = yystack_@{0@}.value;])[
Otherwise, the following line sets YYLHS.VALUE to garbage.
This behavior is undocumented and Bison users should not rely
upon it. */
if (yylen)
yylhs.value = yystack_@{yylen - 1@}.value;
else
yylhs.value = yystack_@{0@}.value;])[
]b4_locations_if([dnl
[
// Compute the default @@$.
{
slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
YYLLOC_DEFAULT (yylhs.location, slice, yylen);
}]])[
// Perform the reduction.
YY_REDUCE_PRINT (yyn);
try
// Default location.
{
switch (yyn)
{
slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
YYLLOC_DEFAULT (yylhs.location, slice, yylen);
yyerror_range[1].location = yylhs.location;
}]])[
// Perform the reduction.
YY_REDUCE_PRINT (yyn);
#if YY_EXCEPTIONS
try
#endif // YY_EXCEPTIONS
{
switch (yyn)
{
]b4_user_actions[
default:
break;
}
}
catch (const syntax_error& yyexc)
{
error (yyexc);
YYERROR;
}
YY_SYMBOL_PRINT ("-> $$ =", yylhs);
yypop_ (yylen);
yylen = 0;
YY_STACK_PRINT ();
default:
break;
}
}
#if YY_EXCEPTIONS
catch (const syntax_error& yyexc)
{
error (yyexc);
YYERROR;
}
#endif // YY_EXCEPTIONS
YY_SYMBOL_PRINT ("-> $$ =", yylhs);
yypop_ (yylen);
yylen = 0;
YY_STACK_PRINT ();
// Shift the result of the reduction.
yypush_ (YY_NULL, yylhs);
// Shift the result of the reduction.
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
}
goto yynewstate;
/*--------------------------------------.
@@ -871,8 +935,7 @@ b4_dollar_popdef])[]dnl
{
++yynerrs_;
error (]b4_join(b4_locations_if([yyla.location]),
[[yysyntax_error_ (yystack_[0].state,
yyempty ? yyempty_ : yyla.type_get ())]])[);
[[yysyntax_error_ (yystack_[0].state, yyla)]])[);
}
]b4_locations_if([[
@@ -885,10 +948,10 @@ b4_dollar_popdef])[]dnl
// Return failure if at end of input.
if (yyla.type_get () == yyeof_)
YYABORT;
else if (!yyempty)
else if (!yyla.empty ())
{
yy_destroy_ ("Error: discarding", yyla);
yyempty = true;
yyla.clear ();
}
}
@@ -905,11 +968,7 @@ b4_dollar_popdef])[]dnl
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (false)
goto yyerrorlab;]b4_locations_if([[
yyerror_range[1].location = yystack_[yylen - 1].location;]])b4_variant_if([[
/* $$ was initialized before running the user action. */
YY_SYMBOL_PRINT ("Error: discarding", yylhs);
yylhs.~stack_symbol_type();]])[
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
yypop_ (yylen);
@@ -952,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;
@@ -967,7 +1026,7 @@ b4_dollar_popdef])[]dnl
goto yyreturn;
yyreturn:
if (!yyempty)
if (!yyla.empty ())
yy_destroy_ ("Cleanup: discarding lookahead", yyla);
/* Do not reclaim the symbols of the rule whose action triggered
@@ -981,38 +1040,38 @@ b4_dollar_popdef])[]dnl
return yyresult;
}
#if YY_EXCEPTIONS
catch (...)
{
YYCDEBUG << "Exception caught: cleaning lookahead and stack"
<< std::endl;
YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
// Do not try to display the values of the reclaimed symbols,
// as their printer might throw an exception.
if (!yyempty)
yy_destroy_ (YY_NULL, yyla);
// as their printers might throw an exception.
if (!yyla.empty ())
yy_destroy_ (YY_NULLPTR, yyla);
while (1 < yystack_.size ())
{
yy_destroy_ (YY_NULL, yystack_[0]);
yy_destroy_ (YY_NULLPTR, yystack_[0]);
yypop_ ();
}
throw;
}
#endif // YY_EXCEPTIONS
}
void
]b4_parser_class_name[::error (const syntax_error& yyexc)
{
error (]b4_join(b4_locations_if([yyexc.location]),
[[yyexc.what()]])[);
[[yyexc.what ()]])[);
}
// Generate an error message.
std::string
]b4_parser_class_name[::yysyntax_error_ (]dnl
b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
[state_type, symbol_number_type])[) const
b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
[state_type, const symbol_type&])[) const
{]b4_error_verbose_if([[
std::string yyres;
// Number of reported tokens (one for the "unexpected", one per
// "expected").
size_t yycount = 0;
@@ -1026,7 +1085,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yytoken) is
- The only way there can be no lookahead present (in yyla) is
if this state is a consistent state with a default action.
Thus, detecting the absence of a lookahead is sufficient to
determine that there is no unexpected or expected token to
@@ -1046,8 +1105,9 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
token that will not be accepted due to an error action in a
later state.
*/
if (yytoken != yyempty_)
if (!yyla.empty ())
{
int yytoken = yyla.type_get ();
yyarg[yycount++] = yytname_[yytoken];
int yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
@@ -1074,22 +1134,24 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
}
}
char const* yyformat = YY_NULL;
char const* yyformat = YY_NULLPTR;
switch (yycount)
{
#define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
default: // Avoid compiler warnings.
YYCASE_ (0, YY_("syntax error"));
YYCASE_ (1, YY_("syntax error, unexpected %s"));
YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_
}
std::string yyres;
// Argument number.
size_t yyi = 0;
for (char const* yyp = yyformat; *yyp; ++yyp)
@@ -1133,18 +1195,18 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
i_end = yystack_.end ();
i != i_end; ++i)
*yycdebug_ << ' ' << i->state;
*yycdebug_ << std::endl;
*yycdebug_ << '\n';
}
// Report on the debug stream that the rule \a yyrule is going to be reduced.
void
]b4_parser_class_name[::yy_reduce_print_ (int yyrule)
{
unsigned int yylno = yyrline_[yyrule];
unsigned yylno = yyrline_[yyrule];
int yynrhs = yyr2_[yyrule];
// Print the symbols being reduced, and their result.
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
<< " (line " << yylno << "):" << std::endl;
<< " (line " << yylno << "):\n";
// The symbols being reduced.
for (int yyi = 0; yyi < yynrhs; yyi++)
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
@@ -1152,10 +1214,10 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
}
#endif // ]b4_api_PREFIX[DEBUG
]b4_token_ctor_if([], [b4_yytranslate_define])[
]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
+24 -21
View File
@@ -1,6 +1,6 @@
# Java skeleton for Bison -*- autoconf -*-
# Copyright (C) 2007-2013 Free Software Foundation, Inc.
# Copyright (C) 2007-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
@@ -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-2013])
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>.
*
@@ -453,6 +452,19 @@ b4_define_state])[
return yyerrstatus_ == 0;
}
/** Compute post-reduction state.
* @@param yystate the current state
* @@param yysym the nonterminal to push on the stack
*/
private int yy_lr_goto_state_ (int yystate, int yysym)
{
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
return yytable_[yyr];
else
return yydefgoto_[yysym - yyntokens_];
}
private int yyaction (int yyn, YYStack yystack, int yylen) ]b4_maybe_throws([b4_throws])[
{
]b4_yystype[ yyval;
@@ -483,14 +495,7 @@ b4_define_state])[
yylen = 0;
/* Shift the result of the reduction. */
yyn = yyr1_[yyn];
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
if (0 <= yystate && yystate <= yylast_
&& yycheck_[yystate] == yystack.stateAt (0))
yystate = yytable_[yystate];
else
yystate = yydefgoto_[yyn - yyntokens_];
int yystate = yy_lr_goto_state_ (yystack.stateAt (0), yyr1_[yyn]);
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
return YYNEWSTATE;
}
@@ -580,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
])[
@@ -591,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
])[
@@ -1062,4 +1065,4 @@ b4_percent_code_get[]dnl
}
b4_epilogue[]dnl
b4_output_end()
b4_output_end
+1 -1
View File
@@ -1,4 +1,4 @@
## Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc.
## Copyright (C) 2002, 2005-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
+111 -83
View File
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -16,31 +16,67 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
[2002-2013])
[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], [[
/// Construct a position.
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,
unsigned int l = ]b4_location_initial_line[u,
unsigned int c = ]b4_location_initial_column[u)
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
unsigned l = ]b4_location_initial_line[u,
unsigned c = ]b4_location_initial_column[u)
: filename (f)
, line (l)
, column (c)
{
}
{}
]])[
/// Initialization.
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL,
unsigned int l = ]b4_location_initial_line[u,
unsigned int c = ]b4_location_initial_column[u)
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
unsigned l = ]b4_location_initial_line[u,
unsigned c = ]b4_location_initial_column[u)
{
filename = fn;
line = l;
@@ -69,21 +105,20 @@ m4_define([b4_position_define],
/// File name to which this position refers.
]b4_percent_define_get([[filename_type]])[* filename;
/// Current line number.
unsigned int line;
unsigned line;
/// Current column number.
unsigned int column;
unsigned column;
private:
/// Compute max(min, lhs+rhs) (provided min <= lhs).
static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min)
/// Compute max (min, lhs+rhs).
static unsigned add_ (unsigned lhs, int rhs, int min)
{
return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
? rhs + lhs
: min);
return static_cast<unsigned> (std::max (min,
static_cast<int> (lhs) + rhs));
}
};
/// Add and assign a position.
/// Add \a width columns, in place.
inline position&
operator+= (position& res, int width)
{
@@ -91,21 +126,21 @@ m4_define([b4_position_define],
return res;
}
/// Add two position objects.
/// Add \a width columns.
inline position
operator+ (position res, int width)
{
return res += width;
}
/// Add and assign a position.
/// Subtract \a width columns, in place.
inline position&
operator-= (position& res, int width)
{
return res += -width;
}
/// Add two position objects.
/// Subtract \a width columns.
inline position
operator- (position res, int width)
{
@@ -135,20 +170,15 @@ m4_define([b4_position_define],
** \param pos a reference to the position to redirect
*/
template <typename YYChar>
inline std::basic_ostream<YYChar>&
std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
{
if (pos.filename)
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:
@@ -157,30 +187,27 @@ m4_define([b4_location_define],
location (const position& b, const position& e)
: begin (b)
, end (e)
{
}
{}
/// Construct a 0-width location in \a p.
explicit location (const position& p = position ())
: begin (p)
, end (p)
{
}
{}
/// Construct a 0-width location in \a f, \a l, \a c.
explicit location (]b4_percent_define_get([[filename_type]])[* f,
unsigned int l = ]b4_location_initial_line[u,
unsigned int c = ]b4_location_initial_column[u)
unsigned l = ]b4_location_initial_line[u,
unsigned c = ]b4_location_initial_column[u)
: begin (f, l, c)
, end (f, l, c)
{
}
{}
])[
/// Initialization.
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,
unsigned int l = ]b4_location_initial_line[u,
unsigned int c = ]b4_location_initial_column[u)
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
unsigned l = ]b4_location_initial_line[u,
unsigned c = ]b4_location_initial_column[u)
{
begin.initialize (f, l, c);
end = begin;
@@ -216,36 +243,42 @@ m4_define([b4_location_define],
position end;
};
/// Join two location objects to create a location.
inline location operator+ (location res, const location& end)
/// Join two locations, in place.
inline location& operator+= (location& res, const location& end)
{
res.end = end.end;
return res;
}
/// Change end position in place.
/// Join two locations.
inline location operator+ (location res, const location& end)
{
return res += end;
}
/// Add \a width columns to the end position, in place.
inline location& operator+= (location& res, int width)
{
res.columns (width);
return res;
}
/// Change end position.
/// Add \a width columns to the end position.
inline location operator+ (location res, int width)
{
return res += width;
}
/// Change end position in place.
/// Subtract \a width columns to the end position, in place.
inline location& operator-= (location& res, int width)
{
return res += -width;
}
/// Change end position.
inline location operator- (const location& begin, int width)
/// Subtract \a width columns to the end position.
inline location operator- (location res, int width)
{
return begin + -width;
return res -= width;
}
]b4_percent_define_flag_if([[define_location_comparison]], [[
/// Compare two location objects.
@@ -269,12 +302,11 @@ m4_define([b4_location_define],
** Avoid duplicate information.
*/
template <typename YYChar>
inline std::basic_ostream<YYChar>&
std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin// << "(" << loc.end << ") "
;
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin;
if (loc.end.filename
&& (!loc.begin.filename
|| *loc.begin.filename != *loc.end.filename))
@@ -288,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>
@@ -305,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])
+63 -58
View File
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -15,60 +15,81 @@
# 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-2013])
# 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],
[[ template <class T, class S = std::vector<T> >
[[ /// A stack with random access from its top.
template <typename T, typename S = std::vector<T> >
class stack
{
public:
// Hide our reversed order.
typedef typename S::reverse_iterator iterator;
typedef typename S::const_reverse_iterator const_iterator;
typedef typename S::size_type size_type;
stack ()
: seq_ ()
{
}
stack (unsigned int n)
stack (size_type n = 200)
: seq_ (n)
{
}
{}
inline
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (unsigned int i)
operator[] (size_type i)
{
return seq_[seq_.size () - 1 - i];
return seq_[size () - 1 - i];
}
inline
const T&
operator[] (unsigned int i) const
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (int i)
{
return seq_[seq_.size () - 1 - i];
return operator[] (size_type (i));
}
/// Random access.
///
/// Index 0 returns the topmost element.
const T&
operator[] (size_type i) const
{
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.
inline
void
push (T& t)
push (YY_MOVE_REF (T) t)
{
seq_.push_back (T());
seq_.push_back (T ());
operator[](0).move (t);
}
inline
void
pop (unsigned int n = 1)
pop (int n = 1)
{
for (; n; --n)
for (; 0 < n; --n)
seq_.pop_back ();
}
@@ -78,21 +99,18 @@ m4_define([b4_stack_define],
seq_.clear ();
}
inline
typename S::size_type
size_type
size () const
{
return seq_.size ();
}
inline
const_iterator
begin () const
{
return seq_.rbegin ();
}
inline
const_iterator
end () const
{
@@ -107,48 +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:
slice (const S& stack, unsigned int range)
slice (const S& stack, int range)
: stack_ (stack)
, range_ (range)
{
}
{}
inline
const T&
operator [] (unsigned int i) const
operator[] (int i) const
{
return stack_[range_ - i];
}
private:
const S& stack_;
unsigned int 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[
]])
+107 -60
View File
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -27,9 +27,9 @@
m4_define([b4_symbol_variant],
[m4_pushdef([b4_dollar_dollar],
[$2.$3< $][3 > (m4_shift3($@))])dnl
switch ($1)
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]))@};
])])
@@ -94,53 +94,86 @@ m4_define([b4_variant_define],
typedef variant<S> self_type;
/// Empty construction.
variant ()]b4_parse_assert_if([
: yytname_ (YY_NULL)])[
variant ()
: yybuffer_ ()]b4_parse_assert_if([
, yytypeid_ (YY_NULLPTR)])[
{}
/// Construct and fill.
template <typename T>
variant (const T& t)]b4_parse_assert_if([
: yytname_ (typeid (T).name ())])[
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.
~variant ()
{]b4_parse_assert_if([
YYASSERT (!yytname_);
YYASSERT (!yytypeid_);
])[}
/// Instantiate an empty \a T in here.
template <typename T>
T&
build ()
emplace ()
{]b4_parse_assert_if([
YYASSERT (!yytname_);
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
yytname_ = typeid (T).name ();])[
return *new (yyas_<T> ()) T;
yytypeid_ = & typeid (T);])[
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 (!yytname_);
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
yytname_ = typeid (T).name ();])[
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>
T&
as ()
{]b4_parse_assert_if([
YYASSERT (yytname_ == typeid (T).name ());
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S);])[
return *yyas_<T> ();
}
@@ -150,7 +183,8 @@ m4_define([b4_variant_define],
const T&
as () const
{]b4_parse_assert_if([
YYASSERT (yytname_ == typeid (T).name ());
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S);])[
return *yyas_<T> ();
}
@@ -160,15 +194,15 @@ 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>
void
swap (self_type& other)
{]b4_parse_assert_if([
YYASSERT (yytname_);
YYASSERT (yytname_ == other.yytname_);])[
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == *other.yytypeid_);])[
std::swap (as<T> (), other.as<T> ());
}
@@ -178,19 +212,33 @@ m4_define([b4_variant_define],
template <typename T>
void
move (self_type& other)
{]b4_parse_assert_if([
YYASSERT (!yytname_);])[
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.
@@ -199,12 +247,12 @@ m4_define([b4_variant_define],
destroy ()
{
as<T> ().~T ();]b4_parse_assert_if([
yytname_ = YY_NULL;])[
yytypeid_ = YY_NULLPTR;])[
}
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.
@@ -234,7 +282,7 @@ m4_define([b4_variant_define],
} yybuffer_;]b4_parse_assert_if([
/// Whether the content is built: if defined, the name of the stored type.
const char *yytname_;])[
const std::type_info *yytypeid_;])[
};
]])
@@ -253,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
])
@@ -281,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])));
])])])
@@ -303,25 +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)])));
}
])])])
@@ -331,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]))[)
: Base (t)
, value (]b4_symbol_if([$1], [has_type], [v])[)]b4_locations_if([
, location (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 (YY_MOVE (v))])[]b4_locations_if([
, location (YY_MOVE (l))])[
{}
]])
# b4_symbol_constructor_define
@@ -359,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])])
+1 -1
View File
@@ -3,7 +3,7 @@
<!--
bison.xsl - common templates for Bison XSLT.
Copyright (C) 2007-2013 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
+8 -4
View File
@@ -3,7 +3,7 @@
<!--
xml2dot.xsl - transform Bison XML Report into DOT.
Copyright (C) 2007-2013 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -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>
@@ -201,6 +201,8 @@
<xsl:if test="$point = 0">
<xsl:text> .</xsl:text>
</xsl:if>
<!-- RHS -->
<xsl:for-each select="rhs/symbol|rhs/empty">
<xsl:apply-templates select="."/>
<xsl:if test="$point = position()">
@@ -214,7 +216,9 @@
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="empty"/>
<xsl:template match="empty">
<xsl:text> %empty</xsl:text>
</xsl:template>
<xsl:template match="lookaheads">
<xsl:text> [</xsl:text>
+2 -7
View File
@@ -3,7 +3,7 @@
<!--
xml2text.xsl - transform Bison XML Report into plain text.
Copyright (C) 2007-2013 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -350,12 +350,7 @@
<xsl:if test="position() = $point + 1">
<xsl:text> .</xsl:text>
</xsl:if>
<xsl:if test="$itemset = 'true' and name(.) != 'empty'">
<xsl:apply-templates select="."/>
</xsl:if>
<xsl:if test="$itemset != 'true'">
<xsl:apply-templates select="."/>
</xsl:if>
<xsl:apply-templates select="."/>
<xsl:if test="position() = last() and position() = $point">
<xsl:text> .</xsl:text>
</xsl:if>
+4 -8
View File
@@ -3,7 +3,7 @@
<!--
xml2html.xsl - transform Bison XML Report into XHTML.
Copyright (C) 2007-2013 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -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>
@@ -532,12 +533,7 @@
<xsl:text> </xsl:text>
<span class="point">.</span>
</xsl:if>
<xsl:if test="$itemset = 'true' and name(.) != 'empty'">
<xsl:apply-templates select="."/>
</xsl:if>
<xsl:if test="$itemset != 'true'">
<xsl:apply-templates select="."/>
</xsl:if>
<xsl:apply-templates select="."/>
<xsl:if test="position() = last() and position() = $point">
<xsl:text> </xsl:text>
<span class="point">.</span>
@@ -563,7 +559,7 @@
</xsl:template>
<xsl:template match="empty">
<xsl:text> &#949;</xsl:text>
<xsl:text> %empty</xsl:text>
</xsl:template>
<xsl:template match="lookaheads">
+75 -78
View File
@@ -1,11 +1,11 @@
-*- C -*-
# Yacc compatible skeleton for Bison
# Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation,
# Inc.
# Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software
# Foundation, Inc.
m4_pushdef([b4_copyright_years],
[1984, 1989-1990, 2000-2013])
[1984, 1989-1990, 2000-2015, 2018])
# 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
@@ -118,7 +118,7 @@ m4_define([b4_int_type],
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
m4_eval([0 <= $1]), [1], [unsigned int],
m4_eval([0 <= $1]), [1], [unsigned],
[int])])
@@ -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
@@ -377,13 +374,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -395,7 +392,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# define YYSIZE_T unsigned
# endif
#endif
@@ -571,7 +568,7 @@ union yyalloc
#define YYMAXUTOK ]b4_user_token_number_max[
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
@@ -719,7 +716,7 @@ do { \
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
b4_parse_param]))[
{
unsigned long int yylno = yyrline[yyrule];
unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -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)
{
@@ -827,7 +824,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
*yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
[full], [[
YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix,
(unsigned long int) yyalloc, yydebug_suffix));]])[
(unsigned long) yyalloc, yydebug_suffix));]])[
}
return 0;
}
@@ -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
@@ -1108,11 +1104,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes,
YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULL;
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
@@ -1187,7 +1183,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
}
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
@@ -1207,6 +1203,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
case N: \
yyformat = S; \
break
default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -1271,7 +1268,7 @@ static char yypstate_allocated = 0;]])b4_pull_if([
b4_function_define([[yyparse]], [[int]], b4_parse_param)[
{
return yypull_parse (YY_NULL]m4_ifset([b4_parse_param],
return yypull_parse (YY_NULLPTR]m4_ifset([b4_parse_param],
[[, ]b4_args(b4_parse_param)])[);
}
@@ -1313,10 +1310,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
{
yypstate *yyps;]b4_pure_if([], [[
if (yypstate_allocated)
return YY_NULL;]])[
return YY_NULLPTR;]])[
yyps = (yypstate *) malloc (sizeof *yyps);
if (!yyps)
return YY_NULL;
return YY_NULLPTR;
yyps->yynew = 1;]b4_pure_if([], [[
yypstate_allocated = 1;]])[
return yyps;
@@ -1325,16 +1322,19 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
]b4_function_define([[yypstate_delete]], [[void]],
[[[yypstate *yyps]], [[yyps]]])[
{
if (yyps)
{
#ifndef yyoverflow
/* If the stack was reallocated but the parse did not complete, then the
stack still needs to be freed. */
if (!yyps->yynew && yyps->yyss != yyps->yyssa)
YYSTACK_FREE (yyps->yyss);
/* If the stack was reallocated but the parse did not complete, then the
stack still needs to be freed. */
if (!yyps->yynew && yyps->yyss != yyps->yyssa)
YYSTACK_FREE (yyps->yyss);
#endif]b4_lac_if([[
if (!yyps->yynew && yyps->yyes != yyps->yyesa)
YYSTACK_FREE (yyps->yyes);]])[
free (yyps);]b4_pure_if([], [[
yypstate_allocated = 0;]])[
if (!yyps->yynew && yyps->yyes != yyps->yyesa)
YYSTACK_FREE (yyps->yyes);]])[
free (yyps);]b4_pure_if([], [[
yypstate_allocated = 0;]])[
}
}
]b4_pure_if([[
#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
@@ -1429,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;
@@ -1447,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
{
@@ -1472,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
@@ -1509,7 +1507,7 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
yylsp = yyls + yysize - 1;])[
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
(unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
@@ -1641,14 +1639,15 @@ yyreduce:
yyval = yyvsp[1-yylen];
]b4_locations_if(
[[ /* Default location. */
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[
[[ /* Default location. */
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
yyerror_range[1] = yyloc;]])[
YY_REDUCE_PRINT (yyn);]b4_lac_if([[
{
int yychar_backup = yychar;
switch (yyn)
{
]b4_user_actions[
]b4_user_actions[
default: break;
}
if (yychar_backup != yychar)
@@ -1682,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;
@@ -1782,8 +1780,7 @@ yyerrorlab:
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen];
]])[ /* Do not reclaim the symbols of the rule whose action triggered
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
@@ -1904,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
@@ -1,7 +1,7 @@
# DJGPP Maintainer's Makefile -*-Makefile-*-
# Requires GNU sed
## Copyright (C) 2005-2013 Free Software Foundation, Inc.
## Copyright (C) 2005-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
+2 -2
View File
@@ -1,6 +1,6 @@
This is a port of GNU Bison @VERSION@ to MSDOS/DJGPP.
Copyright (C) 2005-2013 Free Software Foundation, Inc.
Copyright (C) 2005-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
@@ -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
+6 -6
View File
@@ -4,7 +4,7 @@ Rem Configure Bison for DJGPP.
Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line
Rem format, or else stock DOS/Windows shells will refuse to run it.
Rem Copyright (C) 2005-2013 Free Software Foundation, Inc.
Rem Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
Rem This program is free software: you can redistribute it and/or modify
Rem it under the terms of the GNU General Public License as published by
@@ -80,10 +80,10 @@ goto NextArgument
if "%1" == "no-dep" goto NextArgument
if "%1" == "no-DEP" goto NextArgument
if "%1" == "NO-DEP" goto NextArgument
if "%1" == "dep" goto DependecyTraking
if "%1" == "DEP" goto DependecyTraking
if "%1" == "dep" goto DependecyTracking
if "%1" == "DEP" goto DependecyTracking
goto LibiconvPrefixOption
:DependecyTraking
:DependecyTracking
if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
@@ -290,7 +290,7 @@ if errorlevel 1 goto SedError2
mv -f config.hin %XSRC%/lib/config.hin
Rem Fixing ilicit testsuite file name.
Rem Fixing illicit testsuite file name.
test -f %XSRC%/tests/c++.at
if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.at
@@ -300,7 +300,7 @@ sed -f %XSRC%/djgpp/testsuite.sed %XSRC%/tests/testsuite.org > testsuite.tmp
if errorlevel 1 goto SedError3
mv -f ./testsuite.tmp %XSRC%/tests/testsuite
Rem Fixing ilicit calc++ file names in the calc++ directory.
Rem Fixing illicit calc++ file names in the calc++ directory.
test -d %XSRC%/examples/calc++
if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
test -d %XSRC%/examples/calcxx
+1 -1
View File
@@ -2,7 +2,7 @@
# Sed script for additional DJGPP specific editing
# of the configure script generated by autoconf 2.62.
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
+1 -1
View File
@@ -3,7 +3,7 @@
# This is the config.site file for configuring GNU packages
# which are to be built with DJGPP tools.
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
+1 -1
View File
@@ -1,6 +1,6 @@
# sed script for DJGPP specific editing of config.hin
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
+1 -1
View File
@@ -7,7 +7,7 @@ Rem This batch file unpacks the Bison distribution while simultaneously
Rem renaming some of the files whose names are invalid on DOS or conflict
Rem with other file names after truncation to DOS 8+3 namespace.
Rem
Rem Copyright (C) 2005-2013 Free Software Foundation, Inc.
Rem Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
Rem
Rem This program is free software: you can redistribute it and/or modify
Rem it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,4 +1,4 @@
## Copyright (C) 2008-2013 Free Software Foundation, Inc.
## 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
+1 -1
View File
@@ -1,6 +1,6 @@
/* Subprocesses with pipes.
Copyright (C) 2005-2013 Free Software Foundation, Inc.
Copyright (C) 2005-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
+1 -1
View File
@@ -1,6 +1,6 @@
/* Subprocesses with pipes.
Copyright (C) 2005-2013 Free Software Foundation, Inc.
Copyright (C) 2005-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
+1 -1
View File
@@ -2,7 +2,7 @@
# Sed script for additional DJGPP specific editing
# of the testsuite script generated by autoconf 2.61.
# Copyright (C) 2007-2013 Free Software Foundation, Inc.
# Copyright (C) 2007-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
+12 -9
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
+1406 -961
View File
File diff suppressed because it is too large Load Diff
+1226 -679
View File
File diff suppressed because it is too large Load Diff
+31 -21
View File
@@ -1,4 +1,5 @@
## Copyright (C) 2001-2003, 2005-2013 Free Software Foundation, Inc.
## Copyright (C) 2001-2003, 2005-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
@@ -29,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
@@ -43,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)
@@ -65,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
@@ -81,15 +80,20 @@ 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
## ----------- ##
@@ -106,25 +110,31 @@ remove_time_stamp = \
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
# Depend on configure to get version number changes.
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
if ! CROSS_COMPILING
MAN_DEPS = doc/bison.help doc/bison.x $(top_srcdir)/configure
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
endif
## ----------------------------- ##
## Graphviz examples generation. ##
## ----------------------------- ##
CLEANDIRS += doc/figs
CLEANFILES += $(FIGS_GV:.gv=.eps) $(FIGS_GV:.gv=.pdf) $(FIGS_GV:.gv=.png)
FIGS_GV = \
doc/figs/example.gv \
doc/figs/example-reduce.gv doc/figs/example-shift.gv
+2 -1
View File
@@ -19,7 +19,8 @@
\def\finalout{\overfullrule=0pt}
%\finalout
% Copyright (c) 1998, 2001, 2009-2013 Free Software Foundation, Inc.
% Copyright (c) 1998, 2001, 2009-2015, 2018 Free Software Foundation,
% Inc.
%
% This file is part of Bison.
%
+1 -1
View File
@@ -16,7 +16,7 @@ straightforward use of _build/src/bison would.)
--
Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2006, 2009-2015, 2018 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
+3 -3
View File
@@ -1,6 +1,6 @@
#! /usr/bin/perl -w
# Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc.
# Copyright (C) 2006, 2008-2015, 2018 Free Software Foundation, Inc.
#
# This file is part of Bison, the GNU Compiler Compiler.
#
@@ -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
@@ -738,7 +738,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
void
yy::parser::error(const yy::parser::location_type& loc, const std::string& msg)
{
std::cerr << loc << ": " << msg << std::endl;
std::cerr << loc << ": " << msg << '\n';
}
int main(int argc, char *argv[])
+1 -1
View File
@@ -1,4 +1,4 @@
## Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc.
## Copyright (C) 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
+54
View File
@@ -0,0 +1,54 @@
This directory contains examples of Bison grammar files.
Most of them come from the documentation, which should be installed together
with Bison. The URLs are provided for convenience.
* 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.
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:
+19
View File
@@ -0,0 +1,19 @@
#! /bin/sh
# Copyright (C) 2018 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
: >input
run 0 "{I have three numbers for you., 1, 2, 3, And that's all!}"
+39 -29
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 2008-2013 Free Software Foundation, Inc.
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
@@ -15,19 +15,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
%require "3.2"
%debug
%skeleton "lalr1.cc"
%defines
%language "c++"
%define api.token.constructor
%define api.value.type variant
%define api.location.file none
%define parse.assert
%locations
%code requires // *.hh
{
#include <list>
#include <string>
typedef std::list<std::string> strings_type;
#include <vector>
typedef std::vector<std::string> strings_type;
}
%code // *.cc
@@ -37,30 +38,31 @@ typedef std::list<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 list of strings.
// Koening look up will look into std, since that's an std::list.
namespace std
{
// Print a vector of strings.
std::ostream&
operator<< (std::ostream& o, const strings_type& s)
operator<< (std::ostream& o, const strings_type& ss)
{
std::copy (s.begin (), s.end (),
std::ostream_iterator<strings_type::value_type> (o, "\n"));
return o;
o << '{';
const char *sep = "";
for (strings_type::const_iterator i = ss.begin (), end = ss.end ();
i != end; ++i)
{
o << sep << *i;
sep = ", ";
}
return o << '}';
}
}
// Conversion to string.
// Convert to string.
template <typename T>
inline
std::string
string_cast (const T& t)
to_string (const T& t)
{
std::ostringstream o;
o << t;
@@ -70,31 +72,38 @@ typedef std::list<std::string> strings_type;
%token <::std::string> TEXT;
%token <int> NUMBER;
%printer { yyoutput << $$; } <*>;
%printer { yyo << '(' << &$$ << ") " << $$; } <*>;
%token END_OF_FILE 0;
%type <::std::string> item;
%type <::std::list<std::string>> list;
%type <::std::vector<std::string>> list;
%%
result:
list { std::cout << $1 << std::endl; }
list { std::cout << $1 << '\n'; }
;
list:
/* nothing */ { /* Generates an empty string list */ }
| list item { std::swap ($$, $1); $$.push_back ($2); }
%empty { /* Generates an empty string list */ }
| list item { std::swap ($$, $1); $$.push_back ($2); }
;
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
@@ -107,9 +116,10 @@ namespace yy
parser::symbol_type
yylex ()
{
static int stage = -1;
++stage;
parser::location_type loc(0, 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:
@@ -129,7 +139,7 @@ namespace yy
void
parser::error (const parser::location_type& loc, const std::string& msg)
{
std::cerr << loc << ": " << msg << std::endl;
std::cerr << loc << ": " << msg << '\n';
}
}
+9 -9
View File
@@ -2,18 +2,18 @@
/*.tmp
/.deps
/calc++
/calc++-driver.cc
/calc++-driver.hh
/calc++-parser.cc
/calc++-parser.hh
/calc++-parser.output
/calc++-parser.stamp
/calc++-parser.yy
/calc++-scanner.cc
/calc++-scanner.ll
/calc++.cc
/calc++.exe
/calc.stamp
/driver.cc
/driver.hh
/location.hh
/parser.cc
/parser.hh
/parser.output
/parser.stamp
/parser.yy
/position.hh
/scanner.cc
/scanner.ll
/stack.hh
+27
View File
@@ -0,0 +1,27 @@
# This Makefile is designed to be simple and readable. It does not
# aim at portability. It requires GNU Make.
BISON = bison
CXX = g++
FLEX = flex
all: calc++
%.cc %.hh: %.yy
$(BISON) $(BISONFLAGS) -o $*.cc $<
%.cc: %.ll
$(FLEX) $(FLEXFLAGS) -o$@ $<
%.o: %.cc
$(CXX) $(CXXFLAGS) -c -o$@ $<
calc++: calc++.o driver.o parser.o scanner.o
$(CXX) -o $@ $^
calc++.o: parser.hh
parser.o: parser.hh
scanner.o: parser.hh
clean:
rm -f calc++ *.o parser.hh parser.cc scanner.cc
+52
View File
@@ -0,0 +1,52 @@
This directory contains calc++, a simple Bison grammar file in C++.
Please, read the corresponding chapter in the documentation: "A Complete C++
Example". It is also available on line (maybe with a different version of
Bison):
https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html
To use it, copy this directory into some work directory, and run `make` to
compile the executable, and try it. It is a simple calculator which accepts
several variable definitions, one per line, and then a single expression to
evaluate.
The program calc++ expects the file to parse as argument; pass `-` to read
the standard input (and then hit <Ctrl-d>, control-d, to end your input).
$ ./calc++ -
one := 1
two := 2
three := 3
(one + two * three) * two * three
<Ctrl-d>
42
You may pass `-p` to activate the parser debug traces, and `-s` to activate
the scanner's.
-----
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/>.
# LocalWords: mfcalc calc parsers yy MERCHANTABILITY Ctrl ispell american
+12 -4
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
@@ -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'
+61 -53
View File
@@ -1,17 +1,18 @@
# Copyright (C) 2005-2006, 2008-2013 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. ##
@@ -19,7 +20,7 @@
# Don't depend on $(BISON) otherwise we would rebuild these files
# in srcdir, including during distcheck, which is forbidden.
examples/calc++/calc++-parser.stamp: $(BISON_IN)
%D%/parser.stamp: $(BISON_IN)
SUFFIXES += .yy .stamp
.yy.stamp:
$(AM_V_YACC)rm -f $@
@@ -27,50 +28,57 @@ SUFFIXES += .yy .stamp
$(AM_V_at)$(YACCCOMPILE) -o $*.cc $<
$(AM_V_at)mv -f $@.tmp $@
$(calc_sources_generated): examples/calc++/calc++-parser.stamp
@test -f $@ || rm -f examples/calc++/calc++-parser.stamp
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) examples/calc++/calc++-parser.stamp
CLEANFILES += \
$(calc_sources_generated) \
examples/calc++/calc++-parser.output \
examples/calc++/calc++-parser.stamp \
examples/calc++/calc++-scanner.cc
$(calcxx_sources_generated): %D%/parser.stamp
@test -f $@ || rm -f %D%/parser.stamp
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/parser.stamp
CLEANFILES += \
$(calcxx_sources_generated) \
%D%/parser.output \
%D%/parser.stamp \
%D%/scanner.cc
CLEANDIRS += %D%/*.dSYM
## -------------------- ##
## Building & testing. ##
## -------------------- ##
# Avoid using BUILT_SOURCES which is too global.
$(examples_calc___calc___OBJECTS): $(calc_sources_generated)
$(%C%_calc___OBJECTS): $(calcxx_sources_generated)
calc_sources_extracted = \
examples/calc++/calc++-driver.cc \
examples/calc++/calc++-driver.hh \
examples/calc++/calc++-scanner.ll \
examples/calc++/calc++.cc
calc_extracted = \
$(calc_sources_extracted) \
examples/calc++/calc++-parser.yy
extracted += $(calc_extracted)
calc_sources_generated = \
examples/calc++/calc++-parser.cc \
examples/calc++/calc++-parser.hh \
examples/calc++/location.hh \
examples/calc++/position.hh \
examples/calc++/stack.hh
calc_sources = \
$(calc_sources_extracted) \
$(calc_sources_generated)
calcxx_sources_extracted = \
%D%/driver.cc \
%D%/driver.hh \
%D%/scanner.ll \
%D%/calc++.cc
calcxx_extracted = \
$(calcxx_sources_extracted) \
%D%/parser.yy
extracted += $(calcxx_extracted)
calcxx_sources_generated = \
%D%/parser.cc \
%D%/parser.hh \
%D%/location.hh
calcxx_sources = \
$(calcxx_sources_extracted) \
$(calcxx_sources_generated)
if BISON_CXX_WORKS
check_PROGRAMS += examples/calc++/calc++
nodist_examples_calc___calc___SOURCES = \
$(calc_sources)
if FLEX_CXX_WORKS
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
examples_calc___calc___CPPFLAGS = -I$(top_builddir)/examples/calc++
examples_calc___calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
dist_TESTS += examples/calc++/calc++.test
else
EXTRA_DIST += examples/calc++/calc++.test
endif
## ------------ ##
## Installing. ##
## ------------ ##
calcxxdir = $(docdir)/examples/calc++
calcxx_DATA = $(calcxx_extracted)
dist_calcxx_DATA = %D%/README %D%/Makefile
-6
View File
@@ -1,6 +0,0 @@
// Work around an Automake 1.11.2 bug: it asks for the creation of
// y.tab.c and y.tab.h and then renames them as calc++-parser.cc and
// calc++-parser.h, but in the former it does not convert the
// #include "y.tab.h". We don't want this to show in the
// documentation.
#include "calc++-parser.hh"
+51 -15
View File
@@ -3,8 +3,8 @@
# This file is part of GNU Bison
# Copyright (C) 1992, 2000-2001, 2005-2006, 2009-2013 Free Software
# Foundation, Inc.
# Copyright (C) 1992, 2000-2001, 2005-2006, 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
@@ -19,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Usage: extexi input-file.texi ... -- [FILES to extract]
# Usage: extexi [OPTION...] input-file.texi ... -- [FILES to extract]
# Look for @example environments preceded with lines such as:
#
@@ -32,9 +32,27 @@
# 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;
# normalize($block)
# -----------------
# Remove Texinfo mark up.
@@ -42,7 +60,7 @@ sub normalize($)
{
local ($_) = @_;
s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*//mg;
s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*\n//mg;
s/\@value\{VERSION\}/$ENV{VERSION}/g;
s/^\@(error|result)\{\}//mg;
s/\@([{}@])/$1/g;
@@ -62,9 +80,24 @@ sub message($)
}
}
# basename => full file name for files we should extract.
my %file_wanted;
# The list of files we should extract.
my @file_wanted;
# Whether we should extract that file, and then under which path.
sub file_wanted ($)
{
my ($f) = @_;
for my $file (@file_wanted)
{
# No endswith in Perl 5...
return $file if $f eq substr($file, -length($f));
}
undef
}
# process ($in)
# -------------
# Read input file $in, and generate the outputs.
sub process ($)
{
my ($in) = @_;
@@ -86,9 +119,9 @@ sub process ($)
{
my $f = $1;
$block = $2 || 1;
if ($file_wanted{$f})
if (file_wanted($f))
{
$file = $file_wanted{$f};
$file = file_wanted($f);
message(" GEN $file");
}
else
@@ -102,14 +135,14 @@ sub process ($)
{
# Bison supports synclines, but not Flex.
$input .= sprintf ("#line %s \"$in\"\n", $. + 1)
if $file =~ /\.[chy]*$/;
next;
if $synclines && $file =~ /\.[chy]*$/;
}
elsif (/^\@end (small)?example$/)
{
die "no contents: $file"
if $input eq "";
$file{$file}{$block} .= "\n" if defined $file{$file}{$block};
$file{$file}{$block} .= normalize($input);
$file = $input = undef;
++$block;
@@ -124,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}{$_}
@@ -136,14 +169,17 @@ my @input;
my $seen_dash = 0;
for my $arg (@ARGV)
{
if ($arg eq '--')
if ($seen_dash)
{
push @file_wanted, $arg;
}
elsif ($arg eq '--')
{
$seen_dash = 1;
}
elsif ($seen_dash)
elsif ($arg eq '--synclines')
{
use File::Basename;
$file_wanted{basename($arg)} = $arg;
$synclines = 1;
}
else
{
+64 -26
View File
@@ -1,20 +1,20 @@
# Copyright (C) 2005, 2008-2013 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 = examples/extexi examples/test
TEST_LOG_COMPILER = $(top_srcdir)/examples/test
dist_noinst_SCRIPTS = %D%/extexi %D%/test
TEST_LOG_COMPILER = $(top_srcdir)/%D%/test
AM_CXXFLAGS = \
$(WARN_CXXFLAGS) $(WARN_CXXFLAGS_TEST) $(WERROR_CXXFLAGS)
@@ -24,20 +24,58 @@ AM_CXXFLAGS = \
## ------------ ##
doc = $(top_srcdir)/doc/bison.texi
extexi = $(top_srcdir)/examples/extexi
extract = VERSION="$(VERSION)" $(PERL) -f $(extexi) $(doc) --
extexi = $(top_srcdir)/%D%/extexi
if ENABLE_GCC_WARNINGS
EXTEXIFLAGS = --synclines
endif
extract = VERSION="$(VERSION)" $(PERL) $(extexi) $(EXTEXIFLAGS) $(doc) --
extracted =
CLEANFILES += $(extracted) examples/extracted.stamp
examples/extracted.stamp: $(doc) $(extexi)
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 $@
$(extracted): examples/extracted.stamp
@test -f $@ || rm -f examples/extracted.stamp
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) examples/extracted.stamp
$(extracted): %D%/extracted.stamp
@test -f $@ || rm -f %D%/extracted.stamp
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/extracted.stamp
include examples/calc++/local.mk
include examples/mfcalc/local.mk
include examples/rpcalc/local.mk
## ------ ##
## 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
CLEANDIRS += %D%/*.dSYM
include %D%/calc++/local.mk
include %D%/c++/local.mk
include %D%/mfcalc/local.mk
include %D%/rpcalc/local.mk
+32 -26
View File
@@ -1,36 +1,42 @@
# Copyright (C) 2005-2006, 2008-2013 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. ##
## -------------------- ##
BUILT_SOURCES += $(mfcalc_sources)
CLEANFILES += examples/mfcalc/mfcalc.[ch] examples/mfcalc/mfcalc.output
CLEANFILES += %D%/mfcalc.[ch] %D%/mfcalc.output
CLEANDIRS += %D%/*.dSYM
mfcalc_extracted = \
examples/mfcalc/calc.h \
examples/mfcalc/mfcalc.y
mfcalc_sources = \
$(mfcalc_extracted)
mfcalc_extracted = %D%/calc.h %D%/mfcalc.y
mfcalc_sources = $(mfcalc_extracted)
extracted += $(mfcalc_extracted)
check_PROGRAMS += examples/mfcalc/mfcalc
examples_mfcalc_mfcalc_LDADD = -lm
nodist_examples_mfcalc_mfcalc_SOURCES = \
$(mfcalc_sources)
check_PROGRAMS += %D%/mfcalc
nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
# Don't use gnulib's system headers.
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_mfcalc_LDADD = -lm
examples_mfcalc_mfcalc_CPPFLAGS = -I$(top_builddir)/examples/mfcalc
dist_TESTS += examples/mfcalc/mfcalc.test
dist_TESTS += %D%/mfcalc.test
## ------------ ##
## Installing. ##
## ------------ ##
mfcalcdir = $(docdir)/examples/mfcalc
mfcalc_DATA = $(mfcalc_extracted)
+2 -2
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
@@ -24,4 +24,4 @@ cat >input <<EOF
(1+2) * 3
EOF
run 0 9
run 0 9 -p
run -noerr 0 9 -p
+1
View File
@@ -1,4 +1,5 @@
/calc.h
/rpcalc
/rpcalc.c
/rpcalc.h
/rpcalc.output
+32 -25
View File
@@ -1,35 +1,42 @@
# Copyright (C) 2005-2006, 2008-2013 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. ##
## -------------------- ##
BUILT_SOURCES += $(rpcalc_sources)
CLEANFILES += examples/rpcalc/rpcalc.[ch] examples/rpcalc/rpcalc.output
CLEANFILES += %D%/rpcalc.[ch] %D%/rpcalc.output
CLEANDIRS += %D%/*.dSYM
rpcalc_extracted = \
examples/rpcalc/rpcalc.y
rpcalc_sources = \
$(rpcalc_extracted)
rpcalc_extracted = %D%/rpcalc.y
rpcalc_sources = $(rpcalc_extracted)
extracted += $(rpcalc_extracted)
check_PROGRAMS += examples/rpcalc/rpcalc
examples_rpcalc_rpcalc_LDADD = -lm
nodist_examples_rpcalc_rpcalc_SOURCES = \
$(rpcalc_sources)
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
examples_rpcalc_rpcalc_CPPFLAGS = -I$(top_builddir)/examples/rpcalc
dist_TESTS += examples/rpcalc/rpcalc.test
dist_TESTS += %D%/rpcalc.test
## ------------ ##
## Installing. ##
## ------------ ##
rpcalcdir = $(docdir)/examples/rpcalc
rpcalc_DATA = $(rpcalc_extracted)
+1 -1
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
+33 -15
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Copyright (C) 2005-2013 Free Software Foundation, Inc.
# Copyright (C) 2005-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
@@ -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,17 +24,28 @@ number=1
# Exit status of this script.
exit=true
# top_buiddir.
cwd=`pwd`
# top_builddir.
cwd=$(pwd)
# The exercised program.
prog=$cwd/examples/$me/$me
for p in "$cwd/examples/$medir/$me" "$cwd/examples/$me"
do
if test -x "$p"; then
prog=$p
break
fi
done
if test x"$prog" = x; then
echo "$me: ERROR: cannot find program to exercise"
exit 1
fi
# cleanup
# -------
cleanup ()
{
local status=$?
status=$?
if test -z "$DEBUG"; then
cd $cwd
rm -rf $$.dir
@@ -44,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"
@@ -70,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: 03e96cc338...a79f2a2871
+44 -27
View File
@@ -4,8 +4,7 @@
/*~
/.deps
/.dirstamp
/Makefile
/Makefile.in
/_Noreturn.h
/alignof.h
/alloca.h
/alloca.in.h
@@ -15,7 +14,9 @@
/asnprintf.c
/basename-lgpl.c
/basename.c
/binary-io.c
/binary-io.h
/bitrotate.c
/bitrotate.h
/c++defs.h
/c-ctype.c
@@ -28,8 +29,6 @@
/charset.alias
/cloexec.c
/cloexec.h
/close-hook.c
/close-hook.h
/close-stream.c
/close-stream.h
/close.c
@@ -37,7 +36,6 @@
/closeout.h
/concat-filename.c
/concat-filename.h
/config.charset
/config.h
/config.in.h
/configmake.h
@@ -56,7 +54,6 @@
/exitfail.h
/fatal-signal.c
/fatal-signal.h
/fclose.c
/fcntl.c
/fcntl.h
/fcntl.in.h
@@ -81,19 +78,27 @@
/fseterr.h
/fstat.c
/getdtablesize.c
/getopt-cdefs.in.h
/getopt-core.h
/getopt-ext.h
/getopt-pfx-core.h
/getopt-pfx-ext.h
/getopt.c
/getopt.h
/getopt.in.h
/getopt1.c
/getopt_int.h
/getprogname.c
/getprogname.h
/gettext.h
/gnulib.mk
/hard-locale.c
/hard-locale.h
/hash.c
/hash.h
/intprops.h
/inttypes.h
/inttypes.in.h
/ioctl.c
/isnan.c
/isnand-nolibm.h
/isnand.c
@@ -103,9 +108,15 @@
/isnanl.c
/itold.c
/ldexpl.c
/limits.h
/limits.in.h
/localcharset.c
/localcharset.h
/lstat.c
/malloc.c
/malloca.c
/malloca.h
/math.c
/math.h
/math.in.h
/mbrtowc.c
@@ -114,12 +125,11 @@
/mbswidth.h
/memchr.c
/memchr.valgrind
/minmax.h
/msvc-inval.c
/msvc-inval.h
/msvc-nothrow.c
/msvc-nothrow.h
/nonblocking.c
/nonblocking.h
/obstack.c
/obstack.h
/obstack_printf.c
@@ -140,7 +150,6 @@
/printf.c
/progname.c
/progname.h
/quote.c
/quote.h
/quotearg.c
/quotearg.h
@@ -149,11 +158,10 @@
/rawmemchr.valgrind
/realloc.c
/ref-add.sed
/ref-add.sin
/ref-del.sed
/ref-del.sin
/sched.h
/sched.in.h
/sig-handler.c
/sig-handler.h
/sigaction.c
/signal.h
@@ -182,6 +190,8 @@
/spawnp.c
/sprintf.c
/stamp-h1
/stat-w32.c
/stat-w32.h
/stat.c
/stdbool.h
/stdbool.in.h
@@ -192,7 +202,6 @@
/stdio--.h
/stdio-impl.h
/stdio-safer.h
/stdio-write.c
/stdio.h
/stdio.in.h
/stdlib.h
@@ -211,24 +220,19 @@
/stripslash.c
/strndup.c
/strnlen.c
/strtol.c
/strtoul.c
/strverscmp.c
/sys
/sys_ioctl.h
/sys_ioctl.in.h
/sys_socket.h
/sys_socket.in.h
/sys_stat.h
/sys_stat.in.h
/sys_types.in.h
/sys_wait.h
/sys_wait.in.h
/sysexits.in.h
/time.h
/time.in.h
/unistd--.h
/unistd-safer.h
/unistd.c
/unistd.h
/unistd.in.h
/unitypes.h
@@ -236,6 +240,7 @@
/uniwidth
/uniwidth.h
/uniwidth.in.h
/unlink.c
/unlocked-io.h
/unsetenv.c
/vasnprintf.c
@@ -244,7 +249,6 @@
/vfprintf.c
/vsnprintf.c
/vsprintf.c
/w32sock.h
/w32spawn.h
/wait-process.c
/wait-process.h
@@ -252,6 +256,7 @@
/warn-on-use.h
/wchar.h
/wchar.in.h
/wctype-h.c
/wctype.h
/wctype.in.h
/wcwidth.c
@@ -262,13 +267,25 @@
/xmalloc.c
/xmemdup0.c
/xmemdup0.h
/xsize.c
/xsize.h
/xstrndup.c
/xstrndup.h
/binary-io.c
/xsize.c
/bitrotate.c
/math.c
/sig-handler.c
/unistd.c
/wctype-h.c
/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
+70 -126
View File
@@ -1,7 +1,7 @@
/* Array bitsets.
Copyright (C) 2002-2003, 2006, 2009-2013 Free Software Foundation,
Inc.
Copyright (C) 2002-2003, 2006, 2009-2015, 2018 Free Software
Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
@@ -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 int 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 int 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);
+4 -3
View File
@@ -1,6 +1,7 @@
/* Functions to support abitsets.
Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
@@ -22,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
+25 -17
View File
@@ -1,7 +1,7 @@
/* Base bitset stuff.
Copyright (C) 2002-2004, 2006, 2009-2013 Free Software Foundation,
Inc.
Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software
Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
@@ -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
@@ -50,8 +58,8 @@ extern const char * const bitset_type_names[];
enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC};
/* Data type used to store a word of bits. */
typedef unsigned long int bitset_word;
#define BITSET_WORD_BITS ((unsigned int) (CHAR_BIT * sizeof (bitset_word)))
typedef unsigned long bitset_word;
#define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (bitset_word)))
/* Bit index. In theory we might need a type wider than size_t, but
in practice we lose at most a factor of CHAR_BIT by going with
@@ -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 */
+39 -62
View File
@@ -1,6 +1,7 @@
/* General bitsets.
Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation,
Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
@@ -23,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;
@@ -38,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 ();
@@ -49,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;
}
@@ -100,7 +95,7 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
specified by ATTR. For variable size bitsets, N_BITS is only a
hint and may be zero. */
enum bitset_type
bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned int attr)
bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
{
/* Check attributes. */
if (attr & BITSET_FIXED && attr & BITSET_VARIABLE)
@@ -133,12 +128,9 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned int 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
@@ -153,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);
@@ -168,11 +157,9 @@ bitset_obstack_alloc (struct obstack *bobstack,
/* Create a bitset of N_BITS and with attribute hints specified by
ATTR. */
bitset
bitset_create (bitset_bindex n_bits, unsigned int attr)
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);
}
@@ -199,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);
}
@@ -213,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];
}
@@ -226,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;
@@ -239,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);
}
@@ -248,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;
@@ -290,15 +271,13 @@ bitset_only_set_p (bitset src, bitset_bindex bitno)
static void
bitset_print (FILE *file, bitset bset, bool verbose)
{
unsigned int pos;
bitset_bindex i;
bitset_iterator iter;
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
(unsigned long int) bitset_size (bset));
(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)
@@ -307,9 +286,9 @@ bitset_print (FILE *file, bitset bset, bool verbose)
pos = 0;
}
fprintf (file, "%lu ", (unsigned long int) i);
fprintf (file, "%lu ", (unsigned long) i);
pos += 1 + (i >= 10) + (i >= 100);
};
}
if (verbose)
fprintf (file, "}\n");
@@ -356,7 +335,7 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
bitset_bindex
bitset_size_ (bitset src)
{
return BITSET_NBITS_ (src);
return BITSET_NBITS_ (src);
}
@@ -365,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;
}
@@ -397,7 +376,7 @@ bitset_copy_ (bitset dst, bitset src)
BITSET_FOR_EACH (iter, src, i, 0)
{
bitset_set (dst, i);
};
}
return true;
}
@@ -410,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)
+33 -37
View File
@@ -1,6 +1,7 @@
/* Generic bitsets.
Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation,
Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
@@ -23,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. */
@@ -39,7 +40,7 @@ enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
BITSET_FRUGAL = 16, /* Prefer most compact. */
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
typedef unsigned int bitset_attrs;
typedef unsigned bitset_attrs;
/* The contents of the union should be considered to be private.
While I would like to make this union opaque, it needs to be
@@ -82,7 +83,6 @@ union bitset_union
struct bbitset_struct b;
bitset_windex size; /* Allocated size of array. */
} v;
};
@@ -98,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. */
@@ -180,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)
@@ -280,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
@@ -308,9 +308,7 @@ extern void bitset_dump (FILE *, bitset);
bitset_iterator iter;
BITSET_FOR_EACH (iter, src, i, 0)
{
printf ("%lu ", (unsigned long int) i);
};
printf ("%lu ", (unsigned long) i);
*/
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
@@ -330,9 +328,7 @@ extern void bitset_dump (FILE *, bitset);
bitset_iterator iter;
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
{
printf ("%lu ", (unsigned long int) i);
};
printf ("%lu ", (unsigned long) i);
*/
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
@@ -367,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);
@@ -382,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 */
+101 -98
View File
@@ -1,6 +1,7 @@
/* Bitset statistics.
Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation,
Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
@@ -28,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
@@ -76,23 +78,23 @@
struct bitset_type_info_struct
{
unsigned int allocs;
unsigned int frees;
unsigned int lists;
unsigned int sets;
unsigned int cache_sets;
unsigned int resets;
unsigned int cache_resets;
unsigned int tests;
unsigned int cache_tests;
unsigned int list_counts[BITSET_LOG_COUNT_BINS];
unsigned int list_sizes[BITSET_LOG_SIZE_BINS];
unsigned int list_density[BITSET_DENSITY_BINS];
unsigned allocs;
unsigned frees;
unsigned lists;
unsigned sets;
unsigned cache_sets;
unsigned resets;
unsigned cache_resets;
unsigned tests;
unsigned cache_tests;
unsigned list_counts[BITSET_LOG_COUNT_BINS];
unsigned list_sizes[BITSET_LOG_SIZE_BINS];
unsigned list_density[BITSET_DENSITY_BINS];
};
struct bitset_stats_info_struct
{
unsigned int runs;
unsigned runs;
struct bitset_type_info_struct types[BITSET_TYPE_NUM];
};
@@ -105,20 +107,17 @@ bool bitset_stats_enabled = false;
/* Print a percentage histogram with message MSG to FILE. */
static void
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
unsigned int n_bins, unsigned int *bins)
unsigned n_bins, unsigned *bins)
{
unsigned int i;
unsigned int 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],
@@ -129,39 +128,41 @@ bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
/* Print a log histogram with message MSG to FILE. */
static void
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
unsigned int n_bins, unsigned int *bins)
unsigned n_bins, unsigned *bins)
{
unsigned int i;
unsigned int total;
unsigned int 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 int) (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 int) (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);
}
}
@@ -204,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;
@@ -214,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]);
}
@@ -241,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),
@@ -271,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),
@@ -351,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);
}
@@ -377,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);
}
@@ -572,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;
}
@@ -662,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);
}
@@ -676,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. */
@@ -696,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;

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