From: Eric S. Raymond Date: Thu, 3 Nov 1994 14:11:36 +0000 (+0000) Subject: Initial revision X-Git-Tag: 1-2~94 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=72810572339fe18c1ad685b0c7da012f3eafab23;p=cupl.git Initial revision --- 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 */ + +