/[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.62 by akim, Sun Apr 7 15:29:36 2002 UTC revision 1.63 by akim, Sun Apr 7 17:41:44 2002 UTC
# Line 1  Line 1 
1  /* Compute look-ahead criteria for bison,  /* Compute look-ahead criteria for bison,
2     Copyright 1984, 1986, 1989, 2000, 2001  Free Software Foundation, Inc.     Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002
3       Free Software Foundation, Inc.
4    
5     This file is part of Bison, the GNU Compiler Compiler.     This file is part of Bison, the GNU Compiler Compiler.
6    
# Line 40  Line 41 
41  /* All the decorated states, indexed by the state number.  */  /* All the decorated states, indexed by the state number.  */
42  state_t **states = NULL;  state_t **states = NULL;
43    
44  short *LAruleno = NULL;  rule_t **LArule = NULL;
45  bitsetv LA = NULL;  bitsetv LA = NULL;
46  size_t nLA;  size_t nLA;
47    
# Line 134  initialize_LA (void) Line 135  initialize_LA (void)
135  {  {
136    size_t i;    size_t i;
137    int j;    int j;
138    short *np;    rule_t **np;
139    
140    /* Avoid having to special case 0.  */    /* Avoid having to special case 0.  */
141    if (!nLA)    if (!nLA)
142      nLA = 1;      nLA = 1;
143    
144    LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);    LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);
145    LAruleno = XCALLOC (short, nLA);    LArule = XCALLOC (rule_t *, nLA);
146    lookback = XCALLOC (shorts *, nLA);    lookback = XCALLOC (shorts *, nLA);
147    
148    np = LAruleno;    np = LArule;
149    for (i = 0; i < nstates; i++)    for (i = 0; i < nstates; i++)
150      if (!states[i]->consistent)      if (!states[i]->consistent)
151        for (j = 0; j < states[i]->reductions->nreds; j++)        for (j = 0; j < states[i]->reductions->nreds; j++)
152          *np++ = states[i]->reductions->rules[j];          *np++ = &rules[states[i]->reductions->rules[j]];
153  }  }
154    
155    
# Line 296  add_lookback_edge (state_t *state, int r Line 297  add_lookback_edge (state_t *state, int r
297    shorts *sp;    shorts *sp;
298    
299    for (i = 0; i < state->nlookaheads; ++i)    for (i = 0; i < state->nlookaheads; ++i)
300      if (LAruleno[state->lookaheadsp + i] == ruleno)      if (LArule[state->lookaheadsp + i]->number == ruleno)
301        break;        break;
302    
303    assert (LAruleno[state->lookaheadsp + i] == ruleno);    assert (LArule[state->lookaheadsp + i]->number == ruleno);
304    
305    sp = XCALLOC (shorts, 1);    sp = XCALLOC (shorts, 1);
306    sp->next = lookback[state->lookaheadsp + i];    sp->next = lookback[state->lookaheadsp + i];
# Line 561  lookaheads_print (FILE *out) Line 562  lookaheads_print (FILE *out)
562            if (bitset_test (LA[states[i]->lookaheadsp + j], j))            if (bitset_test (LA[states[i]->lookaheadsp + j], j))
563              fprintf (out, "   on %d (%s) -> rule %d\n",              fprintf (out, "   on %d (%s) -> rule %d\n",
564                       k, symbols[k]->tag,                       k, symbols[k]->tag,
565                       -LAruleno[states[i]->lookaheadsp + j] - 1);                       LArule[states[i]->lookaheadsp + j]->number - 1);
566      }      }
567    fprintf (out, "Lookaheads: END\n");    fprintf (out, "Lookaheads: END\n");
568  }  }

Legend:
Removed from v.1.62  
changed lines
  Added in v.1.63

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