make.tokcase 640 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. cat <<'--EOT--'
  3. /* Generated by make.tokcase */
  4. /* $Id$ */
  5. #include "Lpars.h"
  6. char *
  7. symbol2str(tok)
  8. int tok;
  9. {
  10. #define SIZBUF 8
  11. /* allow for a few invocations in f.i. an argument list */
  12. static char buf[SIZBUF];
  13. static int index;
  14. switch (tok) {
  15. --EOT--
  16. sed '
  17. /{[A-Z]/!d
  18. s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
  19. return \2;/
  20. '
  21. cat <<'--EOT--'
  22. default:
  23. if (tok <= 0) return "end of file";
  24. if (tok < 040 || tok >= 0177) {
  25. return "bad token";
  26. }
  27. /* fall through */
  28. case '\n':
  29. case '\f':
  30. case '\v':
  31. case '\r':
  32. case '\t':
  33. index = (index+2) & (SIZBUF-1);
  34. buf[index] = tok;
  35. return &buf[index];
  36. }
  37. }
  38. --EOT--