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

Diff of /bison/src/lalr.c

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

revision 1.16.2.12 by akim, Wed Dec 5 09:17:05 2001 UTC revision 1.16.2.13 by akim, Wed Dec 5 09:17:20 2001 UTC
# Line 358  initialize_F (void) Line 358  initialize_F (void)
358  {  {
359    int i;    int i;
360    int j;    int j;
   int k;  
   shifts *sp;  
361    short *edge;    short *edge;
362    unsigned *rowp;    unsigned *rowp;
363    short *rp;    short *rp;
364    short **reads;    short **reads;
365    int nedges;    int nedges;
   int stateno;  
366    int symbol;    int symbol;
367    int nwords;    int nwords;
368    
# Line 379  initialize_F (void) Line 376  initialize_F (void)
376    rowp = F;    rowp = F;
377    for (i = 0; i < ngotos; i++)    for (i = 0; i < ngotos; i++)
378      {      {
379        stateno = to_state[i];        int stateno = to_state[i];
380        sp = state_table[stateno].shift_table;        shifts *sp = state_table[stateno].shift_table;
381    
382        if (sp)        if (sp)
383          {          {
384            k = sp->nshifts;            for (j = 0; j < sp->nshifts; j++)
   
           for (j = 0; j < k; j++)  
385              {              {
386                symbol = state_table[sp->shifts[j]].accessing_symbol;                symbol = state_table[sp->shifts[j]].accessing_symbol;
387                if (ISVAR (symbol))                if (ISVAR (symbol))
# Line 394  initialize_F (void) Line 389  initialize_F (void)
389                SETBIT (rowp, symbol);                SETBIT (rowp, symbol);
390              }              }
391    
392            for (; j < k; j++)            for (; j < sp->nshifts; j++)
393              {              {
394                symbol = state_table[sp->shifts[j]].accessing_symbol;                symbol = state_table[sp->shifts[j]].accessing_symbol;
395                if (nullable[symbol])                if (nullable[symbol])
# Line 460  transpose (short **R_arg, int n) Line 455  transpose (short **R_arg, int n)
455    short **new_R;    short **new_R;
456    short **temp_R;    short **temp_R;
457    short *nedges;    short *nedges;
   short *sp;  
458    int i;    int i;
   int k;  
459    
460    nedges = XCALLOC (short, n);    nedges = XCALLOC (short, n);
461    
462    for (i = 0; i < n; i++)    for (i = 0; i < n; i++)
463      {      {
464        sp = R_arg[i];        short *sp = R_arg[i];
465        if (sp)        if (sp)
466          {          {
467            while (*sp >= 0)            while (*sp >= 0)
# Line 480  transpose (short **R_arg, int n) Line 473  transpose (short **R_arg, int n)
473    temp_R = XCALLOC (short *, n);    temp_R = XCALLOC (short *, n);
474    
475    for (i = 0; i < n; i++)    for (i = 0; i < n; i++)
476      {      if (nedges[i] > 0)
477        k = nedges[i];        {
478        if (k > 0)          short *sp = XCALLOC (short, nedges[i] + 1);
479          {          new_R[i] = sp;
480            sp = XCALLOC (short, k + 1);          temp_R[i] = sp;
481            new_R[i] = sp;          sp[nedges[i]] = -1;
482            temp_R[i] = sp;        }
           sp[k] = -1;  
         }  
     }  
483    
484    XFREE (nedges);    XFREE (nedges);
485    
486    for (i = 0; i < n; i++)    for (i = 0; i < n; i++)
487      {      {
488        sp = R_arg[i];        short *sp = R_arg[i];
489        if (sp)        if (sp)
490          {          while (*sp >= 0)
491            while (*sp >= 0)            *temp_R[*sp++]++ = i;
             *temp_R[*sp++]++ = i;  
         }  
492      }      }
493    
494    XFREE (temp_R);    XFREE (temp_R);
# Line 514  build_relations (void) Line 502  build_relations (void)
502  {  {
503    int i;    int i;
504    int j;    int j;
   int k;  
505    short *rulep;    short *rulep;
506    short *rp;    short *rp;
   shifts *sp;  
   int length;  
507    int nedges;    int nedges;
508    int done;    int done;
509    int state1;    int state1;
510    int stateno;    int stateno;
511    int symbol1;    int symbol1;
   int symbol2;  
   short *shortp;  
512    short *edge;    short *edge;
513    short *states;    short *states;
514    short **new_includes;    short **new_includes;
# Line 542  build_relations (void) Line 525  build_relations (void)
525    
526        for (rulep = derives[symbol1]; *rulep > 0; rulep++)        for (rulep = derives[symbol1]; *rulep > 0; rulep++)
527          {          {
528            length = 1;            int length = 1;
529            states[0] = state1;            states[0] = state1;
530            stateno = state1;            stateno = state1;
531    
532            for (rp = ritem + rule_table[*rulep].rhs; *rp > 0; rp++)            for (rp = ritem + rule_table[*rulep].rhs; *rp > 0; rp++)
533              {              {
534                symbol2 = *rp;                int symbol2 = *rp;
535                sp = state_table[stateno].shift_table;                shifts *sp = state_table[stateno].shift_table;
               k = sp->nshifts;  
536    
537                for (j = 0; j < k; j++)                for (j = 0; j < sp->nshifts; j++)
538                  {                  {
539                    stateno = sp->shifts[j];                    stateno = sp->shifts[j];
540                    if (state_table[stateno].accessing_symbol == symbol2)                    if (state_table[stateno].accessing_symbol == symbol2)
# Line 584  build_relations (void) Line 566  build_relations (void)
566    
567        if (nedges)        if (nedges)
568          {          {
569            includes[i] = shortp = XCALLOC (short, nedges + 1);            includes[i] = XCALLOC (short, nedges + 1);
570            for (j = 0; j < nedges; j++)            for (j = 0; j < nedges; j++)
571              shortp[j] = edge[j];              includes[i][j] = edge[j];
572            shortp[nedges] = -1;            includes[i][nedges] = -1;
573          }          }
574      }      }
575    
576    new_includes = transpose (includes, ngotos);    new_includes = transpose (includes, ngotos);
577    
578    for (i = 0; i < ngotos; i++)    for (i = 0; i < ngotos; i++)
579      if (includes[i])      XFREE (includes[i]);
       XFREE (includes[i]);  
   
580    XFREE (includes);    XFREE (includes);
581    
582    includes = new_includes;    includes = new_includes;

Legend:
Removed from v.1.16.2.12  
changed lines
  Added in v.1.16.2.13

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