/[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.130 by akim, Thu Dec 27 18:12:48 2001 UTC revision 1.131 by akim, Thu Dec 27 18:13:09 2001 UTC
# Line 68  static int typed; Line 68  static int typed;
68  /* Incremented for each %left, %right or %nonassoc seen */  /* Incremented for each %left, %right or %nonassoc seen */
69  static int lastprec;  static int lastprec;
70    
71  static bucket *errtoken;  static bucket *errtoken = NULL;
72  static bucket *undeftoken;  static bucket *undeftoken = NULL;
73    static bucket *eoftoken = NULL;
74    
75  static symbol_list *  static symbol_list *
76  symbol_list_new (bucket *sym)  symbol_list_new (bucket *sym)
# Line 441  copy_definition (void) Line 441  copy_definition (void)
441      {      {
442        obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"),        obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"),
443                        lineno, quotearg_style (c_quoting_style,                        lineno, quotearg_style (c_quoting_style,
444                                                muscle_find("filename")));                                                muscle_find ("filename")));
445      }      }
446    
447    after_percent = 0;    after_percent = 0;
# Line 573  parse_token_decl (symbol_class what_is, Line 573  parse_token_decl (symbol_class what_is,
573        else if (symbol && token == tok_number)        else if (symbol && token == tok_number)
574          {          {
575            symbol->user_token_number = numval;            symbol->user_token_number = numval;
576              /* User defined EOF token? */
577              if (numval == 0)
578                eoftoken = symbol;
579          }          }
580        else        else
581          {          {
# Line 902  static void Line 905  static void
905  parse_muscle_decl (void)  parse_muscle_decl (void)
906  {  {
907    int ch = ungetc (skip_white_space (), finput);    int ch = ungetc (skip_white_space (), finput);
908    char* muscle_key;    char *muscle_key;
909    char* muscle_value;    char *muscle_value;
910    
911    /* Read key. */    /* Read key. */
912    if (!isalpha (ch) && ch != '_')    if (!isalpha (ch) && ch != '_')
# Line 1486  read_additionnal_code (void) Line 1489  read_additionnal_code (void)
1489      {      {
1490        obstack_fgrow2 (&el_obstack, muscle_find ("linef"),        obstack_fgrow2 (&el_obstack, muscle_find ("linef"),
1491                        lineno, quotearg_style (c_quoting_style,                        lineno, quotearg_style (c_quoting_style,
1492                                                muscle_find("filename")));                                                muscle_find ("filename")));
1493      }      }
1494    
1495    while ((c = getc (finput)) != EOF)    while ((c = getc (finput)) != EOF)
# Line 1549  packsymbols (void) Line 1552  packsymbols (void)
1552    bucket *bp = NULL;    bucket *bp = NULL;
1553    int tokno = 1;    int tokno = 1;
1554    int last_user_token_number;    int last_user_token_number;
   static char DOLLAR[] = "$";  
1555    
1556    tags = XCALLOC (char *, nsyms + 1);    tags = XCALLOC (char *, nsyms + 1);
1557    user_toknums = XCALLOC (short, nsyms + 1);    user_toknums = XCALLOC (short, nsyms + 1);
# Line 1557  packsymbols (void) Line 1559  packsymbols (void)
1559    sprec = XCALLOC (short, nsyms);    sprec = XCALLOC (short, nsyms);
1560    sassoc = XCALLOC (short, nsyms);    sassoc = XCALLOC (short, nsyms);
1561    
   /* The EOF token. */  
   tags[0] = DOLLAR;  
   user_toknums[0] = 0;  
   
1562    max_user_token_number = 256;    max_user_token_number = 256;
1563    last_user_token_number = 256;    last_user_token_number = 256;
1564    
# Line 1572  packsymbols (void) Line 1570  packsymbols (void)
1570          }          }
1571        else if (bp->alias)        else if (bp->alias)
1572          {          {
1573            /* this symbol and its alias are a single token defn.            /* This symbol and its alias are a single token defn.
1574               allocate a tokno, and assign to both check agreement of               Allocate a tokno, and assign to both check agreement of
1575               ->prec and ->assoc fields and make both the same */               prec and assoc fields and make both the same */
1576            if (bp->value == 0)            if (bp->value == -1)
1577              bp->value = bp->alias->value = tokno++;              {
1578                  if (bp == eoftoken || bp->alias == eoftoken)
1579                    bp->value = bp->alias->value = 0;
1580                  else
1581                    {
1582                      bp->value = bp->alias->value = tokno++;
1583                    }
1584                }
1585    
1586            if (bp->prec != bp->alias->prec)            if (bp->prec != bp->alias->prec)
1587              {              {
# Line 1602  packsymbols (void) Line 1607  packsymbols (void)
1607                  bp->assoc = bp->alias->assoc;                  bp->assoc = bp->alias->assoc;
1608              }              }
1609    
1610              /* Do not do processing below for SALIASs.  */
1611            if (bp->user_token_number == SALIAS)            if (bp->user_token_number == SALIAS)
1612              continue;           /* do not do processing below for SALIASs */              continue;
1613    
1614          }          }
1615        else                      /* bp->class == token_sym */        else /* bp->class == token_sym */
1616          {          {
1617            bp->value = tokno++;            if (bp == eoftoken)
1618                bp->value = 0;
1619              else
1620                bp->value = tokno++;
1621          }          }
1622    
1623        if (bp->class == token_sym)        if (bp->class == token_sym)
# Line 1774  reader (void) Line 1783  reader (void)
1783    start_flag = 0;    start_flag = 0;
1784    startval = NULL;              /* start symbol not specified yet. */    startval = NULL;              /* start symbol not specified yet. */
1785    
1786    nsyms = 1;    nsyms = 0;
1787    nvars = 0;    nvars = 0;
1788    nrules = 0;    nrules = 0;
1789    nitems = 0;    nitems = 0;
# Line 1818  reader (void) Line 1827  reader (void)
1827       TABLE_OBSTACK and FDEFINES file.  Also notice any %token, %left,       TABLE_OBSTACK and FDEFINES file.  Also notice any %token, %left,
1828       etc. found there.  */       etc. found there.  */
1829    read_declarations ();    read_declarations ();
1830    
1831      /* If the user did not define her EOFTOKEN, do it now. */
1832      if (!eoftoken)
1833        {
1834          eoftoken = getsym ("$");
1835          eoftoken->class = token_sym;
1836          /* Value specified by POSIX.  */
1837          eoftoken->user_token_number = 0;
1838        }
1839    
1840    /* Read in the grammar, build grammar in list form.  Write out    /* Read in the grammar, build grammar in list form.  Write out
1841       guards and actions.  */       guards and actions.  */
1842    readgram ();    readgram ();

Legend:
Removed from v.1.130  
changed lines
  Added in v.1.131

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