mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
* 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.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2001-08-06 Marc Autret <autret_@epita.fr>
|
2001-08-06 Marc Autret <autret_@epita.fr>
|
||||||
|
|
||||||
Automaton VCG graph output.
|
Automaton VCG graph output.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ print_core (int state)
|
|||||||
if (k == 0)
|
if (k == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
obstack_sgrow(&graph_obstack, "\t\tlabel:\t\"");
|
obstack_sgrow (&graph_obstack, "\t\tlabel:\t\"");
|
||||||
|
|
||||||
for (i = 0; i < k; i++)
|
for (i = 0; i < k; i++)
|
||||||
{
|
{
|
||||||
@@ -63,20 +63,20 @@ print_core (int state)
|
|||||||
|
|
||||||
rule = -(*sp);
|
rule = -(*sp);
|
||||||
|
|
||||||
obstack_fgrow1(&graph_obstack, _("%d: "), rule);
|
obstack_fgrow1 (&graph_obstack, _("%d: "), rule);
|
||||||
obstack_fgrow1(&graph_obstack, " %s -> ", tags[rlhs[rule]]);
|
obstack_fgrow1 (&graph_obstack, " %s -> ", tags[rlhs[rule]]);
|
||||||
|
|
||||||
for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
|
for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
|
||||||
obstack_fgrow1(&graph_obstack, "%s ", tags[*sp]);
|
obstack_fgrow1 (&graph_obstack, "%s ", tags[*sp]);
|
||||||
|
|
||||||
obstack_1grow(&graph_obstack, '.');
|
obstack_1grow (&graph_obstack, '.');
|
||||||
|
|
||||||
while (*sp > 0)
|
while (*sp > 0)
|
||||||
obstack_fgrow1(&graph_obstack, " %s", tags[*sp++]);
|
obstack_fgrow1 (&graph_obstack, " %s", tags[*sp++]);
|
||||||
|
|
||||||
obstack_sgrow(&graph_obstack, "\\n");
|
obstack_sgrow (&graph_obstack, "\\n");
|
||||||
}
|
}
|
||||||
obstack_sgrow(&graph_obstack, "\"\n");
|
obstack_sgrow (&graph_obstack, "\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -99,10 +99,12 @@ print_actions (int state, node_t *node)
|
|||||||
|
|
||||||
if (!shiftp && !redp)
|
if (!shiftp && !redp)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (final_state == state)
|
if (final_state == state)
|
||||||
;//fprintf(f, " $default\taccept\n");
|
fprintf (f, " $default\taccept\n");
|
||||||
else
|
else
|
||||||
;//fprintf(f, " NO ACTIONS\n");
|
fprintf (f, " NO ACTIONS\n");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,11 +195,11 @@ print_state (int state)
|
|||||||
new_node (&node);
|
new_node (&node);
|
||||||
open_node (&graph_obstack);
|
open_node (&graph_obstack);
|
||||||
|
|
||||||
sprintf(name, "%d", state);
|
sprintf (name, "%d", state);
|
||||||
node.title = name;
|
node.title = name;
|
||||||
output_node (&node, &graph_obstack);
|
output_node (&node, &graph_obstack);
|
||||||
|
|
||||||
print_core (state); /* node label */
|
print_core (state); /* node label */
|
||||||
|
|
||||||
close_node (&graph_obstack);
|
close_node (&graph_obstack);
|
||||||
|
|
||||||
@@ -211,7 +213,7 @@ print_graph (void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!graph_flag)
|
if (!graph_flag)
|
||||||
return ;
|
return;
|
||||||
new_graph (&graph);
|
new_graph (&graph);
|
||||||
|
|
||||||
/* graph.smanhattan_edges = yes;
|
/* graph.smanhattan_edges = yes;
|
||||||
@@ -233,8 +235,8 @@ print_graph (void)
|
|||||||
output_graph (&graph, &graph_obstack);
|
output_graph (&graph, &graph_obstack);
|
||||||
|
|
||||||
for (i = 0; i < nstates; i++)
|
for (i = 0; i < nstates; i++)
|
||||||
/* Output nodes & edges. */
|
/* Output nodes & edges. */
|
||||||
print_state (i);
|
print_state (i);
|
||||||
|
|
||||||
/* Close graph. */
|
/* Close graph. */
|
||||||
close_graph (&graph, &graph_obstack);
|
close_graph (&graph, &graph_obstack);
|
||||||
|
|||||||
14
src/reader.c
14
src/reader.c
@@ -882,16 +882,11 @@ static void
|
|||||||
parse_header_extension_decl (void)
|
parse_header_extension_decl (void)
|
||||||
{
|
{
|
||||||
char buff[32];
|
char buff[32];
|
||||||
int len;
|
|
||||||
|
|
||||||
if (header_extension)
|
if (header_extension)
|
||||||
complain (_("multiple %%header_extension declarations"));
|
complain (_("multiple %%header_extension declarations"));
|
||||||
fscanf (finput, "%s", buff);
|
fscanf (finput, "%s", buff);
|
||||||
printf("-> %s\n", buff);
|
header_extension = xstrdup (buff);
|
||||||
len = strlen (buff);
|
|
||||||
buff[len] = '\0';
|
|
||||||
src_extension = XMALLOC (char, len + 1);
|
|
||||||
stpcpy (header_extension, buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------.
|
/*------------------------------------------.
|
||||||
@@ -902,16 +897,11 @@ static void
|
|||||||
parse_source_extension_decl (void)
|
parse_source_extension_decl (void)
|
||||||
{
|
{
|
||||||
char buff[32];
|
char buff[32];
|
||||||
int len;
|
|
||||||
|
|
||||||
if (src_extension)
|
if (src_extension)
|
||||||
complain (_("multiple %%source_extension declarations"));
|
complain (_("multiple %%source_extension declarations"));
|
||||||
fscanf (finput, "%s", buff);
|
fscanf (finput, "%s", buff);
|
||||||
printf("-> %s\n", buff);
|
src_extension = xstrdup (buff);
|
||||||
len = strlen (buff);
|
|
||||||
buff[len] = '\0';
|
|
||||||
src_extension = XMALLOC (char, len + 1);
|
|
||||||
stpcpy (src_extension, buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
/*----------------------------------------------------------------.
|
||||||
|
|||||||
237
src/vcg.c
237
src/vcg.c
@@ -22,6 +22,7 @@
|
|||||||
#include "vcg.h"
|
#include "vcg.h"
|
||||||
#include "vcg_defaults.h"
|
#include "vcg_defaults.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
#include "complain.h"
|
||||||
|
|
||||||
/* Initialize a graph with the default values. */
|
/* Initialize a graph with the default values. */
|
||||||
void
|
void
|
||||||
@@ -197,41 +198,41 @@ get_color_str (enum color_e c)
|
|||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case white: return ("white");
|
case white: return "white";
|
||||||
case blue: return ("blue");
|
case blue: return "blue";
|
||||||
case red: return ("red");
|
case red: return "red";
|
||||||
case green: return ("green");
|
case green: return "green";
|
||||||
case yellow: return ("yellow");
|
case yellow: return "yellow";
|
||||||
case magenta: return ("magenta");
|
case magenta: return "magenta";
|
||||||
case cyan: return ("cyan");
|
case cyan: return "cyan";
|
||||||
case darkgrey: return ("darkgrey");
|
case darkgrey: return "darkgrey";
|
||||||
case darkblue: return ("darkblue");
|
case darkblue: return "darkblue";
|
||||||
case darkred: return ("darkred");
|
case darkred: return "darkred";
|
||||||
case darkgreen: return ("darkgreen");
|
case darkgreen: return "darkgreen";
|
||||||
case darkyellow: return ("darkyellow");
|
case darkyellow: return "darkyellow";
|
||||||
case darkmagenta: return ("darkmagenta");
|
case darkmagenta: return "darkmagenta";
|
||||||
case darkcyan: return ("darkcyan");
|
case darkcyan: return "darkcyan";
|
||||||
case gold: return ("gold");
|
case gold: return "gold";
|
||||||
case lightgrey: return ("lightgrey");
|
case lightgrey: return "lightgrey";
|
||||||
case lightblue: return ("lightblue");
|
case lightblue: return "lightblue";
|
||||||
case lightred: return ("lightred");
|
case lightred: return "lightred";
|
||||||
case lightgreen: return ("lightgreen");
|
case lightgreen: return "lightgreen";
|
||||||
case lightyellow: return ("lightyellow");
|
case lightyellow: return "lightyellow";
|
||||||
case lightmagenta: return ("lightmagenta");
|
case lightmagenta: return "lightmagenta";
|
||||||
case lightcyan: return ("lightcyan");
|
case lightcyan: return "lightcyan";
|
||||||
case lilac: return ("lilac");
|
case lilac: return "lilac";
|
||||||
case turquoise: return ("turquoise");
|
case turquoise: return "turquoise";
|
||||||
case aquamarine: return ("aquamarine");
|
case aquamarine: return "aquamarine";
|
||||||
case khaki: return ("khaki");
|
case khaki: return "khaki";
|
||||||
case purple: return ("purple");
|
case purple: return "purple";
|
||||||
case yellowgreen: return ("yellowgreen");
|
case yellowgreen: return "yellowgreen";
|
||||||
case pink: return ("pink");
|
case pink: return "pink";
|
||||||
case orange: return ("orange");
|
case orange: return "orange";
|
||||||
case orchid: return ("orchid");
|
case orchid: return "orchid";
|
||||||
case black: return ("black");
|
case black: return "black";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a color."));
|
complain (_("vcg graph: no such a color."));
|
||||||
return (get_color_str(G_COLOR));
|
return get_color_str(G_COLOR);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -241,12 +242,12 @@ get_textmode_str (enum textmode_e t)
|
|||||||
{
|
{
|
||||||
switch (t)
|
switch (t)
|
||||||
{
|
{
|
||||||
case centered: return ("center");
|
case centered: return "center";
|
||||||
case left_justify: return ("left_justify");
|
case left_justify: return "left_justify";
|
||||||
case right_justify: return ("right_justify");
|
case right_justify: return "right_justify";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a text mode.."));
|
complain (_("vcg graph: no such a text mode.."));
|
||||||
return (get_textmode_str(G_TEXTMODE));
|
return get_textmode_str(G_TEXTMODE);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -256,13 +257,13 @@ get_shape_str (enum shape_e s)
|
|||||||
{
|
{
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case box: return ("box");
|
case box: return "box";
|
||||||
case rhomb: return ("rhomb");
|
case rhomb: return "rhomb";
|
||||||
case ellipse: return ("ellipse");
|
case ellipse: return "ellipse";
|
||||||
case triangle: return ("triangle");
|
case triangle: return "triangle";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a shape.."));
|
complain (_("vcg graph: no such a shape.."));
|
||||||
return (get_shape_str(G_SHAPE));
|
return get_shape_str(G_SHAPE);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -272,22 +273,22 @@ get_layoutalgorithm_str (enum layoutalgorithm_e l)
|
|||||||
{
|
{
|
||||||
switch (l)
|
switch (l)
|
||||||
{
|
{
|
||||||
case normal: return ("normal");
|
case normal: return "normal";
|
||||||
case maxdepth: return ("maxdepth");
|
case maxdepth: return "maxdepth";
|
||||||
case mindepth: return ("mindepth");
|
case mindepth: return "mindepth";
|
||||||
case maxdepthslow: return ("maxdepthslow");
|
case maxdepthslow: return "maxdepthslow";
|
||||||
case mindepthslow: return ("mindepthslow");
|
case mindepthslow: return "mindepthslow";
|
||||||
case maxdegree: return ("maxdegree");
|
case maxdegree: return "maxdegree";
|
||||||
case mindegree: return ("mindegree");
|
case mindegree: return "mindegree";
|
||||||
case maxindegree: return ("maxindegree");
|
case maxindegree: return "maxindegree";
|
||||||
case minindegree: return ("minindegree");
|
case minindegree: return "minindegree";
|
||||||
case maxoutdegree: return ("maxoutdegree");
|
case maxoutdegree: return "maxoutdegree";
|
||||||
case minoutdegree: return ("minoutdegree");
|
case minoutdegree: return "minoutdegree";
|
||||||
case minbackward: return ("minbackward");
|
case minbackward: return "minbackward";
|
||||||
case dfs: return ("dfs");
|
case dfs: return "dfs";
|
||||||
case tree: return ("tree");
|
case tree: return "tree";
|
||||||
default:
|
default:
|
||||||
return ("normal");
|
return "normal";
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -297,11 +298,11 @@ get_decision_str (enum decision_e d, enum decision_e defaults)
|
|||||||
{
|
{
|
||||||
switch (d)
|
switch (d)
|
||||||
{
|
{
|
||||||
case no: return ("no");
|
case no: return "no";
|
||||||
case yes: return ("yes");
|
case yes: return "yes";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a decision.."));
|
complain (_("vcg graph: no such a decision.."));
|
||||||
return (get_decision_str(defaults, 0));
|
return get_decision_str(defaults, 0);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -311,13 +312,13 @@ get_orientation_str (enum orientation_e o)
|
|||||||
{
|
{
|
||||||
switch (o)
|
switch (o)
|
||||||
{
|
{
|
||||||
case top_to_bottom: return ("top_to_bottom");
|
case top_to_bottom: return "top_to_bottom";
|
||||||
case bottom_to_top: return ("bottom_to_top");
|
case bottom_to_top: return "bottom_to_top";
|
||||||
case left_to_right: return ("left_to_right");
|
case left_to_right: return "left_to_right";
|
||||||
case right_to_left: return ("right_to_left");
|
case right_to_left: return "right_to_left";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such an orientation.."));
|
complain (_("vcg graph: no such an orientation.."));
|
||||||
return (get_orientation_str(G_ORIENTATION));
|
return get_orientation_str(G_ORIENTATION);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -327,12 +328,12 @@ get_node_alignement_str (enum alignement_e a)
|
|||||||
{
|
{
|
||||||
switch (a)
|
switch (a)
|
||||||
{
|
{
|
||||||
case center: return ("center");
|
case center: return "center";
|
||||||
case top: return ("top");
|
case top: return "top";
|
||||||
case bottom: return ("bottom");
|
case bottom: return "bottom";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such an alignement.."));
|
complain (_("vcg graph: no such an alignement.."));
|
||||||
return (get_node_alignement_str(G_NODE_ALIGNEMENT));
|
return get_node_alignement_str(G_NODE_ALIGNEMENT);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -342,11 +343,11 @@ get_arrow_mode_str (enum arrow_mode_e a)
|
|||||||
{
|
{
|
||||||
switch (a)
|
switch (a)
|
||||||
{
|
{
|
||||||
case fixed: return ("fixed");
|
case fixed: return "fixed";
|
||||||
case free_a: return ("free");
|
case free_a: return "free";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such an arrow mode.."));
|
complain (_("vcg graph: no such an arrow mode.."));
|
||||||
return (get_arrow_mode_str(G_ARROW_MODE));
|
return get_arrow_mode_str(G_ARROW_MODE);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -356,13 +357,13 @@ get_crossing_type_str (enum crossing_type_e c)
|
|||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case bary: return ("bary");
|
case bary: return "bary";
|
||||||
case median: return ("median");
|
case median: return "median";
|
||||||
case barymedian: return ("barymedian");
|
case barymedian: return "barymedian";
|
||||||
case medianbary: return ("medianbary");
|
case medianbary: return "medianbary";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a crossing_type.."));
|
complain (_("vcg graph: no such a crossing_type.."));
|
||||||
return (get_crossing_type_str(G_CROSSING_WEIGHT));
|
return get_crossing_type_str(G_CROSSING_WEIGHT);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -372,14 +373,14 @@ get_view_str (enum view_e v)
|
|||||||
{
|
{
|
||||||
switch (v)
|
switch (v)
|
||||||
{
|
{
|
||||||
case normal_view: return ("normal_view");
|
case normal_view: return "normal_view";
|
||||||
case cfish: return ("cfish");
|
case cfish: return "cfish";
|
||||||
case pfish: return ("pfish");
|
case pfish: return "pfish";
|
||||||
case fcfish: return ("fcfish");
|
case fcfish: return "fcfish";
|
||||||
case fpfish: return ("fpfish");
|
case fpfish: return "fpfish";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a view.."));
|
complain (_("vcg graph: no such a view.."));
|
||||||
return (get_view_str(G_VIEW));
|
return get_view_str(G_VIEW);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -389,13 +390,13 @@ get_linestyle_str (enum linestyle_e l)
|
|||||||
{
|
{
|
||||||
switch (l)
|
switch (l)
|
||||||
{
|
{
|
||||||
case continuous: return ("continuous");
|
case continuous: return "continuous";
|
||||||
case dashed: return ("dashed");
|
case dashed: return "dashed";
|
||||||
case dotted: return ("dotted");
|
case dotted: return "dotted";
|
||||||
case invisible: return ("invisible");
|
case invisible: return "invisible";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such a linestyle.."));
|
complain (_("vcg graph: no such a linestyle.."));
|
||||||
return (get_linestyle_str(E_LINESTYLE));
|
return get_linestyle_str(E_LINESTYLE);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -405,12 +406,12 @@ get_arrowstyle_str (enum arrowstyle_e a)
|
|||||||
{
|
{
|
||||||
switch (a)
|
switch (a)
|
||||||
{
|
{
|
||||||
case solid: return ("solid");
|
case solid: return "solid";
|
||||||
case line: return ("line");
|
case line: return "line";
|
||||||
case none: return ("none");
|
case none: return "none";
|
||||||
default:
|
default:
|
||||||
complain (_("vcg graph: no such an arrowstyle.."));
|
complain (_("vcg graph: no such an arrowstyle.."));
|
||||||
return (get_arrowstyle_str(E_ARROWSTYLE));
|
return get_arrowstyle_str(E_ARROWSTYLE);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -832,55 +833,3 @@ output_graph (graph_t *graph, struct obstack *os)
|
|||||||
if (graph->smax != G_SMAX)
|
if (graph->smax != G_SMAX)
|
||||||
obstack_fgrow1 (os, "\tsmax:\t%d\n", graph->smax);
|
obstack_fgrow1 (os, "\tsmax:\t%d\n", graph->smax);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
|
|
||||||
int main ()
|
|
||||||
{
|
|
||||||
graph_t graph;
|
|
||||||
node_t *node;
|
|
||||||
edge_t *edge;
|
|
||||||
struct obstack graph_obstack;
|
|
||||||
|
|
||||||
obstack_init (&graph_obstack);
|
|
||||||
|
|
||||||
new_graph(&graph);
|
|
||||||
|
|
||||||
graph.title = "graph_title";
|
|
||||||
graph.label = "graph_label";
|
|
||||||
graph.color = yellow;
|
|
||||||
graph.textcolor = green;
|
|
||||||
graph.width = 5;
|
|
||||||
graph.x = 12;
|
|
||||||
graph.y = 17;
|
|
||||||
graph.textmode = right_justify;
|
|
||||||
|
|
||||||
open_graph (&graph, stdout);
|
|
||||||
|
|
||||||
node = XMALLOC (node_t, 1);
|
|
||||||
new_node (node);
|
|
||||||
node->title = "A";
|
|
||||||
node->locx = 12;
|
|
||||||
node->locy = 71;
|
|
||||||
add_node (&graph, node);
|
|
||||||
|
|
||||||
node = XMALLOC (node_t, 1);
|
|
||||||
new_node (node);
|
|
||||||
node->title = "B";
|
|
||||||
add_node (&graph, node);
|
|
||||||
|
|
||||||
edge = XMALLOC (edge_t, 1);
|
|
||||||
new_edge (edge);
|
|
||||||
edge->sourcename = "B";
|
|
||||||
edge->targetname = "A";
|
|
||||||
add_edge (&graph, edge);
|
|
||||||
|
|
||||||
output_graph(&graph, stdout);
|
|
||||||
close_graph (&graph, stdout);
|
|
||||||
|
|
||||||
obstack_save (&graph_obstack, "essai.vcg");
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* not DEBUG */
|
|
||||||
|
|||||||
Reference in New Issue
Block a user