Commit Graph

5972 Commits

Author SHA1 Message Date
Akim Demaille
647bf48797 gnulib: update ignores 2018-11-26 07:03:55 +01:00
Akim Demaille
bcecfbafab gnulib: update to use its bitsets
Bison's bitset were moved to gnulib.

* lib/abitset.c, lib/abitset.h, lib/bbitset.h, lib/bitset.c,
* lib/bitset.h, lib/ebitset.c, lib/ebitset.h, lib/lbitset.c,
* lib/bitset_stats.c, lib/bitset_stats.h, lib/bitsetv-print.c,
* lib/bitsetv-print.h, lib/bitsetv.c, lib/bitsetv.h,
* lib/lbitset.h, lib/vbitset.c, lib/vbitset.h:
Remove.

* gnulib: Update.
* bootstrap.conf, lib/local.mk: Adjust.
2018-11-26 06:33:45 +01:00
Akim Demaille
deb2fc1dfc gnulib: use conditional dependencies
* bootstrap.conf: here.
2018-11-25 19:57:08 +01:00
Akim Demaille
3a203e2e56 CI: run on xenial
Xenial (Ubuntu 16.04) is finally available on Travis.  Let's use it.

Among the changes:

- Automake 1.14.1 -> 1.15.0
- Doxygen  1.8.6  -> 1.8.11
- Flex     2.5.35 -> 2.6.0, with plenty of new compiler warnings
- Gettext  0.18.3 -> 0.19.7
- Graphviz 2.36.0 -> 2.38.0
- Texinfo  5.2    -> 6.1

* .travis.yml: here.
2018-11-25 13:22:54 +01:00
Akim Demaille
709c87bb41 CI: we don't need git show
* .travis.yml: Don't run it.
2018-11-25 11:34:10 +01:00
Akim Demaille
9ffed56cd9 regen 2018-11-25 11:27:08 +01:00
Akim Demaille
cc050fd321 warning: avoid warnings about unreachable code
Reported by Uxio Prego.
https://lists.gnu.org/archive/html/help-bison/2018-11/msg00031.html

We also need to move the unreachable 'goto' to a reachable place,
otherwise clang complains about the code being unreachable anyway.
See also https://bugs.llvm.org/show_bug.cgi?id=39736.

Interestingly, we don't have to apply that trick to
`#define YYCDEBUG if (false) std::cerr`, clang does not warn when the
code comes from macro expansion.

* configure.ac: Use -Wunreachable-code when supported.
* data/lalr1.cc, data/yacc.c: Pacify clang's warning about `if (0)`
by using a macro.
Another possibility was to move this statement to a reachable place.
* tests/actions.at, tests/c++.at: Avoid generating unreachable code.
2018-11-25 11:22:31 +01:00
Akim Demaille
660811a6c5 yacc.c: avoid generating dead code
We should probably introduce some struct and functions to deal with
stack management, rather than open coding it.  yyparse would be much
nicer to read, and a better model for possible other skeletons.

* data/yacc.c (yyparse::yysetstate): Avoid generating code when
neither yyoverflow nor YYSTACK_RELOCATE is defined.
2018-11-24 13:26:27 +01:00
Akim Demaille
7ded5bb764 %expect-rr: tune the number of conflicts per rule
Currently on a grammar such as

    exp : a '1' | a '2' | a '3' | b '1' | b '2' | b '3'
    a:
    b:

we count only one rr-conflict on the `b:` rule, i.e., we expect:

    b: %expect-rr 1

although there are 3 conflicts in total.  That's because in the
conflicted state we count only a single conflict, not three (one for
each of the lookaheads: '1', '2', '3').

    State 0

        0 $accept: . exp $end
        1 exp: . a '1'
        2    | . a '2'
        3    | . a '3'
        4    | . b '1'
        5    | . b '2'
        6    | . b '3'
        7 a: . %empty  ['1', '2', '3']
        8 b: . %empty  ['1', '2', '3']

        '1'       reduce using rule 7 (a)
        '1'       [reduce using rule 8 (b)]
        '2'       reduce using rule 7 (a)
        '2'       [reduce using rule 8 (b)]
        '3'       reduce using rule 7 (a)
        '3'       [reduce using rule 8 (b)]
        $default  reduce using rule 7 (a)

        exp  go to state 1
        a    go to state 2
        b    go to state 3

See https://lists.gnu.org/archive/html/bison-patches/2013-02/msg00106.html.

* src/conflicts.c (rule_has_state_rr_conflicts): Rename as...
(count_rule_state_sr_conflicts): this.
DWIM.
(count_rule_rr_conflicts): Adjust.
* tests/conflicts.at (%expect-rr in grammar rules)
(%expect-rr too much in grammar rules)
(%expect-rr not enough in grammar rules): New.
2018-11-22 08:34:10 +01:00
Akim Demaille
ad0b4661d1 %expect-rr: fix the computation of the overall number of conflicts
On a grammar such as

   exp: "num" | "num" | "num"

we currently report only one RR conflict, instead of two.

This bug is present since the origins of Bison

    commit 08089d5d35
    Author: David MacKenzie <djm@djmnet.org>
    Date:   Tue Apr 20 05:42:52 1993 +0000

       Initial revision

and was preserved in

    commit 676385e29c
    Author: Paul Hilfinger <Hilfinger@CS.Berkeley.EDU>
    Date:   Fri Jun 28 02:26:44 2002 +0000

       Initial check-in introducing experimental GLR parsing.  See entry in
       ChangeLog dated 2002-06-27 from Paul Hilfinger for details.

See
https://lists.gnu.org/archive/html/bison-patches/2018-11/msg00011.html

* src/conflicts.h, src/conflicts.c (count_state_rr_conflicts)
(count_rr_conflicts): Use only the correct count of conflicts.
* tests/glr-regression.at: Fix expectations.
2018-11-22 08:34:07 +01:00
Akim Demaille
260ae5481c tests: generate *.output files
* tests/glr-regression.at: here.
2018-11-21 22:10:35 +01:00
Akim Demaille
e51fd547ca %expect: tune the number of conflicts per rule
Currently on a grammar such as

    exp: "number" | exp "+" exp | exp "*" exp

we count only one sr-conflict for both binary rules, i.e., we expect:

    exp: "number" | exp "+" exp  %expect 1 | exp "*" exp  %expect 1

although there are 4 conflicts in total.  That's because in the states
in conflict, for instance that for the "+" rule:

    State 6

        2 exp: exp . "+" exp
        2    | exp "+" exp .  [$end, "+", "*"]
        3    | exp . "*" exp

        "+"  shift, and go to state 4
        "*"  shift, and go to state 5

        "+"       [reduce using rule 2 (exp)]
        "*"       [reduce using rule 2 (exp)]
        $default  reduce using rule 2 (exp)

we count only a single conflict, although there are two (one on "+"
and another with "*").

See https://lists.gnu.org/archive/html/bison-patches/2013-02/msg00106.html.

* src/conflicts.c (rule_has_state_sr_conflicts): Rename as...
(count_rule_state_sr_conflicts): this.
DWIM.
(count_rule_sr_conflicts): Adjust.
* tests/conflicts.at (%expect in grammar rules): New.
2018-11-21 22:10:35 +01:00
Akim Demaille
4ebebcc438 regen 2018-11-21 22:10:35 +01:00
Akim Demaille
2b2556b41c style: reduce scopes
* src/conflicts.c, src/reader.c: Minor style changes.
2018-11-21 22:08:47 +01:00
Paul Hilfinger
b34b12c4f9 allow %expect and %expect-rr modifiers on individual rules
This change allows one to document (and check) which rules participate
in shift/reduce and reduce/reduce conflicts.  This is particularly
important GLR parsers, where conflicts are a normal occurrence.  For
example,

    %glr-parser
    %expect 1
    %%

    ...

    argument_list:
      arguments %expect 1
    | arguments ','
    | %empty
    ;

    arguments:
      expression
    | argument_list ',' expression
    ;

    ...

Looking at the output from -v, one can see that the shift-reduce
conflict here is due to the fact that the parser does not know whether
to reduce arguments to argument_list until it sees the token AFTER the
following ','.  By marking the rule with %expect 1 (because there is a
conflict in one state), we document the source of the 1 overall shift-
reduce conflict.

In GLR parsers, we can use %expect-rr in a rule for reduce/reduce
conflicts.  In this case, we mark each of the conflicting rules.  For
example,

    %glr-parser
    %expect-rr 1

    %%

    stmt:
      target_list '=' expr ';'
    | expr_list ';'
    ;

    target_list:
      target
    | target ',' target_list
    ;

    target:
      ID %expect-rr 1
    ;

    expr_list:
      expr
    | expr ',' expr_list
    ;

    expr:
      ID %expect-rr 1
    | ...
    ;

In a statement such as

    x, y = 3, 4;

the parser must reduce x to a target or an expr, but does not know
which until it sees the '='.  So we notate the two possible reductions
to indicate that each conflicts in one rule.

See https://lists.gnu.org/archive/html/bison-patches/2013-02/msg00105.html.

* doc/bison.texi (Suppressing Conflict Warnings): Document %expect,
%expect-rr in grammar rules.
* src/conflicts.c (count_state_rr_conflicts): Adjust comment.
(rule_has_state_sr_conflicts): New static function.
(count_rule_sr_conflicts): New static function.
(rule_nast_state_rr_conflicts): New static function.
(count_rule_rr_conflicts): New static function.
(rule_conflicts_print): New static function.
(conflicts_print): Also use rule_conflicts_print to report on individual
rules.
* src/gram.h (struct rule): Add new fields expected_sr_conflicts,
expected_rr_conflicts.
* src/reader.c (grammar_midrule_action): Transfer expected_sr_conflicts,
expected_rr_conflicts to new rule, and turn off in current_rule.
(grammar_current_rule_expect_sr): New function.
(grammar_current_rule_expect_rr): New function.
(packgram): Transfer expected_sr_conflicts, expected_rr_conflicts
to new rule.
* src/reader.h (grammar_current_rule_expect_sr): New function.
(grammar_current_rule_expect_rr): New function.
* src/symlist.c (symbol_list_sym_new): Initialize expected_sr_conflicts,
expected_rr_conflicts.
* src/symlist.h (struct symbol_list): Add new fields expected_sr_conflicts,
expected_rr_conflicts.
* tests/conflicts.at: Add tests "%expect in grammar rule not enough",
"%expect in grammar rule right.", "%expect in grammar rule too much."
2018-11-21 22:08:47 +01:00
Akim Demaille
487a2a9eca NEWS: update 2018-11-21 22:05:45 +01:00
Akim Demaille
559114c3cb gnulib: update 2018-11-21 22:03:50 +01:00
Akim Demaille
dee62718ae remove ancient lint directives
* data/c++.m4, data/yacc.c: Remove surprising remains of lint
directives.
2018-11-21 08:59:38 +01:00
Jannick
bee10f5774 doc: calc++: remove ancient fix for flex
* doc/bison.texi (Calc++ Scanner): Remove fix for Flex 2.5.31-2.5.33.
2018-11-21 08:58:35 +01:00
Jannick
7795db64d1 doc: calc++: ignore \r in the scaner
* doc/bison.texi (Calc++ Scanner): Ignore \r.
2018-11-21 08:39:22 +01:00
Akim Demaille
6bc54a934e style: harmonize the labels of yyparse
* data/glr.c, data/lalr1.cc, data/yacc.c: Fix indentation and
other formatting issues.
2018-11-20 20:52:58 +01:00
Akim Demaille
ebb92c0545 regen 2018-11-20 20:04:06 +01:00
Akim Demaille
e0de1020ea style: avoid lengthy actions
We also lack a consistent naming for directive implementations.
`directive_skeleton` is too long, `percent_skeleton` is not very nice
looking, `process_skeleton` looks ambiguous, `do_skeleton` is somewhat
ambiguous too, but seems a better track.

* src/parse-gram.y (version_check): Rename as...
(do_require): this.
(do_skeleton): New.
Use it.
2018-11-20 20:03:01 +01:00
Akim Demaille
4e510c69b1 c++: using macros around user types breaks when they include comma
We may generate code such as

    basic_symbol (typename Base::kind_type t, YY_RVREF (std::pair<int,int>) v);

which, of course, breaks, because YY_RVREF sees two arguments.  Let's
not play tricks with _VA_ARGS__, I'm unsure about it portability.
Anyway, I plan to change more things in this area.

Reported by Sébastien Villemot.
http://lists.gnu.org/archive/html/bug-bison/2018-11/msg00014.html

* data/variant.hh (b4_basic_symbol_constructor_declare)
(b4_basic_symbol_constructor_define): Don't use macro on user types.
* tests/types.at: Check that we support pairs.
2018-11-20 20:01:50 +01:00
Akim Demaille
b72d654fa2 README: update 2018-11-16 17:37:47 +01:00
Akim Demaille
77086ab57d tests: remove duplicate definition
Probably imported by 6d58c63202, a merge
commit.

* tests/atlocal.in (POSIXLY_CORRECT_IS_EXPORTED): Define it once.
2018-11-16 17:37:47 +01:00
Akim Demaille
8474dbc09e glr.c: fix use of _Noreturn
In C++, [[noreturn]] must not be between "static" and the rest of the
function signature, it must precede it.  C's _Noreturn does not seem
to have such a constraint, but it is therefore compatible with the C++
constraint.  Since we #define _Noreturn as [[noreturn]] is modern C++,
be sure to push the _Noreturn first.

Unfortunately this was not caught by the test suite, because it always
loads config.h first, and config.h contains another definition of
_Noreturn that does not use [[noreturn]], and hides ours.  That's
probably a sign we should avoid always loading config.h.

* data/glr.c (yyFail, yyMemoryExhausted): here.
2018-11-16 17:37:47 +01:00
Akim Demaille
8eb1d79333 tests: run the api.value.type tests for all C++ standards
* tests/local.at (AT_LANG_FOR_EACH_STD): New.
(AT_REQUIRE_CXX_VERSION): Rename as...
(AT_REQUIRE_CXX_STD): this.
Accept an argument for what to do when the requirement is not met.
* tests/types.at (api.value.type): Check all the C++ stds.
2018-11-16 17:37:47 +01:00
Akim Demaille
7bd7644702 CI: split the ASAN job in two
The following commit introduce even more compilations/runs than
before, and with ASAN on, we go beyond to 50min credit from Travis.

* .travis.yml (Clang 7 libc++ and ASAN): Split in two.
2018-11-16 17:36:28 +01:00
Akim Demaille
037eff335b c++: use YY_CPLUSPLUS
* data/c++.m4: here.
2018-11-14 21:25:29 +01:00
Akim Demaille
7adeb80765 c++: factor the handling of __cplusplus into YY_CPLUSPLUS
* data/c++.m4 (b4_cxx_portability): Define it.
Use it.
* data/lalr1.cc, data/variant.hh: Use it.
2018-11-13 07:46:08 +01:00
Akim Demaille
a52723e3e8 style: formatting changes
* src/scan-gram.l: here.
2018-11-13 07:46:08 +01:00
Akim Demaille
e4fd17bffa tests: clarify some magic constant
* tests/c++.at (C++ Variant-based Symbols Unit Tests): here.
2018-11-13 07:46:08 +01:00
Akim Demaille
8ff6ff3ab0 examples: remove useless includes
* examples/c++/variant-11.yy, examples/c++/variant.yy: here.
Fix warning when storing a long into an int.
2018-11-13 06:53:21 +01:00
Akim Demaille
868ea55b7c tests: compile the C++ examples with warnings
* examples/c++/local.mk: Pass $(WARN_CXXFLAGS_TEST).
2018-11-12 18:20:21 +01:00
Akim Demaille
4810ed8107 regen 2018-11-12 07:41:46 +01:00
Akim Demaille
35b8e0e947 parser: deprecate %error-verbose
It is unfortunate that %error_verbose was properly diagnosed as
obsoleted by "%define parse.error verbose", but %error-verbose was
not.

* src/parse-gram.y (%error-verbose): Remove support.
* src/scan-gram.l: Do it here instead, with a warning.
* tests/input.at (Deprecated directives): Check it.
2018-11-12 07:41:46 +01:00
Akim Demaille
be7c620d65 tests: migrate from %error-verbose to %define parse.error verbose
* tests/actions.at, tests/c++.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/regression.at, tests/skeletons.at,
* tests/torture.at:
Here.
2018-11-12 07:28:23 +01:00
Akim Demaille
7928c3e6fb parser: deprecate %nterm
It has several weaknesses.
Reported by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html

* src/scan-gram.l: here.
2018-11-12 07:28:20 +01:00
Akim Demaille
8d454b843c tests: fix syncline tests
These tests are skipped with GCC:

    "\"".c:1:5: error: function declaration isn't a prototype [-Werror=strict-prototypes]
     int main() { return 0; }
         ^~~~

* tests/synclines.at: Stop writing C++ in C.
* tests/local.at: Formatting changes.
2018-11-12 07:10:04 +01:00
Akim Demaille
7823c65ee9 NEWS: expected features of Bison 3.3 2018-11-11 08:57:55 +01:00
Akim Demaille
e4ee138f64 yacc: reduce scope in push mode
* data/yacc.c (yypull_parse): Here.
2018-11-11 08:57:55 +01:00
Akim Demaille
7d1b1133d0 style: comment changes
* data/c++.m4, data/glr.c, data/lalr1.java, data/yacc.c
(yytranslate, YYTRANSLATE): Harmonize comments.
2018-11-11 07:59:55 +01:00
Akim Demaille
2deb687446 c++: simplify a default construction
* data/lalr1.cc (yytnamerr_): here.
2018-11-10 17:03:36 +01:00
Akim Demaille
3d601616da regen 2018-11-10 17:03:36 +01:00
Akim Demaille
bda2bed459 reader: no longer accept %define variable names in quotes
It was never documented.

* src/parse-gram.y (variable): Here.
2018-11-10 17:02:50 +01:00
Akim Demaille
3ae81aa338 dogfooding: use api.value.type union
* src/parse-gram.y (api.value.type): Set to union.
Replace occurrences of %union with explicit %types.
* src/scan-gram.l: Adjust yylval's field names.
(RETURN_VALUE): No longer needs the Field argument.
Use it more.
2018-11-10 17:02:50 +01:00
Akim Demaille
c239e53bab djgpp: remove
Support for DJGPP was announced to be removed in the NEWS of Bison
3.1 (2018-08-27) unless someone expressed interest.  There was no answer.

* djgpp: Remove.
* NEWS, Makefile.am, cfg.mk, po/POTFILES.in: Adjust.
2018-11-10 17:02:50 +01:00
Akim Demaille
eee37354b5 scanner: simplify use of gettext
* src/scan-gram.l (unexpected_end): Leave the actual call to gettext
to the caller.
2018-11-10 17:02:50 +01:00
Akim Demaille
be737c3dd6 style: clean up the scanner and parser
* src/scan-gram.l: Formatting changes.
Add "missing" assertion for symmetry.
* src/parse-gram.y: Formatting changes.
2018-11-10 17:02:50 +01:00