/[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.100 by akim, Mon Nov 19 10:26:16 2001 UTC revision 1.101 by akim, Fri Nov 23 14:13:02 2001 UTC
# Line 36  Line 36 
36  #include "conflicts.h"  #include "conflicts.h"
37  #include "muscle_tab.h"  #include "muscle_tab.h"
38    
 /* Number of slots allocated (but not necessarily used yet) in `rline'  */  
 static int rline_allocated;  
   
39  typedef struct symbol_list  typedef struct symbol_list
40  {  {
41    struct symbol_list *next;    struct symbol_list *next;
42    bucket *sym;    bucket *sym;
43      int line;
44    bucket *ruleprec;    bucket *ruleprec;
45  }  }
46  symbol_list;  symbol_list;
# Line 66  static int lastprec; Line 64  static int lastprec;
64    
65  static bucket *errtoken;  static bucket *errtoken;
66  static bucket *undeftoken;  static bucket *undeftoken;
67    
68    
69    symbol_list *
70    symbol_list_new (bucket *sym)
71    {
72      symbol_list *res = XMALLOC (symbol_list, 1);
73      res->next = NULL;
74      res->sym = sym;
75      res->line = lineno;
76      res->ruleprec = NULL;
77      return res;
78    }
79    
80    
81    
82  /*===================\  /*===================\
# Line 123  read_signed_integer (FILE *stream) Line 134  read_signed_integer (FILE *stream)
134  `--------------------------------------------------------------*/  `--------------------------------------------------------------*/
135    
136  static char *  static char *
137  get_type_name (int n, symbol_list * rule)  get_type_name (int n, symbol_list *rule)
138  {  {
139    int i;    int i;
140    symbol_list *rp;    symbol_list *rp;
# Line 568  parse_token_decl (symbol_class what_is, Line 579  parse_token_decl (symbol_class what_is,
579        else        else
580          {          {
581            complain (_("`%s' is invalid in %s"),            complain (_("`%s' is invalid in %s"),
582                      token_buffer, (what_is == token_sym) ? "%token" : "%nterm");                      token_buffer,
583                        (what_is == token_sym) ? "%token" : "%nterm");
584            skip_to_char ('%');            skip_to_char ('%');
585          }          }
586      }      }
# Line 1393  readgram (void) Line 1405  readgram (void)
1405            nrules++;            nrules++;
1406            nitems++;            nitems++;
1407    
1408            p = XCALLOC (symbol_list, 1);            p = symbol_list_new (lhs);
           p->sym = lhs;  
1409    
1410            crule1 = p1;            crule1 = p1;
1411            if (p1)            if (p1)
# Line 1456  readgram (void) Line 1467  readgram (void)
1467                   non-terminal.  */                   non-terminal.  */
1468                if (action_flag)                if (action_flag)
1469                  {                  {
                   bucket *sdummy;  
   
1470                    /* Since the action was written out with this rule's                    /* Since the action was written out with this rule's
1471                       number, we must give the new rule this number by                       number, we must give the new rule this number by
1472                       inserting the new rule before it.  */                       inserting the new rule before it.  */
1473    
1474                    /* Make a dummy nonterminal, a gensym.  */                    /* Make a dummy nonterminal, a gensym.  */
1475                    sdummy = gensym ();                    bucket *sdummy = gensym ();
1476    
1477                    /* Make a new rule, whose body is empty,                    /* Make a new rule, whose body is empty,
1478                       before the current one, so that the action                       before the current one, so that the action
1479                       just read can belong to it.  */                       just read can belong to it.  */
1480                    nrules++;                    nrules++;
1481                    nitems++;                    nitems++;
1482                    p = XCALLOC (symbol_list, 1);                    p = symbol_list_new (sdummy);
1483                    if (crule1)                    if (crule1)
1484                      crule1->next = p;                      crule1->next = p;
1485                    else                    else
1486                      grammar = p;                      grammar = p;
1487                    p->sym = sdummy;                    /* End of the rule. */
1488                    crule1 = XCALLOC (symbol_list, 1);                    crule1 = symbol_list_new (NULL);
1489                    crule1->next = crule;                    crule1->next = crule;
1490    
1491                    p->next = crule1;                    p->next = crule1;
# Line 1484  readgram (void) Line 1493  readgram (void)
1493                    /* Insert the dummy generated by that rule into this                    /* Insert the dummy generated by that rule into this
1494                       rule.  */                       rule.  */
1495                    nitems++;                    nitems++;
1496                    p = XCALLOC (symbol_list, 1);                    p = symbol_list_new (sdummy);
                   p->sym = sdummy;  
1497                    p1->next = p;                    p1->next = p;
1498                    p1 = p;                    p1 = p;
1499    
# Line 1495  readgram (void) Line 1503  readgram (void)
1503                if (t == tok_identifier)                if (t == tok_identifier)
1504                  {                  {
1505                    nitems++;                    nitems++;
1506                    p = XCALLOC (symbol_list, 1);                    p = symbol_list_new (symval);
                   p->sym = symval;  
1507                    p1->next = p;                    p1->next = p;
1508                    p1 = p;                    p1 = p;
1509                  }                  }
# Line 1510  readgram (void) Line 1517  readgram (void)
1517              }                   /* end of  read rhs of rule */              }                   /* end of  read rhs of rule */
1518    
1519            /* 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  */
1520            p = XCALLOC (symbol_list, 1);            p = symbol_list_new (NULL);
1521            p1->next = p;            p1->next = p;
1522            p1 = p;            p1 = p;
1523    
# Line 1903  packgram (void) Line 1910  packgram (void)
1910    int ruleno;    int ruleno;
1911    symbol_list *p;    symbol_list *p;
1912    
   bucket *ruleprec;  
   
1913    ritem = XCALLOC (short, nitems + 1);    ritem = XCALLOC (short, nitems + 1);
1914    rule_table = XCALLOC (rule_t, nrules) - 1;    rule_table = XCALLOC (rule_t, nrules) - 1;
1915    
# Line 1914  packgram (void) Line 1919  packgram (void)
1919    p = grammar;    p = grammar;
1920    while (p)    while (p)
1921      {      {
1922          bucket *ruleprec = p->ruleprec;
1923        rule_table[ruleno].lhs = p->sym->value;        rule_table[ruleno].lhs = p->sym->value;
1924        rule_table[ruleno].rhs = itemno;        rule_table[ruleno].rhs = itemno;
1925        rule_table[ruleno].line = p->sym->line;        rule_table[ruleno].line = p->line;
       ruleprec = p->ruleprec;  
1926    
1927        p = p->next;        p = p->next;
1928        while (p && p->sym)        while (p && p->sym)

Legend:
Removed from v.1.100  
changed lines
  Added in v.1.101

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