]> git.saurik.com Git - bison.git/commitdiff
Remove `translations' as it is always set to true.
authorAkim Demaille <akim@epita.fr>
Sat, 22 Sep 2001 17:43:26 +0000 (17:43 +0000)
committerAkim Demaille <akim@epita.fr>
Sat, 22 Sep 2001 17:43:26 +0000 (17:43 +0000)
* src/gram.h: Adjust.
* src/reader.c (packsymbols, parse_token_decl): Adjust
* src/print.c (print_grammar): Adjust.
* src/output.c (output_token_translations): Adjust.
* src/lex.c (lex): Adjust.
* src/gram.c: Be sure the set pointers to NULL.
(dummy): Rename as...
(gram_free): this.

ChangeLog
src/gram.c
src/gram.h
src/lex.c
src/output.c
src/print.c
src/reader.c

index 6512f08fb91dceaf39dcf565f0af12cfad02ed7a..e1d6e882dd443dbabc8a532051cc47df130cc035 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2001-09-22  Akim Demaille  <akim@epita.fr>
+
+       Remove `translations' as it is always set to true.
+
+       * src/gram.h: Adjust.
+       * src/reader.c (packsymbols, parse_token_decl): Adjust
+       * src/print.c (print_grammar): Adjust.
+       * src/output.c (output_token_translations): Adjust.
+       * src/lex.c (lex): Adjust.
+       * src/gram.c: Be sure the set pointers to NULL.
+       (dummy): Rename as...
+       (gram_free): this.
+
 2001-09-22  Akim Demaille  <akim@epita.fr>
 
        * configure.in: Invoke AM_LIB_DMALLOC.
 2001-09-22  Akim Demaille  <akim@epita.fr>
 
        * configure.in: Invoke AM_LIB_DMALLOC.
index 1e4ae70f7338292910dbd02e6d6a56f634a47e55..2cab907c50d6bdd94c024da8feee4705919d9a32 100644 (file)
@@ -31,21 +31,19 @@ int nsyms;
 int ntokens;
 int nvars;
 
 int ntokens;
 int nvars;
 
-short *ritem;
-short *rlhs;
-short *rrhs;
-short *rprec;
-short *rprecsym;
-short *sprec;
-short *rassoc;
-short *sassoc;
-short *token_translations;
-short *rline;
+short *ritem = NULL;
+short *rlhs = NULL;
+short *rrhs = NULL;
+short *rprec = NULL;
+short *rprecsym = NULL;
+short *sprec = NULL;
+short *rassoc = NULL;
+short *sassoc = NULL;
+short *token_translations = NULL;
+short *rline = NULL;
 
 int start_symbol;
 
 
 int start_symbol;
 
-int translations;
-
 int max_user_token_number;
 
 int semantic_parser;
 int max_user_token_number;
 
 int semantic_parser;
@@ -54,10 +52,10 @@ int pure_parser;
 
 int error_token_number;
 
 
 int error_token_number;
 
-/* This is to avoid linker problems which occur on VMS when using GCC,
-   when the file in question contains data definitions only.  */
+/* Free all the memory associated to these pointers. */
 
 void
 
 void
-dummy (void)
+gram_free (void)
 {
 {
+
 }
 }
index e270db5c7c7c6ee0cd365a467152cdd6e825faaf..1691c85804c82b2744d9f7c290a85133e2689b99 100644 (file)
@@ -107,13 +107,9 @@ typedef enum
 
 /* token translation table: indexed by a token number as returned by
    the user's yylex routine, it yields the internal token number used
 
 /* token translation table: indexed by a token number as returned by
    the user's yylex routine, it yields the internal token number used
-   by the parser and throughout bison.  If translations is zero, the
-   translation table is not used because the two kinds of token
-   numbers are the same.  (It is noted in reader.c that "Nowadays
-   translations is always set to 1...") */
+   by the parser and throughout bison.  */
 
 extern short *token_translations;
 
 extern short *token_translations;
-extern int translations;
 extern int max_user_token_number;
 
 /* SEMANTIC_PARSER is nonzero if the input file says to use the hairy
 extern int max_user_token_number;
 
 /* SEMANTIC_PARSER is nonzero if the input file says to use the hairy
index cbb7f27846cd4982448cbcd70013113993383312..ecb6507ea7176675c76bae40985537177bb3e847 100644 (file)
--- a/src/lex.c
+++ b/src/lex.c
@@ -419,7 +419,6 @@ lex (void)
     case '\'':
       /* parse the literal token and compute character code in  code  */
 
     case '\'':
       /* parse the literal token and compute character code in  code  */
 
-      translations = -1;
       {
        int code, discode;
 
       {
        int code, discode;
 
@@ -447,7 +446,6 @@ lex (void)
     case '\"':
       /* parse the literal string token and treat as an identifier */
 
     case '\"':
       /* parse the literal string token and treat as an identifier */
 
-      translations = -1;
       {
        int code;               /* ignored here */
 
       {
        int code;               /* ignored here */
 
index 64052a9407dee738bd04eb839ca3377ef8dc6d66..b782cdff2af827d56888d4cad9775bda656a6f38 100644 (file)
@@ -295,25 +295,17 @@ output_token_translations (void)
 \n\
 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
 
 \n\
 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
 
-  if (translations)
-    {
-      obstack_fgrow2 (&table_obstack,
+  obstack_fgrow2 (&table_obstack,
       "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
 \n\
 \n",
       "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
 \n\
 \n",
-              max_user_token_number, nsyms);
+                 max_user_token_number, nsyms);
 
 
-      output_short_or_char_table (&table_obstack,
+  output_short_or_char_table (&table_obstack,
             "YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
             "YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
-                   ntokens < 127 ? "char" : "short",
-                   "yytranslate", token_translations,
-                   0, 1, max_user_token_number + 1);
-    }
-  else
-    {
-      obstack_sgrow (&table_obstack,
-                          "\n#define YYTRANSLATE(x) (x)\n");
-    }
+                             ntokens < 127 ? "char" : "short",
+                             "yytranslate", token_translations,
+                             0, 1, max_user_token_number + 1);
 }
 
 
 }
 
 
index a5be5737bb349e7bd3dfa31bb3cd4e025fdac77b..6aa4c711e4f6d8356c11fc3a5b362c7b8f72d654 100644 (file)
@@ -253,49 +253,26 @@ print_grammar (void)
                 _("Terminals, with rules where they appear"));
   obstack_sgrow (&output_obstack, "\n\n");
   obstack_fgrow1 (&output_obstack, "%s (-1)\n", tags[0]);
                 _("Terminals, with rules where they appear"));
   obstack_sgrow (&output_obstack, "\n\n");
   obstack_fgrow1 (&output_obstack, "%s (-1)\n", tags[0]);
-  if (translations)
-    {
-      for (i = 0; i <= max_user_token_number; i++)
-       if (token_translations[i] != 2)
-         {
-           buffer[0] = 0;
-           column = strlen (tags[token_translations[i]]);
-           obstack_sgrow (&output_obstack, tags[token_translations[i]]);
-           END_TEST (50);
-           sprintf (buffer, " (%d)", i);
-
-           for (j = 1; j <= nrules; j++)
-             for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
-               if (*rule == token_translations[i])
-                 {
-                   END_TEST (65);
-                   sprintf (buffer + strlen (buffer), " %d", j);
-                   break;
-                 }
-           obstack_fgrow1 (&output_obstack, "%s\n", buffer);
-         }
-    }
-  else
-    {
-      for (i = 1; i < ntokens; i++)
-       {
-         buffer[0] = 0;
-         column = strlen (tags[i]);
-         obstack_sgrow (&output_obstack, tags[i]);
-         END_TEST (50);
-         sprintf (buffer, " (%d)", i);
 
 
-         for (j = 1; j <= nrules; j++)
-           for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
-             if (*rule == i)
-               {
-                 END_TEST (65);
-                 sprintf (buffer + strlen (buffer), " %d", j);
-                 break;
-               }
-         obstack_fgrow1 (&output_obstack, "%s\n", buffer);
-       }
-    }
+  for (i = 0; i <= max_user_token_number; i++)
+    if (token_translations[i] != 2)
+      {
+       buffer[0] = 0;
+       column = strlen (tags[token_translations[i]]);
+       obstack_sgrow (&output_obstack, tags[token_translations[i]]);
+       END_TEST (50);
+       sprintf (buffer, " (%d)", i);
+
+       for (j = 1; j <= nrules; j++)
+         for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
+           if (*rule == token_translations[i])
+             {
+               END_TEST (65);
+               sprintf (buffer + strlen (buffer), " %d", j);
+               break;
+             }
+       obstack_fgrow1 (&output_obstack, "%s\n", buffer);
+      }
 
   obstack_sgrow (&output_obstack, "\n");
   obstack_sgrow (&output_obstack,
 
   obstack_sgrow (&output_obstack, "\n");
   obstack_sgrow (&output_obstack,
index 6fbadebbc35d03f34af8e060d46c6ba9f41cb071..6de1222b6a9ce2fb2feeb02d19f70ab84e3571a8 100644 (file)
@@ -512,7 +512,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
              /* symbol and symval combined are only one symbol */
              nsyms--;
            }
              /* symbol and symval combined are only one symbol */
              nsyms--;
            }
-         translations = 1;
          symbol = NULL;
        }
       else if (token == tok_identifier)
          symbol = NULL;
        }
       else if (token == tok_identifier)
@@ -537,7 +536,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
       else if (symbol && token == tok_number)
        {
          symbol->user_token_number = numval;
       else if (symbol && token == tok_number)
        {
          symbol->user_token_number = numval;
-         translations = 1;
        }
       else
        {
        }
       else
        {
@@ -679,7 +677,6 @@ parse_assoc_decl (associativity assoc)
          if (prev == tok_identifier)
            {
              symval->user_token_number = numval;
          if (prev == tok_identifier)
            {
              symval->user_token_number = numval;
-             translations = 1;
            }
          else
            {
            }
          else
            {
@@ -736,7 +733,7 @@ parse_union_decl (void)
 
   while (c != EOF)
     {
 
   while (c != EOF)
     {
-      
+
       /* If C contains '/', it is output by copy_comment ().  */
       if (c != '/')
        {
       /* If C contains '/', it is output by copy_comment ().  */
       if (c != '/')
        {
@@ -744,7 +741,7 @@ parse_union_decl (void)
          if (defines_flag)
            obstack_1grow (&defines_obstack, c);
        }
          if (defines_flag)
            obstack_1grow (&defines_obstack, c);
        }
-      
+
       switch (c)
        {
        case '\n':
       switch (c)
        {
        case '\n':
@@ -827,7 +824,6 @@ parse_thong_decl (void)
   char *typename = 0;
   int usrtoknum;
 
   char *typename = 0;
   int usrtoknum;
 
-  translations = 1;
   token = lex ();              /* fetch typename or first token */
   if (token == tok_typename)
     {
   token = lex ();              /* fetch typename or first token */
   if (token == tok_typename)
     {
@@ -1657,9 +1653,10 @@ output_token_defines (struct obstack *oout)
        continue;
 
       obstack_fgrow2 (oout, "# define\t%s\t%d\n",
        continue;
 
       obstack_fgrow2 (oout, "# define\t%s\t%d\n",
-                     symbol,
-                     (translations ? bp->user_token_number : bp->value));
+                     symbol, bp->user_token_number);
       if (semantic_parser)
       if (semantic_parser)
+       /* FIXME: This is certainly dead wrong, and should be just as
+          above. --akim.  */
        obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);
     }
 
        obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);
     }
 
@@ -1676,9 +1673,9 @@ output_token_defines (struct obstack *oout)
 static void
 packsymbols (void)
 {
 static void
 packsymbols (void)
 {
-  bucket *bp;
+  bucket *bp = NULL;
   int tokno = 1;
   int tokno = 1;
-  int i;
+  int i, j;
   int last_user_token_number;
   static char DOLLAR[] = "$";
 
   int last_user_token_number;
   static char DOLLAR[] = "$";
 
@@ -1744,7 +1741,7 @@ packsymbols (void)
 
       if (bp->class == token_sym)
        {
 
       if (bp->class == token_sym)
        {
-         if (translations && !(bp->user_token_number))
+         if (!bp->user_token_number)
            bp->user_token_number = ++last_user_token_number;
          if (bp->user_token_number > max_user_token_number)
            max_user_token_number = bp->user_token_number;
            bp->user_token_number = ++last_user_token_number;
          if (bp->user_token_number > max_user_token_number)
            max_user_token_number = bp->user_token_number;
@@ -1757,30 +1754,25 @@ packsymbols (void)
 
     }
 
 
     }
 
-  if (translations)
-    {
-      int j;
+  token_translations = XCALLOC (short, max_user_token_number + 1);
 
 
-      token_translations = XCALLOC (short, max_user_token_number + 1);
+  /* initialize all entries for literal tokens to 2, the internal
+     token number for $undefined., which represents all invalid
+     inputs.  */
+  for (j = 0; j <= max_user_token_number; j++)
+    token_translations[j] = 2;
 
 
-      /* initialize all entries for literal tokens to 2, the internal
-         token number for $undefined., which represents all invalid
-         inputs.  */
-      for (j = 0; j <= max_user_token_number; j++)
-       token_translations[j] = 2;
-
-      for (bp = firstsymbol; bp; bp = bp->next)
-       {
-         if (bp->value >= ntokens)
-           continue;           /* non-terminal */
-         if (bp->user_token_number == SALIAS)
-           continue;
-         if (token_translations[bp->user_token_number] != 2)
-           complain (_("tokens %s and %s both assigned number %d"),
-                     tags[token_translations[bp->user_token_number]],
-                     bp->tag, bp->user_token_number);
-         token_translations[bp->user_token_number] = bp->value;
-       }
+  for (bp = firstsymbol; bp; bp = bp->next)
+    {
+      if (bp->value >= ntokens)
+       continue;               /* non-terminal */
+      if (bp->user_token_number == SALIAS)
+       continue;
+      if (token_translations[bp->user_token_number] != 2)
+       complain (_("tokens %s and %s both assigned number %d"),
+                 tags[token_translations[bp->user_token_number]],
+                 bp->tag, bp->user_token_number);
+      token_translations[bp->user_token_number] = bp->value;
     }
 
   error_token_number = errtoken->value;
     }
 
   error_token_number = errtoken->value;
@@ -1906,15 +1898,6 @@ reader (void)
   start_flag = 0;
   startval = NULL;             /* start symbol not specified yet. */
 
   start_flag = 0;
   startval = NULL;             /* start symbol not specified yet. */
 
-#if 0
-  /* initially assume token number translation not needed.  */
-  translations = 0;
-#endif
-  /* Nowadays translations is always set to 1, since we give `error' a
-     user-token-number to satisfy the Posix demand for YYERRCODE==256.
-   */
-  translations = 1;
-
   nsyms = 1;
   nvars = 0;
   nrules = 0;
   nsyms = 1;
   nvars = 0;
   nrules = 0;