]> thyrsus.com Git - cupl.git/commitdiff
Initial revision
authorEric S. Raymond <esr@thyrsus.com>
Thu, 3 Nov 1994 14:11:36 +0000 (14:11 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 3 Nov 1994 14:11:36 +0000 (14:11 +0000)
tokdump.c [new file with mode: 0644]

diff --git a/tokdump.c b/tokdump.c
new file mode 100644 (file)
index 0000000..07324ab
--- /dev/null
+++ b/tokdump.c
@@ -0,0 +1,42 @@
+/* tokdump.c -- a token dumper for debugging */
+
+#include <string.h>
+#include "tokens.h"
+
+typedef struct
+{
+    int        value;
+    char *name;
+}
+symbol;
+
+static symbol toknames[] =
+{
+#include "toktab.h"
+};
+
+char *tokdump(int value)
+{
+    symbol     *sym;
+
+    if (value < 128)
+    {
+       static char namestring[2];
+
+       namestring[0] = value;
+       return(namestring);
+    }
+
+    for (sym = toknames; sym < toknames+sizeof(toknames)/sizeof(symbol); sym++)
+       if (sym->value == value)
+       {
+           return(sym->name);
+           break;
+       }
+
+    return((char *)NULL);
+}
+
+/* tokdump.c ends here */
+ 
+