#!/bin/sh
OLD_IFS=$IFS
IFS="	"

exec 1>gettokname.c

cat <<EOF
#include "rvp.h"
#include "y.tab.h"
char *get_tok_name(int t)
{
    static char cbuf[2];
    switch (t)
    {
EOF
while read directive name value; do
	test -z "${name}" && continue;
	cat <<EOF
	case ${name}:
	    return "${name}";
EOF
done < y.tab.h
cat <<EOF
	default:
	    snprintf(cbuf, sizeof(cbuf), "%c", t);
	    return cbuf;
    }
}
EOF

IFS=$OLD_IFS
