/[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.7 by akim, Sat Jun 15 18:24:25 2002 UTC revision 1.8 by akim, Sun Jun 30 17:28:44 2002 UTC
# Line 20  Line 20 
20    
21    
22  #include "system.h"  #include "system.h"
23    #include "complain.h"
24  #include "gram.h"  #include "gram.h"
25  #include "state.h"  #include "state.h"
26    
27    
28                            /*-------------------.
29                            | Shifts and Gotos.  |
30                            `-------------------*/
31    
32    
33  /*---------------------------------.  /*---------------------------------.
34  | Create a new array of N shitfs.  |  | Create a new array of N shitfs.  |
35  `---------------------------------*/  `---------------------------------*/
# Line 40  shifts_new (int n) Line 47  shifts_new (int n)
47  }  }
48    
49    
50    
51    
52                            /*--------------------.
53                            | Error transitions.  |
54                            `--------------------*/
55    
56    
57  /*-------------------------------.  /*-------------------------------.
58  | Create a new array of N errs.  |  | Create a new array of N errs.  |
59  `-------------------------------*/  `-------------------------------*/
# Line 66  errs_dup (errs *src) Line 80  errs_dup (errs *src)
80    return res;    return res;
81  }  }
82    
83    
84    
85    
86                            /*-------------.
87                            | Reductions.  |
88                            `-------------*/
89    
90    
91  /*-------------------------------------.  /*-------------------------------------.
92  | Create a new array of N reductions.  |  | Create a new array of N reductions.  |
93  `-------------------------------------*/  `-------------------------------------*/
# Line 82  reductions_new (int n) Line 104  reductions_new (int n)
104    return res;    return res;
105  }  }
106    
107    
108    
109                            /*---------.
110                            | States.  |
111                            `---------*/
112    
113    
114    state_number_t nstates = 0;
115    /* FINAL_STATE is properly set by new_state when it recognizes its
116       accessing symbol: EOF.  */
117    state_t *final_state = NULL;
118    
119    /*------------------------------------------------------------.
120    | Create a new state with ACCESSING_SYMBOL, for those items.  |
121    `------------------------------------------------------------*/
122    
123    state_t *
124    state_new (symbol_number_t accessing_symbol,
125               size_t core_size, item_number_t *core)
126    {
127      state_t *res;
128    
129      if (nstates >= STATE_NUMBER_MAX)
130        fatal (_("too many states (max %d)"), STATE_NUMBER_MAX);
131    
132    #define STATE_ALLOC(Nitems)                                             \
133      (state_t *) xcalloc ((unsigned) (sizeof (state_t)                     \
134                                      + (Nitems - 1) * sizeof (item_number_t)), 1)
135    
136      res = STATE_ALLOC (core_size);
137      res->accessing_symbol = accessing_symbol;
138      res->number = nstates;
139      ++nstates;
140      res->solved_conflicts = NULL;
141    
142      res->nitems = core_size;
143      memcpy (res->items, core, core_size * sizeof (core[0]));
144    
145      return res;
146    }
147    
148    
149  /*--------------------------------------------------------------.  /*--------------------------------------------------------------.
150  | 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.7  
changed lines
  Added in v.1.8

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