Commit Graph

7165 Commits

Author SHA1 Message Date
Akim Demaille
d26d10ad6c examples: beware of portability issue on Windows
Reported by Jannick.
https://lists.gnu.org/r/bug-bison/2020-05/msg00040.html
https://lists.gnu.org/r/bug-bison/2020-05/msg00066.html

* examples/test (diff_opts): Use --strip-trailing-cr if supported, to
avoid \n vs. \r\n issues.
* examples/c/bistromathic/bistromathic.test: When on MSYS, don't try
to check autocompletion.
2020-05-08 09:45:29 +02:00
Akim Demaille
1b4108da3e regen 2020-05-08 09:45:29 +02:00
Akim Demaille
53bfc7df94 doc: fix the generation of the man page
When there is no bison.1 at all, the procedure fails.

* doc/local.mk (bison.1): Be robust to cold starts.
2020-05-08 09:02:45 +02:00
Akim Demaille
a5fb4a88ef news: prepare for 3.6 2020-05-08 07:34:30 +02:00
Akim Demaille
54df196d49 doc: complete the table of symbols
* doc/bison.texi: Add YYEMPTY, YYEOF and YYUNDEF.
2020-05-08 07:34:30 +02:00
Akim Demaille
52bb6f0525 doc: clarify the glossary item about kinds
* doc/bison.texi (Glossary): here.
2020-05-07 08:38:58 +02:00
Akim Demaille
76dab18af3 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-05-06 08:48:05 +02:00
Akim Demaille
c982974f33 version 3.5.94
* NEWS: Record release date.
v3.5.94
2020-05-06 08:28:36 +02:00
Akim Demaille
dc2a3578b7 doc: document yypstate_expected_tokens
* doc/bison.texi (Push Parser Interface): Here.
2020-05-06 08:11:52 +02:00
Akim Demaille
9661b2fcbc doc: restructure the push parser documentation
I don't think it's fair to have yypstate_new, yypstate_delete,
yypush_parse and yypull_parse to have their own section, on par with
yyparse and yylex.  Let them be in a single section about push
parsers.  And show new/delete first.

* doc/bison.texi (Push Parser Interface): New.
Fuse the aforementioned sections into it.
2020-05-06 08:11:52 +02:00
Akim Demaille
d9a9b054ae all: fix the interface of yyexpected_tokens
The user gives yyexpected_tokens a limit: the max number of tokens she
wants to hear about.  That's because an error message that reports a
bazillion of possible tokens is useless.

In that case yyexpected_tokens returned 0, so the user would not know
if there are too many expected tokens or none (yes, that's possible).

There are several ways to tell the user in which situation she's in:

- return some E2MANY, a negative value.  Then it makes the pattern

    int argsize = yypcontext_expected_tokens (ctx, arg, ARGS_MAX);
    if (argsize < 0)
      return argsize;

  no longer valid, as for E2MANY (i) the user must generate the error
  message anyway, and (ii) she should not return E2MANY

- return ARGS_MAX + 1.  Then it makes it dangerous for the user, as
  she has to iterate update `min (ARGS_MAX, argsize)`.

Returning 0 is definitely simpler and safer for the user, as it tells
her "this is not an error, just generate your message without a list
of expecting tokens".  So let's still return 0, but set arg[0] to the
empty token when the list is really empty.

* data/skeletons/glr.c, data/skeletons/lalr1.cc, data/skeletons/lalr1.java
* data/skeletons/yacc.c (yyexpected_tokens): Put the empty symbol
first if there are no possible tokens at all.
* examples/c/bistromathic/parse.y: Demonstrate how to use that.
2020-05-06 08:11:52 +02:00
Akim Demaille
cb9f4cb543 examples: fix handling of syntax errors
The shell grammar does not allow empty statements in then/else part of
an if, but examples/test failed to catch the syntax errors from the
script it ran.  So exited with success anyway.

You would expect 'set -e' to suffice, but with bash 3.2 actually it
does not.  As a matter of fact, I could find a way to have this behave
properly:

    $ cat test.sh
    set -e
    cleanup ()
    {
      status=$?
      echo "cleanup: $status"
      exit $status
    }
    trap cleanup 0 1 2 13 15
    . $1
    s=$?
    echo "test.sh: $s"
    exit $s

    $ cat bistro.test
    if true; then
    fi

    $ /bin/sh ./test.sh ./bistro.test
    ./bistro.test: line 2: syntax error near unexpected token `fi'
    cleanup: 0
    $ echo $?
    0

Remove the set -e (or the trap), and tada, it works...  So we have to
deal with the error by hand.

* examples/test ($exit): Replace with...
($status): this.
Preserve the exit status of the test case.
* examples/c/bistromathic/bistromathic.test: Fix syntax error.
2020-05-05 08:21:12 +02:00
Akim Demaille
b86dcaf40b doc: beware of timestamp issues on Haiku
On Haiku, help2man is fired on a freshly extracted tarball.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00055.html

* doc/local.mk (bison.1): Be robust to a missing help2man.
2020-05-04 19:06:59 +02:00
Akim Demaille
0fafbbdefb tests: beware of wchar_t portability issues on AIX
https://lists.gnu.org/r/bug-bison/2020-05/msg00050.html
Reported by Bruno Haible.

* tests/diagnostics.at: here.
2020-05-04 08:09:22 +02:00
Akim Demaille
4b85b969d0 glr.c: beware of portability issues with PTRDIFF_MAX
For instance test 386, "glr.cc api.value.type={double}":

    types.at:366: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o test test.cc $LIBS
    stderr:
    test.cc: In function 'ptrdiff_t yysplitStack(yyGLRStack*, ptrdiff_t)':
    test.cc:490:4: error: 'PTRDIFF_MAX' was not declared in this scope
       (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
        ^
    test.cc:1805:37: note: in expansion of macro 'YYSIZEMAX'
           ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
                                         ^~~~~~~~~
    test.cc:490:4: note: suggested alternative: '__PTRDIFF_MAX__'
       (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
        ^
    test.cc:1805:37: note: in expansion of macro 'YYSIZEMAX'
           ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
                                         ^~~~~~~~~

The failing tests are using glr.cc only, which I don't understand, the
problem is rather in glr.c, so I would expect glr.c tests to also fail.

Reported by Bruno Haible.
https://lists.gnu.org/archive/html/bug-bison/2020-05/msg00053.html

* data/skeletons/yacc.c: Move the block that defines
YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM, and
YYSIZEOF to...
* data/skeletons/c.m4 (b4_sizes_types_define): Here.
(b4_c99_int_type): Also take care of the #undefinition of short.
* data/skeletons/yacc.c, data/skeletons/glr.c: Use
b4_sizes_types_define.
* data/skeletons/glr.c: Adjust to use YYPTRDIFF_T/YYPTRDIFF_MAXIMUM,
YYSIZE_T/YYSIZE_MAXIMUM.
2020-05-04 07:44:42 +02:00
Akim Demaille
7727693711 todo: update 2020-05-04 07:37:40 +02:00
Akim Demaille
ce27796b74 examples: beware of strnlen portability issues
One function missing on Solaris 10 Sparc:

     CCLD     examples/c/bistromathic/bistromathic
    Undefined                       first referenced
    symbol                             in file
    strnlen                             examples/c/bistromathic/bistromathic-parse.o
    ld: fatal: symbol referencing errors. No output written to examples/c/bistromathic/bistromathic

Reported by Dagobert Michelsen.
https://lists.gnu.org/r/bug-bison/2020-05/msg00048.html

* examples/c/bistromathic/parse.y (xstrndup): Don't use strnlen.
xstrndup is assembled from gnulib's xstrndup, strndup and strnlen...
2020-05-04 06:48:00 +02:00
Akim Demaille
6135fdc152 examples: beware of portability issues with sh's trap
On AIX 7.2, when invoking "exit 77", we actually exit with 127.  The
"cleanup" function, called via trap, received an incorrect exit
status, something described in Autoconf's doc.
Reported by Bruno Haible.
https://lists.gnu.org/archive/html/bug-bison/2020-05/msg00029.html
https://lists.gnu.org/archive/html/bug-bison/2020-05/msg00047.html

* examples/test (skip): New.
* examples/c/bistromathic/bistromathic.test,
* examples/c/reccalc/reccalc.test: Use it, to ensure $? is set to 77
when the trap is called.
2020-05-04 06:48:00 +02:00
Akim Demaille
f1497356e8 tests: beware of portability issues with diff -u
AIX 7.1 supports diff -u, but its output does not match the expected
one.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00049.html

* tests/atlocal.in (DIFF_U_WORKS): New.
* tests/local.at (AT_DIFF_U_CHECK): New.
* tests/existing.at (_AT_TEST_EXISTING_GRAMMAR): Use AT_DIFF_U_CHECK.
2020-05-04 06:48:00 +02:00
Akim Demaille
1429569362 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-05-03 19:52:38 +02:00
Akim Demaille
506c368ab2 version 3.5.93
* NEWS: Record release date.
v3.5.93
2020-05-03 19:32:15 +02:00
Akim Demaille
4f9dc3bdc1 news: update for 3.5.93 2020-05-03 19:32:03 +02:00
Akim Demaille
0d81be2dc7 gnulib: update 2020-05-03 19:32:03 +02:00
Akim Demaille
32f44f4bfb tests: really skip tricky multichar test on Cygwin
In Autotest, anything outside AT_SETUP/AT_CLEANUP is discarded.

* tests/diagnostics.at (AT_TEST): Accept a skip-if test.
Use it to skip on cygwin.
2020-05-03 19:08:16 +02:00
Akim Demaille
38a8287813 bistromathic: beware of portability issues of readline on AIX
Readline may emit escape sequences before the prompt.
Reported by Bruno Haible.
https://lists.gnu.org/r/platform-testers/2020-05/msg00001.html.

* examples/c/bistromathic/bistromathic.test: Trust readline _only_ if
we get what we expect on some reference computation.
2020-05-03 18:10:58 +02:00
Akim Demaille
df752784c2 examples: beware of portability issues with cmp
As someone wrote nearly 20 years ago in Autoconf's documentation,
don't use cmp to compare text files, but diff.
https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=abad4f0576a7dc361e5385e19c7681449103cdb1
Reported by Jannick.

* examples/test: Use diff, not cmp.
2020-05-03 17:53:47 +02:00
Akim Demaille
292409e91e build: fix warnings (shown on IRIX)
Appearing on IRIX with gcc -mabi=n32.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00039.html

* examples/c++/variant-11.yy, examples/c/bistromathic/parse.y: Don't
give chars to isdigit, cast them to unsigned char before.
* src/complain.c: Use c_isdigit.
* src/fixits.c (fixits_run): Avoid casts.
* src/lalr.c (goto_print): Use %zu for a size_t.
2020-05-03 17:37:34 +02:00
Akim Demaille
eea56d70d9 c++: be compatible with the pre-3.6 way to get a symbol's kind
Reported by Pramod Kumbhar.
https://lists.gnu.org/r/bug-bison/2020-05/msg00025.html

* data/skeletons/c++.m4: here.
2020-05-03 17:06:13 +02:00
Akim Demaille
6e2de439e6 bistromathic: beware of portability issues with strndup
Reported by Dagobert Michelsen.
https://lists.gnu.org/r/bug-bison/2020-05/msg00026.html

* examples/c/bistromathic/parse.y (xstrndup): New.
Use it.
2020-05-03 17:06:13 +02:00
Akim Demaille
e33cd4b824 flex: fix incorrect use of Automake conditional
AM_CONDITIONAL does _not_ define a shell variable...
Reported privately by Denis Excoffier.

* configure.ac (LEX_CXX_WORKS): Fix its definition.
2020-05-03 17:04:15 +02:00
Bruno Haible
0669780ff8 package: fix a link error on IRIX
https://lists.gnu.org/r/bug-bison/2020-05/msg00035.html

* src/local.mk (src_bison_LDADD): Mention libbison.a before, not after, the
system libraries.
2020-05-03 16:49:29 +02:00
Akim Demaille
160df220b1 bistromathic: beware of portability of readline
Don't try to build bistromathic if we don't have readline.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00028.html

* configure.ac (ENABLE_BISTROMATHIC): New.
* examples/c/bistromathic/local.mk: Use it.
* examples/c/bistromathic/bistromathic.test: Exit 77 for skip.
2020-05-03 16:38:34 +02:00
Akim Demaille
da5c072a62 tests: beware of portability issues of sh
"foo || bar" does not invoke bar on AIX 7.2 when foo does not exist.
It just dies.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00029.html

* examples/c/reccalc/reccalc.test: Check for seq in a subshell.
2020-05-03 16:38:34 +02:00
Akim Demaille
73ac8ff409 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-05-03 13:07:08 +02:00
Akim Demaille
0e0fb0efc9 version 3.5.92
* NEWS: Record release date.
v3.5.92
2020-05-03 12:48:16 +02:00
Akim Demaille
bb1d776be0 news: update for 3.5.92 2020-05-03 12:47:21 +02:00
Akim Demaille
d7e1abe656 gnulib: update 2020-05-03 12:43:55 +02:00
Akim Demaille
13a1537dba java: demonstrate push parsers
* data/skeletons/lalr1.java (Location): Make it a static class.
(Lexer.yylex, Lexer.getLVal, Lexer.getStartPos, Lexer.getEndPos):
These are not needed in push parsers.
* examples/java/calc/Calc.y: Demonstrate push parsers in the Java.
* doc/bison.texi: Push parsers have been supported for a long time,
remove incorrect statements stating the opposite.
2020-05-03 11:28:36 +02:00
Akim Demaille
ac2ba46053 doc: clarify what a location is
Reported by Arthur Schwarz <aschwarz1309@att.net>
https://lists.gnu.org/r/help-bison/2013-12/msg00009.html

* doc/bison.texi (Location Type): here.
2020-05-03 11:28:36 +02:00
Akim Demaille
2a7a2c1d3a tests: beware of mbswidth portability issues
Shy away from these issues on Cygwin.
Reported Denis Excoffier.
https://lists.gnu.org/r/bug-bison/2020-05/msg00003.html

* tests/diagnostics.at (Tabulations and multibyte characters): Split
in two.
2020-05-03 11:28:36 +02:00
Akim Demaille
c9b5b68c73 examples: beware of intl portability issues
Reported by Horst von Brand.
https://lists.gnu.org/r/bug-bison/2020-04/msg00033.html

* examples/c/bistromathic/Makefile: libintl might not be needed, but
libm probably is.
* examples/c/bistromathic/parse.y: Include locale.h.
2020-05-03 10:32:33 +02:00
Akim Demaille
26aef31552 examples: beware of portability issues with readline
On OpenBSD 6.5, the prompt is repeated, but not the actual command
line...  Don't try to cope with that.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00015.html

* examples/c/bistromathic/bistromathic.test: Skip when readline behave
this way.
2020-05-03 10:32:33 +02:00
Akim Demaille
392f3caef6 examples: beware of the portability of flex --header-file
The option --header was introduced in version 2.5.6.
The option --header-file was introduced in version 2.6.4.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00013.html

So use --header, and do bother with versions that don't support it.

* m4/flex.m4: Check whether flex supports --header.
* configure.ac (FLEX_WORKS, FLEX_CXX_WORKS): Set to false if it doesn't.
* * examples/c/reccalc/local.mk, examples/c/reccalc/Makefile:
Use --header rather than --header-file.
2020-05-03 10:32:32 +02:00
Akim Demaille
ccaa8e29f9 c++: provide backward compatibility on by_type
To write unit tests for their scanners, some users depended on
symbol_type::token():

    Lexer lex("12345");
    symbol_type t = lex.nextToken();
    assert(t.token() == token::INTLIT);
    assert(t.value.as<int>() == 12345);

But symbol_type::token() was removed in Bison 3.5 because it relied on
a conversion table.  So users had to find other patterns, such as

    assert(t.type_get() == by_type(token::INTLIT).type_get());

which relies on several private implementation details.

As part of transitioning from "token type" to "token kind", and making
this a public and documented interface, "by_type" was renamed
"by_kind" and "type_get()" was renamed as "kind()".  The latter had
backward compatibility mechanisms, not the former.

In Bison 3.6 none of this should be used, but rather

    assert(t.kind() == symbol_kind::S_INTLIT);

Reported by Pramod Kumbhar.
https://lists.gnu.org/r/bug-bison/2020-05/msg00012.html

* data/skeletons/c++.m4 (by_type): Make it an alias to by_kind.
2020-05-03 09:20:08 +02:00
Akim Demaille
76c3bccf40 yacc.c: improve formatting of the generated code
* data/skeletons/yacc.c (yy_reduce_print): here.
2020-05-02 10:17:01 +02:00
Akim Demaille
6275137378 doc: java supports push parsers since 3.0 (2013-07-25)
* doc/bison.texi: Clarify this.
2020-05-02 09:29:05 +02:00
Akim Demaille
d0571c846f java: fix coding style
I don't plan to fix everything in one go.  But this was in the way of
the next commit.

* data/skeletons/lalr1.java: Avoid space before parens.
* tests/java.at: Adjust.
2020-05-02 09:27:16 +02:00
Akim Demaille
8c1002e4b7 style: comment changes
* tests/java.at: here.
2020-05-02 09:08:26 +02:00
Akim Demaille
dbd8fd71ba todo: more 2020-05-02 08:18:20 +02:00
Akim Demaille
95bac741c3 style: more documentation about errs
Suggested by Angelo Borsotti.
https://lists.gnu.org/r/bug-bison/2014-02/msg00003.html

* src/state.h: here.
2020-05-02 08:18:20 +02:00