From 72810572339fe18c1ad685b0c7da012f3eafab23 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 3 Nov 1994 14:11:36 +0000 Subject: [PATCH] Initial revision --- tokdump.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tokdump.c diff --git a/tokdump.c b/tokdump.c new file mode 100644 index 0000000..07324ab --- /dev/null +++ b/tokdump.c @@ -0,0 +1,42 @@ +/* tokdump.c -- a token dumper for debugging */ + +#include +#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 */ + + -- 2.43.0