Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / cemcom.ansi / tokenname.c
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 /* $Id: tokenname.c,v 1.10 1994/06/27 08:03:00 ceriel Exp $ */
6 /* TOKEN NAME DEFINITIONS */
7
8 #include        "idf.h"
9 #include        "arith.h"
10 #include        "LLlex.h"
11 #include        "tokenname.h"
12 #include        "Lpars.h"
13
14 /*      To centralize the declaration of %tokens, their presence in this
15         file is taken as their declaration. The Makefile will produce
16         a grammar file (tokenfile.g) from this file.
17         Moreover, rather than looking up a symbol in all these lists
18         to find its printable name, a fast version of symbol2str() is
19         generated from these tables.
20         Consequenty some of these tables are not referenced explicitly
21         in the C text any more.  To save space and to avoid lint confusion,
22         these have been made pseudo-invisible by #ifdefs.
23 */
24
25 #ifdef  ____
26 struct tokenname tkspec[] =     {       /* the names of the special tokens */
27         {IDENTIFIER, "identifier"},
28         {TYPE_IDENTIFIER, "type_identifier"},
29         {STRING, "string"},
30         {WCHAR, "wchar"},
31         {FILESPECIFIER, "filespecifier"},
32         {INTEGER, "integer"},
33         {FLOATING, "floating"},
34         {0, ""}
35 };
36 #endif  /* ____ */
37
38 #ifdef  ____
39 struct tokenname tkcomp[] =     {       /* names of the composite tokens */
40         {PLUSAB, "+="},
41         {MINAB, "-="},
42         {TIMESAB, "*="},
43         {DIVAB, "/="},
44         {MODAB, "%="},
45         {LEFTAB, "<<="},
46         {RIGHTAB, ">>="},
47         {ANDAB, "&="},
48         {XORAB, "^="},
49         {ORAB, "|="},
50         {NOTEQUAL, "!="},
51         {AND, "&&"},
52         {PLUSPLUS, "++"},
53         {MINMIN, "--"},
54         {ARROW, "->"},
55         {LEFT, "<<"},
56         {LESSEQ, "<="},
57         {EQUAL, "=="},
58         {GREATEREQ, ">="},
59         {RIGHT, ">>"},
60         {OR, "||"},
61         {ELLIPSIS, "..."},
62         {0, ""}
63 };
64 #endif  /* ____ */
65
66 struct tokenname tkidf[] =      {       /* names of the identifier tokens */
67         {AUTO, "auto"},
68         {BREAK, "break"},
69         {CASE, "case"},
70         {CONST, "const"},
71         {CONTINUE, "continue"},
72         {DEFAULT, "default"},
73         {DO, "do"},
74         {ELSE, "else"},
75         {ENUM, "enum"},
76         {EXTERN, "extern"},
77         {FOR, "for"},
78         {GOTO, "goto"},
79         {IF, "if"},
80         {LONG, "long"},
81         {REGISTER, "register"},
82         {RETURN, "return"},
83         {SHORT, "short"},
84         {SIGNED, "signed"},
85         {SIZEOF, "sizeof"},
86         {STATIC, "static"},
87         {STRUCT, "struct"},
88         {SWITCH, "switch"},
89         {TYPEDEF, "typedef"},
90         {UNION, "union"},
91         {UNSIGNED, "unsigned"},
92         {VOLATILE, "volatile"},
93         {WHILE, "while"},
94
95         {VOID, "void"},
96         {CHAR, "char"},
97         {INT, "int"},
98         {FLOAT, "float"},
99         {DOUBLE, "double"},
100         {0, ""}
101 };
102
103 #ifdef  ____
104 struct tokenname tkfunny[] =    {       /* internal keywords */
105         {LNGDBL, "long double"},
106         {ULONG, "unsigned long"},
107
108         {ARRAY, "array"},
109         {FUNCTION, "function"},
110         {POINTER, "pointer"},
111         {FIELD, "field"},
112
113         {GLOBAL, "global"},
114         {FORMAL, "formal"},
115         {LABEL, "label"},
116         {ERRONEOUS, "erroneous"},
117
118         {PARCOMMA, "parcomma"},
119         {INITCOMMA, "initcomma"},
120         {CAST, "cast"},
121         {CASTAB, "castab"},
122         {ADDRESSOF,"unary &"},
123         {POSTINCR, "postfix ++"},
124         {POSTDECR, "postfix --"},
125
126         {INT2INT, "int2int"},
127         {INT2FLOAT, "int2float"},
128         {FLOAT2INT, "float2int"},
129         {FLOAT2FLOAT, "float2float"},
130         {0, ""}
131 };
132 #endif  /* ____ */
133
134 reserve(resv)
135         register struct tokenname resv[];
136 {
137         /*      The names of the tokens described in resv are entered
138                 as reserved words.
139         */
140         while (resv->tn_symbol) {
141                 struct idf *idf = str2idf(resv->tn_name, 0);
142                 
143                 if (idf->id_reserved)
144                         fatal("maximum identifier length insufficient");
145                 idf->id_reserved = resv->tn_symbol;
146                 resv++;
147         }
148 }