* src/output.c: Various formatting changes.

This commit is contained in:
Akim Demaille
2001-12-17 17:31:24 +00:00
parent 64d15509b6
commit 796d61fbdd
2 changed files with 50 additions and 68 deletions

View File

@@ -1,3 +1,8 @@
2001-12-17 Akim Demaille <akim@epita.fr>
* src/output.c: Various formatting changes.
2001-12-17 Akim Demaille <akim@epita.fr> 2001-12-17 Akim Demaille <akim@epita.fr>
* src/files.c (output_files): Free the output_obstack. * src/files.c (output_files): Free the output_obstack.

View File

@@ -214,7 +214,7 @@ output_gram (void)
XFREE (yyrhs); XFREE (yyrhs);
} }
#if 0 #if 0
if (!semantic_parser) if (!semantic_parser)
obstack_sgrow (&table_obstack, "\n#endif\n"); obstack_sgrow (&table_obstack, "\n#endif\n");
@@ -327,7 +327,6 @@ action_row (int state)
{ {
int i; int i;
int j; int j;
int k;
int m = 0; int m = 0;
int n = 0; int n = 0;
int default_rule; int default_rule;
@@ -397,15 +396,11 @@ action_row (int state)
errp = state_table[state]->errs; errp = state_table[state]->errs;
if (errp) if (errp)
{ for (i = 0; i < errp->nerrs; i++)
k = errp->nerrs; {
symbol = errp->errs[i];
for (i = 0; i < k; i++) actrow[symbol] = MINSHORT;
{ }
symbol = errp->errs[i];
actrow[symbol] = MINSHORT;
}
}
/* Now find the most common reduction and make it the default action /* Now find the most common reduction and make it the default action
for this state. */ for this state. */
@@ -476,10 +471,8 @@ save_row (int state)
count = 0; count = 0;
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
{ if (actrow[i] != 0)
if (actrow[i] != 0) count++;
count++;
}
if (count == 0) if (count == 0)
return; return;
@@ -488,13 +481,11 @@ save_row (int state)
tos[state] = sp2 = XCALLOC (short, count); tos[state] = sp2 = XCALLOC (short, count);
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
{ if (actrow[i] != 0)
if (actrow[i] != 0) {
{ *sp1++ = i;
*sp1++ = i; *sp2++ = actrow[i];
*sp2++ = actrow[i]; }
}
}
tally[state] = count; tally[state] = count;
width[state] = sp1[-1] - sp[0] + 1; width[state] = sp1[-1] - sp[0] + 1;
@@ -582,10 +573,8 @@ save_column (int symbol, int default_state)
count = 0; count = 0;
for (i = begin; i < end; i++) for (i = begin; i < end; i++)
{ if (to_state[i] != default_state)
if (to_state[i] != default_state) count++;
count++;
}
if (count == 0) if (count == 0)
return; return;
@@ -596,13 +585,11 @@ save_column (int symbol, int default_state)
tos[symno] = sp2 = XCALLOC (short, count); tos[symno] = sp2 = XCALLOC (short, count);
for (i = begin; i < end; i++) for (i = begin; i < end; i++)
{ if (to_state[i] != default_state)
if (to_state[i] != default_state) {
{ *sp1++ = from_state[i];
*sp1++ = from_state[i]; *sp2++ = to_state[i];
*sp2++ = to_state[i]; }
}
}
tally[symno] = count; tally[symno] = count;
width[symno] = sp1[-1] - sp[0] + 1; width[symno] = sp1[-1] - sp[0] + 1;
@@ -633,13 +620,11 @@ default_goto (int symbol)
default_state = -1; default_state = -1;
for (i = 0; i < nstates; i++) for (i = 0; i < nstates; i++)
{ if (state_count[i] > max)
if (state_count[i] > max) {
{ max = state_count[i];
max = state_count[i]; default_state = i;
default_state = i; }
}
}
return default_state; return default_state;
} }
@@ -693,26 +678,24 @@ sort_actions (void)
nentries = 0; nentries = 0;
for (i = 0; i < nvectors; i++) for (i = 0; i < nvectors; i++)
{ if (tally[i] > 0)
if (tally[i] > 0) {
{ t = tally[i];
t = tally[i]; w = width[i];
w = width[i]; j = nentries - 1;
j = nentries - 1;
while (j >= 0 && (width[order[j]] < w)) while (j >= 0 && (width[order[j]] < w))
j--; j--;
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t)) while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
j--; j--;
for (k = nentries - 1; k > j; k--) for (k = nentries - 1; k > j; k--)
order[k + 1] = order[k]; order[k + 1] = order[k];
order[j + 1] = i; order[j + 1] = i;
nentries++; nentries++;
} }
}
} }
@@ -742,10 +725,8 @@ matching_state (int vector)
match = 1; match = 1;
for (k = 0; match && k < t; k++) for (k = 0; match && k < t; k++)
{ if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k])
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]) match = 0;
match = 0;
}
if (match) if (match)
return j; return j;
@@ -790,10 +771,8 @@ pack_vector (int vector)
} }
for (k = 0; ok && k < vector; k++) for (k = 0; ok && k < vector; k++)
{ if (pos[k] == j)
if (pos[k] == j) ok = 0;
ok = 0;
}
if (ok) if (ok)
{ {
@@ -855,10 +834,8 @@ pack_table (void)
for (i = 0; i < nvectors; i++) for (i = 0; i < nvectors; i++)
{ {
if (froms[i]) XFREE (froms[i]);
XFREE (froms[i]); XFREE (tos[i]);
if (tos[i])
XFREE (tos[i]);
} }
XFREE (froms); XFREE (froms);