/[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.17 by akim, Mon Nov 19 09:13:12 2001 UTC revision 1.72.2.18 by akim, Fri Nov 23 14:03:43 2001 UTC
# Line 34  Line 34 
34  #include "reader.h"  #include "reader.h"
35  #include "conflicts.h"  #include "conflicts.h"
36    
 /* Number of slots allocated (but not necessarily used yet) in `rline'  */  
 static int rline_allocated;  
   
37  typedef struct symbol_list  typedef struct symbol_list
38  {  {
39    struct symbol_list *next;    struct symbol_list *next;
40    bucket *sym;    bucket *sym;
41      int line;
42    bucket *ruleprec;    bucket *ruleprec;
43  }  }
44  symbol_list;  symbol_list;
# Line 64  static int lastprec; Line 62  static int lastprec;
62    
63  static bucket *errtoken;  static bucket *errtoken;
64  static bucket *undeftoken;  static bucket *undeftoken;
65    
66    
67    symbol_list *
68    symbol_list_new (bucket *sym)
69    {
70      symbol_list *res = XMALLOC (symbol_list, 1);
71      res->next = NULL;
72      res->sym = sym;
73      res->line = lineno;
74      res->ruleprec = NULL;
75      return res;
76    }
77    
78    
79    
80  /*===================\  /*===================\
# Line 121  read_signed_integer (FILE *stream) Line 132  read_signed_integer (FILE *stream)
132  `--------------------------------------------------------------*/  `--------------------------------------------------------------*/
133    
134  static char *  static char *
135  get_type_name (int n, symbol_list * rule)  get_type_name (int n, symbol_list *rule)
136  {  {
137    int i;    int i;
138    symbol_list *rp;    symbol_list *rp;
# Line 539  parse_token_decl (symbol_class what_is, Line 550  parse_token_decl (symbol_class what_is,
550        else        else
551          {          {
552            complain (_("`%s' is invalid in %s"),            complain (_("`%s' is invalid in %s"),
553                      token_buffer, (what_is == token_sym) ? "%token" : "%nterm");                      token_buffer,
554                        (what_is == token_sym) ? "%token" : "%nterm");
555            skip_to_char ('%');            skip_to_char ('%');
556          }          }
557      }      }
# Line 1357  readgram (void) Line 1369  readgram (void)
1369            nrules++;            nrules++;
1370            nitems++;            nitems++;
1371    
1372            p = XCALLOC (symbol_list, 1);            p = symbol_list_new (lhs);
           p->sym = lhs;  
1373    
1374            crule1 = p1;            crule1 = p1;
1375            if (p1)            if (p1)
# Line 1420  readgram (void) Line 1431  readgram (void)
1431                   non-terminal.  */                   non-terminal.  */
1432                if (action_flag)                if (action_flag)
1433                  {                  {
                   bucket *sdummy;  
   
1434                    /* Since the action was written out with this rule's                    /* Since the action was written out with this rule's
1435                       number, we must give the new rule this number by                       number, we must give the new rule this number by
1436                       inserting the new rule before it.  */                       inserting the new rule before it.  */
1437    
1438                    /* Make a dummy nonterminal, a gensym.  */                    /* Make a dummy nonterminal, a gensym.  */
1439                    sdummy = gensym ();                    bucket *sdummy = gensym ();
1440    
1441                    /* Make a new rule, whose body is empty,                    /* Make a new rule, whose body is empty,
1442                       before the current one, so that the action                       before the current one, so that the action
1443                       just read can belong to it.  */                       just read can belong to it.  */
1444                    nrules++;                    nrules++;
1445                    nitems++;                    nitems++;
1446                    p = XCALLOC (symbol_list, 1);                    p = symbol_list_new (sdummy);
1447                    if (crule1)                    if (crule1)
1448                      crule1->next = p;                      crule1->next = p;
1449                    else                    else
1450                      grammar = p;                      grammar = p;
1451                    p->sym = sdummy;                    /* End of the rule. */
1452                    crule1 = XCALLOC (symbol_list, 1);                    crule1 = symbol_list_new (NULL);
1453                    crule1->next = crule;                    crule1->next = crule;
1454    
1455                    p->next = crule1;                    p->next = crule1;
# Line 1448  readgram (void) Line 1457  readgram (void)
1457                    /* Insert the dummy generated by that rule into this                    /* Insert the dummy generated by that rule into this
1458                       rule.  */                       rule.  */
1459                    nitems++;                    nitems++;
1460                    p = XCALLOC (symbol_list, 1);                    p = symbol_list_new (sdummy);
                   p->sym = sdummy;  
1461                    p1->next = p;                    p1->next = p;
1462                    p1 = p;                    p1 = p;
1463    
# Line 1459  readgram (void) Line 1467  readgram (void)
1467                if (t == tok_identifier)                if (t == tok_identifier)
1468                  {                  {
1469                    nitems++;                    nitems++;
1470                    p = XCALLOC (symbol_list, 1);                    p = symbol_list_new (symval);
                   p->sym = symval;  
1471                    p1->next = p;                    p1->next = p;
1472                    p1 = p;                    p1 = p;
1473                  }                  }
# Line 1474  readgram (void) Line 1481  readgram (void)
1481              }                   /* end of  read rhs of rule */              }                   /* end of  read rhs of rule */
1482    
1483            /* Put an empty link in the list to mark the end of this rule  */            /* Put an empty link in the list to mark the end of this rule  */
1484            p = XCALLOC (symbol_list, 1);            p = symbol_list_new (NULL);
1485            p1->next = p;            p1->next = p;
1486            p1 = p;            p1 = p;
1487    
# Line 1855  packgram (void) Line 1862  packgram (void)
1862    int ruleno;    int ruleno;
1863    symbol_list *p;    symbol_list *p;
1864    
   bucket *ruleprec;  
   
1865    ritem = XCALLOC (short, nitems + 1);    ritem = XCALLOC (short, nitems + 1);
1866    rule_table = XCALLOC (rule_t, nrules) - 1;    rule_table = XCALLOC (rule_t, nrules) - 1;
1867    
# Line 1866  packgram (void) Line 1871  packgram (void)
1871    p = grammar;    p = grammar;
1872    while (p)    while (p)
1873      {      {
1874          bucket *ruleprec = p->ruleprec;
1875        rule_table[ruleno].lhs = p->sym->value;        rule_table[ruleno].lhs = p->sym->value;
1876        rule_table[ruleno].rhs = itemno;        rule_table[ruleno].rhs = itemno;
1877        rule_table[ruleno].line = p->sym->line;        rule_table[ruleno].line = p->line;
       ruleprec = p->ruleprec;  
1878    
1879        p = p->next;        p = p->next;
1880        while (p && p->sym)        while (p && p->sym)

Legend:
Removed from v.1.72.2.17  
changed lines
  Added in v.1.72.2.18

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