[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03-symbol-get.patch
From: |
Akim Demaille |
Subject: |
03-symbol-get.patch |
Date: |
Sun, 30 Jun 2002 19:26:38 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/reader.c (gensym): Rename as...
* src/symtab.h, src/symtab.c (dummy_symbol_get): this.
(getsym): Rename as...
(symbol_get): this.
Index: src/parse-gram.y
--- src/parse-gram.y Fri, 28 Jun 2002 21:50:19 +0200 akim
+++ src/parse-gram.y Sat, 29 Jun 2002 10:38:30 +0200 akim
@@ -368,7 +368,7 @@ rhs:
symbol:
ID { $$ = $1; }
| string_as_id { $$ = $1; }
-| CHARACTER { $$ = getsym ($1, @1); }
+| CHARACTER { $$ = symbol_get ($1, @1); }
;
action:
@@ -380,7 +380,7 @@ action:
string_as_id:
STRING
{
- $$ = getsym ($1, @1);
+ $$ = symbol_get ($1, @1);
symbol_class_set ($$, token_sym, @1);
}
;
Index: src/scan-gram.l
--- src/scan-gram.l Fri, 28 Jun 2002 21:50:19 +0200 akim
+++ src/scan-gram.l Sat, 29 Jun 2002 10:38:33 +0200 akim
@@ -160,7 +160,7 @@
{eols} YY_LINES; YY_STEP;
{blanks} YY_STEP;
{id} {
- yylval->symbol = getsym (yytext, *yylloc);
+ yylval->symbol = symbol_get (yytext, *yylloc);
return ID;
}
@@ -292,7 +292,7 @@
assert (yy_top_state () == INITIAL);
{
YY_OBS_FINISH;
- yylval->symbol = getsym (last_string, *yylloc);
+ yylval->symbol = symbol_get (last_string, *yylloc);
symbol_class_set (yylval->symbol, token_sym, *yylloc);
symbol_user_token_number_set (yylval->symbol, last_string[1], *yylloc);
YY_OBS_FREE;
Index: src/reader.c
--- src/reader.c Fri, 28 Jun 2002 21:50:19 +0200 akim
+++ src/reader.c Sat, 29 Jun 2002 10:39:50 +0200 akim
@@ -126,7 +126,7 @@
type = "";
head.next = merge_functions;
- for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
+ for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
if (strcmp (name, syms->next->name) == 0)
break;
if (syms->next == NULL) {
@@ -136,7 +136,7 @@
syms->next->next = NULL;
merge_functions = head.next;
} else if (strcmp (type, syms->next->type) != 0)
- warn (_("result type clash on merge function %s: `%s' vs. `%s'"),
+ warn (_("result type clash on merge function %s: `%s' vs. `%s'"),
name, type, syms->next->type);
return n;
}
@@ -160,26 +160,6 @@
}
}
-/*-------------------------------------------------------------------.
-| Generate a dummy symbol, a nonterminal, whose name cannot conflict |
-| with the user's names. |
-`-------------------------------------------------------------------*/
-
-static symbol_t *
-gensym (location_t location)
-{
- /* Incremented for each generated symbol */
- static int gensym_count = 0;
- static char buf[256];
-
- symbol_t *sym;
-
- sprintf (buf, "@%d", ++gensym_count);
- sym = getsym (buf, location);
- sym->class = nterm_sym;
- sym->number = nvars++;
- return sym;
-}
/*-------------------------------------------------------------------.
| Parse the input grammar into a one symbol_list_t structure. Each |
@@ -323,7 +303,7 @@
/* Make a DUMMY nonterminal, whose location is that of the midrule
action. Create the MIDRULE. */
location_t dummy_location = current_rule->action_location;
- symbol_t *dummy = gensym (dummy_location);
+ symbol_t *dummy = dummy_symbol_get (dummy_location);
symbol_list_t *midrule = symbol_list_new (dummy, dummy_location);
/* Make a new rule, whose body is empty, before the current one, so
@@ -371,7 +351,7 @@
warn_at (location, _("%%dprec affects only GLR parsers"));
if (dprec <= 0)
complain_at (location, _("%%dprec must be followed by positive number"));
- else if (current_rule->dprec != 0)
+ else if (current_rule->dprec != 0)
complain_at (location, _("only one %%dprec allowed per rule"));
current_rule->dprec = dprec;
}
@@ -384,9 +364,9 @@
{
if (! glr_parser)
warn_at (location, _("%%merge affects only GLR parsers"));
- if (current_rule->merger != 0)
+ if (current_rule->merger != 0)
complain_at (location, _("only one %%merge allowed per rule"));
- current_rule->merger =
+ current_rule->merger =
get_merge_function (name, current_rule->sym->type_name);
}
@@ -499,18 +479,18 @@
symbols_new ();
/* Construct the axiom symbol. */
- axiom = getsym ("$axiom", empty_location);
+ axiom = symbol_get ("$axiom", empty_location);
axiom->class = nterm_sym;
axiom->number = nvars++;
/* Construct the error token */
- errtoken = getsym ("error", empty_location);
+ errtoken = symbol_get ("error", empty_location);
errtoken->class = token_sym;
errtoken->number = ntokens++;
/* Construct a token that represents all undefined literal tokens.
It is always token number 2. */
- undeftoken = getsym ("$undefined.", empty_location);
+ undeftoken = symbol_get ("$undefined.", empty_location);
undeftoken->class = token_sym;
undeftoken->number = ntokens++;
@@ -536,7 +516,7 @@
/* If the user did not define her EOFTOKEN, do it now. */
if (!eoftoken)
{
- eoftoken = getsym ("$", empty_location);
+ eoftoken = symbol_get ("$", empty_location);
eoftoken->class = token_sym;
eoftoken->number = 0;
/* Value specified by POSIX. */
Index: src/symtab.c
--- src/symtab.c Fri, 28 Jun 2002 21:50:19 +0200 akim
+++ src/symtab.c Sat, 29 Jun 2002 10:42:09 +0200 akim
@@ -447,7 +447,7 @@
`----------------------------------------------------------------*/
symbol_t *
-getsym (const char *key, location_t location)
+symbol_get (const char *key, location_t location)
{
symbol_t probe;
symbol_t *entry;
@@ -462,6 +462,28 @@
hash_insert (symbol_table, entry);
}
return entry;
+}
+
+
+/*------------------------------------------------------------------.
+| Generate a dummy nonterminal, whose name cannot conflict with the |
+| user's names. |
+`------------------------------------------------------------------*/
+
+symbol_t *
+dummy_symbol_get (location_t location)
+{
+ /* Incremented for each generated symbol. */
+ static int dummy_count = 0;
+ static char buf[256];
+
+ symbol_t *sym;
+
+ sprintf (buf, "@%d", ++dummy_count);
+ sym = symbol_get (buf, location);
+ sym->class = nterm_sym;
+ sym->number = nvars++;
+ return sym;
}
Index: src/symtab.h
--- src/symtab.h Fri, 28 Jun 2002 21:50:19 +0200 akim
+++ src/symtab.h Sat, 29 Jun 2002 10:40:51 +0200 akim
@@ -103,7 +103,11 @@
void symbol_tag_print PARAMS ((symbol_t *symbol, FILE *out));
/* Fetch (or create) the symbol associated to KEY. */
-symbol_t *getsym PARAMS ((const char *key, location_t location));
+symbol_t *symbol_get PARAMS ((const char *key, location_t location));
+
+/* Generate a dummy nonterminal, whose name cannot conflict with the
+ user's names. */
+symbol_t *dummy_symbol_get PARAMS ((location_t location));
/* Declare the new SYMBOL. Make it an alias of SYMVAL. */
void symbol_make_alias PARAMS ((symbol_t *symbol, symbol_t *symval));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 03-symbol-get.patch,
Akim Demaille <=