Commit Graph

6089 Commits

Author SHA1 Message Date
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
Jannick
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