tokenname.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. *
  5. * Author: Ceriel J.H. Jacobs
  6. */
  7. /* T O K E N D E F I N I T I O N S */
  8. /* $Id$ */
  9. #include "tokenname.h"
  10. #include "Lpars.h"
  11. #include "idf.h"
  12. /* To centralize the declaration of %tokens, their presence in this
  13. file is taken as their declaration. The Makefile will produce
  14. a grammar file (tokenfile.g) from this file. This scheme ensures
  15. that all tokens have a printable name.
  16. Also, the "token2str.c" file is produced from this file.
  17. */
  18. #ifdef ___XXX___
  19. struct tokenname tkspec[] = { /* the names of the special tokens */
  20. {IDENT, "identifier"},
  21. {STRING, "string"},
  22. {INTEGER, "number"},
  23. {REAL, "real"},
  24. {0, ""}
  25. };
  26. struct tokenname tkcomp[] = { /* names of the composite tokens */
  27. {LESSEQUAL, "<="},
  28. {GREATEREQUAL, ">="},
  29. {UPTO, ".."},
  30. {BECOMES, ":="},
  31. {0, ""}
  32. };
  33. #endif
  34. struct tokenname tkidf[] = { /* names of the identifier tokens */
  35. {AND, "AND"},
  36. {ARRAY, "ARRAY"},
  37. {BEGIN, "BEGIN"},
  38. {BY, "BY"},
  39. {CASE, "CASE"},
  40. {CONST, "CONST"},
  41. {DEFINITION, "DEFINITION"},
  42. {DIV, "DIV"},
  43. {DO, "DO"},
  44. {ELSE, "ELSE"},
  45. {ELSIF, "ELSIF"},
  46. {END, "END"},
  47. {EXIT, "EXIT"},
  48. {EXPORT, "EXPORT"},
  49. {FOR, "FOR"},
  50. {FROM, "FROM"},
  51. {IF, "IF"},
  52. {IMPLEMENTATION, "IMPLEMENTATION"},
  53. {IMPORT, "IMPORT"},
  54. {IN, "IN"},
  55. {LOOP, "LOOP"},
  56. {MOD, "MOD"},
  57. {MODULE, "MODULE"},
  58. {NOT, "NOT"},
  59. {OF, "OF"},
  60. {OR, "OR"},
  61. {POINTER, "POINTER"},
  62. {PROCEDURE, "PROCEDURE"},
  63. {QUALIFIED, "QUALIFIED"},
  64. {RECORD, "RECORD"},
  65. {REPEAT, "REPEAT"},
  66. {RETURN, "RETURN"},
  67. {SET, "SET"},
  68. {THEN, "THEN"},
  69. {TO, "TO"},
  70. {TYPE, "TYPE"},
  71. {UNTIL, "UNTIL"},
  72. {VAR, "VAR"},
  73. {WHILE, "WHILE"},
  74. {WITH, "WITH"},
  75. {0, ""}
  76. };
  77. #ifdef ___XXX___
  78. struct tokenname tkinternal[] = { /* internal keywords */
  79. {PROGRAM, ""},
  80. {COERCION, ""},
  81. {CAST, ""},
  82. {0, "0"}
  83. };
  84. struct tokenname tkstandard[] = { /* standard identifiers */
  85. {0, ""}
  86. };
  87. #endif
  88. /* Some routines to handle tokennames */
  89. reserve(resv)
  90. register struct tokenname *resv;
  91. {
  92. /* The names of the tokens described in resv are entered
  93. as reserved words.
  94. */
  95. register t_idf *p;
  96. while (resv->tn_symbol) {
  97. p = str2idf(resv->tn_name, 0);
  98. if (!p) fatal("out of Memory");
  99. p->id_reserved = resv->tn_symbol;
  100. resv++;
  101. }
  102. }