cex: clean the display of conflicted symbols

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
commit 1ec93ca2a2b4718b5d94871475520a2688b4c5c8
Author: Akim Demaille <[email protected]>
Date:   Sat May 23 18:17:57 2020 +0200

    cex: clean the display of conflicted symbols
    
    Instead of `On Symbols: {b,c,}`, display `On Symbols: b, c`.
    
    * src/counterexample.c (counterexample_report_reduce_reduce): We don't
    need braces.
    Use commas as a separator, not a terminator.
    * tests/counterexample.at: Adjust.

diff --git a/src/counterexample.c b/src/counterexample.c
index d5dca5e3..90ab72f7 100644
--- a/src/counterexample.c
+++ b/src/counterexample.c
@@ -19,15 +19,16 @@
 
 #include <config.h>
 
-#include <time.h>
-#include <hash.h>
-#include <stdlib.h>
+#include "counterexample.h"
+
 #include <gl_linked_list.h>
 #include <gl_rbtreehash_list.h>
+#include <hash.h>
+#include <stdlib.h>
+#include <time.h>
 
 #include "closure.h"
 #include "complain.h"
-#include "counterexample.h"
 #include "derivation.h"
 #include "getargs.h"
 #include "gram.h"
@@ -1202,11 +1203,15 @@ counterexample_report_reduce_reduce (state_item_number itm1, state_item_number i
   fputs ("Reduce-Reduce Conflict:\n", out);
   print_state_item (&state_items[itm1], out);
   print_state_item (&state_items[itm2], out);
-  fputs ("On Symbols: {", out);
+  fputs ("On Symbols: ", out);
   bitset_iterator biter;
   state_item_number sym;
+  const char *sep = "";
   BITSET_FOR_EACH (biter, conflict_syms, sym, 0)
-    fprintf (out, "%s,", symbols[sym]->tag);
-  fputs ("}\n", out);
+    {
+      fprintf (out, "%s%s", sep, symbols[sym]->tag);
+      sep = ", ";
+    }
+  fputs ("\n", out);
   counterexample_report (itm1, itm2, bitset_first (conflict_syms), false);
 }
diff --git a/tests/counterexample.at b/tests/counterexample.at
index 09a354cd..6cddb501 100644
--- a/tests/counterexample.at
+++ b/tests/counterexample.at
@@ -261,7 +261,7 @@ AT_BISON_CHECK_CEX([input.y], [], [],
 [[Reduce-Reduce Conflict:
 4:    1 a: A b .
 4:    3 b: b .
-On Symbols: {$end,}
+On Symbols: $end
 Example  A  b  •
 First  derivation  a ::=[ A  b  • ]
 Second derivation  a ::=[ A  b ::=[ b  • ] ]
@@ -291,7 +291,7 @@ AT_BISON_CHECK_CEX([input.y], [], [],
 [[Reduce-Reduce Conflict:
 2:    5 a: D .
 2:    6 b: D .
-On Symbols: {A,C,}
+On Symbols: A, C
 First  Example D  •  A  $end
 First  derivation  $accept ::=[ s ::=[ a ::=[ D  • ]  A ]  $end ]
 Second Example B  D  •  A  $end
@@ -393,7 +393,7 @@ AT_BISON_CHECK_CEX([input.y], [], [],
 [[Reduce-Reduce Conflict:
 3:    3 A: B .
 3:    5 A: . %empty
-On Symbols: {b,c,}
+On Symbols: b, c
 Example  B  •  b  A  A  c  A
 First  derivation  S ::=[ B ::=[ A ::=[ B  • ]  b  A ]  C ::=[ A  c  A ] ]
 Second derivation  S ::=[ B  C ::=[ A ::=[ B ::=[ A ::=[ • ]  b  A ] ]  c  A ] ]
@@ -401,7 +401,7 @@ Second derivation  S ::=[ B  C ::=[ A ::=[ B ::=[ A ::=[ • ]  b  A ] ]  c  A ]
 Reduce-Reduce Conflict:
 4:    4 A: C .
 4:    5 A: . %empty
-On Symbols: {b,c,}
+On Symbols: b, c
 Example  C  •  c  A  A  b  A
 First  derivation  S ::=[ C ::=[ A ::=[ C  • ]  c  A ]  B ::=[ A  b  A ] ]
 Second derivation  S ::=[ C  B ::=[ A ::=[ C ::=[ A ::=[ • ]  c  A ] ]  b  A ] ]
@@ -431,7 +431,7 @@ AT_BISON_CHECK_CEX([input.y], [], [],
 [[Reduce-Reduce Conflict:
 0:    3 b: . %empty
 0:    4 c: . %empty
-On Symbols: {A,}
+On Symbols: A
 First  Example •  c  A  A  $end
 First  derivation  $accept ::=[ a ::=[ b ::=[ • ]  d ::=[ c  A  A ] ]  $end ]
 Second Example •  c  A  A  $end
@@ -470,7 +470,7 @@ Second derivation  a ::=[ b  d ::=[ c  •  A ] ]
 Reduce-Reduce Conflict:
 6:    3 b: . %empty
 6:    4 c: . %empty
-On Symbols: {A,}
+On Symbols: A
 First  Example b  c  •  c  A  A  $end
 First  derivation  $accept ::=[ a ::=[ b  d ::=[ a ::=[ c  d ::=[ a ::=[ b ::=[ • ]  d ::=[ c  A  A ] ] ] ] ] ]  $end ]
 Second Example b  c  •  A  $end
@@ -488,7 +488,7 @@ Second derivation  a ::=[ b  d ::=[ c  •  A ] ]
 Reduce-Reduce Conflict:
 7:    1 a: b d .
 7:    7 d: d .
-On Symbols: {$end,}
+On Symbols: $end
 Example  b  d  •
 First  derivation  a ::=[ b  d  • ]
 Second derivation  a ::=[ b  d ::=[ d  • ] ]
@@ -496,7 +496,7 @@ Second derivation  a ::=[ b  d ::=[ d  • ] ]
 Reduce-Reduce Conflict:
 8:    2 a: c d .
 8:    7 d: d .
-On Symbols: {$end,}
+On Symbols: $end
 Example  c  d  •
 First  derivation  a ::=[ c  d  • ]
 Second derivation  a ::=[ c  d ::=[ d  • ] ]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.