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