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

Diff of /bison/src/nullable.c

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

revision 1.10.2.5 by akim, Mon Nov 19 09:27:37 2001 UTC revision 1.10.2.6 by akim, Wed Dec 5 09:16:22 2001 UTC
# Line 71  set_nullable (void) Line 71  set_nullable (void)
71    relts = XCALLOC (shorts, nitems + nvars + 1);    relts = XCALLOC (shorts, nitems + nvars + 1);
72    p = relts;    p = relts;
73    
74    r = ritem;    for (r = ritem; *r; ++r)
   while (*r)  
75      {      {
76        if (*r < 0)        /* Walk RITEM to find (i), if there are any tokens in the
77          {           RHS, and (ii), to find RULENO. */
78            int symbol = rule_table[-(*r++)].lhs;        int ruleno;
79            if (symbol >= 0 && !nullable[symbol])        int any_tokens = 0;
80              {        short *r1;
81                nullable[symbol] = 1;        for (r1 = r; *r1 > 0; ++r1)
82                *s2++ = symbol;          if (ISTOKEN (*r1))
83              }            any_tokens = 1;
84          }        ruleno = -*r1;
       else  
         {  
           int any_tokens = 0;  
           int symbol;  
           short *r1 = r;  
           for (symbol = *r++; symbol > 0; symbol = *r++)  
             if (ISTOKEN (symbol))  
               any_tokens = 1;  
85    
86            if (!any_tokens)        /* Examine the RHS of the rule.  */
87              {        if (!any_tokens)
88                int ruleno = -symbol;          for (/* Nothing. */; *r > 0; ++r)
89                r = r1;            {
90                for (symbol = *r++; symbol > 0; symbol = *r++)              rcount[ruleno]++;
91                  {              p->next = rsets[*r];
92                    rcount[ruleno]++;              p->value = ruleno;
93                    p->next = rsets[symbol];              rsets[*r] = p;
94                    p->value = ruleno;              p++;
95                    rsets[symbol] = p;            }
96                    p++;  
97                  }        /* Examine its LHS. */
98              }        if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
99          }          {
100              nullable[rule_table[ruleno].lhs] = 1;
101              *s2++ = rule_table[ruleno].lhs;
102            }
103      }      }
104    
105    while (s1 < s2)    while (s1 < s2)

Legend:
Removed from v.1.10.2.5  
changed lines
  Added in v.1.10.2.6

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