/[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.70 by akim, Sat Jun 15 18:24:08 2002 UTC revision 1.71 by akim, Sun Jun 30 17:27:34 2002 UTC
# Line 48  size_t nLA; Line 48  size_t nLA;
48    
49  static int ngotos;  static int ngotos;
50  short *goto_map = NULL;  short *goto_map = NULL;
51  short *from_state = NULL;  state_number_t *from_state = NULL;
52  short *to_state = NULL;  state_number_t *to_state = NULL;
53    
54  /* And for the famous F variable, which name is so descriptive that a  /* And for the famous F variable, which name is so descriptive that a
55     comment is hardly needed.  <grin>.  */     comment is hardly needed.  <grin>.  */
# Line 134  digraph (short **relation) Line 134  digraph (short **relation)
134  static void  static void
135  initialize_LA (void)  initialize_LA (void)
136  {  {
137    size_t i;    state_number_t i;
138    int j;    int j;
139    rule_t **np;    rule_t **np;
140    
# Line 157  initialize_LA (void) Line 157  initialize_LA (void)
157  static void  static void
158  set_goto_map (void)  set_goto_map (void)
159  {  {
160    size_t state;    state_number_t state;
   int i;  
161    short *temp_map;    short *temp_map;
162    
163    goto_map = XCALLOC (short, nvars + 1) - ntokens;    goto_map = XCALLOC (short, nvars + 1) - ntokens;
# Line 168  set_goto_map (void) Line 167  set_goto_map (void)
167    for (state = 0; state < nstates; ++state)    for (state = 0; state < nstates; ++state)
168      {      {
169        shifts *sp = states[state]->shifts;        shifts *sp = states[state]->shifts;
170          int i;
171        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
172          {          {
173            if (ngotos == SHRT_MAX)            if (ngotos == SHRT_MAX)
# Line 180  set_goto_map (void) Line 180  set_goto_map (void)
180    
181    {    {
182      int k = 0;      int k = 0;
183        int i;
184      for (i = ntokens; i < nsyms; i++)      for (i = ntokens; i < nsyms; i++)
185        {        {
186          temp_map[i] = k;          temp_map[i] = k;
# Line 193  set_goto_map (void) Line 194  set_goto_map (void)
194      temp_map[nsyms] = ngotos;      temp_map[nsyms] = ngotos;
195    }    }
196    
197    from_state = XCALLOC (short, ngotos);    from_state = XCALLOC (state_number_t, ngotos);
198    to_state = XCALLOC (short, ngotos);    to_state = XCALLOC (state_number_t, ngotos);
199    
200    for (state = 0; state < nstates; ++state)    for (state = 0; state < nstates; ++state)
201      {      {
202        shifts *sp = states[state]->shifts;        shifts *sp = states[state]->shifts;
203          int i;
204        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
205          {          {
206            int k = temp_map[SHIFT_SYMBOL (sp, i)]++;            int k = temp_map[SHIFT_SYMBOL (sp, i)]++;
# Line 217  set_goto_map (void) Line 219  set_goto_map (void)
219  `----------------------------------------------------------*/  `----------------------------------------------------------*/
220    
221  static int  static int
222  map_goto (int state, symbol_number_t symbol)  map_goto (state_number_t state, symbol_number_t symbol)
223  {  {
224    int high;    int high;
225    int low;    int low;
226    int middle;    int middle;
227    int s;    state_number_t s;
228    
229    low = goto_map[symbol];    low = goto_map[symbol];
230    high = goto_map[symbol + 1] - 1;    high = goto_map[symbol + 1] - 1;
# Line 258  initialize_F (void) Line 260  initialize_F (void)
260    
261    for (i = 0; i < ngotos; i++)    for (i = 0; i < ngotos; i++)
262      {      {
263        int stateno = to_state[i];        state_number_t stateno = to_state[i];
264        shifts *sp = states[stateno]->shifts;        shifts *sp = states[stateno]->shifts;
265    
266        int j;        int j;
# Line 400  static void Line 402  static void
402  build_relations (void)  build_relations (void)
403  {  {
404    short *edge = XCALLOC (short, ngotos + 1);    short *edge = XCALLOC (short, ngotos + 1);
405    short *states1 = XCALLOC (short, ritem_longest_rhs () + 1);    state_number_t *states1 = XCALLOC (state_number_t, ritem_longest_rhs () + 1);
406    int i;    int i;
407    
408    includes = XCALLOC (short *, ngotos);    includes = XCALLOC (short *, ngotos);
# Line 514  compute_lookaheads (void) Line 516  compute_lookaheads (void)
516  static void  static void
517  states_lookaheads_count (void)  states_lookaheads_count (void)
518  {  {
519    size_t i;    state_number_t i;
520    nLA = 0;    nLA = 0;
521    
522    /* Count   */    /* Count   */
# Line 555  states_lookaheads_count (void) Line 557  states_lookaheads_count (void)
557  static void  static void
558  states_lookaheads_initialize (void)  states_lookaheads_initialize (void)
559  {  {
560    size_t i;    state_number_t i;
561    bitsetv pLA = LA;    bitsetv pLA = LA;
562    rule_t **pLArule = LArule;    rule_t **pLArule = LArule;
563    
# Line 578  states_lookaheads_initialize (void) Line 580  states_lookaheads_initialize (void)
580  static void  static void
581  lookaheads_print (FILE *out)  lookaheads_print (FILE *out)
582  {  {
583    size_t i;    state_number_t i;
584    int j, k;    int j, k;
585    fprintf (out, "Lookaheads: BEGIN\n");    fprintf (out, "Lookaheads: BEGIN\n");
586    for (i = 0; i < nstates; ++i)    for (i = 0; i < nstates; ++i)

Legend:
Removed from v.1.70  
changed lines
  Added in v.1.71

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