* src/vcg.c (complain.h): Include it.

Unepitaize `return' invocations.
[NDEBUG] (main): Remove.
* src/vcg.h (node_t, edge_t, graph_t): Constify the char * memebers.
* src/files.c (open_files): Initialize graph_obstack.
* src/print_graph.c (print_actions): CPP out useless code.
(print_core): Don't output the last `n' in labels.
Use `quote'.
* src/files.c (output_files): Output the VCG file.
* src/main.c (main): Invoke print_graph ();
This commit is contained in:
Akim Demaille
2001-08-07 07:58:43 +00:00
parent ea4e548a4a
commit c4b661269e
5 changed files with 435 additions and 417 deletions

View File

@@ -1,9 +1,15 @@
2001-08-06 Akim Demaille <akim@epita.fr>, Marc Autret <autret_@epita.fr>
* src/print_graph.c (print_actions): CPP out useless code.
* src/vcg.c (complain.h): Include it.
Unepitaize `return' invocations.
* src/vcg.c [NDEBUG] (main): Remove.
[NDEBUG] (main): Remove.
* src/vcg.h (node_t, edge_t, graph_t): Constify the char * memebers.
* src/files.c (open_files): Initialize graph_obstack.
* src/print_graph.c (print_actions): CPP out useless code.
(print_core): Don't output the last `\n' in labels.
Use `quote'.
* src/files.c (output_files): Output the VCG file.
* src/main.c (main): Invoke print_graph ();
2001-08-06 Marc Autret <autret_@epita.fr>

View File

@@ -349,6 +349,7 @@ open_files (void)
obstack_init (&defines_obstack);
obstack_init (&guard_obstack);
obstack_init (&output_obstack);
obstack_init (&graph_obstack);
}
@@ -407,4 +408,7 @@ output_files (void)
/* We used to use just .out if spec_name_prefix (-p) was used, but
that conflicts with Posix. */
obstack_save (&output_obstack, stringappend (short_base_name, EXT_OUTPUT));
if (graph_flag)
obstack_save (&graph_obstack, stringappend (short_base_name, ".vcg"));
}

View File

@@ -33,6 +33,7 @@
#include "print.h"
#include "LR0.h"
#include "conflicts.h"
#include "print_graph.h"
/* The name this program was run with, for messages. */
char *program_name;
@@ -83,6 +84,9 @@ main (int argc, char *argv[])
/* Print information about results, if requested. */
print_results ();
/* Output the VCG graph. */
print_graph ();
/* Output the tables and the parser to ftable. In file output. */
output ();

View File

@@ -32,6 +32,7 @@
#include "obstack.h"
#include "print_graph.h"
#include "vcg.h"
#include "quote.h"
static graph_t graph;
@@ -56,6 +57,9 @@ print_core (int state)
for (i = 0; i < k; i++)
{
if (i)
obstack_sgrow (&graph_obstack, "\\n");
sp1 = sp = ritem + statep->items[i];
while (*sp > 0)
@@ -64,17 +68,16 @@ print_core (int state)
rule = -(*sp);
obstack_fgrow1 (&graph_obstack, _("%d: "), rule);
obstack_fgrow1 (&graph_obstack, " %s -> ", tags[rlhs[rule]]);
obstack_fgrow1 (&graph_obstack, " %s -> ", quote (tags[rlhs[rule]]));
for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
obstack_fgrow1 (&graph_obstack, "%s ", tags[*sp]);
obstack_fgrow1 (&graph_obstack, "%s ", quote (tags[*sp]));
obstack_1grow (&graph_obstack, '.');
while (*sp > 0)
obstack_fgrow1 (&graph_obstack, " %s", tags[*sp++]);
obstack_fgrow1 (&graph_obstack, " %s", quote (tags[*sp++]));
obstack_sgrow (&graph_obstack, "\\n");
}
obstack_sgrow (&graph_obstack, "\"\n");
}
@@ -129,10 +132,12 @@ print_actions (int state, node_t *node)
edge.type = back_edge;
open_edge (&edge, &graph_obstack);
edge.sourcename = node->title;
sprintf (buff, "%d", state1);
edge.targetname = buff;
sprintf (edge.targetname, "%d", state1);
edge.color = (symbol == 0) ? blue : red;
edge.label = tags[symbol];
/* FIXME: Be aware that quote uses static memory. The string
must be output immediately (which is the case here). */
edge.label = tags[symbol] ? quote (tags[symbol]) : NULL;
output_edge (&edge, &graph_obstack);
close_edge (&graph_obstack);
}
@@ -176,10 +181,10 @@ print_actions (int state, node_t *node)
new_edge (&edge);
open_edge (&edge, &graph_obstack);
edge.sourcename = node->title;
sprintf (buff, "%d", state1);
edge.targetname = buff;
edge.color = red;
sprintf (edge.targetname, "%d", state1);
edge.label = tags[symbol];
edge.label = tags[symbol] ? quote (tags[symbol]) : NULL;
output_edge (&edge, &graph_obstack);
close_edge (&graph_obstack);
}

View File

@@ -329,16 +329,16 @@ struct edge_s
/* Sourcename is the title of the source node of the edge.
Default: none. */
char *sourcename; /* Mandatory. */
const char *sourcename; /* Mandatory. */
/* Targetname is the title of the target node of the edge.
Default: none. */
char *targetname; /* Mandatory. */
const char *targetname; /* Mandatory. */
/* Label specifies the label of the edge. It is drawn if
display.edge.labels is set to yes.
Default: no label. */
char *label;
const char *label;
/* Linestyle specifies the style the edge is drawn. Possibilities are:
ffl continuous a solid line is drawn ( -- ) ffl dashed the edge
@@ -459,7 +459,7 @@ struct graph_s
the root of the first subgraph in the graph, if the subgraph is
visualized explicitly.
By default, it's the name of the vcg graph file description. */
char *title;
const char *title;
/* Graph label.
Label the text displayed inside the node, when the graph is folded
@@ -467,7 +467,7 @@ struct graph_s
be used. Note that this text may contain control characters like
NEWLINE that influences the size of the node.
By default, it takes the title value */
char *label;
const char *label;
/* Any informations.
Info1, info2, info3 combines additional text labels with a node or a
@@ -475,7 +475,7 @@ struct graph_s
interactively. The corresponding text labels can be shown by mouse
clicks on nodes.
Defalut values are empty strings (here NULL pointers) */
char *infos[3];
const char *infos[3];
/* Background color and summary node colors
Color specifies the background color for the outermost graph, or the
@@ -972,4 +972,3 @@ void output_graph PARAMS ((graph_t *graph, struct obstack *os));
void close_graph PARAMS ((graph_t *graph, struct obstack *os));
#endif /* VCG_H_ */