* 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);
}

813
src/vcg.h

File diff suppressed because it is too large Load Diff