make.tokcase 633 B

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