make.tokcase 439 B

12345678910111213141516171819202122232425262728293031323334
  1. cat <<'--EOT--'
  2. #include "Lpars.h"
  3. char *
  4. symbol2str(tok)
  5. int tok;
  6. {
  7. static char buf[2] = { '\0', '\0' };
  8. if (040 <= tok && tok < 0177) {
  9. buf[0] = tok;
  10. buf[1] = '\0';
  11. return buf;
  12. }
  13. switch (tok) {
  14. --EOT--
  15. sed '
  16. /{[A-Z]/!d
  17. s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
  18. return \2;/
  19. '
  20. cat <<'--EOT--'
  21. case '\n':
  22. case '\f':
  23. case '\v':
  24. case '\r':
  25. case '\t':
  26. buf[0] = tok;
  27. return buf;
  28. default:
  29. return "bad token";
  30. }
  31. }
  32. --EOT--