38 |
static graph_t graph; |
static graph_t graph; |
39 |
static FILE *fgraph = NULL; |
static FILE *fgraph = NULL; |
40 |
|
|
|
static inline const char * |
|
|
escape (const char *s) |
|
|
{ |
|
|
return quotearg_n_style (1, escape_quoting_style, s); |
|
|
} |
|
41 |
|
|
42 |
|
/*----------------------------. |
43 |
|
| Construct the node labels. | |
44 |
|
`----------------------------*/ |
45 |
|
|
|
/* This part will construct the label of nodes. */ |
|
46 |
static void |
static void |
47 |
print_core (struct obstack *oout, state_t *state) |
print_core (struct obstack *oout, state_t *state) |
48 |
{ |
{ |
75 |
if (i) |
if (i) |
76 |
obstack_1grow (oout, '\n'); |
obstack_1grow (oout, '\n'); |
77 |
obstack_fgrow1 (oout, " %s -> ", |
obstack_fgrow1 (oout, " %s -> ", |
78 |
escape (rules[rule].lhs->tag)); |
symbol_tag_get (rules[rule].lhs)); |
79 |
|
|
80 |
for (sp = rules[rule].rhs; sp < sp1; sp++) |
for (sp = rules[rule].rhs; sp < sp1; sp++) |
81 |
obstack_fgrow1 (oout, "%s ", escape (symbols[*sp]->tag)); |
obstack_fgrow1 (oout, "%s ", symbol_tag_get (symbols[*sp])); |
82 |
|
|
83 |
obstack_1grow (oout, '.'); |
obstack_1grow (oout, '.'); |
84 |
|
|
85 |
for (/* Nothing */; *sp >= 0; ++sp) |
for (/* Nothing */; *sp >= 0; ++sp) |
86 |
obstack_fgrow1 (oout, " %s", escape (symbols[*sp]->tag)); |
obstack_fgrow1 (oout, " %s", symbol_tag_get (symbols[*sp])); |
87 |
|
|
88 |
/* Experimental feature: display the lookaheads. */ |
/* Experimental feature: display the lookaheads. */ |
89 |
if (trace_flag && state->nlookaheads) |
if (trace_flag && state->nlookaheads) |
104 |
if (bitset_test (LA[state->lookaheadsp + j], k) |
if (bitset_test (LA[state->lookaheadsp + j], k) |
105 |
&& LArule[state->lookaheadsp + j]->number == rule) |
&& LArule[state->lookaheadsp + j]->number == rule) |
106 |
obstack_fgrow2 (oout, "%s%s", |
obstack_fgrow2 (oout, "%s%s", |
107 |
quotearg_style (escape_quoting_style, |
symbol_tag_get (symbols[k]), |
|
symbols[k]->tag), |
|
108 |
--nlookaheads ? ", " : ""); |
--nlookaheads ? ", " : ""); |
109 |
obstack_sgrow (oout, "]"); |
obstack_sgrow (oout, "]"); |
110 |
} |
} |
152 |
edge.color = red; |
edge.color = red; |
153 |
else |
else |
154 |
edge.color = SHIFT_IS_SHIFT(shiftp, i) ? blue : green; |
edge.color = SHIFT_IS_SHIFT(shiftp, i) ? blue : green; |
155 |
edge.label = escape (symbols[symbol]->tag); |
edge.label = symbol_tag_get (symbols[symbol]); |
156 |
output_edge (&edge, fgraph); |
output_edge (&edge, fgraph); |
157 |
close_edge (fgraph); |
close_edge (fgraph); |
158 |
} |
} |