bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/6] cex: use the glyphs


From: Akim Demaille
Subject: [PATCH 5/6] cex: use the glyphs
Date: Sat, 18 Jul 2020 07:59:05 +0200

* src/derivation.c: here.
* src/gram.h, src/gram.c (print_arrow, print_dot, print_fallback):
Remove.
---
 src/derivation.c |  7 +++----
 src/gram.c       |  4 ++--
 src/gram.h       | 37 -------------------------------------
 3 files changed, 5 insertions(+), 43 deletions(-)

diff --git a/src/derivation.c b/src/derivation.c
index 39f66211..235333cc 100644
--- a/src/derivation.c
+++ b/src/derivation.c
@@ -20,6 +20,7 @@
 #include <config.h>
 
 #include "derivation.h"
+#include "glyphs.h"
 
 #include <gl_linked_list.h>
 
@@ -145,9 +146,7 @@ derivation_print_impl (const derivation *deriv, FILE *out,
         {
           fputs (prefix, out);
           begin_use_class ("cex-step", out);
-          fprintf (out, "%s ", sym->tag);
-          print_arrow (out);
-          fprintf (out, " [ ");
+          fprintf (out, "%s %s [ ", sym->tag, arrow);
           end_use_class ("cex-step", out);
           prefix = "";
         }
@@ -181,7 +180,7 @@ derivation_print_impl (const derivation *deriv, FILE *out,
     {
       fputs (prefix, out);
       begin_use_class ("cex-dot", out);
-      print_dot (out);
+      fputs (dot, out);
       end_use_class ("cex-dot", out);
     }
   else // leaf.
diff --git a/src/gram.c b/src/gram.c
index f81192cb..cc5e54b5 100644
--- a/src/gram.c
+++ b/src/gram.c
@@ -23,6 +23,7 @@
 
 #include "complain.h"
 #include "getargs.h"
+#include "glyphs.h"
 #include "gram.h"
 #include "print-xml.h"
 #include "reader.h"
@@ -56,8 +57,7 @@ item_print (item_number *item, rule const *previous_rule, 
FILE *out)
 
   for (item_number *sp = r->rhs; sp < item; sp++)
     fprintf (out, " %s", symbols[*sp]->tag);
-  putc (' ', out);
-  print_dot (out);
+  fprintf (out, " %s", dot);
   if (0 <= *r->rhs)
     for (item_number *sp = item; 0 <= *sp; ++sp)
       fprintf (out, " %s", symbols[*sp]->tag);
diff --git a/src/gram.h b/src/gram.h
index 71e3db94..c6ce4194 100644
--- a/src/gram.h
+++ b/src/gram.h
@@ -103,8 +103,6 @@
 
 # include "system.h"
 
-# include <unicodeio.h>
-
 # include "location.h"
 # include "symtab.h"
 
@@ -217,41 +215,6 @@ typedef struct
 extern rule *rules;
 extern rule_number nrules;
 
-/* Fallback in case we can't print "•" or "→".  */
-static inline long
-print_fallback (unsigned int code _GL_UNUSED,
-                const char *msg _GL_UNUSED,
-                void *callback_arg)
-{
-  FILE *out = (FILE *) callback_arg;
-  switch (code)
-    {
-    case 0x2022:
-      putc ('.', out);
-      break;
-    case 0x2192:
-      fputs ("->", out);
-      break;
-    default:
-      abort ();
-    }
-  return -1;
-}
-
-static inline void
-print_arrow (FILE *out)
-{
-  unicode_to_mb (0x2192, fwrite_success_callback, print_fallback, out);
-}
-
-/* Print "•", the symbol used to represent a point in an item (aka, a
-   dotted rule).  */
-static inline void
-print_dot (FILE *out)
-{
-  unicode_to_mb (0x2022, fwrite_success_callback, print_fallback, out);
-}
-
 /* Get the rule associated to this item.  ITEM points inside RITEM.  */
 static inline rule const *
 item_rule (item_number const *item)
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]