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

Diff of /bison/src/state.c

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

revision 1.10 by akim, Sun Jun 30 17:30:29 2002 UTC revision 1.11 by akim, Sun Jun 30 17:30:46 2002 UTC
# Line 61  shifts_new (int nshifts, state_number_t Line 61  shifts_new (int nshifts, state_number_t
61  `-------------------------------*/  `-------------------------------*/
62    
63  #define ERRS_ALLOC(Nerrs)                                               \  #define ERRS_ALLOC(Nerrs)                                               \
64    (errs *) xcalloc ((unsigned) (sizeof (errs)                           \    (errs_t *) xcalloc ((unsigned) (sizeof (errs_t)                       \
65                                    + (Nerrs - 1) * sizeof (short)), 1)                                    + (Nerrs - 1) * sizeof (short)), 1)
66    
67    
68  errs *  errs_t *
69  errs_new (int n)  errs_new (int n)
70  {  {
71    errs *res = ERRS_ALLOC (n);    errs_t *res = ERRS_ALLOC (n);
72    res->nerrs = n;    res->nerrs = n;
73    return res;    return res;
74  }  }
75    
76    
77  errs *  errs_t *
78  errs_dup (errs *src)  errs_dup (errs_t *src)
79  {  {
80    errs *res = errs_new (src->nerrs);    errs_t *res = errs_new (src->nerrs);
81    memcpy (res->errs, src->errs, src->nerrs * sizeof (src->errs[0]));    memcpy (res->errs, src->errs, src->nerrs * sizeof (src->errs[0]));
82    return res;    return res;
83  }  }
# Line 95  errs_dup (errs *src) Line 95  errs_dup (errs *src)
95  `-------------------------------------*/  `-------------------------------------*/
96    
97  #define REDUCTIONS_ALLOC(Nreductions)                                   \  #define REDUCTIONS_ALLOC(Nreductions)                                   \
98    (reductions *) xcalloc ((unsigned) (sizeof (reductions)               \    (reductions_t *) xcalloc ((unsigned) (sizeof (reductions_t)           \
99                                    + (Nreductions - 1) * sizeof (short)), 1)                                    + (Nreductions - 1) * sizeof (short)), 1)
100    
101  reductions *  static reductions_t *
102  reductions_new (int n)  reductions_new (int nreductions, short *reductions)
103  {  {
104    reductions *res = REDUCTIONS_ALLOC (n);    reductions_t *res = REDUCTIONS_ALLOC (nreductions);
105    res->nreds = n;    res->nreds = nreductions;
106      memcpy (res->rules, reductions, nreductions * sizeof (reductions[0]));
107    return res;    return res;
108  }  }
109    
# Line 159  state_shifts_set (state_t *state, int ns Line 160  state_shifts_set (state_t *state, int ns
160  }  }
161    
162    
163    /*------------------------------.
164    | Set the reductions of STATE.  |
165    `------------------------------*/
166    
167    void
168    state_reductions_set (state_t *state, int nreductions, short *reductions)
169    {
170      state->reductions = reductions_new (nreductions, reductions);
171    }
172    
173    
174    
175  /*--------------------------------------------------------------.  /*--------------------------------------------------------------.
176  | Print on OUT all the lookaheads such that this STATE wants to |  | Print on OUT all the lookaheads such that this STATE wants to |

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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