tokenname.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* $Id$ */
  2. #include "tokenname.h"
  3. #include "Lpars.h"
  4. #include "position.h"
  5. #include "file.h"
  6. #include "idf.h"
  7. #include "misc.h"
  8. /* To centralize the declaration of %tokens, their presence in this
  9. file is taken as their declaration. The Makefile will produce
  10. a grammar file (tokenfile.g) from this file. This scheme ensures
  11. that all tokens have a printable name.
  12. Also, the "token2str.c" file is produced from this file.
  13. */
  14. #if 0
  15. struct tokenname tkspec[] = { /* the names of the special tokens */
  16. {NAME, "name"},
  17. {STRING, "string"},
  18. {INTEGER, "number"},
  19. {EXPRESSION, "<expression>"},
  20. {REAL, "real"},
  21. {CHAR, "char"},
  22. {BIN_OP, "<operator>"},
  23. {PREF_OR_BIN_OP, "<operator>"},
  24. {PREF_OP, "<operator>"},
  25. {POST_OP, "<operator>"},
  26. {SEL_OP, "<operator>"},
  27. {0, ""}
  28. };
  29. #endif
  30. struct tokenname tkidf[] = { /* names of the identifier tokens */
  31. {LIST, "list"},
  32. {XFILE, "file"},
  33. {RUN, "run"},
  34. {RERUN, "rerun"},
  35. {STOP, "stop"},
  36. {WHEN, "when"},
  37. {AT, "at"},
  38. {IN, "in"},
  39. {ON, "on"},
  40. {IF, "if"},
  41. {CONT, "cont"},
  42. {STEP, "step"},
  43. {NEXT, "next"},
  44. {REGS, "regs"},
  45. {WHERE, "where"},
  46. {STATUS, "status"},
  47. {DELETE, "delete"},
  48. {PRINT, "print"},
  49. {DUMP, "dump"},
  50. {RESTORE, "restore"},
  51. {TRACE, "trace"},
  52. {SET, "set"},
  53. {TO, "to"},
  54. {FIND, "find"},
  55. {DISPLAY, "display"},
  56. {WHICH, "which"},
  57. {HELP, "help"},
  58. {DISABLE,"disable"},
  59. {ENABLE,"enable"},
  60. {SOURCE, "source"},
  61. {FRAME, "frame"},
  62. {LOG, "log"},
  63. {-1, "quit"},
  64. {0, ""}
  65. };
  66. #if 0
  67. struct tokenname tkinternal[] = { /* internal keywords */
  68. {0, "0"}
  69. };
  70. struct tokenname tkstandard[] = { /* standard identifiers */
  71. {0, ""}
  72. };
  73. #endif
  74. /* Some routines to handle tokennames */
  75. reserve(resv)
  76. register struct tokenname *resv;
  77. {
  78. /* The names of the tokens described in resv are entered
  79. as reserved words.
  80. */
  81. register struct idf *p;
  82. while (resv->tn_symbol) {
  83. p = str2idf(resv->tn_name, 0);
  84. if (!p) fatal("out of Memory");
  85. p->id_reserved = resv->tn_symbol;
  86. resv++;
  87. }
  88. }