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

Diff of /bison/src/LR0.c

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

revision 1.27 by akim, Mon Nov 26 13:01:17 2001 UTC revision 1.28 by akim, Wed Nov 28 14:53:29 2001 UTC
# Line 311  new_states (void) Line 311  new_states (void)
311  }  }
312    
313    
314    /*---------------------------------.
315    | Create a new array of N shitfs.  |
316    `---------------------------------*/
317    
318    static shifts *
319    shifts_new (int n)
320    {
321      shifts *res = SHIFTS_ALLOC (n);
322      res->nshifts = n;
323      return res;
324    }
325    
326    
327    /*------------------------------------------------------------.
328    | Save the NSHIFTS of SHIFTSET into the current linked list.  |
329    `------------------------------------------------------------*/
330    
331  static void  static void
332  save_shifts (void)  save_shifts (void)
333  {  {
334    shifts *p = SHIFTS_ALLOC (nshifts);    shifts *p = shifts_new (nshifts);
335    
336    p->number = this_state->number;    p->number = this_state->number;
   p->nshifts = nshifts;  
337    
338    shortcpy (p->shifts, shiftset, nshifts);    shortcpy (p->shifts, shiftset, nshifts);
339    
# Line 348  insert_start_shift (void) Line 364  insert_start_shift (void)
364    last_state = statep;    last_state = statep;
365    
366    /* Make a shift from this state to (what will be) the final state.  */    /* Make a shift from this state to (what will be) the final state.  */
367    sp = SHIFTS_ALLOC (1);    sp = shifts_new (1);
368    sp->number = nstates++;    sp->number = nstates++;
   sp->nshifts = 1;  
369    sp->shifts[0] = nstates;    sp->shifts[0] = nstates;
370    
371    last_shift->next = sp;    last_shift->next = sp;
# Line 405  augment_automaton (void) Line 420  augment_automaton (void)
420    
421                if (sp && sp->number == k)                if (sp && sp->number == k)
422                  {                  {
423                    sp2 = SHIFTS_ALLOC (sp->nshifts + 1);                    sp2 = shifts_new (sp->nshifts + 1);
424                    sp2->number = k;                    sp2->number = k;
                   sp2->nshifts = sp->nshifts + 1;  
425                    sp2->shifts[0] = nstates;                    sp2->shifts[0] = nstates;
426                    for (i = sp->nshifts; i > 0; i--)                    for (i = sp->nshifts; i > 0; i--)
427                      sp2->shifts[i] = sp->shifts[i - 1];                      sp2->shifts[i] = sp->shifts[i - 1];
# Line 422  augment_automaton (void) Line 436  augment_automaton (void)
436                  }                  }
437                else                else
438                  {                  {
439                    sp2 = SHIFTS_ALLOC (1);                    sp2 = shifts_new (1);
440                    sp2->number = k;                    sp2->number = k;
                   sp2->nshifts = 1;  
441                    sp2->shifts[0] = nstates;                    sp2->shifts[0] = nstates;
442    
443                    /* Patch sp2 into the chain of shifts between sp1 and sp.  */                    /* Patch sp2 into the chain of shifts between sp1 and sp.  */
# Line 441  augment_automaton (void) Line 454  augment_automaton (void)
454                   going to the next-to-final state (yet to be made).  */                   going to the next-to-final state (yet to be made).  */
455                sp = first_shift;                sp = first_shift;
456    
457                sp2 = SHIFTS_ALLOC (sp->nshifts + 1);                sp2 = shifts_new (sp->nshifts + 1);
               sp2->nshifts = sp->nshifts + 1;  
458    
459                /* Stick this shift into the vector at the proper place.  */                /* Stick this shift into the vector at the proper place.  */
460                statep = first_state->next;                statep = first_state->next;
# Line 474  augment_automaton (void) Line 486  augment_automaton (void)
486          {          {
487            /* The initial state didn't even have any shifts.            /* The initial state didn't even have any shifts.
488               Give it one shift, to the next-to-final state.  */               Give it one shift, to the next-to-final state.  */
489            sp = SHIFTS_ALLOC (1);            sp = shifts_new (1);
           sp->nshifts = 1;  
490            sp->shifts[0] = nstates;            sp->shifts[0] = nstates;
491    
492            /* Patch sp into the chain of shifts at the beginning.  */            /* Patch sp into the chain of shifts at the beginning.  */
# Line 492  augment_automaton (void) Line 503  augment_automaton (void)
503        /* There are no shifts for any state.        /* There are no shifts for any state.
504           Make one shift, from the initial state to the next-to-final state.  */           Make one shift, from the initial state to the next-to-final state.  */
505    
506        sp = SHIFTS_ALLOC (1);        sp = shifts_new (1);
       sp->nshifts = 1;  
507        sp->shifts[0] = nstates;        sp->shifts[0] = nstates;
508    
509        /* Initialize the chain of shifts with sp.  */        /* Initialize the chain of shifts with sp.  */
# Line 514  augment_automaton (void) Line 524  augment_automaton (void)
524    last_state = statep;    last_state = statep;
525    
526    /* Make the shift from the final state to the termination state.  */    /* Make the shift from the final state to the termination state.  */
527    sp = SHIFTS_ALLOC (1);    sp = shifts_new (1);
528    sp->number = nstates++;    sp->number = nstates++;
   sp->nshifts = 1;  
529    sp->shifts[0] = nstates;    sp->shifts[0] = nstates;
530    last_shift->next = sp;    last_shift->next = sp;
531    last_shift = sp;    last_shift = sp;

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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