]> git.saurik.com Git - bison.git/commitdiff
* src/symtab.c, src/symtab.c (symbol_type_set)
authorAkim Demaille <akim@epita.fr>
Mon, 10 Jun 2002 08:36:49 +0000 (08:36 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 10 Jun 2002 08:36:49 +0000 (08:36 +0000)
(symbol_precedence_set): New.
* src/reader.c (parse_type_decl, parse_assoc_decl): Use them.
(value_components_used): Remove, unused.

ChangeLog
TODO
src/reader.c
src/symtab.c
src/symtab.h

index 02a0e19ddcb37f7efe50b3dcfa6d7bea71fa1c7b..45aaf92dcbddb9391433afccd347c0c1d71de550 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-06-10  Akim Demaille  <akim@epita.fr>
+
+       * src/symtab.c, src/symtab.c (symbol_type_set)
+       (symbol_precedence_set): New.
+       * src/reader.c (parse_type_decl, parse_assoc_decl): Use them.
+       (value_components_used): Remove, unused.
+
 2002-06-09  Akim Demaille  <akim@epita.fr>
 
        Move symbols handling code out of the reader.
diff --git a/TODO b/TODO
index d5fb1f399c60e0e0ea7b1a4342a0442680f5269f..14bd676f20c3ccac8de849a7460a86adf61a277e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,6 +3,11 @@
 * URGENT: Documenting C++ output
 Write a first documentation for C++ output.
 
+* value_components_used
+Was defined but not used: where was it coming from?  It can't be to
+check if %union is used, since the user is free to $<foo>n on her
+union, doesn't she?
+
 * yyerror, yyprint interface
 It should be improved, in particular when using Bison features such as
 locations, and YYPARSE_PARAMS.  For the time being, it is recommended
index 63d993f9151d5a9ff056b9db3a0809c1afb8a2c1..70629837b215717c1d9d215c205975baae88fe7f 100644 (file)
@@ -52,10 +52,6 @@ int lineno;
 static symbol_list *grammar = NULL;
 static int start_flag = 0;
 
-/* Nonzero if components of semantic values are used, implying
-   they must be unions.  */
-static int value_components_used;
-
 /* Nonzero if %union has been seen.  */
 static int typed = 0;
 
@@ -378,7 +374,6 @@ copy_dollar (FILE *fin, struct obstack *oout,
     {
       read_type_name (fin);
       type_name = token_buffer;
-      value_components_used = 1;
       c = getc (fin);
     }
 
@@ -525,7 +520,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
       if (token == tok_typename)
        {
          typename = xstrdup (token_buffer);
-         value_components_used = 1;
          symbol = NULL;
        }
       else if (token == tok_identifier && *symval->tag == '\"' && symbol)
@@ -630,17 +624,12 @@ parse_type_decl (void)
 
       switch (t)
        {
-
        case tok_comma:
        case tok_semicolon:
          break;
 
        case tok_identifier:
-         if (symval->type_name == NULL)
-           symval->type_name = name;
-         else if (strcmp (name, symval->type_name) != 0)
-           complain (_("type redeclaration for %s"), symval->tag);
-
+         symbol_type_set (symval, name);
          break;
 
        default:
@@ -689,10 +678,6 @@ parse_assoc_decl (associativity assoc)
          break;
 
        case tok_identifier:
-         if (symval->prec != 0)
-           complain (_("redefining precedence of %s"), symval->tag);
-         symval->prec = lastprec;
-         symval->assoc = assoc;
          if (symval->class == nterm_sym)
            complain (_("symbol %s redefined"), symval->tag);
          if (symval->number == NUMBER_UNDEFINED)
@@ -700,13 +685,9 @@ parse_assoc_decl (associativity assoc)
              symval->number = ntokens++;
              symval->class = token_sym;
            }
+         symbol_precedence_set (symval, lastprec, assoc);
          if (name)
-           {                   /* record the type, if one is specified */
-             if (symval->type_name == NULL)
-               symval->type_name = name;
-             else if (strcmp (name, symval->type_name) != 0)
-               complain (_("type redeclaration for %s"), symval->tag);
-           }
+           symbol_type_set (symval, name);
          break;
 
        case tok_number:
@@ -851,7 +832,6 @@ parse_thong_decl (void)
   if (token == tok_typename)
     {
       typename = xstrdup (token_buffer);
-      value_components_used = 1;
       token = lex ();          /* fetch first token */
     }
 
index 217b8e0a3ba14f3ce3f5714368f0d5b90fd46983..08571d837126cc21657373f6365646d9f95045c6 100644 (file)
@@ -59,6 +59,34 @@ symbol_new (const char *tag)
 }
 
 
+/*-----------------------------------------.
+| Set the TYPE_NAME associated to SYMBOL.  |
+`-----------------------------------------*/
+
+void
+symbol_type_set (symbol_t *symbol, char *type_name)
+{
+  if (symbol->type_name)
+    complain (_("type redeclaration for %s"), symbol->tag);
+  symbol->type_name = type_name;
+}
+
+
+/*------------------------------------------.
+| Set the PRECEDENCE associated to SYMBOL.  |
+`------------------------------------------*/
+
+void
+symbol_precedence_set (symbol_t *symbol,
+                      int prec, associativity assoc)
+{
+  if (symbol->prec != 0)
+    complain (_("redefining precedence of %s"), symbol->tag);
+  symbol->prec = prec;
+  symbol->assoc = assoc;
+}
+
+
 /*------------.
 | Free THIS.  |
 `------------*/
index b7a9fbc82732f49b1291fcbff03f7123c40360d1..4ca81465d9e2dae9586d6ba1ca400e51c0d6828d 100644 (file)
@@ -89,6 +89,13 @@ symbol_t *getsym PARAMS ((const char *key));
 void symbol_make_alias PARAMS ((symbol_t *symbol, symbol_t *symval,
                                char *typename));
 
+/* Set the TYPE_NAME associated to SYMBOL. */
+void symbol_type_set PARAMS ((symbol_t *symbol, char *type_name));
+
+/* Set the PRECEDENCE associated to SYMBOL.  */
+void symbol_precedence_set PARAMS ((symbol_t *symbol,
+                                   int prec, associativity assoc));
+
 /* Distinguished symbols.  AXIOM is the real start symbol, that used
    by the automaton.  STARTSYMBOL is the one specified by the user.
    */