/[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.182 by akim, Mon Jun 10 08:37:30 2002 UTC revision 1.183 by akim, Mon Jun 10 08:37:55 2002 UTC
# Line 483  copy_definition (struct obstack *oout) Line 483  copy_definition (struct obstack *oout)
483  }  }
484    
485    
486  /*-------------------------------------------------------------------.  /*------------------------------------------.
487  | Parse what comes after %token or %nterm.  For %token, WHAT_IS is   |  | Parse what comes after %token or %nterm.  |
488  | token_sym and WHAT_IS_NOT is nterm_sym.  For %nterm, the arguments |  `------------------------------------------*/
 | are reversed.                                                      |  
 `-------------------------------------------------------------------*/  
489    
490  static void  static void
491  parse_token_decl (symbol_class what_is, symbol_class what_is_not)  parse_token_decl (symbol_class class)
492  {  {
493    token_t token = tok_undef;    token_t token = tok_undef;
494    char *typename = NULL;    char *typename = NULL;
# Line 512  parse_token_decl (symbol_class what_is, Line 510  parse_token_decl (symbol_class what_is,
510          fatal (_("Premature EOF after %s"), token_buffer);          fatal (_("Premature EOF after %s"), token_buffer);
511    
512        token = lex ();        token = lex ();
513        if (token == tok_comma)        switch (token)
514          {          {
515            case tok_comma:
516            symbol = NULL;            symbol = NULL;
517            continue;            break;
518          }  
519        if (token == tok_typename)          case tok_typename:
         {  
520            typename = xstrdup (token_buffer);            typename = xstrdup (token_buffer);
521            symbol = NULL;            symbol = NULL;
522          }            break;
       else if (token == tok_identifier && *symval->tag == '\"' && symbol)  
         {  
           symbol_make_alias (symbol, symval, typename);  
           symbol = NULL;  
         }  
       else if (token == tok_identifier)  
         {  
           int oldclass = symval->class;  
           symbol = symval;  
   
           if (symbol->class == what_is_not)  
             complain (_("symbol %s redefined"), symbol->tag);  
           symbol->class = what_is;  
           if (what_is == nterm_sym && oldclass != nterm_sym)  
             symbol->number = nvars++;  
           if (what_is == token_sym && symbol->number == NUMBER_UNDEFINED)  
             symbol->number = ntokens++;  
523    
524            if (typename)          case tok_identifier:
525              if (*symval->tag == '\"' && symbol)
526              {              {
527                if (symbol->type_name == NULL)                symbol_make_alias (symbol, symval, typename);
528                  symbol->type_name = typename;                symbol = NULL;
               else if (strcmp (typename, symbol->type_name) != 0)  
                 complain (_("type redeclaration for %s"), symbol->tag);  
529              }              }
530          }            else
       else if (symbol && token == tok_number)  
         {  
           symbol->user_token_number = numval;  
           /* User defined EOF token? */  
           if (numval == 0)  
531              {              {
532                eoftoken = symbol;                symbol = symval;
533                eoftoken->number = 0;                symbol_class_set (symbol, class);
534                /* It is always mapped to 0, so it was already counted in                if (typename)
535                   NTOKENS.  */                  symbol_type_set (symbol, typename);
               --ntokens;  
536              }              }
537          }            break;
538        else  
539          {          case tok_number:
540              symbol_user_token_number_set (symbol, numval);
541              break;
542    
543            default:
544            complain (_("`%s' is invalid in %s"),            complain (_("`%s' is invalid in %s"),
545                      token_buffer,                      token_buffer,
546                      (what_is == token_sym) ? "%token" : "%nterm");                      (class == token_sym) ? "%token" : "%nterm");
547            skip_to_char ('%');            skip_to_char ('%');
548          }          }
549      }      }
# Line 922  read_declarations (void) Line 900  read_declarations (void)
900                break;                break;
901    
902              case tok_token:              case tok_token:
903                parse_token_decl (token_sym, nterm_sym);                parse_token_decl (token_sym);
904                break;                break;
905    
906              case tok_nterm:              case tok_nterm:
907                parse_token_decl (nterm_sym, token_sym);                parse_token_decl (nterm_sym);
908                break;                break;
909    
910              case tok_type:              case tok_type:

Legend:
Removed from v.1.182  
changed lines
  Added in v.1.183

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