[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: symbol declarations after rules
From: |
Joel E. Denny |
Subject: |
Re: symbol declarations after rules |
Date: |
Sun, 25 Jun 2006 02:59:58 -0400 (EDT) |
On Sat, 24 Jun 2006, Joel E. Denny wrote:
> On Thu, 22 Jun 2006, Joel E. Denny wrote:
>
> > %union {
> > int val;
> > }
> > %%
> > start: 'a' { } ;
> > %type <val> 'a';
> > %destructor { } 'a';
> > %printer { } 'a';
> > %%
> >
> > [...]
> >
> > By the way, Bison 2.3 has no problem with the above. Bison built from the
> > current CVS sources does this:
> >
> > tmp.y: warning: 1 useless nonterminal and 1 useless rule
> > tmp.y:5.12-15: warning: useless nonterminal: @1
> > tmp.y:5.12-15: warning: useless rule: @1: /* empty */
> > *** glibc detected *** double free or corruption (out): 0x0808d990 ***
> > Aborted
>
> I committed the following to fix this.
I cleaned it up a little.
Joel
Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1513
diff -p -u -r1.1513 ChangeLog
--- ChangeLog 24 Jun 2006 06:51:27 -0000 1.1513
+++ ChangeLog 25 Jun 2006 06:54:33 -0000
@@ -1,3 +1,13 @@
+2006-06-25 Joel E. Denny <address@hidden>
+
+ Clean up yesterday's patch.
+ * parse-gram.y (rhs): Move grammar_midrule_action invocation from here
+ to...
+ * src/reader.c (grammar_current_rule_action_append): ... here for
+ consistency with grammar_current_rule_symbol_append.
+ * tests/regression.at (Braced code in declaration in rules section):
+ Make yyerror and yylex static as usual.
+
2006-06-24 Joel E. Denny <address@hidden>
Fix bug that mistakes braced code in a declaration in the rules section
Index: src/parse-gram.y
===================================================================
RCS file: /sources/bison/bison/src/parse-gram.y,v
retrieving revision 1.81
diff -p -u -r1.81 parse-gram.y
--- src/parse-gram.y 24 Jun 2006 06:51:27 -0000 1.81
+++ src/parse-gram.y 25 Jun 2006 06:54:34 -0000
@@ -473,11 +473,7 @@ rhs:
| rhs symbol
{ grammar_current_rule_symbol_append ($2, @2); }
| rhs "{...}"
- {
- if (current_rule && current_rule->action)
- grammar_midrule_action ();
- grammar_current_rule_action_append ($2, @2);
- }
+ { grammar_current_rule_action_append ($2, @2); }
| rhs "%prec" symbol
{ grammar_current_rule_prec_set ($3, @3); }
| rhs "%dprec" INT
Index: src/reader.c
===================================================================
RCS file: /sources/bison/bison/src/reader.c,v
retrieving revision 1.257
diff -p -u -r1.257 reader.c
--- src/reader.c 23 Jun 2006 20:17:28 -0000 1.257
+++ src/reader.c 25 Jun 2006 06:54:34 -0000
@@ -403,6 +403,8 @@ grammar_current_rule_symbol_append (symb
void
grammar_current_rule_action_append (const char *action, location loc)
{
+ if (current_rule->action)
+ grammar_midrule_action ();
current_rule->action = translate_rule_action (current_rule, action, loc);
current_rule->action_location = loc;
}
Index: tests/regression.at
===================================================================
RCS file: /sources/bison/bison/tests/regression.at,v
retrieving revision 1.102
diff -p -u -r1.102 regression.at
--- tests/regression.at 24 Jun 2006 06:51:27 -0000 1.102
+++ tests/regression.at 25 Jun 2006 06:54:34 -0000
@@ -1019,8 +1019,8 @@ AT_SETUP([Braced code in declaration in
AT_DATA_GRAMMAR([input.y],
[[%{
#include <stdio.h>
-void yyerror (char const *msg);
-int yylex (void);
+static void yyerror (char const *msg);
+static int yylex (void);
%}
%error-verbose
@@ -1039,13 +1039,13 @@ start:
%%
-void
+static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
-int
+static int
yylex (void)
{
return 'a';
- Re: symbol declarations after rules, (continued)
- Re: symbol declarations after rules, Akim Demaille, 2006/06/27
- Re: symbol declarations after rules, Joel E. Denny, 2006/06/27
- Re: symbol declarations after rules, Akim Demaille, 2006/06/27
- Re: symbol declarations after rules, Joel E. Denny, 2006/06/27
- Re: symbol declarations after rules, Akim Demaille, 2006/06/28
Re: symbol declarations after rules, Joel E. Denny, 2006/06/24
- Re: symbol declarations after rules,
Joel E. Denny <=