Reputation: 11377
I want to write a YACC grammar which conforms to POSIX YACC. I have tried to use the Bison options -y
and -Wyacc
, however, the following test program which contains the Bison specific directive %code
compiles with no warnings:
%code {}
%%
dummy:;
Any clues?
Upvotes: 1
Views: 2587
Reputation: 8759
Thomas Dickey's reading of the Bison documentation is incorrect.
Bison's documentation disclaims the notion that it complies with POSIX
is just false, and the quoted paragraph perfectly stated that. It even stated that problems should be reported as bugs.
However, that part of the documentation could definitely use some improvement. It was written this way because some people used to ask whether there were "certificates of compliance", which does not exist. It comes from older documentation.
Before
Is Bison Y2K compliant?
If you're looking for a guarantee or certification, I can't
provide it. With a little thought you can answer this one for
yourself, though. (Hint: does a parser generator rely on the
date or time for anything?) If you're still confused, see
http://www.gnu.org/software/year2000.html for more information.
After
Is Bison secure? Does it conform to POSIX?
If you're looking for a guarantee or certification, we don't
provide it. However, Bison is intended to be a reliable program
that conforms to the POSIX specification for Yacc. If you run
into problems, please send us a bug report.
In the past there was little interest from users in the accuracy of the option -Wyacc
. In fact, this very question on StackOverflow was not asked on the Bison bug report list.
However, since then -Wyacc
is more complete, and in particular the case at hand is handled.
$ bison -Wyacc q.y
q.y:1.1-5: warning: POSIX Yacc does not support %code [-Wyacc]
1 | %code {}
| ^~~~~
Upvotes: 1
Reputation: 54465
Bison's documentation disclaims the notion that it complies with POSIX:
11.6 Secure? Conform?
Is Bison secure? Does it conform to POSIX?
If you’re looking for a guarantee or certification, we don’t provide it. However, Bison is intended to be a reliable program that conforms to the POSIX specification for Yacc. If you run into problems, please send us a bug report.
While it does have the -Wyacc
option, that does not cover everything. As noted a while back (in 2003):
Bison has a Yacc compatibility mode which is supposed to be POSIX compliant, but that is all. Things that go beyond POSIX are extras.
If you read the source code, look for the symbol Wyacc
. It is used only in a few places, this is the only message emitted:
Upvotes: 0