[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: %union ... {
From: |
Akim Demaille |
Subject: |
Re: %union ... { |
Date: |
Tue, 20 Jun 2006 13:44:37 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
>>> "Paul" == Paul Eggert <address@hidden> writes:
> Doesn't this invoke uniqstr_new on the same symbol twice? Once by the
> scanner, and once by the parser. Admittedly hashing is not the
> biggest overhead in Bison, but still it's a bit weird that we
> immediately look up the same symbol twice in the same table.
Sure. I refrained from this because there is no overloading in C, so
it widens the interface, but not by much.
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/symtab.h, src/symtab.c (symbol_from_uniqstr): New.
(symbol_get): Use it.
* src/parse-gram.y: Use it.
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.77
diff -u -u -r1.77 parse-gram.y
--- src/parse-gram.y 19 Jun 2006 21:32:40 -0000 1.77
+++ src/parse-gram.y 20 Jun 2006 11:32:45 -0000
@@ -463,7 +463,7 @@
id:
ID
- { $$ = symbol_get ($1, @1); }
+ { $$ = symbol_from_uniqstr ($1, @1); }
| CHAR
{
$$ = symbol_get (char_name ($1), @1);
@@ -473,7 +473,7 @@
;
id_colon:
- ID_COLON { $$ = symbol_get ($1, @1); }
+ ID_COLON { $$ = symbol_from_uniqstr ($1, @1); }
;
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.70
diff -u -u -r1.70 symtab.c
--- src/symtab.c 21 Jan 2006 04:35:09 -0000 1.70
+++ src/symtab.c 20 Jun 2006 11:32:45 -0000
@@ -499,12 +499,11 @@
`----------------------------------------------------------------*/
symbol *
-symbol_get (const char *key, location loc)
+symbol_from_uniqstr (const uniqstr key, location loc)
{
symbol probe;
symbol *entry;
- key = uniqstr_new (key);
probe.tag = key;
entry = hash_lookup (symbol_table, &probe);
@@ -518,6 +517,18 @@
}
+/*----------------------------------------------------------------.
+| Find the symbol named KEY, and return it. If it does not exist |
+| yet, create it. |
+`----------------------------------------------------------------*/
+
+symbol *
+symbol_get (const char *key, location loc)
+{
+ return symbol_from_uniqstr (uniqstr_new (key), loc);
+}
+
+
/*------------------------------------------------------------------.
| Generate a dummy nonterminal, whose name cannot conflict with the |
| user's names. |
Index: src/symtab.h
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.h,v
retrieving revision 1.59
diff -u -u -r1.59 symtab.h
--- src/symtab.h 3 Jan 2006 21:31:57 -0000 1.59
+++ src/symtab.h 20 Jun 2006 11:32:45 -0000
@@ -98,6 +98,9 @@
void symbol_print (symbol *s, FILE *f);
/* Fetch (or create) the symbol associated to KEY. */
+symbol *symbol_from_uniqstr (const uniqstr key, location loc);
+
+/* Fetch (or create) the symbol associated to KEY. */
symbol *symbol_get (const char *key, location loc);
/* Generate a dummy nonterminal, whose name cannot conflict with the
- Re: Dubious features, (continued)
- Re: Dubious features, Paul Eggert, 2006/06/08
- Re: Dubious features, Akim Demaille, 2006/06/10
- Re: Dubious features, Paul Eggert, 2006/06/11
- Re: %union ... {, Akim Demaille, 2006/06/16
- Re: %union ... {, Paul Eggert, 2006/06/16
- Re: %union ... {, Akim Demaille, 2006/06/17
- Re: %union ... {, Paul Eggert, 2006/06/19
- Re: %union ... {, Hans Aberg, 2006/06/19
- Re: %union ... {, Akim Demaille, 2006/06/19
- Re: %union ... {, Paul Eggert, 2006/06/19
- Re: %union ... {,
Akim Demaille <=
- Problems with CVS, Akim Demaille, 2006/06/20
- Re: Problems with CVS, Paul Eggert, 2006/06/20
- Re: %union ... {, Joel E. Denny, 2006/06/19
- Re: %union ... {, Akim Demaille, 2006/06/20
- Re: %union ... {, Hans Aberg, 2006/06/20