[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03-fyi-formatting.patch~
From: |
Akim Demaille |
Subject: |
03-fyi-formatting.patch~ |
Date: |
Fri, 30 Nov 2001 11:43:22 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/reduce.c (reduce_output): Formatting changes.
* src/print.c (print_results, print_grammar): Likewise.
* tests/regression.at (Rule Line Numbers)
(Solved SR Conflicts, Unresolved SR Conflicts): Adjust.
Index: src/conflicts.c
--- src/conflicts.c Sat, 24 Nov 2001 18:28:40 +0100 akim
+++ src/conflicts.c Thu, 29 Nov 2001 23:03:57 +0100 akim
@@ -419,6 +419,7 @@
void
conflicts_output (FILE *out)
{
+ bool printed_sth = FALSE;
int i;
for (i = 0; i < nstates; i++)
if (conflicts[i])
@@ -426,7 +427,10 @@
fprintf (out, _("State %d contains "), i);
fputs (conflict_report (count_sr_conflicts (i),
count_rr_conflicts (i)), out);
+ printed_sth = TRUE;
}
+ if (printed_sth)
+ fputs ("\n\n", out);
}
Index: src/print.c
--- src/print.c Thu, 22 Nov 2001 21:32:24 +0100 akim
+++ src/print.c Thu, 29 Nov 2001 23:05:36 +0100 akim
@@ -181,11 +181,11 @@
static void
print_state (FILE *out, int state)
{
- fputs ("\n\n", out);
fprintf (out, _("state %d"), state);
fputs ("\n\n", out);
print_core (out, state);
print_actions (out, state);
+ fputs ("\n\n", out);
}
/*-----------------------------------------.
@@ -212,7 +212,7 @@
int column = 0;
/* rule # : LHS -> RHS */
- fprintf (out, "\n%s\n\n", _("Grammar"));
+ fprintf (out, "%s\n\n", _("Grammar"));
fprintf (out, " %s\n", _("Number, Line, Rule"));
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
@@ -228,9 +228,11 @@
fprintf (out, " /* %s */", _("empty"));
fputc ('\n', out);
}
+ fputs ("\n\n", out);
+
/* TERMINAL (type #) : rule #s terminal is on RHS */
- fprintf (out, "\n%s\n\n", _("Terminals, with rules where they appear"));
+ fprintf (out, "%s\n\n", _("Terminals, with rules where they appear"));
fprintf (out, "%s (-1)\n", tags[0]);
for (i = 0; i <= max_user_token_number; i++)
@@ -252,9 +254,10 @@
}
fprintf (out, "%s\n", buffer);
}
+ fputs ("\n\n", out);
+
- fprintf (out, "\n%s\n\n",
- _("Nonterminals, with rules where they appear"));
+ fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
for (i = ntokens; i <= nsyms - 1; i++)
{
int left_count = 0, right_count = 0;
@@ -309,6 +312,7 @@
}
fprintf (out, "%s\n", buffer);
}
+ fputs ("\n\n", out);
}
void
@@ -324,6 +328,8 @@
size_t size = obstack_object_size (&output_obstack);
fwrite (obstack_finish (&output_obstack), 1, size, out);
+ if (size)
+ fputs ("\n\n", out);
reduce_output (out);
conflicts_output (out);
Index: src/reduce.c
--- src/reduce.c Thu, 29 Nov 2001 22:49:28 +0100 akim
+++ src/reduce.c Thu, 29 Nov 2001 23:02:04 +0100 akim
@@ -407,50 +407,46 @@
void
reduce_output (FILE *out)
{
- int i;
- rule r;
- bool b;
-
if (nuseless_nonterminals > 0)
{
- fprintf (out, _("Useless nonterminals:"));
- fprintf (out, "\n\n");
+ int i;
+ fprintf (out, "%s\n\n", _("Useless nonterminals:"));
for (i = 0; i < nuseless_nonterminals; ++i)
fprintf (out, " %s\n", tags[nsyms + i]);
+ fputs ("\n\n", out);
}
- b = FALSE;
- for (i = 0; i < ntokens; i++)
- {
+
+ {
+ bool b = FALSE;
+ int i;
+ for (i = 0; i < ntokens; i++)
if (!BITISSET (V, i) && !BITISSET (V1, i))
{
if (!b)
- {
- fprintf (out, "\n\n");
- fprintf (out, _("Terminals which are not used:"));
- fprintf (out, "\n\n");
- b = TRUE;
- }
+ fprintf (out, "%s\n\n", _("Terminals which are not used:"));
+ b = TRUE;
fprintf (out, " %s\n", tags[i]);
}
- }
+ if (b)
+ fputs ("\n\n", out);
+ }
if (nuseless_productions > 0)
{
- fprintf (out, "\n\n");
- fprintf (out, _("Useless rules:"));
- fprintf (out, "\n\n");
+ int i;
+ fprintf (out, "%s\n\n", _("Useless rules:"));
for (i = 1; i <= nrules; i++)
if (!BITISSET (P, i))
{
+ rule r;
fprintf (out, "#%-4d ", i);
fprintf (out, "%s :\t", tags[rule_table[i].lhs]);
for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
fprintf (out, " %s", tags[*r]);
- fprintf (out, ";\n");
+ fputs (";\n", out);
}
+ fputs ("\n\n", out);
}
- if (nuseless_nonterminals > 0 || nuseless_productions > 0 || b)
- fprintf (out, "\n\n");
}
static void
Index: tests/regression.at
--- tests/regression.at Thu, 29 Nov 2001 21:52:19 +0100 akim
+++ tests/regression.at Thu, 29 Nov 2001 23:06:57 +0100 akim
@@ -63,12 +63,14 @@ exp: exp OP exp | NUM;
AT_CHECK([cat input.output], [],
[[State 4 contains 1 shift/reduce conflict.
+
Grammar
Number, Line, Rule
1 3 exp -> exp OP exp
2 3 exp -> NUM
+
Terminals, with rules where they appear
$ (-1)
@@ -76,6 +78,7 @@ exp: exp OP exp | NUM;
NUM (257) 2
OP (258) 1
+
Nonterminals, with rules where they appear
exp (5)
@@ -138,6 +141,8 @@ exp: exp OP exp | NUM;
state 6
$default accept
+
+
]])
AT_CLEANUP
@@ -162,12 +167,14 @@ exp: exp OP exp | NUM;
AT_CHECK([cat input.output], [],
[[Conflict in state 4 between rule 1 and token OP resolved as shift.
+
Grammar
Number, Line, Rule
1 4 exp -> exp OP exp
2 4 exp -> NUM
+
Terminals, with rules where they appear
$ (-1)
@@ -175,6 +182,7 @@ exp: exp OP exp | NUM;
NUM (257) 2
OP (258) 1
+
Nonterminals, with rules where they appear
exp (5)
@@ -236,6 +244,8 @@ exp: exp OP exp | NUM;
state 6
$default accept
+
+
]])
AT_CLEANUP
@@ -283,8 +293,7 @@ expr:
# Check the contents of the report.
AT_CHECK([cat input.output], [],
-[[
-Grammar
+[[Grammar
Number, Line, Rule
1 2 @1 -> /* empty */
@@ -292,6 +301,7 @@ expr:
3 15 @2 -> /* empty */
4 15 expr -> @2 'c'
+
Terminals, with rules where they appear
$ (-1)
@@ -300,6 +310,7 @@ expr:
'c' (99) 4
error (256)
+
Nonterminals, with rules where they appear
expr (6)
@@ -378,6 +389,8 @@ expr:
state 8
$default accept
+
+
]])
AT_CLEANUP
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 03-fyi-formatting.patch~,
Akim Demaille <=