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

Diff of /bison/src/print_graph.c

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

revision 1.17 by akim, Mon Dec 10 08:45:22 2001 UTC revision 1.18 by akim, Thu Dec 13 11:01:51 2001 UTC
# Line 28  Line 28 
28  #include "getargs.h"  #include "getargs.h"
29  #include "state.h"  #include "state.h"
30  #include "reader.h"  #include "reader.h"
31    #include "closure.h"
32  #include "obstack.h"  #include "obstack.h"
33  #include "print_graph.h"  #include "print_graph.h"
34  #include "vcg.h"  #include "vcg.h"
# Line 40  static void Line 41  static void
41  print_core (int state, struct obstack *node_obstack)  print_core (int state, struct obstack *node_obstack)
42  {  {
43    int i;    int i;
44    state_t *statep = state_table[state];    short *sitems = state_table[state]->items;
45      int snitems   = state_table[state]->nitems;
46    
47    if (!statep->nitems)    /* Output all the items of a state, not only its kernel.  */
48      return;    closure (sitems, snitems);
49      sitems = itemset;
50      snitems = nitemset;
51    
52    for (i = 0; i < statep->nitems; i++)    obstack_fgrow1 (node_obstack, "%2d: ", state);
53      for (i = 0; i < snitems; i++)
54      {      {
55        short *sp;        short *sp;
56        short *sp1;        short *sp1;
57        int rule;        int rule;
58    
59        sp1 = sp = ritem + statep->items[i];        sp1 = sp = ritem + sitems[i];
60    
61        while (*sp > 0)        while (*sp > 0)
62          sp++;          sp++;
# Line 59  print_core (int state, struct obstack *n Line 64  print_core (int state, struct obstack *n
64        rule = -(*sp);        rule = -(*sp);
65    
66        if (i)        if (i)
67          obstack_1grow (node_obstack, '\n');          obstack_sgrow (node_obstack, "\n    ");
       obstack_fgrow1 (node_obstack, "%d: ", rule);  
68        obstack_fgrow1 (node_obstack, " %s  ->  ",        obstack_fgrow1 (node_obstack, " %s  ->  ",
69                        tags[rule_table[rule].lhs]);                        tags[rule_table[rule].lhs]);
70    
# Line 120  print_actions (int state, const char *no Line 124  print_actions (int state, const char *no
124          edge.sourcename = node_name;          edge.sourcename = node_name;
125          sprintf (buff, "%d", state1);          sprintf (buff, "%d", state1);
126          edge.targetname = buff;          edge.targetname = buff;
127          edge.color = (symbol == 0) ? red : blue;          /* Shifts are blue, gotos are red. */
128            edge.color = SHIFT_IS_SHIFT(shiftp, i) ? blue : red;
129          edge.label = tags[symbol];          edge.label = tags[symbol];
130          output_edge (&edge, fgraph);          output_edge (&edge, fgraph);
131          close_edge (fgraph);          close_edge (fgraph);
# Line 162  print_actions (int state, const char *no Line 167  print_actions (int state, const char *no
167                        rule, tags[symbol]);                        rule, tags[symbol]);
168      }      }
169  #endif  #endif
   
   if (i < shiftp->nshifts)  
     for (; i < shiftp->nshifts; i++)  
       if (!SHIFT_IS_DISABLED (shiftp, i))  
         {  
           int state1 = shiftp->shifts[i];  
           int symbol = state_table[state1]->accessing_symbol;  
   
           new_edge (&edge);  
           open_edge (&edge, fgraph);  
           edge.sourcename = node_name;  
           sprintf (buff, "%d", state1);  
           edge.targetname = buff;  
           edge.color = red;  
           edge.label = tags[symbol];  
           output_edge (&edge, fgraph);  
           close_edge (fgraph);  
         }  
170  }  }
171    
172    
# Line 249  print_graph (void) Line 236  print_graph (void)
236    output_graph (&graph, fgraph);    output_graph (&graph, fgraph);
237    
238    /* Output nodes and edges. */    /* Output nodes and edges. */
239      new_closure (nitems);
240    for (i = 0; i < nstates; i++)    for (i = 0; i < nstates; i++)
241      print_state (i);      print_state (i);
242      free_closure ();
243    
244    /* Close graph. */    /* Close graph. */
245    close_graph (&graph, fgraph);    close_graph (&graph, fgraph);

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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