Adjust to renamings.

This commit is contained in:
Paul Eggert
2002-12-11 06:56:18 +00:00
parent 3671fb8483
commit 17ee7397a8
10 changed files with 820 additions and 819 deletions

View File

@@ -21,26 +21,29 @@
#include "system.h"
#include "bitset_stats.h"
#include "bitset.h"
#include "getargs.h"
#include "struniq.h"
#include "symtab.h"
#include "gram.h"
#include "files.h"
#include "complain.h"
#include "derives.h"
#include "tables.h"
#include "output.h"
#include "reader.h"
#include "lalr.h"
#include "reduce.h"
#include "nullable.h"
#include "print.h"
#include <bitset_stats.h>
#include <bitset.h>
#include <timevar.h>
#include "LR0.h"
#include "complain.h"
#include "conflicts.h"
#include "print_graph.h"
#include "derives.h"
#include "files.h"
#include "getargs.h"
#include "gram.h"
#include "lalr.h"
#include "muscle_tab.h"
#include "nullable.h"
#include "output.h"
#include "print.h"
#include "print_graph.h"
#include "reader.h"
#include "reduce.h"
#include "symtab.h"
#include "tables.h"
#include "uniqstr.h"
/* The name this program was run with, for messages. */
char *program_name;
@@ -55,11 +58,11 @@ main (int argc, char *argv[])
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
struniqs_new ();
uniqstrs_new ();
getargs (argc, argv);
time_report = trace_flag & trace_time;
timevar_report = trace_flag & trace_time;
init_timevar ();
timevar_start (TV_TOTAL);
@@ -166,7 +169,7 @@ main (int argc, char *argv[])
contains things such as user actions, prologue, epilogue etc. */
scanner_free ();
muscle_free ();
struniqs_free ();
uniqstrs_free ();
/* If using alloca.c, flush the alloca'ed memory for the benefit of
people running Bison as a library in IDEs. */
#if C_ALLOCA

View File

@@ -21,20 +21,22 @@
#include "system.h"
#include "quotearg.h"
#include "files.h"
#include "symtab.h"
#include "gram.h"
#include <bitset.h>
#include <quotearg.h>
#include "LR0.h"
#include "lalr.h"
#include "conflicts.h"
#include "getargs.h"
#include "state.h"
#include "reader.h"
#include "print.h"
#include "reduce.h"
#include "closure.h"
#include "bitset.h"
#include "conflicts.h"
#include "files.h"
#include "getargs.h"
#include "gram.h"
#include "lalr.h"
#include "print.h"
#include "reader.h"
#include "reduce.h"
#include "state.h"
#include "symtab.h"
static bitset shiftset;
static bitset lookaheadset;
@@ -66,12 +68,12 @@ max_length (size_t *width, const char *str)
`--------------------------------*/
static void
print_core (FILE *out, state_t *state)
print_core (FILE *out, state *s)
{
int i;
item_number_t *sitems = state->items;
int snritems = state->nitems;
symbol_t *previous_lhs = NULL;
item_number *sitems = s->items;
int snritems = s->nitems;
symbol *previous_lhs = NULL;
/* Output all the items of a state, not only its kernel. */
if (report_flag & report_itemsets)
@@ -88,21 +90,21 @@ print_core (FILE *out, state_t *state)
for (i = 0; i < snritems; i++)
{
item_number_t *sp;
item_number_t *sp1;
int rule;
item_number *sp;
item_number *sp1;
int r;
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
sp++;
rule = item_number_as_rule_number (*sp);
r = item_number_as_rule_number (*sp);
rule_lhs_print (&rules[rule], previous_lhs, out);
previous_lhs = rules[rule].lhs;
rule_lhs_print (&rules[r], previous_lhs, out);
previous_lhs = rules[r].lhs;
for (sp = rules[rule].rhs; sp < sp1; sp++)
for (sp = rules[r].rhs; sp < sp1; sp++)
fprintf (out, " %s", symbols[*sp]->tag);
fputs (" .", out);
for (/* Nothing */; *sp >= 0; ++sp)
@@ -110,32 +112,32 @@ print_core (FILE *out, state_t *state)
/* Display the lookaheads? */
if (report_flag & report_lookaheads)
state_rule_lookaheads_print (state, &rules[rule], out);
state_rule_lookaheads_print (s, &rules[r], out);
fputc ('\n', out);
}
}
/*----------------------------------------------------------------.
| Report the shifts iff DISPLAY_SHIFTS_P or the gotos of STATE on |
/*------------------------------------------------------------.
| Report the shifts iff DISPLAY_SHIFTS_P or the gotos of S on |
| OUT. |
`----------------------------------------------------------------*/
`------------------------------------------------------------*/
static void
print_transitions (state_t *state, FILE *out, bool display_transitions_p)
print_transitions (state *s, FILE *out, bool display_transitions_p)
{
transitions_t *transitions = state->transitions;
transitions *trans = s->transitions;
size_t width = 0;
int i;
/* Compute the width of the lookaheads column. */
for (i = 0; i < transitions->num; i++)
if (!TRANSITION_IS_DISABLED (transitions, i)
&& TRANSITION_IS_SHIFT (transitions, i) == display_transitions_p)
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
{
symbol_t *symbol = symbols[TRANSITION_SYMBOL (transitions, i)];
max_length (&width, symbol->tag);
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
max_length (&width, sym->tag);
}
/* Nothing to report. */
@@ -146,34 +148,34 @@ print_transitions (state_t *state, FILE *out, bool display_transitions_p)
width += 2;
/* Report lookaheads and shifts. */
for (i = 0; i < transitions->num; i++)
if (!TRANSITION_IS_DISABLED (transitions, i)
&& TRANSITION_IS_SHIFT (transitions, i) == display_transitions_p)
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
{
symbol_t *symbol = symbols[TRANSITION_SYMBOL (transitions, i)];
const char *tag = symbol->tag;
state_t *state1 = transitions->states[i];
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
const char *tag = sym->tag;
state *s1 = trans->states[i];
int j;
fprintf (out, " %s", tag);
for (j = width - strlen (tag); j > 0; --j)
fputc (' ', out);
if (display_transitions_p)
fprintf (out, _("shift, and go to state %d\n"), state1->number);
fprintf (out, _("shift, and go to state %d\n"), s1->number);
else
fprintf (out, _("go to state %d\n"), state1->number);
fprintf (out, _("go to state %d\n"), s1->number);
}
}
/*------------------------------------------------------------.
| Report the explicit errors of STATE raised from %nonassoc. |
`------------------------------------------------------------*/
/*--------------------------------------------------------.
| Report the explicit errors of S raised from %nonassoc. |
`--------------------------------------------------------*/
static void
print_errs (FILE *out, state_t *state)
print_errs (FILE *out, state *s)
{
errs_t *errp = state->errs;
errs *errp = s->errs;
size_t width = 0;
int i;
@@ -203,66 +205,65 @@ print_errs (FILE *out, state_t *state)
}
/*----------------------------------------------------------.
| Return the default rule of this STATE if it has one, NULL |
| otherwise. |
`----------------------------------------------------------*/
/*-------------------------------------------------------------.
| Return the default rule of S if it has one, NULL otherwise. |
`-------------------------------------------------------------*/
static rule_t *
state_default_rule (state_t *state)
static rule *
state_default_rule (state *s)
{
reductions_t *redp = state->reductions;
rule_t *default_rule = NULL;
reductions *reds = s->reductions;
rule *default_rule = NULL;
int cmax = 0;
int i;
/* No need for a lookahead. */
if (state->consistent)
return redp->rules[0];
if (s->consistent)
return reds->rules[0];
/* 1. Each reduction is possibly masked by the lookaheads on which
we shift (S/R conflicts)... */
bitset_zero (shiftset);
{
transitions_t *transitions = state->transitions;
FOR_EACH_SHIFT (transitions, i)
transitions *trans = s->transitions;
FOR_EACH_SHIFT (trans, i)
{
/* If this state has a shift for the error token, don't use a
default rule. */
if (TRANSITION_IS_ERROR (transitions, i))
if (TRANSITION_IS_ERROR (trans, i))
return NULL;
bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
bitset_set (shiftset, TRANSITION_SYMBOL (trans, i));
}
}
/* 2. Each reduction is possibly masked by the lookaheads on which
we raise an error (due to %nonassoc). */
{
errs_t *errp = state->errs;
errs *errp = s->errs;
for (i = 0; i < errp->num; i++)
if (errp->symbols[i])
bitset_set (shiftset, errp->symbols[i]->number);
}
for (i = 0; i < redp->num; ++i)
for (i = 0; i < reds->num; ++i)
{
int count = 0;
/* How many non-masked lookaheads are there for this reduction?
*/
bitset_andn (lookaheadset, redp->lookaheads[i], shiftset);
bitset_andn (lookaheadset, reds->lookaheads[i], shiftset);
count = bitset_count (lookaheadset);
if (count > cmax)
{
cmax = count;
default_rule = redp->rules[i];
default_rule = reds->rules[i];
}
/* 3. And finally, each reduction is possibly masked by previous
reductions (in R/R conflicts, we keep the first reductions).
*/
bitset_or (shiftset, shiftset, redp->lookaheads[i]);
bitset_or (shiftset, shiftset, reds->lookaheads[i]);
}
return default_rule;
@@ -278,7 +279,7 @@ state_default_rule (state_t *state)
static void
print_reduction (FILE *out, size_t width,
const char *lookahead,
rule_t *rule, bool enabled)
rule *r, bool enabled)
{
int j;
fprintf (out, " %s", lookahead);
@@ -286,9 +287,8 @@ print_reduction (FILE *out, size_t width,
fputc (' ', out);
if (!enabled)
fputc ('[', out);
if (rule->number)
fprintf (out, _("reduce using rule %d (%s)"),
rule->number, rule->lhs->tag);
if (r->number)
fprintf (out, _("reduce using rule %d (%s)"), r->number, r->lhs->tag);
else
fprintf (out, _("accept"));
if (!enabled)
@@ -297,43 +297,43 @@ print_reduction (FILE *out, size_t width,
}
/*----------------------------------------------------.
| Report on OUT the reduction actions of this STATE. |
`----------------------------------------------------*/
/*-------------------------------------------.
| Report on OUT the reduction actions of S. |
`-------------------------------------------*/
static void
print_reductions (FILE *out, state_t *state)
print_reductions (FILE *out, state *s)
{
transitions_t *transitions = state->transitions;
reductions_t *redp = state->reductions;
rule_t *default_rule = NULL;
transitions *trans = s->transitions;
reductions *reds = s->reductions;
rule *default_rule = NULL;
size_t width = 0;
int i, j;
if (redp->num == 0)
if (reds->num == 0)
return;
default_rule = state_default_rule (state);
default_rule = state_default_rule (s);
bitset_zero (shiftset);
FOR_EACH_SHIFT (transitions, i)
bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
FOR_EACH_SHIFT (trans, i)
bitset_set (shiftset, TRANSITION_SYMBOL (trans, i));
/* Compute the width of the lookaheads column. */
if (default_rule)
width = strlen (_("$default"));
if (redp->lookaheads)
if (reds->lookaheads)
for (i = 0; i < ntokens; i++)
{
int count = bitset_test (shiftset, i);
for (j = 0; j < redp->num; ++j)
if (bitset_test (redp->lookaheads[j], i))
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i))
{
if (count == 0)
{
if (redp->rules[j] != default_rule)
if (reds->rules[j] != default_rule)
max_length (&width, symbols[i]->tag);
count++;
}
@@ -352,21 +352,21 @@ print_reductions (FILE *out, state_t *state)
width += 2;
/* Report lookaheads (or $default) and reductions. */
if (redp->lookaheads)
if (reds->lookaheads)
for (i = 0; i < ntokens; i++)
{
int defaulted = 0;
int count = bitset_test (shiftset, i);
for (j = 0; j < redp->num; ++j)
if (bitset_test (redp->lookaheads[j], i))
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i))
{
if (count == 0)
{
if (redp->rules[j] != default_rule)
if (reds->rules[j] != default_rule)
print_reduction (out, width,
symbols[i]->tag,
redp->rules[j], true);
reds->rules[j], true);
else
defaulted = 1;
count++;
@@ -380,7 +380,7 @@ print_reductions (FILE *out, state_t *state)
defaulted = 0;
print_reduction (out, width,
symbols[i]->tag,
redp->rules[j], false);
reds->rules[j], false);
}
}
}
@@ -393,38 +393,37 @@ print_reductions (FILE *out, state_t *state)
/*--------------------------------------------------------------.
| Report on OUT all the actions (shifts, gotos, reductions, and |
| explicit erros from %nonassoc) of STATE. |
| explicit erros from %nonassoc) of S. |
`--------------------------------------------------------------*/
static void
print_actions (FILE *out, state_t *state)
print_actions (FILE *out, state *s)
{
/* Print shifts. */
print_transitions (state, out, true);
print_errs (out, state);
print_reductions (out, state);
print_transitions (s, out, true);
print_errs (out, s);
print_reductions (out, s);
/* Print gotos. */
print_transitions (state, out, false);
print_transitions (s, out, false);
}
/*--------------------------------------.
| Report all the data on STATE on OUT. |
`--------------------------------------*/
/*----------------------------------.
| Report all the data on S on OUT. |
`----------------------------------*/
static void
print_state (FILE *out, state_t *state)
print_state (FILE *out, state *s)
{
fputs ("\n\n", out);
fprintf (out, _("state %d"), state->number);
fprintf (out, _("state %d"), s->number);
fputc ('\n', out);
print_core (out, state);
print_actions (out, state);
if ((report_flag & report_solved_conflicts)
&& state->solved_conflicts)
print_core (out, s);
print_actions (out, s);
if ((report_flag & report_solved_conflicts) && s->solved_conflicts)
{
fputc ('\n', out);
fputs (state->solved_conflicts, out);
fputs (s->solved_conflicts, out);
}
}
@@ -446,7 +445,7 @@ do { \
static void
print_grammar (FILE *out)
{
symbol_number_t i;
symbol_number i;
char buffer[90];
int column = 0;
@@ -458,8 +457,8 @@ print_grammar (FILE *out)
if (token_translations[i] != undeftoken->number)
{
const char *tag = symbols[token_translations[i]]->tag;
rule_number_t r;
item_number_t *rhsp;
rule_number r;
item_number *rhsp;
buffer[0] = 0;
column = strlen (tag);
@@ -484,12 +483,12 @@ print_grammar (FILE *out)
for (i = ntokens; i < nsyms; i++)
{
int left_count = 0, right_count = 0;
rule_number_t r;
rule_number r;
const char *tag = symbols[i]->tag;
for (r = 0; r < nrules; r++)
{
item_number_t *rhsp;
item_number *rhsp;
if (rules[r].lhs->number == i)
left_count++;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
@@ -527,7 +526,7 @@ print_grammar (FILE *out)
sprintf (buffer + strlen (buffer), _(" on right:"));
for (r = 0; r < nrules; r++)
{
item_number_t *rhsp;
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == i)
{
@@ -544,7 +543,7 @@ print_grammar (FILE *out)
void
print_results (void)
{
state_number_t i;
state_number i;
/* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but
that conflicts with Posix. */

View File

@@ -19,21 +19,22 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "system.h"
#include "quotearg.h"
#include "getargs.h"
#include "files.h"
#include "symtab.h"
#include "symlist.h"
#include "gram.h"
#include <quotearg.h>
#include "complain.h"
#include "conflicts.h"
#include "files.h"
#include "getargs.h"
#include "gram.h"
#include "muscle_tab.h"
#include "output.h"
#include "reader.h"
#include "conflicts.h"
#include "muscle_tab.h"
#include "symlist.h"
#include "symtab.h"
static symbol_list_t *grammar = NULL;
static symbol_list *grammar = NULL;
static int start_flag = 0;
merger_list *merge_functions;
@@ -45,15 +46,15 @@ int typed = 0;
`-----------------------*/
void
grammar_start_symbol_set (symbol_t *s, location_t l)
grammar_start_symbol_set (symbol *s, location loc)
{
if (start_flag)
complain_at (l, _("multiple %s declarations"), "%start");
complain_at (loc, _("multiple %s declarations"), "%start");
else
{
start_flag = 1;
startsymbol = s;
startsymbol_location = l;
startsymbol_location = loc;
}
}
@@ -64,15 +65,14 @@ grammar_start_symbol_set (symbol_t *s, location_t l)
`----------------------------------------------------------------*/
void
prologue_augment (const char *prologue, location_t location)
prologue_augment (const char *prologue, location loc)
{
struct obstack *oout =
!typed ? &pre_prologue_obstack : &post_prologue_obstack;
obstack_fgrow1 (oout, "]b4_syncline([[%d]], [[",
location.start.line);
MUSCLE_OBSTACK_SGROW (oout, quotearg_style (c_quoting_style,
location.start.file));
obstack_fgrow1 (oout, "]b4_syncline([[%d]], [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (oout,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (oout, "]])[\n");
obstack_sgrow (oout, prologue);
}
@@ -85,13 +85,12 @@ prologue_augment (const char *prologue, location_t location)
`----------------------*/
void
epilogue_augment (const char *epilogue, location_t location)
epilogue_augment (const char *epilogue, location loc)
{
char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[",
location.start.line);
obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
quotearg_style (c_quoting_style, location.start.file));
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, "]])[\n");
obstack_sgrow (&muscle_obstack, epilogue);
obstack_1grow (&muscle_obstack, 0);
@@ -110,7 +109,7 @@ epilogue_augment (const char *epilogue, location_t location)
`-------------------------------------------------------------------*/
static int
get_merge_function (struniq_t name, struniq_t type, location_t loc)
get_merge_function (uniqstr name, uniqstr type, location loc)
{
merger_list *syms;
merger_list head;
@@ -120,21 +119,21 @@ get_merge_function (struniq_t name, struniq_t type, location_t loc)
return 0;
if (type == NULL)
type = struniq_new ("");
type = uniqstr_new ("");
head.next = merge_functions;
for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
if (STRUNIQ_EQ (name, syms->next->name))
if (UNIQSTR_EQ (name, syms->next->name))
break;
if (syms->next == NULL)
{
syms->next = XMALLOC (merger_list, 1);
syms->next->name = struniq_new (name);
syms->next->type = struniq_new (type);
syms->next->name = uniqstr_new (name);
syms->next->type = uniqstr_new (type);
syms->next->next = NULL;
merge_functions = head.next;
}
else if (!STRUNIQ_EQ (type, syms->next->type))
else if (!UNIQSTR_EQ (type, syms->next->type))
warn_at (loc, _("result type clash on merge function %s: <%s> != <%s>"),
name, type, syms->next->type);
return n;
@@ -161,7 +160,7 @@ free_merger_functions (void)
/*-------------------------------------------------------------------.
| Parse the input grammar into a one symbol_list_t structure. Each |
| Parse the input grammar into a one symbol_list structure. Each |
| rule is represented by a sequence of symbols: the left hand side |
| followed by the contents of the right hand side, followed by a |
| null pointer instead of a symbol to terminate the rule. The next |
@@ -179,13 +178,13 @@ free_merger_functions (void)
`-------------------------------------------------------------------*/
/* The (currently) last symbol of GRAMMAR. */
symbol_list_t *grammar_end = NULL;
symbol_list *grammar_end = NULL;
/* Append S to the GRAMMAR. */
void
grammar_symbol_append (symbol_t *symbol, location_t location)
grammar_symbol_append (symbol *sym, location loc)
{
symbol_list_t *p = symbol_list_new (symbol, location);
symbol_list *p = symbol_list_new (sym, loc);
if (grammar_end)
grammar_end->next = p;
@@ -198,8 +197,8 @@ grammar_symbol_append (symbol_t *symbol, location_t location)
/* The rule currently being defined, and the previous rule.
CURRENT_RULE points to the first LHS of the current rule, while
PREVIOUS_RULE_END points to the *end* of the previous rule (NULL). */
symbol_list_t *current_rule = NULL;
symbol_list_t *previous_rule_end = NULL;
symbol_list *current_rule = NULL;
symbol_list *previous_rule_end = NULL;
/*----------------------------------------------.
@@ -207,12 +206,12 @@ symbol_list_t *previous_rule_end = NULL;
`----------------------------------------------*/
void
grammar_rule_begin (symbol_t *lhs, location_t location)
grammar_rule_begin (symbol *lhs, location loc)
{
if (!start_flag)
{
startsymbol = lhs;
startsymbol_location = location;
startsymbol_location = loc;
start_flag = 1;
}
@@ -221,7 +220,7 @@ grammar_rule_begin (symbol_t *lhs, location_t location)
++nritems;
previous_rule_end = grammar_end;
grammar_symbol_append (lhs, location);
grammar_symbol_append (lhs, loc);
current_rule = grammar_end;
/* Mark the rule's lhs as a nonterminal if not already so. */
@@ -233,7 +232,7 @@ grammar_rule_begin (symbol_t *lhs, location_t location)
++nvars;
}
else if (lhs->class == token_sym)
complain_at (location, _("rule given for %s, which is a token"), lhs->tag);
complain_at (loc, _("rule given for %s, which is a token"), lhs->tag);
}
/* Check that the last rule (CURRENT_RULE) is properly defined. For
@@ -242,9 +241,9 @@ grammar_rule_begin (symbol_t *lhs, location_t location)
static void
grammar_current_rule_check (void)
{
symbol_t *lhs = current_rule->sym;
symbol *lhs = current_rule->sym;
char const *lhs_type = lhs->type_name;
symbol_t *first_rhs = current_rule->next->sym;
symbol *first_rhs = current_rule->next->sym;
/* If there is an action, then there is nothing we can do: the user
is allowed to shoot herself in the foot. */
@@ -260,7 +259,7 @@ grammar_current_rule_check (void)
if (first_rhs)
{
const char *rhs_type = first_rhs->type_name ? first_rhs->type_name : "";
if (!STRUNIQ_EQ (lhs_type, rhs_type))
if (!UNIQSTR_EQ (lhs_type, rhs_type))
warn_at (current_rule->location,
_("type clash on default action: <%s> != <%s>"),
lhs_type, rhs_type);
@@ -277,11 +276,11 @@ grammar_current_rule_check (void)
`-------------------------------------*/
void
grammar_rule_end (location_t location)
grammar_rule_end (location loc)
{
/* Put an empty link in the list to mark the end of this rule */
grammar_symbol_append (NULL, grammar_end->location);
current_rule->location = location;
current_rule->location = loc;
grammar_current_rule_check ();
}
@@ -302,9 +301,9 @@ grammar_midrule_action (void)
/* Make a DUMMY nonterminal, whose location is that of the midrule
action. Create the MIDRULE. */
location_t dummy_location = current_rule->action_location;
symbol_t *dummy = dummy_symbol_get (dummy_location);
symbol_list_t *midrule = symbol_list_new (dummy, dummy_location);
location dummy_location = current_rule->action_location;
symbol *dummy = dummy_symbol_get (dummy_location);
symbol_list *midrule = symbol_list_new (dummy, dummy_location);
/* Make a new rule, whose body is empty, before the current one, so
that the action just read can belong to it. */
@@ -335,25 +334,24 @@ grammar_midrule_action (void)
/* Set the precedence symbol of the current rule to PRECSYM. */
void
grammar_current_rule_prec_set (symbol_t *precsym, location_t location)
grammar_current_rule_prec_set (symbol *precsym, location loc)
{
if (current_rule->ruleprec)
complain_at (location, _("only one %s allowed per rule"), "%prec");
complain_at (loc, _("only one %s allowed per rule"), "%prec");
current_rule->ruleprec = precsym;
}
/* Attach dynamic precedence DPREC to the current rule. */
void
grammar_current_rule_dprec_set (int dprec, location_t location)
grammar_current_rule_dprec_set (int dprec, location loc)
{
if (! glr_parser)
warn_at (location, _("%s affects only GLR parsers"), "%dprec");
warn_at (loc, _("%s affects only GLR parsers"), "%dprec");
if (dprec <= 0)
complain_at (location,
_("%s must be followed by positive number"), "%dprec");
complain_at (loc, _("%s must be followed by positive number"), "%dprec");
else if (current_rule->dprec != 0)
complain_at (location, _("only one %s allowed per rule"), "%dprec");
complain_at (loc, _("only one %s allowed per rule"), "%dprec");
current_rule->dprec = dprec;
}
@@ -361,38 +359,38 @@ grammar_current_rule_dprec_set (int dprec, location_t location)
rule. */
void
grammar_current_rule_merge_set (struniq_t name, location_t location)
grammar_current_rule_merge_set (uniqstr name, location loc)
{
if (! glr_parser)
warn_at (location, _("%s affects only GLR parsers"), "%merge");
warn_at (loc, _("%s affects only GLR parsers"), "%merge");
if (current_rule->merger != 0)
complain_at (location, _("only one %s allowed per rule"), "%merge");
complain_at (loc, _("only one %s allowed per rule"), "%merge");
current_rule->merger =
get_merge_function (name, current_rule->sym->type_name, location);
get_merge_function (name, current_rule->sym->type_name, loc);
}
/* Attach a SYMBOL to the current rule. If needed, move the previous
/* Attach SYM to the current rule. If needed, move the previous
action as a mid-rule action. */
void
grammar_current_rule_symbol_append (symbol_t *symbol, location_t location)
grammar_current_rule_symbol_append (symbol *sym, location loc)
{
if (current_rule->action)
grammar_midrule_action ();
++nritems;
grammar_symbol_append (symbol, location);
grammar_symbol_append (sym, loc);
}
/* Attach an ACTION to the current rule. If needed, move the previous
action as a mid-rule action. */
void
grammar_current_rule_action_append (const char *action, location_t location)
grammar_current_rule_action_append (const char *action, location loc)
{
if (current_rule->action)
grammar_midrule_action ();
current_rule->action = action;
current_rule->action_location = location;
current_rule->action_location = loc;
}
@@ -405,15 +403,15 @@ static void
packgram (void)
{
unsigned int itemno = 0;
rule_number_t ruleno = 0;
symbol_list_t *p = grammar;
rule_number ruleno = 0;
symbol_list *p = grammar;
ritem = XCALLOC (item_number_t, nritems);
rules = XCALLOC (rule_t, nrules);
ritem = XCALLOC (item_number, nritems);
rules = XCALLOC (rule, nrules);
while (p)
{
symbol_t *ruleprec = p->ruleprec;
symbol *ruleprec = p->ruleprec;
rules[ruleno].user_number = ruleno;
rules[ruleno].number = ruleno;
rules[ruleno].lhs = p->sym;
@@ -428,7 +426,7 @@ packgram (void)
p = p->next;
while (p && p->sym)
{
/* item_number_t = symbol_number_t.
/* item_number = symbol_number.
But the former needs to contain more: negative rule numbers. */
ritem[itemno++] = symbol_number_as_item_number (p->sym->number);
/* A rule gets by default the precedence and associativity
@@ -528,7 +526,7 @@ reader (void)
accept: %start EOF. */
{
symbol_list_t *p = symbol_list_new (accept, empty_location);
symbol_list *p = symbol_list_new (accept, empty_location);
p->location = grammar->location;
p->next = symbol_list_new (startsymbol, empty_location);
p->next->next = symbol_list_new (endtoken, empty_location);
@@ -539,7 +537,7 @@ reader (void)
grammar = p;
}
if (! (nsyms <= SYMBOL_NUMBER_MAX && nsyms == ntokens + nvars))
if (! (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars))
abort ();
xfclose (finput);
@@ -551,6 +549,6 @@ reader (void)
/* Convert the grammar into the format described in gram.h. */
packgram ();
/* The grammar as a symbol_list_t is no longer needed. */
LIST_FREE (symbol_list_t, grammar);
/* The grammar as a symbol_list is no longer needed. */
LIST_FREE (symbol_list, grammar);
}

View File

@@ -26,16 +26,17 @@
user's parser. */
#include "system.h"
#include "quotearg.h"
#include "getargs.h"
#include "files.h"
#include "symtab.h"
#include "gram.h"
#include <bitset.h>
#include <quotearg.h>
#include "complain.h"
#include "reduce.h"
#include "reader.h"
#include "files.h"
#include "getargs.h"
#include "bitset.h"
#include "gram.h"
#include "reader.h"
#include "reduce.h"
#include "symtab.h"
/* Set of all nonterminals which are not useless. */
static bitset N;
@@ -50,10 +51,10 @@ static bitset V;
`useless', but no warning should be issued). */
static bitset V1;
static rule_number_t nuseful_productions;
rule_number_t nuseless_productions;
static rule_number nuseful_productions;
rule_number nuseless_productions;
static int nuseful_nonterminals;
symbol_number_t nuseless_nonterminals;
symbol_number nuseless_nonterminals;
/*-------------------------------------------------------------------.
| Another way to do this would be with a set for each production and |
@@ -62,9 +63,9 @@ symbol_number_t nuseless_nonterminals;
`-------------------------------------------------------------------*/
static bool
useful_production (rule_number_t r, bitset N0)
useful_production (rule_number r, bitset N0)
{
item_number_t *rhsp;
item_number *rhsp;
/* A production is useful if all of the nonterminals in its appear
in the set of useful nonterminals. */
@@ -84,7 +85,7 @@ static void
useless_nonterminals (void)
{
bitset Np, Ns;
rule_number_t r;
rule_number r;
/* N is set as built. Np is set being built this iteration. P is
set of all productions which have a RHS all in N. */
@@ -167,7 +168,7 @@ inaccessable_symbols (void)
while (1)
{
rule_number_t r;
rule_number r;
bitset_copy (Vp, V);
for (r = 0; r < nrules; r++)
{
@@ -175,7 +176,7 @@ inaccessable_symbols (void)
&& bitset_test (P, r)
&& bitset_test (V, rules[r].lhs->number))
{
item_number_t *rhsp;
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
bitset_set (Vp, *rhsp);
@@ -206,7 +207,7 @@ inaccessable_symbols (void)
nuseful_nonterminals = 0;
{
symbol_number_t i;
symbol_number i;
for (i = ntokens; i < nsyms; i++)
if (bitset_test (V, i))
nuseful_nonterminals++;
@@ -215,7 +216,7 @@ inaccessable_symbols (void)
/* A token that was used in %prec should not be warned about. */
{
rule_number_t r;
rule_number r;
for (r = 0; r < nrules; ++r)
if (rules[r].precsym != 0)
bitset_set (V1, rules[r].precsym->number);
@@ -233,7 +234,7 @@ reduce_grammar_tables (void)
{
/* Report and flag useless productions. */
{
rule_number_t r;
rule_number r;
for (r = 0; r < nrules; r++)
rules[r].useful = bitset_test (P, r);
grammar_rules_never_reduced_report (_("useless rule"));
@@ -244,8 +245,8 @@ reduce_grammar_tables (void)
{
int useful = 0;
int useless = nrules - nuseless_productions;
rule_t *rules_sorted = XMALLOC (rule_t, nrules);
rule_number_t r;
rule *rules_sorted = XMALLOC (rule, nrules);
rule_number r;
for (r = 0; r < nrules; ++r)
rules_sorted[rules[r].useful ? useful++ : useless++] = rules[r];
free (rules);
@@ -254,7 +255,7 @@ reduce_grammar_tables (void)
/* Renumber the rules markers in RITEMS. */
for (r = 0; r < nrules; ++r)
{
item_number_t *rhsp = rules[r].rhs;
item_number *rhsp = rules[r].rhs;
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
/* Nothing. */;
*rhsp = rule_number_as_item_number (r);
@@ -283,12 +284,12 @@ reduce_grammar_tables (void)
static void
nonterminals_reduce (void)
{
symbol_number_t i, n;
symbol_number i, n;
/* Map the nonterminals to their new index: useful first, useless
afterwards. Kept for later report. */
symbol_number_t *nontermmap = XCALLOC (symbol_number_t, nvars) - ntokens;
symbol_number *nontermmap = XCALLOC (symbol_number, nvars) - ntokens;
n = ntokens;
for (i = ntokens; i < nsyms; i++)
if (bitset_test (V, i))
@@ -304,7 +305,7 @@ nonterminals_reduce (void)
/* Shuffle elements of tables indexed by symbol number. */
{
symbol_t **symbols_sorted = XMALLOC (symbol_t *, nvars) - ntokens;
symbol **symbols_sorted = XMALLOC (symbol *, nvars) - ntokens;
for (i = ntokens; i < nsyms; i++)
symbols[i]->number = nontermmap[i];
@@ -316,10 +317,10 @@ nonterminals_reduce (void)
}
{
rule_number_t r;
rule_number r;
for (r = 0; r < nrules; ++r)
{
item_number_t *rhsp;
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp]);

View File

@@ -1,4 +1,5 @@
/* Grammar reduction for Bison.
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -25,6 +26,6 @@ void reduce_grammar (void);
void reduce_output (FILE *out);
void reduce_free (void);
extern symbol_number_t nuseless_nonterminals;
extern rule_number_t nuseless_productions;
extern symbol_number nuseless_nonterminals;
extern rule_number nuseless_productions;
#endif /* !REDUCE_H_ */

View File

@@ -19,21 +19,23 @@
Boston, MA 02111-1307, USA. */
#include "system.h"
#include "bitsetv.h"
#include "relation.h"
#include <bitsetv.h>
#include "getargs.h"
#include "relation.h"
void
relation_print (relation_t relation, size_t size, FILE *out)
relation_print (relation r, size_t size, FILE *out)
{
unsigned i, j;
for (i = 0; i < size; ++i)
{
fprintf (out, "%3d: ", i);
if (relation[i])
for (j = 0; relation[i][j] != -1; ++j)
fprintf (out, "%3d ", relation[i][j]);
if (r[i])
for (j = 0; r[i][j] != -1; ++j)
fprintf (out, "%3d ", r[i][j]);
fputc ('\n', out);
}
fputc ('\n', out);
@@ -47,9 +49,9 @@ relation_print (relation_t relation, size_t size, FILE *out)
| two. |
`---------------------------------------------------------------*/
static relation_t R;
static relation_nodes_t INDEX;
static relation_nodes_t VERTICES;
static relation R;
static relation_nodes INDEX;
static relation_nodes VERTICES;
static int top;
static int infinity;
static bitsetv F;
@@ -90,17 +92,16 @@ traverse (int i)
void
relation_digraph (relation_t relation, size_t size,
bitsetv *function)
relation_digraph (relation r, size_t size, bitsetv *function)
{
unsigned i;
infinity = size + 2;
INDEX = XCALLOC (relation_node_t, size + 1);
VERTICES = XCALLOC (relation_node_t, size + 1);
INDEX = XCALLOC (relation_node, size + 1);
VERTICES = XCALLOC (relation_node, size + 1);
top = 0;
R = relation;
R = r;
F = *function;
for (i = 0; i < size; i++)
@@ -122,12 +123,12 @@ relation_digraph (relation_t relation, size_t size,
`-------------------------------------------*/
void
relation_transpose (relation_t *R_arg, int n)
relation_transpose (relation *R_arg, int n)
{
/* The result. */
relation_t new_R = XCALLOC (relation_nodes_t, n);
relation new_R = XCALLOC (relation_nodes, n);
/* END_R[I] -- next entry of NEW_R[I]. */
relation_t end_R = XCALLOC (relation_nodes_t, n);
relation end_R = XCALLOC (relation_nodes, n);
/* NEDGES[I] -- total size of NEW_R[I]. */
int *nedges = XCALLOC (int, n);
int i, j;
@@ -148,7 +149,7 @@ relation_transpose (relation_t *R_arg, int n)
for (i = 0; i < n; i++)
if (nedges[i] > 0)
{
relation_node_t *sp = XCALLOC (relation_node_t, nedges[i] + 1);
relation_node *sp = XCALLOC (relation_node, nedges[i] + 1);
sp[nedges[i]] = -1;
new_R[i] = sp;
end_R[i] = sp;

View File

@@ -20,7 +20,9 @@
#include "system.h"
#include "hash.h"
#include <hash.h>
#include "complain.h"
#include "gram.h"
#include "state.h"
@@ -36,13 +38,14 @@
`---------------------------------------*/
#define TRANSITIONS_ALLOC(Num) \
(transitions_t *) xcalloc ((sizeof (transitions_t) \
+ (Num - 1) * sizeof (state_t *)), 1)
(transitions *) xcalloc ((sizeof (transitions) \
+ (Num - 1) * sizeof (state *)), \
1)
static transitions_t *
transitions_new (int num, state_t **the_states)
static transitions *
transitions_new (int num, state **the_states)
{
transitions_t *res = TRANSITIONS_ALLOC (num);
transitions *res = TRANSITIONS_ALLOC (num);
res->num = num;
memcpy (res->states, the_states, num * sizeof (the_states[0]));
return res;
@@ -51,11 +54,11 @@ transitions_new (int num, state_t **the_states)
/*-------------------------------------------------------------------.
| Return the state such these TRANSITIONS contain a shift/goto to it |
| on SYMBOL. Aborts if none found. |
| on S. Abort if none found. |
`-------------------------------------------------------------------*/
state_t *
transitions_to (transitions_t *shifts, symbol_number_t s)
state *
transitions_to (transitions *shifts, symbol_number s)
{
int j;
for (j = 0; j < shifts->num; j++)
@@ -75,14 +78,13 @@ transitions_to (transitions_t *shifts, symbol_number_t s)
`-------------------------------*/
#define ERRS_ALLOC(Nerrs) \
(errs_t *) xcalloc ((sizeof (errs_t) \
+ (Nerrs - 1) * sizeof (symbol_t *)), 1)
((errs *) xcalloc ((sizeof (errs) + (Nerrs - 1) * sizeof (symbol *)), 1))
errs_t *
errs_new (int num, symbol_t **tokens)
errs *
errs_new (int num, symbol **tokens)
{
errs_t *res = ERRS_ALLOC (num);
errs *res = ERRS_ALLOC (num);
res->num = num;
memcpy (res->symbols, tokens, num * sizeof (tokens[0]));
return res;
@@ -101,15 +103,15 @@ errs_new (int num, symbol_t **tokens)
`-------------------------------------*/
#define REDUCTIONS_ALLOC(Nreductions) \
(reductions_t *) xcalloc ((sizeof (reductions_t) \
+ (Nreductions - 1) * sizeof (rule_t *)), 1)
(reductions *) xcalloc ((sizeof (reductions) \
+ (Nreductions - 1) * sizeof (rule *)), 1)
static reductions_t *
reductions_new (int num, rule_t **reductions)
static reductions *
reductions_new (int num, rule **reds)
{
reductions_t *res = REDUCTIONS_ALLOC (num);
reductions *res = REDUCTIONS_ALLOC (num);
res->num = num;
memcpy (res->rules, reductions, num * sizeof (reductions[0]));
memcpy (res->rules, reds, num * sizeof (reds[0]));
res->lookaheads = NULL;
return res;
}
@@ -121,27 +123,28 @@ reductions_new (int num, rule_t **reductions)
`---------*/
state_number_t nstates = 0;
state_number nstates = 0;
/* FINAL_STATE is properly set by new_state when it recognizes its
accessing symbol: $end. */
state_t *final_state = NULL;
state *final_state = NULL;
#define STATE_ALLOC(Nitems) \
(state_t *) xcalloc ((sizeof (state_t) \
+ (Nitems - 1) * sizeof (item_number_t)), 1)
(state *) xcalloc ((sizeof (state) \
+ (Nitems - 1) * sizeof (item_number)), \
1)
/*------------------------------------------------------------------.
| Create a new state with ACCESSING_SYMBOL, for those items. Store |
| it in the state hash table. |
`------------------------------------------------------------------*/
state_t *
state_new (symbol_number_t accessing_symbol,
size_t core_size, item_number_t *core)
state *
state_new (symbol_number accessing_symbol,
size_t core_size, item_number *core)
{
state_t *res;
state *res;
if (STATE_NUMBER_MAX <= nstates)
if (STATE_NUMBER_MAXIMUM <= nstates)
abort ();
res = STATE_ALLOC (core_size);
@@ -159,83 +162,83 @@ state_new (symbol_number_t accessing_symbol,
}
/*-------------.
| Free STATE. |
`-------------*/
/*---------.
| Free S. |
`---------*/
static void
state_free (state_t *state)
state_free (state *s)
{
free (state->transitions);
free (state->reductions);
free (state->errs);
free (state);
free (s->transitions);
free (s->reductions);
free (s->errs);
free (s);
}
/*-------------------------------.
| Set the transitions of STATE. |
`-------------------------------*/
/*---------------------------.
| Set the transitions of S. |
`---------------------------*/
void
state_transitions_set (state_t *state, int num, state_t **transitions)
state_transitions_set (state *s, int num, state **trans)
{
if (state->transitions)
if (s->transitions)
abort ();
state->transitions = transitions_new (num, transitions);
s->transitions = transitions_new (num, trans);
}
/*------------------------------.
| Set the reductions of STATE. |
`------------------------------*/
/*--------------------------.
| Set the reductions of S. |
`--------------------------*/
void
state_reductions_set (state_t *state, int num, rule_t **reductions)
state_reductions_set (state *s, int num, rule **reds)
{
if (state->reductions)
if (s->reductions)
abort ();
state->reductions = reductions_new (num, reductions);
s->reductions = reductions_new (num, reds);
}
int
state_reduction_find (state_t *state, rule_t *rule)
state_reduction_find (state *s, rule *r)
{
int i;
reductions_t *reds = state->reductions;
reductions *reds = s->reductions;
for (i = 0; i < reds->num; ++i)
if (reds->rules[i] == rule)
if (reds->rules[i] == r)
return i;
return -1;
}
/*------------------------.
| Set the errs of STATE. |
`------------------------*/
/*--------------------.
| Set the errs of S. |
`--------------------*/
void
state_errs_set (state_t *state, int num, symbol_t **tokens)
state_errs_set (state *s, int num, symbol **tokens)
{
if (state->errs)
if (s->errs)
abort ();
state->errs = errs_new (num, tokens);
s->errs = errs_new (num, tokens);
}
/*--------------------------------------------------------------.
| Print on OUT all the lookaheads such that this STATE wants to |
| reduce this RULE. |
`--------------------------------------------------------------*/
/*-----------------------------------------------------.
| Print on OUT all the lookaheads such that S wants to |
| reduce R. |
`-----------------------------------------------------*/
void
state_rule_lookaheads_print (state_t *state, rule_t *rule, FILE *out)
state_rule_lookaheads_print (state *s, rule *r, FILE *out)
{
/* Find the reduction we are handling. */
reductions_t *reds = state->reductions;
int red = state_reduction_find (state, rule);
reductions *reds = s->reductions;
int red = state_reduction_find (s, r);
/* Print them if there are. */
if (reds->lookaheads && red != -1)
@@ -264,7 +267,7 @@ static struct hash_table *state_table = NULL;
/* Two states are equal if they have the same core items. */
static bool
state_compare (const state_t *s1, const state_t *s2)
state_compare (state const *s1, state const *s2)
{
int i;
@@ -279,13 +282,13 @@ state_compare (const state_t *s1, const state_t *s2)
}
static unsigned int
state_hash (const state_t *state, unsigned int tablesize)
state_hash (state const *s, unsigned int tablesize)
{
/* Add up the state's item numbers to get a hash key. */
int key = 0;
int i;
for (i = 0; i < state->nitems; ++i)
key += state->items[i];
for (i = 0; i < s->nitems; ++i)
key += s->items[i];
return key % tablesize;
}
@@ -316,14 +319,14 @@ state_hash_free (void)
}
/*---------------------------------------.
| Insert STATE in the state hash table. |
`---------------------------------------*/
/*-----------------------------------.
| Insert S in the state hash table. |
`-----------------------------------*/
void
state_hash_insert (state_t *state)
state_hash_insert (state *s)
{
hash_insert (state_table, state);
hash_insert (state_table, s);
}
@@ -332,11 +335,11 @@ state_hash_insert (state_t *state)
| not exist yet, return NULL. |
`------------------------------------------------------------------*/
state_t *
state_hash_lookup (size_t core_size, item_number_t *core)
state *
state_hash_lookup (size_t core_size, item_number *core)
{
state_t *probe = STATE_ALLOC (core_size);
state_t *entry;
state *probe = STATE_ALLOC (core_size);
state *entry;
probe->nitems = core_size;
memcpy (probe->items, core, core_size * sizeof (core[0]));
@@ -346,7 +349,7 @@ state_hash_lookup (size_t core_size, item_number_t *core)
}
/* All the decorated states, indexed by the state number. */
state_t **states = NULL;
state **states = NULL;
/*----------------------.
@@ -356,7 +359,7 @@ state_t **states = NULL;
void
states_free (void)
{
state_number_t i;
state_number i;
for (i = 0; i < nstates; ++i)
state_free (states[i]);
free (states);

View File

@@ -1,4 +1,5 @@
/* Lists of symbols for Bison
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -19,21 +20,22 @@
Boston, MA 02111-1307, USA. */
#include "system.h"
#include "complain.h"
#include "symlist.h"
/*----------------------------------------------.
| Create a list containing SYMBOL at LOCATION. |
`----------------------------------------------*/
/*--------------------------------------.
| Create a list containing SYM at LOC. |
`--------------------------------------*/
symbol_list_t *
symbol_list_new (symbol_t *sym, location_t location)
symbol_list *
symbol_list_new (symbol *sym, location loc)
{
symbol_list_t *res = XMALLOC (symbol_list_t, 1);
symbol_list *res = XMALLOC (symbol_list, 1);
res->next = NULL;
res->sym = sym;
res->location = location;
res->location = loc;
res->action = NULL;
res->ruleprec = NULL;
res->dprec = 0;
@@ -42,15 +44,14 @@ symbol_list_new (symbol_t *sym, location_t location)
}
/*-----------------------------------------.
| Prepend SYMBOL at LOCATION to the LIST. |
`-----------------------------------------*/
/*---------------------------------.
| Prepend SYM at LOC to the LIST. |
`---------------------------------*/
symbol_list_t *
symbol_list_prepend (symbol_list_t *list,
symbol_t *symbol, location_t location)
symbol_list *
symbol_list_prepend (symbol_list *list, symbol *sym, location loc)
{
symbol_list_t *res = symbol_list_new (symbol, location);
symbol_list *res = symbol_list_new (sym, loc);
res->next = list;
return res;
}
@@ -61,9 +62,9 @@ symbol_list_prepend (symbol_list_t *list,
`-------------------------------------------------*/
void
symbol_list_free (symbol_list_t *list)
symbol_list_free (symbol_list *list)
{
LIST_FREE (symbol_list_t, list);
LIST_FREE (symbol_list, list);
}
@@ -72,7 +73,7 @@ symbol_list_free (symbol_list_t *list)
`--------------------*/
unsigned int
symbol_list_length (symbol_list_t *list)
symbol_list_length (symbol_list *list)
{
int res = 0;
for (/* Nothing. */; list; list = list->next)
@@ -83,22 +84,20 @@ symbol_list_length (symbol_list_t *list)
/*--------------------------------------------------------------.
| Get the data type (alternative in the union) of the value for |
| symbol N in rule RULE. |
| symbol N in symbol list RP. |
`--------------------------------------------------------------*/
struniq_t
symbol_list_n_type_name_get (symbol_list_t *rule, location_t location, int n)
uniqstr
symbol_list_n_type_name_get (symbol_list *rp, location loc, int n)
{
int i;
symbol_list_t *rp;
if (n < 0)
{
complain_at (location, _("invalid $ value"));
complain_at (loc, _("invalid $ value"));
return NULL;
}
rp = rule;
i = 0;
while (i < n)
@@ -106,7 +105,7 @@ symbol_list_n_type_name_get (symbol_list_t *rule, location_t location, int n)
rp = rp->next;
if (rp == NULL || rp->sym == NULL)
{
complain_at (location, _("invalid $ value"));
complain_at (loc, _("invalid $ value"));
return NULL;
}
++i;

View File

@@ -20,35 +20,37 @@
#include "system.h"
#include "quotearg.h"
#include "hash.h"
#include <hash.h>
#include <quotearg.h>
#include "complain.h"
#include "symtab.h"
#include "gram.h"
#include "symtab.h"
/*------------------------.
| Distinguished symbols. |
`------------------------*/
symbol_t *errtoken = NULL;
symbol_t *undeftoken = NULL;
symbol_t *endtoken = NULL;
symbol_t *accept = NULL;
symbol_t *startsymbol = NULL;
location_t startsymbol_location;
symbol *errtoken = NULL;
symbol *undeftoken = NULL;
symbol *endtoken = NULL;
symbol *accept = NULL;
symbol *startsymbol = NULL;
location startsymbol_location;
/*---------------------------------.
| Create a new symbol, named TAG. |
`---------------------------------*/
static symbol_t *
symbol_new (struniq_t tag, location_t location)
static symbol *
symbol_new (uniqstr tag, location loc)
{
symbol_t *res = XMALLOC (symbol_t, 1);
symbol *res = XMALLOC (symbol, 1);
struniq_assert (tag);
uniqstr_assert (tag);
res->tag = tag;
res->location = location;
res->location = loc;
res->type_name = NULL;
res->destructor = NULL;
@@ -67,127 +69,119 @@ symbol_new (struniq_t tag, location_t location)
}
/*------------------------------------------------------------------.
| Set the TYPE_NAME associated to SYMBOL. Does nothing if passed 0 |
/*-----------------------------------------------------------------.
| Set the TYPE_NAME associated with SYM. Does nothing if passed 0 |
| as TYPE_NAME. |
`------------------------------------------------------------------*/
`-----------------------------------------------------------------*/
void
symbol_type_set (symbol_t *symbol, struniq_t type_name, location_t location)
symbol_type_set (symbol *sym, uniqstr type_name, location loc)
{
if (type_name)
{
if (symbol->type_name)
complain_at (location,
_("type redeclaration for %s"), symbol->tag);
struniq_assert (type_name);
symbol->type_name = type_name;
}
}
/*-------------------------------------------------------------------.
| Set the DESTRUCTOR associated to SYMBOL. Do nothing if passed 0. |
`-------------------------------------------------------------------*/
void
symbol_destructor_set (symbol_t *symbol, char *destructor, location_t location)
{
if (destructor)
{
if (symbol->destructor)
complain_at (location,
_("%s redeclaration for %s"),
"%destructor", symbol->tag);
symbol->destructor = destructor;
symbol->destructor_location = location;
}
}
/*----------------------------------------------------------------.
| Set the PRINTER associated to SYMBOL. Do nothing if passed 0. |
`----------------------------------------------------------------*/
void
symbol_printer_set (symbol_t *symbol, char *printer, location_t location)
{
if (printer)
{
if (symbol->printer)
complain_at (location,
_("%s redeclaration for %s"),
"%printer", symbol->tag);
symbol->printer = printer;
symbol->printer_location = location;
if (sym->type_name)
complain_at (loc, _("type redeclaration for %s"), sym->tag);
uniqstr_assert (type_name);
sym->type_name = type_name;
}
}
/*------------------------------------------------------------------.
| Set the PRECEDENCE associated to SYMBOL. Does nothing if invoked |
| with UNDEF_ASSOC as ASSOC. |
| Set the DESTRUCTOR associated with SYM. Do nothing if passed 0. |
`------------------------------------------------------------------*/
void
symbol_precedence_set (symbol_t *symbol,
int prec, assoc_t assoc, location_t location)
symbol_destructor_set (symbol *sym, char *destructor, location loc)
{
if (assoc != undef_assoc)
if (destructor)
{
if (symbol->prec != 0)
complain_at (location,
_("redefining precedence of %s"),
symbol->tag);
symbol->prec = prec;
symbol->assoc = assoc;
if (sym->destructor)
complain_at (loc, _("%s redeclaration for %s"),
"%destructor", sym->tag);
sym->destructor = destructor;
sym->destructor_location = loc;
}
}
/*---------------------------------------------------------------.
| Set the PRINTER associated with SYM. Do nothing if passed 0. |
`---------------------------------------------------------------*/
void
symbol_printer_set (symbol *sym, char *printer, location loc)
{
if (printer)
{
if (sym->printer)
complain_at (loc, _("%s redeclaration for %s"),
"%printer", sym->tag);
sym->printer = printer;
sym->printer_location = loc;
}
}
/*-----------------------------------------------------------------.
| Set the PRECEDENCE associated with SYM. Does nothing if invoked |
| with UNDEF_ASSOC as ASSOC. |
`-----------------------------------------------------------------*/
void
symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
{
if (a != undef_assoc)
{
if (sym->prec != 0)
complain_at (loc, _("redefining precedence of %s"), sym->tag);
sym->prec = prec;
sym->assoc = a;
}
/* Only terminals have a precedence. */
symbol_class_set (symbol, token_sym, location);
symbol_class_set (sym, token_sym, loc);
}
/*-------------------------------------.
| Set the CLASS associated to SYMBOL. |
`-------------------------------------*/
/*------------------------------------.
| Set the CLASS associated with SYM. |
`------------------------------------*/
void
symbol_class_set (symbol_t *symbol, symbol_class class, location_t location)
symbol_class_set (symbol *sym, symbol_class class, location loc)
{
if (symbol->class != unknown_sym && symbol->class != class)
complain_at (location, _("symbol %s redefined"), symbol->tag);
if (sym->class != unknown_sym && sym->class != class)
complain_at (loc, _("symbol %s redefined"), sym->tag);
if (class == nterm_sym && symbol->class != nterm_sym)
symbol->number = nvars++;
else if (class == token_sym && symbol->number == NUMBER_UNDEFINED)
symbol->number = ntokens++;
if (class == nterm_sym && sym->class != nterm_sym)
sym->number = nvars++;
else if (class == token_sym && sym->number == NUMBER_UNDEFINED)
sym->number = ntokens++;
symbol->class = class;
sym->class = class;
}
/*-------------------------------------------------.
| Set the USER_TOKEN_NUMBER associated to SYMBOL. |
`-------------------------------------------------*/
/*------------------------------------------------.
| Set the USER_TOKEN_NUMBER associated with SYM. |
`------------------------------------------------*/
void
symbol_user_token_number_set (symbol_t *symbol,
int user_token_number, location_t location)
symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
{
if (symbol->class != token_sym)
if (sym->class != token_sym)
abort ();
if (symbol->user_token_number != USER_NUMBER_UNDEFINED
&& symbol->user_token_number != user_token_number)
complain_at (location, _("redefining user token number of %s"),
symbol->tag);
if (sym->user_token_number != USER_NUMBER_UNDEFINED
&& sym->user_token_number != user_token_number)
complain_at (loc, _("redefining user token number of %s"), sym->tag);
symbol->user_token_number = user_token_number;
sym->user_token_number = user_token_number;
/* User defined $end token? */
if (user_token_number == 0)
{
endtoken = symbol;
endtoken = sym;
endtoken->number = 0;
/* It is always mapped to 0, so it was already counted in
NTOKENS. */
@@ -196,67 +190,67 @@ symbol_user_token_number_set (symbol_t *symbol,
}
/*------------.
| Free THIS. |
`------------*/
/*-----------.
| Free SYM. |
`-----------*/
static void
symbol_free (symbol_t *this)
symbol_free (symbol *sym)
{
free (this);
free (sym);
}
/*-----------------------------------------------------------.
| If THIS is not defined, report an error, and consider it a |
/*----------------------------------------------------------.
| If SYM is not defined, report an error, and consider it a |
| nonterminal. |
`-----------------------------------------------------------*/
`----------------------------------------------------------*/
static bool
symbol_check_defined (symbol_t *this)
symbol_check_defined (symbol *sym)
{
if (this->class == unknown_sym)
if (sym->class == unknown_sym)
{
complain_at
(this->location,
(sym->location,
_("symbol %s is used, but is not defined as a token and has no rules"),
this->tag);
this->class = nterm_sym;
this->number = nvars++;
sym->tag);
sym->class = nterm_sym;
sym->number = nvars++;
}
return true;
}
/*-------------------------------------------------------------------.
| Declare the new SYMBOL. Make it an alias of SYMVAL, and type them |
| with TYPENAME. |
`-------------------------------------------------------------------*/
/*------------------------------------------------------------------.
| Declare the new symbol SYM. Make it an alias of SYMVAL, and type |
| them with TYPENAME. |
`------------------------------------------------------------------*/
void
symbol_make_alias (symbol_t *symbol, symbol_t *symval, location_t loc)
symbol_make_alias (symbol *sym, symbol *symval, location loc)
{
if (symval->alias)
warn_at (loc, _("symbol `%s' used more than once as a literal string"),
symval->tag);
else if (symbol->alias)
else if (sym->alias)
warn_at (loc, _("symbol `%s' given more than one literal string"),
symbol->tag);
sym->tag);
else
{
symval->class = token_sym;
symval->user_token_number = symbol->user_token_number;
symbol->user_token_number = USER_NUMBER_ALIAS;
symval->alias = symbol;
symbol->alias = symval;
/* symbol and symval combined are only one symbol */
symval->user_token_number = sym->user_token_number;
sym->user_token_number = USER_NUMBER_ALIAS;
symval->alias = sym;
sym->alias = symval;
/* sym and symval combined are only one symbol. */
nsyms--;
ntokens--;
if (ntokens != symbol->number && ntokens != symval->number)
if (ntokens != sym->number && ntokens != symval->number)
abort ();
symbol->number = symval->number =
(symval->number < symbol->number) ? symval->number : symbol->number;
sym->number = symval->number =
(symval->number < sym->number) ? symval->number : sym->number;
}
}
@@ -267,7 +261,7 @@ symbol_make_alias (symbol_t *symbol, symbol_t *symval, location_t loc)
`---------------------------------------------------------*/
static bool
symbol_check_alias_consistence (symbol_t *this)
symbol_check_alias_consistence (symbol *this)
{
/* Check only those who _are_ the aliases. */
if (this->alias && this->user_token_number == USER_NUMBER_ALIAS)
@@ -307,7 +301,7 @@ symbol_check_alias_consistence (symbol_t *this)
`-------------------------------------------------------------------*/
static bool
symbol_pack (symbol_t *this)
symbol_pack (symbol *this)
{
if (this->class == nterm_sym)
{
@@ -351,7 +345,7 @@ symbol_pack (symbol_t *this)
`--------------------------------------------------*/
static bool
symbol_translation (symbol_t *this)
symbol_translation (symbol *this)
{
/* Non-terminal? */
if (this->class == token_sym
@@ -381,14 +375,14 @@ symbol_translation (symbol_t *this)
static struct hash_table *symbol_table = NULL;
static bool
hash_compare_symbol (const symbol_t *m1, const symbol_t *m2)
hash_compare_symbol (const symbol *m1, const symbol *m2)
{
/* Since tags are unique, we can compare the pointers themselves. */
return STRUNIQ_EQ (m1->tag, m2->tag);
return UNIQSTR_EQ (m1->tag, m2->tag);
}
static unsigned int
hash_symbol (const symbol_t *m, unsigned int tablesize)
hash_symbol (const symbol *m, unsigned int tablesize)
{
/* Since tags are unique, we can hash the pointer itself. */
return ((size_t) m->tag) % tablesize;
@@ -415,21 +409,21 @@ symbols_new (void)
| yet, create it. |
`----------------------------------------------------------------*/
symbol_t *
symbol_get (const char *key, location_t location)
symbol *
symbol_get (const char *key, location loc)
{
symbol_t probe;
symbol_t *entry;
symbol probe;
symbol *entry;
/* Keep the symbol in a printable form. */
key = struniq_new (quotearg_style (escape_quoting_style, key));
key = uniqstr_new (quotearg_style (escape_quoting_style, key));
*(char const **) &probe.tag = key;
entry = hash_lookup (symbol_table, &probe);
if (!entry)
{
/* First insertion in the hash. */
entry = symbol_new (key, location);
entry = symbol_new (key, loc);
hash_insert (symbol_table, entry);
}
return entry;
@@ -441,17 +435,17 @@ symbol_get (const char *key, location_t location)
| user's names. |
`------------------------------------------------------------------*/
symbol_t *
dummy_symbol_get (location_t location)
symbol *
dummy_symbol_get (location loc)
{
/* Incremented for each generated symbol. */
static int dummy_count = 0;
static char buf[256];
symbol_t *sym;
symbol *sym;
sprintf (buf, "@%d", ++dummy_count);
sym = symbol_get (buf, location);
sym = symbol_get (buf, loc);
sym->class = nterm_sym;
sym->number = nvars++;
return sym;
@@ -511,7 +505,7 @@ symbols_token_translations_init (void)
max_user_token_number = 0;
for (i = 0; i < ntokens; ++i)
{
symbol_t *this = symbols[i];
symbol *this = symbols[i];
if (this->user_token_number != USER_NUMBER_UNDEFINED)
{
if (this->user_token_number > max_user_token_number)
@@ -532,14 +526,14 @@ symbols_token_translations_init (void)
for (i = 0; i < ntokens; ++i)
{
symbol_t *this = symbols[i];
symbol *this = symbols[i];
if (this->user_token_number == USER_NUMBER_UNDEFINED)
this->user_token_number = ++max_user_token_number;
if (this->user_token_number > max_user_token_number)
max_user_token_number = this->user_token_number;
}
token_translations = XCALLOC (symbol_number_t, max_user_token_number + 1);
token_translations = XCALLOC (symbol_number, max_user_token_number + 1);
/* Initialize all entries for literal tokens to 2, the internal
token number for $undefined, which represents all invalid inputs.
@@ -558,7 +552,7 @@ symbols_token_translations_init (void)
void
symbols_pack (void)
{
symbols = XCALLOC (symbol_t *, nsyms);
symbols = XCALLOC (symbol *, nsyms);
symbols_do (symbol_check_alias_consistence, NULL);
symbols_do (symbol_pack, NULL);

620
src/vcg.c
View File

@@ -19,9 +19,11 @@
Boston, MA 02111-1307, USA. */
#include "system.h"
#include <quotearg.h>
#include "vcg.h"
#include "vcg_defaults.h"
#include "quotearg.h"
/* Return an unambiguous printable representated, for NAME, suitable
for C strings. Use slot 2 since the user may use slots 0 and 1.
@@ -36,7 +38,7 @@ quote (char const *name)
/* Initialize a graph with the default values. */
void
new_graph (graph_t *g)
new_graph (graph *g)
{
g->title = G_TITLE;
g->label = G_LABEL;
@@ -56,7 +58,7 @@ new_graph (graph_t *g)
g->y = G_Y;
g->folding = G_FOLDING;
g->shrink = G_SHRINK;
g->stretch = G_STRETCH;
g->expand = G_EXPAND;
g->textmode = G_TEXTMODE;
g->shape = G_SHAPE;
@@ -93,14 +95,14 @@ new_graph (graph_t *g)
g->dirty_edge_labels = G_DIRTY_EDGE_LABELS;
g->finetuning = G_FINETUNING;
g->ignore_singles = G_IGNORE_SINGLES;
g->straight_phase = G_STRAIGHT_PHASE;
g->long_straight_phase = G_LONG_STRAIGHT_PHASE;
g->priority_phase = G_PRIORITY_PHASE;
g->manhattan_edges = G_MANHATTAN_EDGES;
g->smanhattan_edges = G_SMANHATTAN_EDGES;
g->near_edges = G_NEAR_EDGES;
g->orientation = G_ORIENTATION;
g->node_alignement = G_NODE_ALIGNEMENT;
g->node_alignment = G_NODE_ALIGNMENT;
g->port_sharing = G_PORT_SHARING;
g->arrow_mode = G_ARROW_MODE;
g->treefactor = G_TREEFACTOR;
@@ -126,79 +128,79 @@ new_graph (graph_t *g)
g->node_list = G_NODE_LIST;
g->edge_list = G_EDGE_LIST;
new_edge(&g->edge);
new_node(&g->node);
new_edge (&g->edge);
new_node (&g->node);
}
/* Initialize a node with the defalut values. */
/* Initialize a node with the default values. */
void
new_node (node_t *node)
new_node (node *n)
{
node->title = N_TITLE;
node->label = N_LABEL;
n->title = N_TITLE;
n->label = N_LABEL;
node->locx = N_LOCX; /* Default unspcified. */
node->locy = N_LOCY; /* Default unspcified. */
n->locx = N_LOCX; /* Default unspcified. */
n->locy = N_LOCY; /* Default unspcified. */
node->vertical_order = N_VERTICAL_ORDER; /* Default unspcified. */
node->horizontal_order = N_HORIZONTAL_ORDER; /* Default unspcified. */
n->vertical_order = N_VERTICAL_ORDER; /* Default unspcified. */
n->horizontal_order = N_HORIZONTAL_ORDER; /* Default unspcified. */
node->width = N_WIDTH; /* We assume that we can't define it now. */
node->height = N_HEIGHT; /* Also. */
n->width = N_WIDTH; /* We assume that we can't define it now. */
n->height = N_HEIGHT; /* Also. */
node->shrink = N_SHRINK;
node->stretch = N_STRETCH;
n->shrink = N_SHRINK;
n->expand = N_EXPAND;
node->folding = N_FOLDING; /* No explicit default value. */
n->folding = N_FOLDING; /* No explicit default value. */
node->shape = N_SHAPE;
node->textmode = N_TEXTMODE;
node->borderwidth = N_BORDERWIDTH;
n->shape = N_SHAPE;
n->textmode = N_TEXTMODE;
n->borderwidth = N_BORDERWIDTH;
node->color = N_COLOR;
node->textcolor = N_TEXTCOLOR;
node->bordercolor = N_BORDERCOLOR;
n->color = N_COLOR;
n->textcolor = N_TEXTCOLOR;
n->bordercolor = N_BORDERCOLOR;
node->infos[0] = N_INFOS1;
node->infos[1] = N_INFOS2;
node->infos[2] = N_INFOS3;
n->infos[0] = N_INFOS1;
n->infos[1] = N_INFOS2;
n->infos[2] = N_INFOS3;
node->next = N_NEXT;
n->next = N_NEXT;
}
/* Initialize a edge with the defalut values. */
/* Initialize an edge with the default values. */
void
new_edge (edge_t *edge)
new_edge (edge *e)
{
edge->type = E_EDGE_TYPE;
e->type = E_EDGE_TYPE;
edge->sourcename = E_SOURCENAME;
edge->targetname = E_TARGETNAME;
edge->label = E_LABEL;
e->sourcename = E_SOURCENAME;
e->targetname = E_TARGETNAME;
e->label = E_LABEL;
edge->linestyle = E_LINESTYLE;
edge->thickness = E_THICKNESS;
e->linestyle = E_LINESTYLE;
e->thickness = E_THICKNESS;
edge->class = E_CLASS;
e->class = E_CLASS;
edge->color = E_COLOR;
edge->textcolor = E_TEXTCOLOR;
edge->arrowcolor = E_ARROWCOLOR;
edge->backarrowcolor = E_BACKARROWCOLOR;
e->color = E_COLOR;
e->textcolor = E_TEXTCOLOR;
e->arrowcolor = E_ARROWCOLOR;
e->backarrowcolor = E_BACKARROWCOLOR;
edge->arrowsize = E_ARROWSIZE;
edge->backarrowsize = E_BACKARROWSIZE;
edge->arrowstyle = E_ARROWSTYLE;
e->arrowsize = E_ARROWSIZE;
e->backarrowsize = E_BACKARROWSIZE;
e->arrowstyle = E_ARROWSTYLE;
edge->backarrowstyle = E_BACKARROWSTYLE;
e->backarrowstyle = E_BACKARROWSTYLE;
edge->priority = E_PRIORITY;
e->priority = E_PRIORITY;
edge->anchor = E_ANCHOR;
e->anchor = E_ANCHOR;
edge->horizontal_order = E_HORIZONTAL_ORDER;
e->horizontal_order = E_HORIZONTAL_ORDER;
edge->next = E_NEXT;
e->next = E_NEXT;
}
/*----------------------------------------------.
@@ -207,7 +209,7 @@ new_edge (edge_t *edge)
`----------------------------------------------*/
static const char *
get_color_str (enum color_e c)
get_color_str (enum color c)
{
switch (c)
{
@@ -248,7 +250,7 @@ get_color_str (enum color_e c)
}
static const char *
get_textmode_str (enum textmode_e t)
get_textmode_str (enum textmode t)
{
switch (t)
{
@@ -260,7 +262,7 @@ get_textmode_str (enum textmode_e t)
}
static const char *
get_shape_str (enum shape_e s)
get_shape_str (enum shape s)
{
switch (s)
{
@@ -273,7 +275,7 @@ get_shape_str (enum shape_e s)
}
static const char *
get_layoutalgorithm_str (enum layoutalgorithm_e l)
get_layoutalgorithm_str (enum layoutalgorithm l)
{
switch (l)
{
@@ -296,7 +298,7 @@ get_layoutalgorithm_str (enum layoutalgorithm_e l)
}
static const char *
get_decision_str (enum decision_e d)
get_decision_str (enum decision d)
{
switch (d)
{
@@ -307,7 +309,7 @@ get_decision_str (enum decision_e d)
}
static const char *
get_orientation_str (enum orientation_e o)
get_orientation_str (enum orientation o)
{
switch (o)
{
@@ -320,7 +322,7 @@ get_orientation_str (enum orientation_e o)
}
static const char *
get_node_alignement_str (enum alignement_e a)
get_node_alignment_str (enum alignment a)
{
switch (a)
{
@@ -332,7 +334,7 @@ get_node_alignement_str (enum alignement_e a)
}
static const char *
get_arrow_mode_str (enum arrow_mode_e a)
get_arrow_mode_str (enum arrow_mode a)
{
switch (a)
{
@@ -343,7 +345,7 @@ get_arrow_mode_str (enum arrow_mode_e a)
}
static const char *
get_crossing_type_str (enum crossing_type_e c)
get_crossing_type_str (enum crossing_type c)
{
switch (c)
{
@@ -356,7 +358,7 @@ get_crossing_type_str (enum crossing_type_e c)
}
static const char *
get_view_str (enum view_e v)
get_view_str (enum view v)
{
switch (v)
{
@@ -370,7 +372,7 @@ get_view_str (enum view_e v)
}
static const char *
get_linestyle_str (enum linestyle_e l)
get_linestyle_str (enum linestyle l)
{
switch (l)
{
@@ -383,7 +385,7 @@ get_linestyle_str (enum linestyle_e l)
}
static const char *
get_arrowstyle_str (enum arrowstyle_e a)
get_arrowstyle_str (enum arrowstyle a)
{
switch (a)
{
@@ -394,31 +396,31 @@ get_arrowstyle_str (enum arrowstyle_e a)
}
}
/*----------------------------.
/*------------------------------.
| Add functions. |
| Edge and Nodes int a graph. |
`----------------------------*/
| Edge and nodes into a graph. |
`------------------------------*/
void
add_node (graph_t *graph, node_t *node)
add_node (graph *g, node *n)
{
node->next = graph->node_list;
graph->node_list = node;
n->next = g->node_list;
g->node_list = n;
}
void
add_edge (graph_t *graph, edge_t *edge)
add_edge (graph *g, edge *e)
{
edge->next = graph->edge_list;
graph->edge_list = edge;
e->next = g->edge_list;
g->edge_list = e;
}
void
add_classname (graph_t *g, int val, const char *name)
add_classname (graph *g, int val, const char *name)
{
struct classname_s *classname;
struct classname *classname;
classname = XMALLOC (struct classname_s, 1);
classname = XMALLOC (struct classname, 1);
classname->no = val;
classname->name = name;
classname->next = g->classname;
@@ -426,25 +428,25 @@ add_classname (graph_t *g, int val, const char *name)
}
void
add_infoname (graph_t *g, int integer, const char *string)
add_infoname (graph *g, int integer, const char *str)
{
struct infoname_s *infoname;
struct infoname *infoname;
infoname = XMALLOC (struct infoname_s, 1);
infoname = XMALLOC (struct infoname, 1);
infoname->integer = integer;
infoname->string = string;
infoname->chars = str;
infoname->next = g->infoname;
g->infoname = infoname;
}
/* Build a colorentry struct and add it to the list. */
void
add_colorentry (graph_t *g, int color_idx, int red_cp,
add_colorentry (graph *g, int color_idx, int red_cp,
int green_cp, int blue_cp)
{
struct colorentry_s *ce;
struct colorentry *ce;
ce = XMALLOC (struct colorentry_s, 1);
ce = XMALLOC (struct colorentry, 1);
ce->color_index = color_idx;
ce->red_cp = red_cp;
ce->green_cp = green_cp;
@@ -458,9 +460,9 @@ add_colorentry (graph_t *g, int color_idx, int red_cp,
`-------------------------------------*/
void
open_edge(edge_t *edge, FILE *fout)
open_edge (edge *e, FILE *fout)
{
switch (edge->type)
switch (e->type)
{
case normal_edge:
fputs ("\tedge: {\n", fout);
@@ -480,42 +482,42 @@ open_edge(edge_t *edge, FILE *fout)
}
void
close_edge(FILE *fout)
close_edge (FILE *fout)
{
fputs ("\t}\n", fout);
}
void
open_node(FILE *fout)
open_node (FILE *fout)
{
fputs ("\tnode: {\n", fout);
}
void
close_node(FILE *fout)
close_node (FILE *fout)
{
fputs ("\t}\n", fout);
}
void
open_graph(FILE *fout)
open_graph (FILE *fout)
{
fputs ("graph: {\n", fout);
}
void
close_graph(graph_t *graph, FILE *fout)
close_graph (graph *g, FILE *fout)
{
fputc ('\n', fout);
/* FIXME: Unallocate nodes and edges if required. */
{
node_t *node;
node *n;
for (node = graph->node_list; node; node = node->next)
for (n = g->node_list; n; n = n->next)
{
open_node (fout);
output_node (node, fout);
output_node (n, fout);
close_node (fout);
}
}
@@ -523,12 +525,12 @@ close_graph(graph_t *graph, FILE *fout)
fputc ('\n', fout);
{
edge_t *edge;
edge *e;
for (edge = graph->edge_list; edge; edge = edge->next)
for (e = g->edge_list; e; e = e->next)
{
open_edge (edge, fout);
output_edge (edge, fout);
open_edge (e, fout);
output_edge (e, fout);
close_edge (fout);
}
}
@@ -541,221 +543,221 @@ close_graph(graph_t *graph, FILE *fout)
`-------------------------------------------*/
void
output_node (node_t *node, FILE *fout)
output_node (node *n, FILE *fout)
{
if (node->title != N_TITLE)
fprintf (fout, "\t\ttitle:\t%s\n", quote (node->title));
if (node->label != N_LABEL)
fprintf (fout, "\t\tlabel:\t%s\n", quote (node->label));
if (n->title != N_TITLE)
fprintf (fout, "\t\ttitle:\t%s\n", quote (n->title));
if (n->label != N_LABEL)
fprintf (fout, "\t\tlabel:\t%s\n", quote (n->label));
if ((node->locx != N_LOCX) && (node->locy != N_LOCY))
fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", node->locx, node->locy);
if ((n->locx != N_LOCX) && (n->locy != N_LOCY))
fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", n->locx, n->locy);
if (node->vertical_order != N_VERTICAL_ORDER)
fprintf (fout, "\t\tvertical_order:\t%d\n", node->vertical_order);
if (node->horizontal_order != N_HORIZONTAL_ORDER)
fprintf (fout, "\t\thorizontal_order:\t%d\n", node->horizontal_order);
if (n->vertical_order != N_VERTICAL_ORDER)
fprintf (fout, "\t\tvertical_order:\t%d\n", n->vertical_order);
if (n->horizontal_order != N_HORIZONTAL_ORDER)
fprintf (fout, "\t\thorizontal_order:\t%d\n", n->horizontal_order);
if (node->width != N_WIDTH)
fprintf (fout, "\t\twidth:\t%d\n", node->width);
if (node->height != N_HEIGHT)
fprintf (fout, "\t\theight:\t%d\n", node->height);
if (n->width != N_WIDTH)
fprintf (fout, "\t\twidth:\t%d\n", n->width);
if (n->height != N_HEIGHT)
fprintf (fout, "\t\theight:\t%d\n", n->height);
if (node->shrink != N_SHRINK)
fprintf (fout, "\t\tshrink:\t%d\n", node->shrink);
if (node->stretch != N_STRETCH)
fprintf (fout, "\t\tstretch:\t%d\n", node->stretch);
if (n->shrink != N_SHRINK)
fprintf (fout, "\t\tshrink:\t%d\n", n->shrink);
if (n->expand != N_EXPAND)
fprintf (fout, "\t\texpand:\t%d\n", n->expand);
if (node->folding != N_FOLDING)
fprintf (fout, "\t\tfolding:\t%d\n", node->folding);
if (n->folding != N_FOLDING)
fprintf (fout, "\t\tfolding:\t%d\n", n->folding);
if (node->textmode != N_TEXTMODE)
if (n->textmode != N_TEXTMODE)
fprintf (fout, "\t\ttextmode:\t%s\n",
get_textmode_str (node->textmode));
get_textmode_str (n->textmode));
if (node->shape != N_SHAPE)
fprintf (fout, "\t\tshape:\t%s\n", get_shape_str (node->shape));
if (n->shape != N_SHAPE)
fprintf (fout, "\t\tshape:\t%s\n", get_shape_str (n->shape));
if (node->borderwidth != N_BORDERWIDTH)
fprintf (fout, "\t\tborderwidth:\t%d\n", node->borderwidth);
if (n->borderwidth != N_BORDERWIDTH)
fprintf (fout, "\t\tborderwidth:\t%d\n", n->borderwidth);
if (node->color != N_COLOR)
fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (node->color));
if (node->textcolor != N_TEXTCOLOR)
if (n->color != N_COLOR)
fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (n->color));
if (n->textcolor != N_TEXTCOLOR)
fprintf (fout, "\t\ttextcolor:\t%s\n",
get_color_str (node->textcolor));
if (node->bordercolor != N_BORDERCOLOR)
get_color_str (n->textcolor));
if (n->bordercolor != N_BORDERCOLOR)
fprintf (fout, "\t\tbordercolor:\t%s\n",
get_color_str (node->bordercolor));
get_color_str (n->bordercolor));
{
int i;
for (i = 0; i < 3; ++i)
if (node->infos[i])
if (n->infos[i])
fprintf (fout, "\t\tinfo%d:\t%s\n",
i, quote (node->infos[i]));
i, quote (n->infos[i]));
}
}
void
output_edge (edge_t *edge, FILE *fout)
output_edge (edge *e, FILE *fout)
{
/* FIXME: SOURCENAME and TARGETNAME are mandatory
so it has to be fatal not to give these informations. */
if (edge->sourcename != E_SOURCENAME)
fprintf (fout, "\t\tsourcename:\t%s\n", quote (edge->sourcename));
if (edge->targetname != E_TARGETNAME)
fprintf (fout, "\t\ttargetname:\t%s\n", quote (edge->targetname));
if (e->sourcename != E_SOURCENAME)
fprintf (fout, "\t\tsourcename:\t%s\n", quote (e->sourcename));
if (e->targetname != E_TARGETNAME)
fprintf (fout, "\t\ttargetname:\t%s\n", quote (e->targetname));
if (edge->label != E_LABEL)
fprintf (fout, "\t\tlabel:\t%s\n", quote (edge->label));
if (e->label != E_LABEL)
fprintf (fout, "\t\tlabel:\t%s\n", quote (e->label));
if (edge->linestyle != E_LINESTYLE)
if (e->linestyle != E_LINESTYLE)
fprintf (fout, "\t\tlinestyle:\t%s\n",
quote (get_linestyle_str(edge->linestyle)));
quote (get_linestyle_str (e->linestyle)));
if (edge->thickness != E_THICKNESS)
fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness);
if (edge->class != E_CLASS)
fprintf (fout, "\t\tclass:\t%d\n", edge->class);
if (e->thickness != E_THICKNESS)
fprintf (fout, "\t\tthickness:\t%d\n", e->thickness);
if (e->class != E_CLASS)
fprintf (fout, "\t\tclass:\t%d\n", e->class);
if (edge->color != E_COLOR)
fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (edge->color));
if (edge->color != E_TEXTCOLOR)
if (e->color != E_COLOR)
fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (e->color));
if (e->color != E_TEXTCOLOR)
fprintf (fout, "\t\ttextcolor:\t%s\n",
get_color_str (edge->textcolor));
if (edge->arrowcolor != E_ARROWCOLOR)
get_color_str (e->textcolor));
if (e->arrowcolor != E_ARROWCOLOR)
fprintf (fout, "\t\tarrowcolor:\t%s\n",
get_color_str (edge->arrowcolor));
if (edge->backarrowcolor != E_BACKARROWCOLOR)
get_color_str (e->arrowcolor));
if (e->backarrowcolor != E_BACKARROWCOLOR)
fprintf (fout, "\t\tbackarrowcolor:\t%s\n",
get_color_str (edge->backarrowcolor));
get_color_str (e->backarrowcolor));
if (edge->arrowsize != E_ARROWSIZE)
fprintf (fout, "\t\tarrowsize:\t%d\n", edge->arrowsize);
if (edge->backarrowsize != E_BACKARROWSIZE)
fprintf (fout, "\t\tbackarrowsize:\t%d\n", edge->backarrowsize);
if (e->arrowsize != E_ARROWSIZE)
fprintf (fout, "\t\tarrowsize:\t%d\n", e->arrowsize);
if (e->backarrowsize != E_BACKARROWSIZE)
fprintf (fout, "\t\tbackarrowsize:\t%d\n", e->backarrowsize);
if (edge->arrowstyle != E_ARROWSTYLE)
if (e->arrowstyle != E_ARROWSTYLE)
fprintf (fout, "\t\tarrowstyle:\t%s\n",
get_arrowstyle_str(edge->arrowstyle));
if (edge->backarrowstyle != E_BACKARROWSTYLE)
get_arrowstyle_str (e->arrowstyle));
if (e->backarrowstyle != E_BACKARROWSTYLE)
fprintf (fout, "\t\tbackarrowstyle:\t%s\n",
get_arrowstyle_str(edge->backarrowstyle));
get_arrowstyle_str (e->backarrowstyle));
if (edge->priority != E_PRIORITY)
fprintf (fout, "\t\tpriority:\t%d\n", edge->priority);
if (edge->anchor != E_ANCHOR)
fprintf (fout, "\t\tanchor:\t%d\n", edge->anchor);
if (edge->horizontal_order != E_HORIZONTAL_ORDER)
fprintf (fout, "\t\thorizontal_order:\t%d\n", edge->horizontal_order);
if (e->priority != E_PRIORITY)
fprintf (fout, "\t\tpriority:\t%d\n", e->priority);
if (e->anchor != E_ANCHOR)
fprintf (fout, "\t\tanchor:\t%d\n", e->anchor);
if (e->horizontal_order != E_HORIZONTAL_ORDER)
fprintf (fout, "\t\thorizontal_order:\t%d\n", e->horizontal_order);
}
void
output_graph (graph_t *graph, FILE *fout)
output_graph (graph *g, FILE *fout)
{
if (graph->title)
fprintf (fout, "\ttitle:\t%s\n", quote (graph->title));
if (graph->label)
fprintf (fout, "\tlabel:\t%s\n", quote (graph->label));
if (g->title)
fprintf (fout, "\ttitle:\t%s\n", quote (g->title));
if (g->label)
fprintf (fout, "\tlabel:\t%s\n", quote (g->label));
{
int i;
for (i = 0; i < 3; ++i)
if (graph->infos[i])
fprintf (fout, "\tinfo%d:\t%s\n", i, quote (graph->infos[i]));
if (g->infos[i])
fprintf (fout, "\tinfo%d:\t%s\n", i, quote (g->infos[i]));
}
if (graph->color != G_COLOR)
fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color));
if (graph->textcolor != G_TEXTCOLOR)
fprintf (fout, "\ttextcolor:\t%s\n", get_color_str (graph->textcolor));
if (graph->bordercolor != G_BORDERCOLOR)
if (g->color != G_COLOR)
fprintf (fout, "\tcolor:\t%s\n", get_color_str (g->color));
if (g->textcolor != G_TEXTCOLOR)
fprintf (fout, "\ttextcolor:\t%s\n", get_color_str (g->textcolor));
if (g->bordercolor != G_BORDERCOLOR)
fprintf (fout, "\tbordercolor:\t%s\n",
get_color_str (graph->bordercolor));
get_color_str (g->bordercolor));
if (graph->width != G_WIDTH)
fprintf (fout, "\twidth:\t%d\n", graph->width);
if (graph->height != G_HEIGHT)
fprintf (fout, "\theight:\t%d\n", graph->height);
if (graph->borderwidth != G_BORDERWIDTH)
fprintf (fout, "\tborderwidth:\t%d\n", graph->borderwidth);
if (g->width != G_WIDTH)
fprintf (fout, "\twidth:\t%d\n", g->width);
if (g->height != G_HEIGHT)
fprintf (fout, "\theight:\t%d\n", g->height);
if (g->borderwidth != G_BORDERWIDTH)
fprintf (fout, "\tborderwidth:\t%d\n", g->borderwidth);
if (graph->x != G_X)
fprintf (fout, "\tx:\t%d\n", graph->x);
if (graph->y != G_Y)
fprintf (fout, "\ty:\t%d\n", graph->y);
if (g->x != G_X)
fprintf (fout, "\tx:\t%d\n", g->x);
if (g->y != G_Y)
fprintf (fout, "\ty:\t%d\n", g->y);
if (graph->folding != G_FOLDING)
fprintf (fout, "\tfolding:\t%d\n", graph->folding);
if (g->folding != G_FOLDING)
fprintf (fout, "\tfolding:\t%d\n", g->folding);
if (graph->shrink != G_SHRINK)
fprintf (fout, "\tshrink:\t%d\n", graph->shrink);
if (graph->stretch != G_STRETCH)
fprintf (fout, "\tstretch:\t%d\n", graph->stretch);
if (g->shrink != G_SHRINK)
fprintf (fout, "\tshrink:\t%d\n", g->shrink);
if (g->expand != G_EXPAND)
fprintf (fout, "\texpand:\t%d\n", g->expand);
if (graph->textmode != G_TEXTMODE)
if (g->textmode != G_TEXTMODE)
fprintf (fout, "\ttextmode:\t%s\n",
get_textmode_str (graph->textmode));
get_textmode_str (g->textmode));
if (graph->shape != G_SHAPE)
fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape));
if (g->shape != G_SHAPE)
fprintf (fout, "\tshape:\t%s\n", get_shape_str (g->shape));
if (graph->vertical_order != G_VERTICAL_ORDER)
fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order);
if (graph->horizontal_order != G_HORIZONTAL_ORDER)
fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order);
if (g->vertical_order != G_VERTICAL_ORDER)
fprintf (fout, "\tvertical_order:\t%d\n", g->vertical_order);
if (g->horizontal_order != G_HORIZONTAL_ORDER)
fprintf (fout, "\thorizontal_order:\t%d\n", g->horizontal_order);
if (graph->xmax != G_XMAX)
fprintf (fout, "\txmax:\t%d\n", graph->xmax);
if (graph->ymax != G_YMAX)
fprintf (fout, "\tymax:\t%d\n", graph->ymax);
if (g->xmax != G_XMAX)
fprintf (fout, "\txmax:\t%d\n", g->xmax);
if (g->ymax != G_YMAX)
fprintf (fout, "\tymax:\t%d\n", g->ymax);
if (graph->xbase != G_XBASE)
fprintf (fout, "\txbase:\t%d\n", graph->xbase);
if (graph->ybase != G_YBASE)
fprintf (fout, "\tybase:\t%d\n", graph->ybase);
if (g->xbase != G_XBASE)
fprintf (fout, "\txbase:\t%d\n", g->xbase);
if (g->ybase != G_YBASE)
fprintf (fout, "\tybase:\t%d\n", g->ybase);
if (graph->xspace != G_XSPACE)
fprintf (fout, "\txspace:\t%d\n", graph->xspace);
if (graph->yspace != G_YSPACE)
fprintf (fout, "\tyspace:\t%d\n", graph->yspace);
if (graph->xlspace != G_XLSPACE)
fprintf (fout, "\txlspace:\t%d\n", graph->xlspace);
if (g->xspace != G_XSPACE)
fprintf (fout, "\txspace:\t%d\n", g->xspace);
if (g->yspace != G_YSPACE)
fprintf (fout, "\tyspace:\t%d\n", g->yspace);
if (g->xlspace != G_XLSPACE)
fprintf (fout, "\txlspace:\t%d\n", g->xlspace);
if (graph->xraster != G_XRASTER)
fprintf (fout, "\txraster:\t%d\n", graph->xraster);
if (graph->yraster != G_YRASTER)
fprintf (fout, "\tyraster:\t%d\n", graph->yraster);
if (graph->xlraster != G_XLRASTER)
fprintf (fout, "\txlraster:\t%d\n", graph->xlraster);
if (g->xraster != G_XRASTER)
fprintf (fout, "\txraster:\t%d\n", g->xraster);
if (g->yraster != G_YRASTER)
fprintf (fout, "\tyraster:\t%d\n", g->yraster);
if (g->xlraster != G_XLRASTER)
fprintf (fout, "\txlraster:\t%d\n", g->xlraster);
if (graph->hidden != G_HIDDEN)
fprintf (fout, "\thidden:\t%d\n", graph->hidden);
if (g->hidden != G_HIDDEN)
fprintf (fout, "\thidden:\t%d\n", g->hidden);
/* FIXME: Unallocate struct list if required.
Maybe with a little function. */
if (graph->classname != G_CLASSNAME)
if (g->classname != G_CLASSNAME)
{
struct classname_s *ite;
struct classname *ite;
for (ite = graph->classname; ite; ite = ite->next)
for (ite = g->classname; ite; ite = ite->next)
fprintf (fout, "\tclassname %d :\t%s\n", ite->no, ite->name);
}
if (graph->infoname != G_INFONAME)
if (g->infoname != G_INFONAME)
{
struct infoname_s *ite;
struct infoname *ite;
for (ite = graph->infoname; ite; ite = ite->next)
fprintf (fout, "\tinfoname %d :\t%s\n", ite->integer, ite->string);
for (ite = g->infoname; ite; ite = ite->next)
fprintf (fout, "\tinfoname %d :\t%s\n", ite->integer, ite->chars);
}
if (graph->colorentry != G_COLORENTRY)
if (g->colorentry != G_COLORENTRY)
{
struct colorentry_s *ite;
struct colorentry *ite;
for (ite = graph->colorentry; ite; ite = ite->next)
for (ite = g->colorentry; ite; ite = ite->next)
{
fprintf (fout, "\tcolorentry %d :\t%d %d %d\n",
ite->color_index,
@@ -765,110 +767,110 @@ output_graph (graph_t *graph, FILE *fout)
}
}
if (graph->layoutalgorithm != G_LAYOUTALGORITHM)
if (g->layoutalgorithm != G_LAYOUTALGORITHM)
fprintf (fout, "\tlayoutalgorithm:\t%s\n",
get_layoutalgorithm_str(graph->layoutalgorithm));
get_layoutalgorithm_str (g->layoutalgorithm));
if (graph->layout_downfactor != G_LAYOUT_DOWNFACTOR)
fprintf (fout, "\tlayout_downfactor:\t%d\n", graph->layout_downfactor);
if (graph->layout_upfactor != G_LAYOUT_UPFACTOR)
fprintf (fout, "\tlayout_upfactor:\t%d\n", graph->layout_upfactor);
if (graph->layout_nearfactor != G_LAYOUT_NEARFACTOR)
fprintf (fout, "\tlayout_nearfactor:\t%d\n", graph->layout_nearfactor);
if (graph->layout_splinefactor != G_LAYOUT_SPLINEFACTOR)
if (g->layout_downfactor != G_LAYOUT_DOWNFACTOR)
fprintf (fout, "\tlayout_downfactor:\t%d\n", g->layout_downfactor);
if (g->layout_upfactor != G_LAYOUT_UPFACTOR)
fprintf (fout, "\tlayout_upfactor:\t%d\n", g->layout_upfactor);
if (g->layout_nearfactor != G_LAYOUT_NEARFACTOR)
fprintf (fout, "\tlayout_nearfactor:\t%d\n", g->layout_nearfactor);
if (g->layout_splinefactor != G_LAYOUT_SPLINEFACTOR)
fprintf (fout, "\tlayout_splinefactor:\t%d\n",
graph->layout_splinefactor);
g->layout_splinefactor);
if (graph->late_edge_labels != G_LATE_EDGE_LABELS)
if (g->late_edge_labels != G_LATE_EDGE_LABELS)
fprintf (fout, "\tlate_edge_labels:\t%s\n",
get_decision_str(graph->late_edge_labels));
if (graph->display_edge_labels != G_DISPLAY_EDGE_LABELS)
get_decision_str (g->late_edge_labels));
if (g->display_edge_labels != G_DISPLAY_EDGE_LABELS)
fprintf (fout, "\tdisplay_edge_labels:\t%s\n",
get_decision_str(graph->display_edge_labels));
if (graph->dirty_edge_labels != G_DIRTY_EDGE_LABELS)
get_decision_str (g->display_edge_labels));
if (g->dirty_edge_labels != G_DIRTY_EDGE_LABELS)
fprintf (fout, "\tdirty_edge_labels:\t%s\n",
get_decision_str(graph->dirty_edge_labels));
if (graph->finetuning != G_FINETUNING)
get_decision_str (g->dirty_edge_labels));
if (g->finetuning != G_FINETUNING)
fprintf (fout, "\tfinetuning:\t%s\n",
get_decision_str(graph->finetuning));
if (graph->ignore_singles != G_IGNORE_SINGLES)
get_decision_str (g->finetuning));
if (g->ignore_singles != G_IGNORE_SINGLES)
fprintf (fout, "\tignore_singles:\t%s\n",
get_decision_str(graph->ignore_singles));
if (graph->straight_phase != G_STRAIGHT_PHASE)
fprintf (fout, "\tstraight_phase:\t%s\n",
get_decision_str(graph->straight_phase));
if (graph->priority_phase != G_PRIORITY_PHASE)
get_decision_str (g->ignore_singles));
if (g->long_straight_phase != G_LONG_STRAIGHT_PHASE)
fprintf (fout, "\tlong_straight_phase:\t%s\n",
get_decision_str (g->long_straight_phase));
if (g->priority_phase != G_PRIORITY_PHASE)
fprintf (fout, "\tpriority_phase:\t%s\n",
get_decision_str(graph->priority_phase));
if (graph->manhattan_edges != G_MANHATTAN_EDGES)
get_decision_str (g->priority_phase));
if (g->manhattan_edges != G_MANHATTAN_EDGES)
fprintf (fout,
"\tmanhattan_edges:\t%s\n",
get_decision_str(graph->manhattan_edges));
if (graph->smanhattan_edges != G_SMANHATTAN_EDGES)
get_decision_str (g->manhattan_edges));
if (g->smanhattan_edges != G_SMANHATTAN_EDGES)
fprintf (fout,
"\tsmanhattan_edges:\t%s\n",
get_decision_str(graph->smanhattan_edges));
if (graph->near_edges != G_NEAR_EDGES)
get_decision_str (g->smanhattan_edges));
if (g->near_edges != G_NEAR_EDGES)
fprintf (fout, "\tnear_edges:\t%s\n",
get_decision_str(graph->near_edges));
get_decision_str (g->near_edges));
if (graph->orientation != G_ORIENTATION)
if (g->orientation != G_ORIENTATION)
fprintf (fout, "\torientation:\t%s\n",
get_orientation_str(graph->orientation));
get_orientation_str (g->orientation));
if (graph->node_alignement != G_NODE_ALIGNEMENT)
fprintf (fout, "\tnode_alignement:\t%s\n",
get_node_alignement_str(graph->node_alignement));
if (g->node_alignment != G_NODE_ALIGNMENT)
fprintf (fout, "\tnode_alignment:\t%s\n",
get_node_alignment_str (g->node_alignment));
if (graph->port_sharing != G_PORT_SHARING)
if (g->port_sharing != G_PORT_SHARING)
fprintf (fout, "\tport_sharing:\t%s\n",
get_decision_str(graph->port_sharing));
get_decision_str (g->port_sharing));
if (graph->arrow_mode != G_ARROW_MODE)
if (g->arrow_mode != G_ARROW_MODE)
fprintf (fout, "\tarrow_mode:\t%s\n",
get_arrow_mode_str(graph->arrow_mode));
get_arrow_mode_str (g->arrow_mode));
if (graph->treefactor != G_TREEFACTOR)
fprintf (fout, "\ttreefactor:\t%f\n", graph->treefactor);
if (graph->spreadlevel != G_SPREADLEVEL)
fprintf (fout, "\tspreadlevel:\t%d\n", graph->spreadlevel);
if (g->treefactor != G_TREEFACTOR)
fprintf (fout, "\ttreefactor:\t%f\n", g->treefactor);
if (g->spreadlevel != G_SPREADLEVEL)
fprintf (fout, "\tspreadlevel:\t%d\n", g->spreadlevel);
if (graph->crossing_weight != G_CROSSING_WEIGHT)
if (g->crossing_weight != G_CROSSING_WEIGHT)
fprintf (fout, "\tcrossing_weight:\t%s\n",
get_crossing_type_str(graph->crossing_weight));
if (graph->crossing_phase2 != G_CROSSING_PHASE2)
get_crossing_type_str (g->crossing_weight));
if (g->crossing_phase2 != G_CROSSING_PHASE2)
fprintf (fout, "\tcrossing_phase2:\t%s\n",
get_decision_str(graph->crossing_phase2));
if (graph->crossing_optimization != G_CROSSING_OPTIMIZATION)
get_decision_str (g->crossing_phase2));
if (g->crossing_optimization != G_CROSSING_OPTIMIZATION)
fprintf (fout, "\tcrossing_optimization:\t%s\n",
get_decision_str(graph->crossing_optimization));
get_decision_str (g->crossing_optimization));
if (graph->view != G_VIEW)
fprintf (fout, "\tview:\t%s\n", get_view_str(graph->view));
if (g->view != G_VIEW)
fprintf (fout, "\tview:\t%s\n", get_view_str (g->view));
if (graph->edges != G_EDGES)
fprintf (fout, "\tedges:\t%s\n", get_decision_str(graph->edges));
if (g->edges != G_EDGES)
fprintf (fout, "\tedges:\t%s\n", get_decision_str (g->edges));
if (graph->nodes != G_NODES)
fprintf (fout,"\tnodes:\t%s\n", get_decision_str(graph->nodes));
if (g->nodes != G_NODES)
fprintf (fout,"\tnodes:\t%s\n", get_decision_str (g->nodes));
if (graph->splines != G_SPLINES)
fprintf (fout, "\tsplines:\t%s\n", get_decision_str(graph->splines));
if (g->splines != G_SPLINES)
fprintf (fout, "\tsplines:\t%s\n", get_decision_str (g->splines));
if (graph->bmax != G_BMAX)
fprintf (fout, "\tbmax:\t%d\n", graph->bmax);
if (graph->cmin != G_CMIN)
fprintf (fout, "\tcmin:\t%d\n", graph->cmin);
if (graph->cmax != G_CMAX)
fprintf (fout, "\tcmax:\t%d\n", graph->cmax);
if (graph->pmin != G_PMIN)
fprintf (fout, "\tpmin:\t%d\n", graph->pmin);
if (graph->pmax != G_PMAX)
fprintf (fout, "\tpmax:\t%d\n", graph->pmax);
if (graph->rmin != G_RMIN)
fprintf (fout, "\trmin:\t%d\n", graph->rmin);
if (graph->rmax != G_RMAX)
fprintf (fout, "\trmax:\t%d\n", graph->rmax);
if (graph->smax != G_SMAX)
fprintf (fout, "\tsmax:\t%d\n", graph->smax);
if (g->bmax != G_BMAX)
fprintf (fout, "\tbmax:\t%d\n", g->bmax);
if (g->cmin != G_CMIN)
fprintf (fout, "\tcmin:\t%d\n", g->cmin);
if (g->cmax != G_CMAX)
fprintf (fout, "\tcmax:\t%d\n", g->cmax);
if (g->pmin != G_PMIN)
fprintf (fout, "\tpmin:\t%d\n", g->pmin);
if (g->pmax != G_PMAX)
fprintf (fout, "\tpmax:\t%d\n", g->pmax);
if (g->rmin != G_RMIN)
fprintf (fout, "\trmin:\t%d\n", g->rmin);
if (g->rmax != G_RMAX)
fprintf (fout, "\trmax:\t%d\n", g->rmax);
if (g->smax != G_SMAX)
fprintf (fout, "\tsmax:\t%d\n", g->smax);
}