[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
More about %destructor
From: |
Akim Demaille |
Subject: |
More about %destructor |
Date: |
18 Jun 2002 11:55:39 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
The result of this patch on test 40 is:
/*-------------------------------------------------.
| Release the memory associated to SYMBOL-NUMBER. |
`-------------------------------------------------*/
static void
yydestructor (int symbol_type, YYSTYPE symbol_value)
{
switch (symbol_type)
{
case 3: /* 'x' */
#line 19 "input.y"
{ printf ("Freeing 'x' %d\n", symbol_value.ival); };
#line 1260 "input.c"
break;
case 6: /* input */
#line 16 "input.y"
{ printf ("Freeing input %d\n", symbol_value.ival); };
#line 1265 "input.c"
break;
case 7: /* line */
#line 17 "input.y"
{ printf ("Freeing line %d\n", symbol_value.ival); };
#line 1270 "input.c"
break;
case 8: /* thing */
#line 18 "input.y"
{ printf ("Freeing thing %d\n", symbol_value.ival); };
#line 1275 "input.c"
break;
default:
YYDPRINTF ((stderr, "yydestructor: unknown symbol type: %d (%s)\n",
symbol_type, yytname[symbol_type]));
break;
}
}
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/symtab.h, src/symtab.c (symbol_t): destructor_location is a
new member.
(symbol_destructor_set): Adjust.
* src/output.c (symbol_destructors_output): Output the destructor
locations.
Output the symbol name.
* data/bison.simple (b4_symbol_destructor): Adjust.
Index: data/bison.simple
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.simple,v
retrieving revision 1.34
diff -u -u -r1.34 bison.simple
--- data/bison.simple 18 Jun 2002 09:12:58 -0000 1.34
+++ data/bison.simple 18 Jun 2002 09:54:02 -0000
@@ -1267,7 +1267,11 @@
return yyresult;
]}
-/* Release the memory associated to SYMBOL-NUMBER. */
+
+/*-------------------------------------------------.
+| Release the memory associated to SYMBOL-NUMBER. |
+`-------------------------------------------------*/
+
m4_divert_push([KILL])# M4 code.
# b4_eval
# -------
@@ -1280,9 +1284,11 @@
# b4_symbol_destructor(SYMBOL-NUMBER, DESTRUCTOR, TYPE-NAME)
# ----------------------------------------------------------
m4_define([b4_symbol_destructor],
-[m4_pushdef([b4_dollar_dollar], [symbol_value.$3])dnl
- case $1:
- b4_eval($2);
+[m4_pushdef([b4_dollar_dollar], [symbol_value.$6])dnl
+ case $4: /* $3 */
+#line $2 "$1"
+ b4_eval($5);
+#line __oline__ "__ofile__"
break;
m4_popdef([b4_dollar_dollar])])
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.165
diff -u -u -r1.165 output.c
--- src/output.c 17 Jun 2002 08:43:11 -0000 1.165
+++ src/output.c 18 Jun 2002 09:54:02 -0000
@@ -622,10 +622,16 @@
{
symbol_t *symbol = symbols[i];
- /* Symbol-number, destructor. */
- fprintf (out, "%s[[[%d]], [[%s]], [[%s]]]",
+ /* Filename, lineno,
+ Symbol-name, Symbol-number,
+ destructor, typename. */
+ fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
first ? "" : ",\n",
- symbol->number, symbol->destructor, symbol->type_name);
+ infile, symbol->destructor_location.first_line,
+ symbol_tag_get (symbol),
+ symbol->number,
+ symbol->destructor,
+ symbol->type_name);
first = 0;
}
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.35
diff -u -u -r1.35 symtab.c
--- src/symtab.c 17 Jun 2002 08:43:11 -0000 1.35
+++ src/symtab.c 18 Jun 2002 09:54:02 -0000
@@ -47,9 +47,11 @@
symbol_t *res = XMALLOC (symbol_t, 1);
res->tag = xstrdup (tag);
+ res->location = location;
+
res->type_name = NULL;
res->destructor = NULL;
- res->location = location;
+
res->number = NUMBER_UNDEFINED;
res->prec = 0;
res->assoc = right_assoc;
@@ -130,6 +132,7 @@
_("destructor redeclaration for %s"),
symbol_tag_get (symbol));
symbol->destructor = destructor;
+ symbol->destructor_location = location;
}
}
Index: src/symtab.h
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.h,v
retrieving revision 1.35
diff -u -u -r1.35 symtab.h
--- src/symtab.h 17 Jun 2002 08:43:11 -0000 1.35
+++ src/symtab.h 18 Jun 2002 09:54:02 -0000
@@ -56,13 +56,14 @@
{
/* The key, name of the symbol. */
char *tag;
+ /* The location of its first occurence. */
+ location_t location;
/* Its %type and associated destructor. */
char *type_name;
char *destructor;
+ location_t destructor_location;
- /* The location of its first occurence. */
- location_t location;
symbol_number_t number;
short prec;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- More about %destructor,
Akim Demaille <=