bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: Requiring the ending `;'


From: Akim Demaille
Subject: RFC: Requiring the ending `;'
Date: 03 Mar 2002 16:31:05 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

You may know that the Bison grammar (that of the grammar files) is not
LALR(1) because it's LR(2).  This is due to the optionality of the
ending `;': the parser has to read the `:' after each identifier to
learn whether the latter is an additional symbol of the current rule,
or the LHS of the next rule.

Since I'm willing to have a more flexible grammar parser (many new
interesting features require additional Bison directives), I am highly
tempted by making the `;' mandatory.  As far as I could see, no
significant grammar exhibits lacks of `;'.  The Bison documentation,
while it never says `;' is mandatory, does not document it as
optional, nor exhibits samples where it is not used.

All the presentations I know of Yacc do use this terminator, including
Johnson's paper.  Nevertheless, he acknowledges the problem of the non
LR(1) grammar of Yacc, explains why, and hints at the implementation
of a workaround, which is a form of not condemning such grammars.

This workaround is yet ported to Bison grammar (in a word: instead of
returning ID COLON, recognize this sequence, and return ID_COLON in
addition to ID and to COLON).  But this is quite awkward, and, unless
you really fight with Lex, won't work for

my_lhs /* some comment. */ :

Again, I can workaround this, but puke.

So, I am really willing to (i) make this `;' encouraged by having 1.34
warn about its absence, and (ii), in the future, move 1.5x to a Bison
grammar of grammars without kludges.

Thus, I would like to

- know whether POSIX says something,
- have the opinion of the people on this list
  (please, don't answer if you simply agree.  Please, if you don't
  agree, provide an objective rationale)
- have people use the following patch to see the impact of the warning
  on your grammars.  This patch is relative to 1.5x, but should apply
  directly to 1.3x, maybe at the exception of the test suite patch,
  which, of course, is a minor detail.

Thanks!

Attachment: 25-ending-semicolon.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]