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

Diff of /bison/src/closure.c

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

revision 1.43 by akim, Mon Mar 4 13:56:41 2002 UTC revision 1.44 by akim, Mon Mar 4 13:58:05 2002 UTC
# Line 1  Line 1 
1  /* Subroutines for bison  /* Subroutines for bison
2     Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
3    
4     This file is part of Bison, the GNU Compiler Compiler.     This file is part of Bison, the GNU Compiler Compiler.
5    
# Line 19  Line 19 
19     02111-1307, USA.  */     02111-1307, USA.  */
20    
21  #include "system.h"  #include "system.h"
22    #include "bitset.h"
23    #include "bitsetv.h"
24  #include "getargs.h"  #include "getargs.h"
25  #include "symtab.h"  #include "symtab.h"
26  #include "gram.h"  #include "gram.h"
27  #include "reader.h"  #include "reader.h"
28  #include "closure.h"  #include "closure.h"
29  #include "derives.h"  #include "derives.h"
 #include "bitset.h"  
30  #include "warshall.h"  #include "warshall.h"
31    
32  /* NITEMSET is the size of the array ITEMSET.  */  /* NITEMSET is the size of the array ITEMSET.  */
# Line 35  int nitemset; Line 36  int nitemset;
36  static bitset ruleset;  static bitset ruleset;
37    
38  /* internal data.  See comments before set_fderives and set_firsts.  */  /* internal data.  See comments before set_fderives and set_firsts.  */
39  static bitset *fderives = NULL;  static bitsetv fderives = NULL;
40  static bitset *firsts = NULL;  static bitsetv firsts = NULL;
41    
42  /* Retrieve the FDERIVES/FIRSTS sets of the nonterminals numbered Var.  */  /* Retrieve the FDERIVES/FIRSTS sets of the nonterminals numbered Var.  */
43  #define FDERIVES(Var)   fderives[(Var) - ntokens]  #define FDERIVES(Var)   fderives[(Var) - ntokens]
# Line 120  set_firsts (void) Line 121  set_firsts (void)
121  {  {
122    int i, j;    int i, j;
123    
124    firsts = XCALLOC (bitset, nvars);    firsts = bitsetv_create (nvars, nvars, BITSET_FIXED);
125    
126    for (i = ntokens; i < nsyms; i++)    for (i = ntokens; i < nsyms; i++)
127      {      for (j = 0; derives[i][j] >= 0; ++j)
128        FIRSTS (i) = bitset_create (nvars, BITSET_FIXED);        {
129        for (j = 0; derives[i][j] >= 0; ++j)          int symbol = ritem[rules[derives[i][j]].rhs];
130          {          if (ISVAR (symbol))
131            int symbol = ritem[rules[derives[i][j]].rhs];            bitset_set (FIRSTS (i), symbol - ntokens);
132            if (ISVAR (symbol))        }
             bitset_set (FIRSTS (i), symbol - ntokens);  
         }  
     }  
133    
134    RTC (firsts, nvars);    RTC (firsts);
135    
136    if (trace_flag)    if (trace_flag)
137      print_firsts ();      print_firsts ();
# Line 153  set_fderives (void) Line 152  set_fderives (void)
152  {  {
153    int i, j, k;    int i, j, k;
154    
155    fderives = XCALLOC (bitset, nvars);    fderives = bitsetv_create (nvars, nrules + 1, BITSET_FIXED);
   bitset_stats_init ();  
   for (i = 0 ; i < nvars; ++i)  
     fderives[i] = bitset_create (nrules + 1, BITSET_FIXED);  
156    
157    set_firsts ();    set_firsts ();
158    
# Line 169  set_fderives (void) Line 165  set_fderives (void)
165    if (trace_flag)    if (trace_flag)
166      print_fderives ();      print_fderives ();
167    
168    for (i = ntokens; i < nsyms; ++i)    bitsetv_free (firsts);
     bitset_free (FIRSTS (i));  
   XFREE (firsts);  
169  }  }
170    
171    
# Line 246  closure (short *core, int n) Line 240  closure (short *core, int n)
240  void  void
241  free_closure (void)  free_closure (void)
242  {  {
   int i;  
243    XFREE (itemset);    XFREE (itemset);
   
244    bitset_free (ruleset);    bitset_free (ruleset);
245      bitsetv_free (fderives);
   for (i = 0 ; i < nvars; ++i)  
     bitset_free (fderives[i]);  
   free (fderives);  
246  }  }

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

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