Pristine Ack-5.5
[Ack-5.5.git] / lang / pc / comp / tokenname.c
1 /* T O K E N   D E F I N I T I O N S */
2
3 #include        "Lpars.h"
4 #include        "idf.h"
5 #include        "tokenname.h"
6
7 /*      To centralize the declaration of %tokens, their presence in this
8         file is taken as their declaration. The Makefile will produce
9         a grammar file (tokenfile.g) from this file. This scheme ensures
10         that all tokens have a printable name.
11         Also, the "symbol2str.c" file is produced from this file.
12 */
13
14 #ifdef ____
15 struct tokenname tkspec[] =     {       /* the names of the special tokens */
16         {IDENT, "identifier"},
17         {STRING, "string"},
18         {INTEGER, "integer"},
19         {REAL, "real"},
20         {0, ""}
21 };
22
23 struct tokenname tkcomp[] =     {       /* names of the composite tokens */
24         {LESSEQUAL, "<="},
25         {GREATEREQUAL, ">="},
26         {NOTEQUAL, "<>"},
27         {UPTO, ".."},
28         {BECOMES, ":="},
29         {0, ""}
30 };
31 #endif /* ____ */
32
33 struct tokenname tkidf[] =      {       /* names of the identifier tokens */
34         {AND, "and"},
35         {ARRAY, "array"},
36         {BEGIN, "begin"},
37         {CASE, "case"},
38         {CONST, "const"},
39         {DIV, "div"},
40         {DO, "do"},
41         {DOWNTO, "downto"},
42         {ELSE, "else"},
43         {END, "end"},
44         {FILE, "file"},
45         {FOR, "for"},
46         {FUNCTION, "function"},
47         {GOTO, "goto"},
48         {IF, "if"},
49         {IN, "in"},
50         {LABEL, "label"},
51         {MOD, "mod"},
52         {NIL, "nil"},
53         {NOT, "not"},
54         {OF, "of"},
55         {OR, "or"},
56         {PACKED, "packed"},
57         {PROCEDURE, "procedure"},
58         {PROGRAM, "program"},
59         {RECORD, "record"},
60         {REPEAT, "repeat"},
61         {SET, "set"},
62         {THEN, "then"},
63         {TO, "to"},
64         {TYPE, "type"},
65         {UNTIL, "until"},
66         {VAR, "var"},
67         {WHILE, "while"},
68         {WITH, "with"},
69         {0, ""}
70 };
71
72 struct tokenname tkstandard[] = {       /* standard identifiers */
73         /* These are the only standard identifiers entered here, because
74          * they can get a variable number of arguments, and there are
75          * special syntaxrules in the grammar for them
76          */
77         {READ, "read"},
78         {READLN, "readln"},
79         {WRITE, "write"},
80         {WRITELN, "writeln"},
81         {0, ""}
82 };
83
84 /* Some routines to handle tokennames */
85
86 reserve(resv)
87         register struct tokenname *resv;
88 {
89         /*      The names of the tokens described in resv are entered
90                 as reserved words.
91         */
92         register struct idf *p;
93
94         while( resv->tn_symbol )        {
95                 p = str2idf(resv->tn_name, 0);
96                 if( !p ) fatal("out of Memory");
97                 p->id_reserved = resv->tn_symbol;
98                 resv++;
99         }
100 }