38 |
|
|
39 |
/* This part will construct the label of nodes. */ |
/* This part will construct the label of nodes. */ |
40 |
static void |
static void |
41 |
print_core (int state, struct obstack *node_obstack) |
print_core (state_t *state, struct obstack *node_obstack) |
42 |
{ |
{ |
43 |
int i; |
int i; |
44 |
short *sitems = state_table[state]->items; |
short *sitems = state->items; |
45 |
int snitems = state_table[state]->nitems; |
int snitems = state->nitems; |
46 |
|
|
47 |
/* Output all the items of a state, not only its kernel. */ |
/* Output all the items of a state, not only its kernel. */ |
48 |
closure (sitems, snitems); |
closure (sitems, snitems); |
49 |
sitems = itemset; |
sitems = itemset; |
50 |
snitems = nitemset; |
snitems = nitemset; |
51 |
|
|
52 |
obstack_fgrow1 (node_obstack, "%2d: ", state); |
obstack_fgrow1 (node_obstack, "%2d: ", state->number); |
53 |
for (i = 0; i < snitems; i++) |
for (i = 0; i < snitems; i++) |
54 |
{ |
{ |
55 |
short *sp; |
short *sp; |
65 |
|
|
66 |
if (i) |
if (i) |
67 |
obstack_sgrow (node_obstack, "\n "); |
obstack_sgrow (node_obstack, "\n "); |
68 |
obstack_fgrow1 (node_obstack, " %s -> ", |
obstack_fgrow1 (node_obstack, " %s -> ", |
69 |
tags[rule_table[rule].lhs]); |
tags[rule_table[rule].lhs]); |
70 |
|
|
71 |
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++) |
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++) |
85 |
`---------------------------------------------------------------*/ |
`---------------------------------------------------------------*/ |
86 |
|
|
87 |
static void |
static void |
88 |
print_actions (int state, const char *node_name) |
print_actions (state_t *state, const char *node_name) |
89 |
{ |
{ |
90 |
int i; |
int i; |
91 |
|
|
92 |
shifts *shiftp = state_table[state]->shifts; |
shifts *shiftp = state->shifts; |
93 |
reductions *redp = state_table[state]->reductions; |
reductions *redp = state->reductions; |
94 |
#if 0 |
#if 0 |
95 |
errs *errp = state_table[state]->errs; |
errs *errp = state->errs; |
96 |
#endif |
#endif |
97 |
|
|
98 |
static char buff[10]; |
static char buff[10]; |
117 |
|
|
118 |
new_edge (&edge); |
new_edge (&edge); |
119 |
|
|
120 |
if (state > state1) |
if (state->number > state1) |
121 |
edge.type = back_edge; |
edge.type = back_edge; |
122 |
open_edge (&edge, fgraph); |
open_edge (&edge, fgraph); |
123 |
/* The edge source is the current node. */ |
/* The edge source is the current node. */ |
155 |
obstack_1grow (node_obstack, '\n'); |
obstack_1grow (node_obstack, '\n'); |
156 |
} |
} |
157 |
|
|
158 |
if (state_table[state]->consistent && redp) |
if (state->consistent && redp) |
159 |
{ |
{ |
160 |
rule = redp->rules[0]; |
rule = redp->rules[0]; |
161 |
symbol = rule_table[rule].lhs; |
symbol = rule_table[rule].lhs; |
176 |
`-------------------------------------------------------------*/ |
`-------------------------------------------------------------*/ |
177 |
|
|
178 |
static void |
static void |
179 |
print_state (int state) |
print_state (state_t *state) |
180 |
{ |
{ |
181 |
static char name[10]; |
static char name[10]; |
182 |
struct obstack node_obstack; |
struct obstack node_obstack; |
185 |
/* The labels of the nodes are their the items. */ |
/* The labels of the nodes are their the items. */ |
186 |
obstack_init (&node_obstack); |
obstack_init (&node_obstack); |
187 |
new_node (&node); |
new_node (&node); |
188 |
sprintf (name, "%d", state); |
sprintf (name, "%d", state->number); |
189 |
node.title = name; |
node.title = name; |
190 |
print_core (state, &node_obstack); |
print_core (state, &node_obstack); |
191 |
obstack_1grow (&node_obstack, '\0'); |
obstack_1grow (&node_obstack, '\0'); |
235 |
/* Output nodes and edges. */ |
/* Output nodes and edges. */ |
236 |
new_closure (nitems); |
new_closure (nitems); |
237 |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
238 |
print_state (i); |
print_state (state_table[i]); |
239 |
free_closure (); |
free_closure (); |
240 |
|
|
241 |
/* Close graph. */ |
/* Close graph. */ |