Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / cemcom / 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 3.3 1994/06/24 12:06:34 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         {FILESPECIFIER, "filespecifier"},
31         {INTEGER, "integer"},
32         {FLOATING, "floating"},
33         {0, ""}
34 };
35 #endif  /* ____ */
36
37 #ifdef  ____
38 struct tokenname tkcomp[] =     {       /* names of the composite tokens */
39         {NOTEQUAL, "!="},
40         {AND, "&&"},
41         {PLUSPLUS, "++"},
42         {MINMIN, "--"},
43         {ARROW, "->"},
44         {LEFT, "<<"},
45         {LESSEQ, "<="},
46         {EQUAL, "=="},
47         {GREATEREQ, ">="},
48         {RIGHT, ">>"},
49         {OR, "||"},
50         {0, ""}
51 };
52 #endif  /* ____ */
53
54 struct tokenname tkidf[] =      {       /* names of the identifier tokens */
55         {ASM, "asm"},
56         {AUTO, "auto"},
57         {BREAK, "break"},
58         {CASE, "case"},
59         {CONTINUE, "continue"},
60         {DEFAULT, "default"},
61         {DO, "do"},
62         {ELSE, "else"},
63         {ENUM, "enum"},
64         {EXTERN, "extern"},
65         {FOR, "for"},
66         {GOTO, "goto"},
67         {IF, "if"},
68         {LONG, "long"},
69         {REGISTER, "register"},
70         {RETURN, "return"},
71         {SHORT, "short"},
72         {SIZEOF, "sizeof"},
73         {STATIC, "static"},
74         {STRUCT, "struct"},
75         {SWITCH, "switch"},
76         {TYPEDEF, "typedef"},
77         {UNION, "union"},
78         {UNSIGNED, "unsigned"},
79         {WHILE, "while"},
80         {0, ""}
81 };
82
83 struct tokenname tkother[] =    {       /* additional keywords from the RM */
84         {ENTRY, "entry"},
85         {FORTRAN, "fortran"},
86         {0, ""}
87 };
88
89 #ifdef  ____
90 struct tokenname tkfunny[] =    {       /* internal keywords */
91         {CHAR, "char"},
92         {INT, "int"},
93         {FLOAT, "float"},
94         {DOUBLE, "double"},
95         {VOID, "void"},
96
97         {ARRAY, "array"},
98         {FUNCTION, "function"},
99         {POINTER, "pointer"},
100         {FIELD, "field"},
101         {NEWLINE, "newline"},
102
103         {GLOBAL, "global"},
104         {IMPLICIT, "implicit"},
105         {FORMAL, "formal"},
106         {LABEL, "label"},
107         {ERRONEOUS, "erroneous"},
108
109         {PARCOMMA, "parcomma"},
110         {INITCOMMA, "initcomma"},
111         {CAST, "cast"},
112         {POSTINCR, "postfix ++"},
113         {POSTDECR, "postfix --"},
114         {PLUSAB, "+="},
115         {MINAB, "-="},
116         {TIMESAB, "*="},
117         {DIVAB, "/="},
118         {MODAB, "%="},
119         {LEFTAB, "<<="},
120         {RIGHTAB, ">>="},
121         {ANDAB, "&="},
122         {XORAB, "^="},
123         {ORAB, "|="},
124
125         {INT2INT, "int2int"},
126         {INT2FLOAT, "int2float"},
127         {FLOAT2INT, "float2int"},
128         {FLOAT2FLOAT, "float2float"},
129         {0, ""}
130 };
131 #endif  /* ____ */
132
133 reserve(resv)
134         register struct tokenname resv[];
135 {
136         /*      The names of the tokens described in resv are entered
137                 as reserved words.
138         */
139         while (resv->tn_symbol) {
140                 struct idf *idf = str2idf(resv->tn_name);
141                 
142                 if (idf->id_reserved)
143                         fatal("maximum identifier length insufficient");
144                 idf->id_reserved = resv->tn_symbol;
145                 resv++;
146         }
147 }