forked from akimd/bison
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNEWS
3519 lines (2456 loc) · 121 KB
/
NEWS
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
1000
GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
** Changes
In conformance with the recommendations of the GraphViz team, if %require
"3.4" (or better) is specified, the option --graph generates a *.gv file
by default, instead of *.dot.
** New features
*** Disabling output
When given -fsyntax-only, the diagnostics are reported, but no output is
generated.
** Documentation
A new example in C shows an simple infix calculator with a hand-written
scanner (examples/c/calc).
A new example in C shows a reentrant parser (capable of recursive calls)
built with Flex and Bison (examples/c/reccalc).
* Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
** Bug fixes
Bison 3.3 failed to generate parsers for grammars with unused nonterminal
symbols.
* Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
** Changes
The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
extensions into errors. It now makes them simple warnings (-Wyacc).
* Noteworthy changes in release 3.3 (2019-01-26) [stable]
A new mailing list was created, Bison Announce. It is low traffic, and is
only about announcing new releases and important messages (e.g., polls
about major decisions to make).
https://lists.gnu.org/mailman/listinfo/bison-announce
** Backward incompatible changes
Support for DJGPP, which has been unmaintained and untested for years, is
removed.
** Deprecated features
A new feature, --update (see below) helps adjusting existing grammars to
deprecations.
*** Deprecated directives
The %error-verbose directive is deprecated in favor of '%define
parse.error verbose' since Bison 3.0, but no warning was issued.
The '%name-prefix "xx"' directive is deprecated in favor of '%define
api.prefix {xx}' since Bison 3.0, but no warning was issued. These
directives are slightly different, you might need to adjust your code.
%name-prefix renames only symbols with external linkage, while api.prefix
also renames types and macros, including YYDEBUG, YYTOKENTYPE,
yytokentype, YYSTYPE, YYLTYPE, etc.
Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix
{xx}' will typically have to update YY_DECL from
#define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc)
to
#define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc)
*** Deprecated %define variable names
The following variables, mostly related to parsers in Java, have been
renamed for consistency. Backward compatibility is ensured, but upgrading
is recommended.
abstract -> api.parser.abstract
annotations -> api.parser.annotations
extends -> api.parser.extends
final -> api.parser.final
implements -> api.parser.implements
parser_class_name -> api.parser.class
public -> api.parser.public
strictfp -> api.parser.strictfp
** New features
*** Generation of fix-its for IDEs/Editors
When given the new option -ffixit (aka -fdiagnostics-parseable-fixits),
bison now generates machine readable editing instructions to fix some
issues. Currently, this is mostly limited to updating deprecated
directives and removing duplicates. For instance:
$ cat foo.y
%error-verbose
%define parser_class_name "Parser"
%define api.parser.class "Parser"
%%
exp:;
See the "fix-it:" lines below:
$ bison -ffixit foo.y
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
%error-verbose
^~~~~~~~~~~~~~
fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose"
foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
%define parser_class_name "Parser"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}"
foo.y:3.1-33: error: %define variable 'api.parser.class' redefined
%define api.parser.class "Parser"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.y:2.1-34: previous definition
%define parser_class_name "Parser"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fix-it:"foo.y":{3:1-3:34}:""
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
This uses the same output format as GCC and Clang.
*** Updating grammar files
Fixes can be applied on the fly. The previous example ends with the
suggestion to re-run bison with the option -u/--update, which results in a
cleaner grammar file.
$ bison --update foo.y
[...]
bison: file 'foo.y' was updated (backup: 'foo.y~')
$ cat foo.y
%define parse.error verbose
%define api.parser.class {Parser}
%%
exp:;
*** Bison is now relocatable
If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
A relocatable program can be moved or copied to a different location on
the file system. It can also be used through mount points for network
sharing. It is possible to make symbolic links to the installed and moved
programs, and invoke them through the symbolic link.
*** %expect and %expect-rr modifiers on individual rules
One can now 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.
This feature needs user feedback, and might evolve in the future.
*** C++: Actual token constructors
When variants and token constructors are enabled, in addition to the
type-safe named token constructors (make_ID, make_INT, etc.), we now
generate genuine constructors for symbol_type.
For instance with these declarations
%token ':'
<std::string> ID
<int> INT;
you may use these constructors:
symbol_type (int token, const std::string&);
symbol_type (int token, const int&);
symbol_type (int token);
Correct matching between token types and value types is checked via
'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named
constructors are preferable, as they offer better type safety (for
instance 'make_ID (42)' would not even compile), but symbol_type
constructors may help when token types are discovered at run-time, e.g.,
[a-z]+ {
if (auto i = lookup_keyword (yytext))
return yy::parser::symbol_type (i);
else
return yy::parser::make_ID (yytext);
}
*** C++: Variadic emplace
If your application requires C++11 and you don't use symbol constructors,
you may now use a variadic emplace for semantic values:
%define api.value.type variant
%token <std::pair<int, int>> PAIR
in your scanner:
int yylex (parser::semantic_type *lvalp)
{
lvalp->emplace <std::pair<int, int>> (1, 2);
return parser::token::PAIR;
}
*** C++: Syntax error exceptions in GLR
The glr.cc skeleton now supports syntax_error exceptions thrown from user
actions, or from the scanner.
*** More POSIX Yacc compatibility warnings
More Bison specific directives are now reported with -y or -Wyacc. This
change was ready since the release of Bison 3.0 in September 2015. It was
delayed because Autoconf used to define YACC as `bison -y`, which resulted
in numerous warnings for Bison users that use the GNU Build System.
If you still experience that problem, either redefine YACC as `bison -o
y.tab.c`, or pass -Wno-yacc to Bison.
*** The tables yyrhs and yyphrs are back
Because no Bison skeleton uses them, these tables were removed (no longer
passed to the skeletons, not even computed) in 2008. However, some users
have expressed interest in being able to use them in their own skeletons.
** Bug fixes
*** Incorrect number of reduce-reduce conflicts
On a grammar such as
exp: "num" | "num" | "num"
bison used to report a single RR conflict, instead of two. This is now
fixed. This was the oldest (known) bug in Bison: it was there when Bison
was entered in the RCS version control system, in December 1987.
Some grammar files might have to adjust their %expect-rr.
*** Parser directives that were not careful enough
Passing invalid arguments to %nterm, for instance character literals, used
to result in unclear error messages.
** Documentation
The examples/ directory (installed in .../share/doc/bison/examples) has
been restructured per language for clarity. The examples come with a
README and a Makefile. Not only can they be used to toy with Bison, they
can also be starting points for your own grammars.
There is now a Java example, and a simple example in C based on Flex and
Bison (examples/c/lexcalc/).
** Changes
*** Parsers in C++
They now use noexcept and constexpr. Please, report missing annotations.
*** Symbol Declarations
The syntax of the variation directives to declare symbols was overhauled
for more consistency, and also better POSIX Yacc compliance (which, for
instance, allows "%type" without actually providing a type). The %nterm
directive, supported by Bison since its inception, is now documented and
officially supported.
The syntax is now as follows:
%token TAG? ( ID NUMBER? STRING? )+ ( TAG ( ID NUMBER? STRING? )+ )*
%left TAG? ( ID NUMBER? )+ ( TAG ( ID NUMBER? )+ )*
%type TAG? ( ID | CHAR | STRING )+ ( TAG ( ID | CHAR | STRING )+ )*
%nterm TAG? ID+ ( TAG ID+ )*
where TAG denotes a type tag such as ‘<ival>’, ID denotes an identifier
such as ‘NUM’, NUMBER a decimal or hexadecimal integer such as ‘300’ or
‘0x12d’, CHAR a character literal such as ‘'+'’, and STRING a string
literal such as ‘"number"’. The post-fix quantifiers are ‘?’ (zero or
one), ‘*’ (zero or more) and ‘+’ (one or more).
* Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
** Bug fixes
Fix the move constructor of symbol_type.
Always provide a copy constructor for symbol_type, even in modern C++.
* Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
** Bug fixes
Properly support token constructors in C++ with types that include commas
(e.g., std::pair<int, int>). A regression introduced in Bison 3.2.
* Noteworthy changes in release 3.2.2 (2018-11-21) [stable]
** Bug fixes
C++ portability issues.
* Noteworthy changes in release 3.2.1 (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 has 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 has 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]
** WARNING: Future backward-incompatibilities!
Like other GNU packages, Bison will start using some of the C99 features
for its own code, especially the definition of variables after statements.
The generated C parsers still aim at C90.
** Backward incompatible changes
*** Obsolete features
Support for YYFAIL is removed (deprecated in Bison 2.4.2): use YYERROR.
Support for yystype and yyltype is removed (deprecated in Bison 1.875):
use YYSTYPE and YYLTYPE.
Support for YYLEX_PARAM and YYPARSE_PARAM is removed (deprecated in Bison
1.875): use %lex-param, %parse-param, or %param.
Missing semicolons at the end of actions are no longer added (as announced
in the release 2.5).
*** Use of YACC='bison -y'
TL;DR: With Autoconf <= 2.69, pass -Wno-yacc to (AM_)YFLAGS if you use
Bison extensions.
Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
'y.tab.h' and 'y.output') to be generated from 'foo.y'.
To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
implementation of Yacc, was using Bison as 'bison -y'. While it does
ensure compatible output file names, it also enables warnings for
incompatibilities with POSIX Yacc. In other words, 'bison -y' triggers
warnings for Bison extensions.
Autoconf 2.70+ fixes this incompatibility by using YACC='bison -o y.tab.c'
(which also generates 'y.tab.h' and 'y.output' when needed).
Alternatively, disable Yacc warnings by passing '-Wno-yacc' to your Yacc
flags (YFLAGS, or AM_YFLAGS with Automake).
** Bug fixes
*** The epilogue is no longer affected by internal #defines (glr.c)
The glr.c skeleton uses defines such as #define yylval (yystackp->yyval) in
generated code. These weren't properly undefined before the inclusion of
the user epilogue, so functions such as the following were butchered by the
preprocessor expansion:
int yylex (YYSTYPE *yylval);
This is fixed: yylval, yynerrs, yychar, and yylloc are now valid
identifiers for user-provided variables.
*** stdio.h is no longer needed when locations are enabled (yacc.c)
Changes in Bison 2.7 introduced a dependency on FILE and fprintf when
locations are enabled. This is fixed.
*** Warnings about useless %pure-parser/%define api.pure are restored
** Diagnostics reported by Bison
Most of these features were contributed by Théophile Ranquet and Victor
Santet.
*** Carets
Version 2.7 introduced caret errors, for a prettier output. These are now
activated by default. The old format can still be used by invoking Bison
with -fno-caret (or -fnone).
Some error messages that reproduced excerpts of the grammar are now using
the caret information only. For instance on:
%%
exp: 'a' | 'a';
Bison 2.7 reports:
in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
in.y:2.12-14: warning: rule useless in parser due to conflicts: exp: 'a' [-Wother]
Now bison reports:
in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
exp: 'a' | 'a';
^^^
and "bison -fno-caret" reports:
in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
*** Enhancements of the -Werror option
The -Werror=CATEGORY option is now recognized, and will treat specified
warnings as errors. The warnings need not have been explicitly activated
using the -W option, this is similar to what GCC 4.7 does.
For example, given the following command line, Bison will treat both
warnings related to POSIX Yacc incompatibilities and S/R conflicts as
errors (and only those):
$ bison -Werror=yacc,error=conflicts-sr input.y
If no categories are specified, -Werror will make all active warnings into
errors. For example, the following line does the same the previous example:
$ bison -Werror -Wnone -Wyacc -Wconflicts-sr input.y
(By default -Wconflicts-sr,conflicts-rr,deprecated,other is enabled.)
Note that the categories in this -Werror option may not be prefixed with
"no-". However, -Wno-error[=CATEGORY] is valid.
Note that -y enables -Werror=yacc. Therefore it is now possible to require
Yacc-like behavior (e.g., always generate y.tab.c), but to report
incompatibilities as warnings: "-y -Wno-error=yacc".
*** The display of warnings is now richer
The option that controls a given warning is now displayed:
foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
In the case of warnings treated as errors, the prefix is changed from
"warning: " to "error: ", and the suffix is displayed, in a manner similar
to GCC, as [-Werror=CATEGORY].
For instance, where the previous version of Bison would report (and exit
with failure):
bison: warnings being treated as errors
input.y:1.1: warning: stray ',' treated as white space
it now reports:
input.y:1.1: error: stray ',' treated as white space [-Werror=other]
*** Deprecated constructs
The new 'deprecated' warning category flags obsolete constructs whose
support will be discontinued. It is enabled by default. These warnings
used to be reported as 'other' warnings.
*** Useless semantic types
Bison now warns about useless (uninhabited) semantic types. Since
semantic types are not declared to Bison (they are defined in the opaque
%union structure), it is %printer/%destructor directives about useless
types that trigger the warning:
%token <type1> term
%type <type2> nterm