/[bison]/bison/src/reader.c
ViewVC logotype

Diff of /bison/src/reader.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.72.2.5 by marc, Tue Sep 18 11:37:11 2001 UTC revision 1.72.2.6 by akim, Sat Sep 22 17:43:26 2001 UTC
# Line 512  parse_token_decl (symbol_class what_is, Line 512  parse_token_decl (symbol_class what_is,
512                /* symbol and symval combined are only one symbol */                /* symbol and symval combined are only one symbol */
513                nsyms--;                nsyms--;
514              }              }
           translations = 1;  
515            symbol = NULL;            symbol = NULL;
516          }          }
517        else if (token == tok_identifier)        else if (token == tok_identifier)
# Line 537  parse_token_decl (symbol_class what_is, Line 536  parse_token_decl (symbol_class what_is,
536        else if (symbol && token == tok_number)        else if (symbol && token == tok_number)
537          {          {
538            symbol->user_token_number = numval;            symbol->user_token_number = numval;
           translations = 1;  
539          }          }
540        else        else
541          {          {
# Line 679  parse_assoc_decl (associativity assoc) Line 677  parse_assoc_decl (associativity assoc)
677            if (prev == tok_identifier)            if (prev == tok_identifier)
678              {              {
679                symval->user_token_number = numval;                symval->user_token_number = numval;
               translations = 1;  
680              }              }
681            else            else
682              {              {
# Line 736  parse_union_decl (void) Line 733  parse_union_decl (void)
733    
734    while (c != EOF)    while (c != EOF)
735      {      {
736          
737        /* If C contains '/', it is output by copy_comment ().  */        /* If C contains '/', it is output by copy_comment ().  */
738        if (c != '/')        if (c != '/')
739          {          {
# Line 744  parse_union_decl (void) Line 741  parse_union_decl (void)
741            if (defines_flag)            if (defines_flag)
742              obstack_1grow (&defines_obstack, c);              obstack_1grow (&defines_obstack, c);
743          }          }
744          
745        switch (c)        switch (c)
746          {          {
747          case '\n':          case '\n':
# Line 827  parse_thong_decl (void) Line 824  parse_thong_decl (void)
824    char *typename = 0;    char *typename = 0;
825    int usrtoknum;    int usrtoknum;
826    
   translations = 1;  
827    token = lex ();               /* fetch typename or first token */    token = lex ();               /* fetch typename or first token */
828    if (token == tok_typename)    if (token == tok_typename)
829      {      {
# Line 1657  output_token_defines (struct obstack *oo Line 1653  output_token_defines (struct obstack *oo
1653          continue;          continue;
1654    
1655        obstack_fgrow2 (oout, "# define\t%s\t%d\n",        obstack_fgrow2 (oout, "# define\t%s\t%d\n",
1656                        symbol,                        symbol, bp->user_token_number);
                       (translations ? bp->user_token_number : bp->value));  
1657        if (semantic_parser)        if (semantic_parser)
1658            /* FIXME: This is certainly dead wrong, and should be just as
1659               above. --akim.  */
1660          obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);          obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);
1661      }      }
1662    
# Line 1676  output_token_defines (struct obstack *oo Line 1673  output_token_defines (struct obstack *oo
1673  static void  static void
1674  packsymbols (void)  packsymbols (void)
1675  {  {
1676    bucket *bp;    bucket *bp = NULL;
1677    int tokno = 1;    int tokno = 1;
1678    int i;    int i, j;
1679    int last_user_token_number;    int last_user_token_number;
1680    static char DOLLAR[] = "$";    static char DOLLAR[] = "$";
1681    
# Line 1744  packsymbols (void) Line 1741  packsymbols (void)
1741    
1742        if (bp->class == token_sym)        if (bp->class == token_sym)
1743          {          {
1744            if (translations && !(bp->user_token_number))            if (!bp->user_token_number)
1745              bp->user_token_number = ++last_user_token_number;              bp->user_token_number = ++last_user_token_number;
1746            if (bp->user_token_number > max_user_token_number)            if (bp->user_token_number > max_user_token_number)
1747              max_user_token_number = bp->user_token_number;              max_user_token_number = bp->user_token_number;
# Line 1757  packsymbols (void) Line 1754  packsymbols (void)
1754    
1755      }      }
1756    
1757    if (translations)    token_translations = XCALLOC (short, max_user_token_number + 1);
     {  
       int j;  
1758    
1759        token_translations = XCALLOC (short, max_user_token_number + 1);    /* initialize all entries for literal tokens to 2, the internal
1760         token number for $undefined., which represents all invalid
1761         inputs.  */
1762      for (j = 0; j <= max_user_token_number; j++)
1763        token_translations[j] = 2;
1764    
1765        /* initialize all entries for literal tokens to 2, the internal    for (bp = firstsymbol; bp; bp = bp->next)
1766           token number for $undefined., which represents all invalid      {
1767           inputs.  */        if (bp->value >= ntokens)
1768        for (j = 0; j <= max_user_token_number; j++)          continue;               /* non-terminal */
1769          token_translations[j] = 2;        if (bp->user_token_number == SALIAS)
1770            continue;
1771        for (bp = firstsymbol; bp; bp = bp->next)        if (token_translations[bp->user_token_number] != 2)
1772          {          complain (_("tokens %s and %s both assigned number %d"),
1773            if (bp->value >= ntokens)                    tags[token_translations[bp->user_token_number]],
1774              continue;           /* non-terminal */                    bp->tag, bp->user_token_number);
1775            if (bp->user_token_number == SALIAS)        token_translations[bp->user_token_number] = bp->value;
             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;  
         }  
1776      }      }
1777    
1778    error_token_number = errtoken->value;    error_token_number = errtoken->value;
# Line 1906  reader (void) Line 1898  reader (void)
1898    start_flag = 0;    start_flag = 0;
1899    startval = NULL;              /* start symbol not specified yet. */    startval = NULL;              /* start symbol not specified yet. */
1900    
 #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;  
   
1901    nsyms = 1;    nsyms = 1;
1902    nvars = 0;    nvars = 0;
1903    nrules = 0;    nrules = 0;

Legend:
Removed from v.1.72.2.5  
changed lines
  Added in v.1.72.2.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26