forked from farisawan-2000/cfront-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.h
297 lines (271 loc) · 6.33 KB
/
token.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*ident "@(#)cls4:src/token.h 1.8" */
/*******************************************************************************
C++ source for the C++ Language System, Release 3.0. This product
is a new release of the original cfront developed in the computer
science research center of AT&T Bell Laboratories.
Copyright (c) 1993 UNIX System Laboratories, Inc.
Copyright (c) 1991, 1992 AT&T and UNIX System Laboratories, Inc.
Copyright (c) 1984, 1989, 1990 AT&T. All Rights Reserved.
THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE of AT&T and UNIX System
Laboratories, Inc. The copyright notice above does not evidence
any actual or intended publication of such source code.
*******************************************************************************/
/*
#ifndef PRESAFE
extern "C" {
#endif
extern void free(char*); // alloc.h
extern char* malloc(unsigned);
extern char* calloc(unsigned, unsigned);
extern strncmp(const char*, const char*, const); // string.h
extern strcmp(const char*, const char*);
extern int strlen(const char*);
extern char* strcpy(char*, const char*);
#ifdef apollo
extern void set_sbrk_size(int);
#endif
#ifndef PRESAFE
}
#endif
*/
#ifdef SVR42
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <string.h>
#include <stdio.h>
extern void lex_clear();
extern void otbl_init();
//#define yylex() lalex()
#define putstring(s) fputs(s, out_file)
#define putst(s) (fputs(s, out_file), putc(' ', out_file))
#define putch(c) putc(c, out_file)
#define putcat(c, s) (putc(c, out_file), fputs(s, out_file))
/* token numbers for C parser */
#define MAXTOK 255
extern char *keys[MAXTOK + 1];
#define EOFTOK 0 /* EOF */
/* keywords in alphabetical order */
#define ASM 1
#define AUTO 2
#define BREAK 3
#define CASE 4
#define CHAR 5
#define CLASS 6
#define CONTINUE 7
#define DEFAULT 8
#define DELETE 9
#define DO 10
#define DOUBLE 11
#define ELSE 12
#define ENUM 13
#define EXTERN 14
#define FLOAT 15
#define FOR 16
#define FORTRAN 17
#define FRIEND 18
#define GOTO 19
#define IF 20
#define INT 21
#define LONG 22
#define NEW 23
#define OPERATOR 24
#define PUBLIC 25
#define CONST 26
#define REGISTER 27
#define RETURN 28
#define SHORT 29
#define SIZEOF 30
#define STATIC 31
#define STRUCT 32
#define SWITCH 33
#define THIS 34
#define TYPEDEF 35
#define UNION 36
#define UNSIGNED 37
#define VOID 38
#define WHILE 39
/* operators in priority order (sort of) */
#define LP 40
#define RP 41
#define LB 42
#define RB 43
#define REF 44
#define DOT 45
#define NOT 46
#define COMPL 47
#define INCR 48
#define DECR 49
#define MUL 50
#define DIV 51
#define AND 52
#define MOD 53
#define PLUS 54
#define MINUS 55
#define LS 56
#define RS 57
#define LT 58
#define LE 59
#define GT 60
#define GE 61
#define EQ 62
#define NE 63
#define ER 64
#define OR 65
#define ANDAND 66
#define OROR 67
#define QUEST 68
#define COLON 69
#define ASSIGN 70
#define CM 71
#define SM 72
#define LC 73
#define RC 74
#define INLINE 75
#define OVERLOAD 76
#define VIRTUAL 77
#define COERCE 78
#define PROTECTED 79
/* constants etc. */
#define ID 80
#define STRING 81
#define ICON 82
#define FCON 83
#define CCON 84
#define NAME 85
#define ZERO 86
#define W_CHAR 87
#define W_STRING 88
/* groups of tokens */
#define ASOP 90 /* op= */
#define RELOP 91 /* LE GE LT GT */
#define EQUOP 92 /* EQ NE */
#define DIVOP 93 /* DIV MOD */
#define SHIFTOP 94 /* LS RS */
#define ICOP 95 /* INCR DECR */
#define UNOP 96 /* NOT COMPL */
#define TYPE 97
/* TYPE = INT FLOAT CHAR DOUBLE REGISTER STATIC EXTERN AUTO
LONG SHORT UNSIGNED INLINE FRIEND VIRTUAL */
#define CATCH 98
#define THROW 99
#define TRY 100
#define MUTABLE 101
#define NAMESPACE 102
#define USING 103
/* new tokens generated by syn() */
#define UMINUS 107
#define FCT 108
#define CALL 109
#define VEC 110
#define DEREF 111
#define ADDROF 112
#define CAST 113
//#define ENDCAST 122
#define FIELD 114
#define LABEL 115
#define BLOCK 116
#define FDCL 117
#define DCL 118 /* local declaration statement */
#define COBJ 119
#define EOBJ 121
#define TNAME 123
#define ILIST 124
#define PTR 125
#define ASPLUS 126
#define ASMINUS 127
#define ASMUL 128
#define ASDIV 129
#define ASMOD 130
#define ASAND 131
#define ASOR 132
#define ASER 133
#define ASLS 134
#define ASRS 135
#define ARG 136
#define ARGS 137
#define ZTYPE 138
#define ARGT 139
#define ELIST 140
#define ANY 141
#define TABLE 142
#define LOC 143
#define DUMMY 144
#define G_ADDROF 145
#define G_CALL 146
#define G_CM 147
#define G_NAME 148 /* Generated name */
#define KTABLE 149 /* parsing table */
#define IVAL 150
//#define FVAL 151
//#define LVAL 152
#define ELLIPSIS 155
#define AGGR 156
#define VALUE 157 /* constructor call */
#define RPTR 158 /* reference */
#define HIDDEN 159
#define MEM 160
#define CTOR 161
#define DTOR 162
#define CONST_PTR 163
#define CONST_RPTR 164
#define TEXT 165
#define PAIR 166
#define ANON 167
#define ICALL 168
#define ANAME 169
#define VOLATILE 170
#define SIGNED 171
#define UPLUS 172
#define MEMPTR 173
#define PRIVATE 174
#define PR 175 /* PUBLIC PRIVATE or PROTECTED */
#define MEMQ 176 /* qualifier list after . or -> -- postpone lookup until after type checking */
#define MDOT 177
#define TSCOPE 178
#define DECL_MARKER 179
#define REFMUL 180
#define LDOUBLE 181
#define LINKAGE 182
#define GNEW 184
#define TEMPLATE 185
#define STAT_INIT 186
#define GDELETE 188
//#define CONVERT 189
#define TPDEF 190
#define G_CAST 191
// class parameterized types constants
#define XVIRT 200 /* class virt */
#define XNLIST 201 /* struct name_list */
#define XILINE 202
#define XIA 203
#define PT_OVERLOAD 204 /* handle ANY arg type strictly */
#define STATEMENT 205
#define EXPRESSION 206
#define SM_PARAM 207
#define TEMPLATE_TEST 208
#define PTNAME 209
#define NEW_INIT_KLUDGE 210
#define XDELETED_NODE 211
#define DUMMY_LAST_NODE 212
//-------------------------------------------------------------------------
// oper values for type::check
// The defines "ARG..MAXTOK" are here, so, all oper's are visible in one place
// (note that ARG..MAXTOK were defined earlier in this file)
#define NORMAL 0
#define IGNORE_CONST 254
//#define ARG 136
//#define ASSIGN 70
//#define OVERLOAD 76
//#define RETURN 28
//#define VIRTUAL 77
//#define COERCE 78
//#define MAXTOK 255
//-------------------------------------------------------------------------
//#define SYN 1
//#define TYP 2
//#define SIMPL 3
//#define ERROR 4
//#define ICTOR 88
//#define IDTOR 89