bison-patches
[Top][All Lists]
Advanced

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

Re: ending ;


From: Paul Eggert
Subject: Re: ending ;
Date: 14 May 2003 12:43:34 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

On 28 Mar 2003 Akim Demaille <address@hidden> writes:

> So as far as %directives are concerned, I will struggle even more than
> in the case of rules for which I would now agree provided a warning is
> issued.

But warnings can cause their own problems, as we've discovered from
our autoconf experiences.  I'm not sure I see the need for a warning
by default, unless we can convince POSIX to require a semicolon in a
future version.  (It would be OK to add an option to Bison to generate
style-oriented warnings, though.)

I just reread the POSIX grammar again, and you'll love this: it allows
one or more ";" just before "|".  We should allow this as well.  (Yacc
already does.)

> | It's certainly not a POSIX issue, and as far as I know no real
> | grammars use this feature, so I won't insist strongly on this part of
> | the change. 
> 
> Good :)

OK, I installed this patch so that ";" is required after in-grammar
directives, and also so that ";" is allowed just before "|".

2003-05-14  Paul Eggert  <address@hidden>

        * src/parse-gram.y (rules_or_grammar_declaration): Require a
        semicolon after a grammar declaration, in the interest of possible
        future changes to the Bison input language.
        Do not allow a stray semicolon at the start of the grammar.
        (rhses.1): Allow one or more semicolons after any rule, including
        just before "|" as required by POSIX.
        * tests/input.at (Torturing the Scanner): Add tests for ";|" in a
        grammar.

--- src/parse-gram.y    29 Apr 2003 12:57:36 -0000      1.40
+++ src/parse-gram.y    14 May 2003 19:26:16 -0000      1.41
@@ -332,7 +332,7 @@ grammar:
    body of the grammar.  */
 rules_or_grammar_declaration:
   rules
-| grammar_declaration
+| grammar_declaration ";"
     {
       if (yacc_flag)
        complain_at (@$, _("POSIX forbids declarations in the grammar"));
@@ -341,7 +341,6 @@ rules_or_grammar_declaration:
     {
       yyerrok;
     }
-| ";"
 ;
 
 rules:
@@ -351,6 +350,7 @@ rules:
 rhses.1:
   rhs                { grammar_rule_end (@1); }
 | rhses.1 "|" rhs    { grammar_rule_end (@3); }
+| rhses.1 ";"
 ;
 
 rhs:
--- tests/input.at      13 Mar 2003 07:05:44 -0000      1.26
+++ tests/input.at      14 May 2003 19:26:52 -0000      1.27
@@ -1,4 +1,4 @@
-# Checking the output filenames.                    -*- Autotest -*-
+# Checking the Bison scanner.                    -*- Autotest -*-
 # Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -171,7 +171,7 @@ static int yylex (void);
 
 %%
 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 1.  */
-exp: '@<:@' '\1' two '$' '@' '{' oline output
+exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
   {
     /* Exercise quotes in braces.  */
     char tmp[] = "@<:@%c@:>@,\n";
@@ -181,6 +181,7 @@ exp: '@<:@' '\1' two '$' '@' '{' oline o
 
 two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
 oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
+output.or.oline.opt: ;|oline;;|output;;;
 output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
 %%
 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 2.  */




reply via email to

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