Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libexpr/Oexparse.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1989-2012 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
/* : : generated by a yacc that works -- solaris take note : : */
21
#include "ast.h"
22
#ifndef lint
23
static const char exsccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
24
#endif
25
26
#include <stdlib.h>
27
#include <string.h>
28
29
#define EXBYACC 1
30
#define EXMAJOR 1
31
#define EXMINOR 9
32
#define EXPATCH 20070509
33
34
#define EXEMPTY (-1)
35
#define exclearin (exchar = EXEMPTY)
36
#define exerrok (exerrflag = 0)
37
#define EXRECOVERING (exerrflag != 0)
38
39
extern int exparse(void);
40
41
static int exgrowstack(void);
42
#define EXPREFIX "ex"
43
/* #line 2 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
44
45
/*
46
* Glenn Fowler
47
* AT&T Research
48
*
49
* expression library grammar and compiler
50
*/
51
52
#include <ast.h>
53
54
#undef RS /* hp.pa <signal.h> grabs this!! */
55
56
/* #line 16 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
57
typedef union
58
{
59
struct Exnode_s*expr;
60
double floating;
61
struct Exref_s* reference;
62
struct Exid_s* id;
63
Sflong_t integer;
64
int op;
65
char* string;
66
struct Exbuf_s* buffer;
67
} EXSTYPE;
68
/* #line 129 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
69
70
#include "exgram.h"
71
72
/* #line 52 "y.tab.c" */
73
#define MINTOKEN 257
74
#define CHAR 258
75
#define INT 259
76
#define INTEGER 260
77
#define UNSIGNED 261
78
#define FLOATING 262
79
#define STRING 263
80
#define VOID 264
81
#define STATIC 265
82
#define ADDRESS 266
83
#define BREAK 267
84
#define CALL 268
85
#define CASE 269
86
#define CONSTANT 270
87
#define CONTINUE 271
88
#define DECLARE 272
89
#define DEFAULT 273
90
#define DYNAMIC 274
91
#define ELSE 275
92
#define EXIT 276
93
#define FOR 277
94
#define FUNCTION 278
95
#define ITERATE 279
96
#define ID 280
97
#define IF 281
98
#define LABEL 282
99
#define MEMBER 283
100
#define NAME 284
101
#define POS 285
102
#define PRAGMA 286
103
#define PRE 287
104
#define PRINTF 288
105
#define PROCEDURE 289
106
#define QUERY 290
107
#define RETURN 291
108
#define SCANF 292
109
#define SPRINTF 293
110
#define SSCANF 294
111
#define SWITCH 295
112
#define WHILE 296
113
#define F2I 297
114
#define F2S 298
115
#define I2F 299
116
#define I2S 300
117
#define S2B 301
118
#define S2F 302
119
#define S2I 303
120
#define F2X 304
121
#define I2X 305
122
#define S2X 306
123
#define X2F 307
124
#define X2I 308
125
#define X2S 309
126
#define OR 310
127
#define AND 311
128
#define EQ 312
129
#define NE 313
130
#define LE 314
131
#define GE 315
132
#define LS 316
133
#define RS 317
134
#define UNARY 318
135
#define INC 319
136
#define DEC 320
137
#define CAST 321
138
#define MAXTOKEN 322
139
#define EXERRCODE 256
140
short exlhs[] = { -1,
141
0, 25, 25, 27, 26, 2, 2, 1, 1, 28,
142
29, 1, 1, 1, 1, 1, 30, 1, 1, 1,
143
1, 31, 31, 14, 32, 32, 33, 33, 24, 24,
144
10, 10, 34, 11, 20, 20, 4, 4, 5, 5,
145
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
146
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
147
6, 35, 36, 6, 6, 6, 6, 6, 6, 6,
148
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
149
6, 15, 15, 15, 15, 15, 21, 21, 21, 22,
150
22, 8, 8, 8, 23, 23, 12, 12, 7, 7,
151
3, 3, 16, 16, 16, 17, 17, 37, 18, 19,
152
19, 9, 9, 13, 38, 39, 13,
153
};
154
short exlen[] = { 2,
155
2, 0, 2, 0, 4, 0, 2, 3, 2, 0,
156
0, 6, 6, 5, 9, 5, 0, 8, 3, 3,
157
3, 0, 2, 2, 1, 2, 3, 2, 0, 1,
158
1, 3, 0, 5, 1, 1, 0, 2, 0, 1,
159
3, 4, 3, 3, 3, 3, 3, 3, 3, 3,
160
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
161
3, 0, 0, 7, 2, 2, 2, 2, 2, 5,
162
4, 4, 4, 4, 3, 2, 2, 2, 2, 2,
163
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
164
1, 3, 2, 1, 0, 2, 0, 3, 0, 1,
165
1, 3, 0, 1, 1, 1, 3, 0, 3, 0,
166
4, 0, 2, 1, 0, 0, 8,
167
};
168
short exdefred[] = { 6,
169
0, 0, 84, 86, 83, 0, 30, 0, 82, 0,
170
0, 0, 0, 0, 94, 87, 0, 88, 0, 90,
171
89, 91, 0, 0, 0, 0, 0, 0, 0, 0,
172
0, 0, 6, 7, 0, 0, 0, 81, 0, 0,
173
0, 10, 0, 0, 0, 0, 0, 93, 0, 0,
174
0, 0, 0, 0, 0, 69, 0, 68, 67, 65,
175
66, 77, 79, 0, 0, 0, 9, 0, 62, 0,
176
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177
0, 0, 0, 0, 0, 0, 0, 0, 78, 80,
178
76, 0, 0, 0, 0, 0, 0, 3, 75, 19,
179
20, 0, 0, 0, 0, 0, 0, 0, 0, 21,
180
0, 0, 0, 41, 8, 0, 0, 0, 0, 0,
181
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
182
0, 0, 45, 46, 47, 0, 0, 0, 0, 0,
183
11, 4, 98, 71, 0, 0, 0, 0, 72, 0,
184
0, 42, 0, 0, 111, 73, 74, 110, 6, 0,
185
14, 0, 0, 0, 16, 63, 70, 0, 31, 0,
186
0, 0, 0, 13, 22, 0, 110, 12, 0, 33,
187
0, 38, 0, 0, 32, 0, 0, 0, 0, 0,
188
18, 23, 0, 25, 0, 0, 15, 85, 0, 28,
189
0, 26, 96, 115, 114, 34, 27, 0, 0, 116,
190
0, 106, 0, 0, 0, 36, 35, 109, 0, 108,
191
107, 6, 0, 117,
192
};
193
short exdgoto[] = { 1,
194
34, 2, 107, 174, 35, 36, 109, 37, 91, 168,
195
169, 48, 206, 192, 38, 210, 211, 212, 39, 218,
196
40, 41, 196, 42, 43, 98, 159, 96, 158, 150,
197
183, 193, 194, 187, 117, 176, 213, 208, 214,
198
};
199
short exsindex[] = { 0,
200
0, 181, 0, 0, 0, -24, 0, 376, 0, 376,
201
-62, -5, 2, 7, 0, 0, 21, 0, 376, 0,
202
0, 0, 49, 60, -244, 376, 376, 376, 376, -244,
203
-244, 310, 0, 0, 45, 936, -61, 0, -190, 66,
204
67, 0, -171, -168, 57, 58, 376, 0, 376, 376,
205
376, 376, 63, 376, 376, 0, -161, 0, 0, 0,
206
0, 0, 0, 82, 734, 75, 0, 376, 0, 376,
207
376, 376, 376, 376, 376, 376, 376, 376, 376, 376,
208
376, 376, 376, 376, 376, 376, 376, 376, 0, 0,
209
0, 93, -62, 376, 376, -138, 77, 0, 0, 0,
210
0, 761, 788, 78, 4, 799, 92, 963, 97, 0,
211
936, 834, 376, 0, 0, 963, 376, 994, 1095, 111,
212
1021, 1116, 123, 123, -30, -30, -30, -30, 56, 56,
213
-19, -19, 0, 0, 0, 963, 376, 95, 106, 118,
214
0, 0, 0, 0, 376, 181, 181, 376, 0, 121,
215
181, 0, 871, 126, 0, 0, 0, 0, 0, 110,
216
0, -103, 963, 64, 0, 0, 0, 15, 0, -214,
217
181, 376, 181, 0, 0, 376, 0, 0, -62, 0,
218
133, 0, -87, 963, 0, 95, 88, 181, -131, 130,
219
0, 0, -189, 0, 91, -29, 0, 0, 131, 0,
220
181, 0, 0, 0, 0, 0, 0, -91, 0, 0,
221
147, 0, -207, 151, -78, 0, 0, 0, 73, 0,
222
0, 0, 112, 0,
223
};
224
short exrindex[] = { 0,
225
0, 140, 0, 0, 0, 639, 0, -51, 0, -51,
226
472, 0, 0, 0, 0, 0, 0, 0, -51, 0,
227
0, 0, 0, 0, -83, -184, -184, -184, -184, -83,
228
-83, -184, 0, 0, 0, -22, 676, 0, 0, 0,
229
0, 0, 202, 0, 0, 0, -184, 0, -184, -51,
230
-184, -39, 0, -184, -184, 0, 0, 0, 0, 0,
231
0, 0, 0, 0, 0, -55, 0, -184, 0, -184,
232
-184, -184, -184, -184, -184, -184, -184, -184, -184, -184,
233
-184, -184, -184, -184, -184, -184, -184, -184, 0, 0,
234
0, 0, 445, -39, -39, 0, 0, 0, 0, 0,
235
0, 0, 0, 0, 900, 0, 162, -20, 0, 0,
236
163, 0, -184, 0, 0, 28, -184, -8, 149, 51,
237
600, 1398, 1400, 1426, 1257, 1301, 1330, 1341, 1136, 1225,
238
1162, 1199, 0, 0, 0, 84, -39, 499, 0, 0,
239
0, 0, 0, 0, -51, -55, -55, -184, 0, 0,
240
-55, 0, 0, 0, 0, 0, 0, 0, 0, 0,
241
0, 1, 61, 0, 0, 0, 0, 0, 0, 0,
242
339, -35, -55, 0, 0, -184, 0, 0, 160, 0,
243
0, 0, 0, 172, 0, 0, 14, -55, 0, 0,
244
0, 0, 38, 0, 0, 20, 0, 0, 0, 0,
245
626, 0, 0, 0, 0, 0, 0, 169, -38, 0,
246
170, 0, 0, 0, 0, 0, 0, 0, 0, 0,
247
0, 0, -55, 0,
248
};
249
short exgindex[] = { 0,
250
-120, -13, 0, 0, 6, 1550, -85, 32, 19, 0,
251
41, -88, 0, 0, 31, 0, 0, 13, 18, 0,
252
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
253
0, 0, 29, 0, 0, 0, 0, 0, 0,
254
};
255
#define EXTABLESIZE 1737
256
short extable[] = { 88,
257
37, 99, 104, 39, 138, 39, 87, 39, 139, 140,
258
204, 85, 83, 45, 84, 46, 86, 87, 40, 66,
259
101, 44, 85, 101, 53, 161, 162, 86, 47, 11,
260
165, 88, 60, 37, 49, 60, 40, 191, 37, 15,
261
37, 50, 57, 37, 146, 37, 51, 57, 57, 60,
262
60, 154, 182, 95, 60, 104, 56, 95, 177, 37,
263
52, 62, 63, 112, 88, 179, 216, 197, 61, 180,
264
6, 61, 95, 178, 95, 6, 217, 6, 112, 189,
265
6, 105, 6, 190, 60, 61, 61, 92, 54, 93,
266
186, 56, 87, 110, 56, 110, 6, 85, 83, 55,
267
84, 102, 86, 67, 102, 94, 95, 28, 56, 56,
268
97, 99, 25, 56, 32, 100, 101, 26, 93, 27,
269
61, 110, 113, 37, 113, 37, 37, 113, 3, 4,
270
5, 198, 137, 141, 142, 148, 145, 149, 9, 2,
271
155, 113, 113, 56, 28, 171, 156, 87, 74, 25,
272
160, 32, 85, 83, 26, 84, 27, 86, 157, 87,
273
6, 164, 6, 6, 85, 83, 167, 84, 172, 86,
274
77, 173, 78, 188, 56, 170, 113, 181, 195, 201,
275
209, 189, 77, 203, 78, 190, 175, 200, 207, 59,
276
215, 219, 59, 220, 170, 222, 110, 33, 39, 115,
277
29, 1, 100, 17, 73, 97, 59, 59, 223, 103,
278
105, 59, 64, 28, 205, 64, 29, 185, 25, 199,
279
32, 202, 110, 26, 110, 27, 110, 221, 110, 64,
280
64, 0, 0, 0, 33, 108, 224, 29, 110, 0,
281
110, 59, 110, 0, 110, 108, 0, 0, 0, 0,
282
0, 0, 0, 0, 0, 0, 0, 89, 90, 0,
283
37, 37, 37, 37, 64, 37, 0, 37, 0, 37,
284
37, 37, 37, 37, 37, 0, 37, 37, 37, 0,
285
37, 37, 37, 0, 37, 81, 82, 0, 37, 37,
286
37, 37, 37, 37, 37, 37, 37, 6, 6, 6,
287
6, 60, 6, 33, 6, 0, 29, 6, 6, 6,
288
0, 6, 0, 6, 6, 6, 0, 6, 6, 37,
289
37, 6, 89, 90, 0, 6, 6, 6, 6, 6,
290
6, 6, 6, 6, 3, 4, 5, 6, 5, 7,
291
0, 8, 28, 0, 9, 10, 0, 25, 11, 32,
292
12, 13, 26, 0, 27, 14, 6, 6, 15, 0,
293
56, 56, 16, 17, 18, 19, 20, 21, 22, 23,
294
24, 3, 4, 5, 6, 0, 7, 0, 8, 0,
295
0, 9, 10, 0, 0, 11, 0, 12, 13, 0,
296
0, 0, 14, 30, 31, 15, 0, 39, 0, 16,
297
17, 18, 19, 20, 21, 22, 23, 24, 28, 0,
298
0, 29, 0, 25, 0, 32, 0, 110, 26, 110,
299
27, 2, 75, 76, 79, 80, 81, 82, 0, 0,
300
30, 31, 0, 0, 0, 29, 79, 80, 81, 82,
301
3, 4, 5, 6, 0, 7, 0, 8, 0, 0,
302
9, 10, 0, 0, 11, 0, 12, 13, 59, 59,
303
0, 14, 0, 0, 15, 0, 0, 0, 16, 17,
304
18, 19, 20, 21, 22, 23, 24, 0, 0, 0,
305
0, 97, 97, 0, 0, 97, 97, 97, 97, 97,
306
97, 97, 0, 0, 0, 0, 0, 0, 0, 30,
307
31, 29, 97, 97, 97, 97, 97, 97, 97, 97,
308
0, 0, 97, 97, 97, 97, 97, 0, 97, 0,
309
0, 0, 0, 0, 0, 0, 0, 0, 0, 97,
310
97, 97, 97, 97, 97, 92, 92, 97, 97, 92,
311
92, 92, 92, 92, 0, 92, 0, 0, 0, 0,
312
0, 0, 0, 0, 0, 0, 92, 92, 92, 92,
313
92, 92, 0, 0, 97, 97, 0, 0, 97, 3,
314
4, 5, 6, 0, 0, 0, 0, 0, 0, 9,
315
0, 64, 0, 11, 0, 12, 0, 0, 0, 0,
316
0, 92, 92, 15, 0, 97, 0, 16, 17, 18,
317
0, 20, 21, 22, 0, 0, 0, 0, 0, 0,
318
29, 0, 0, 0, 0, 0, 110, 0, 110, 0,
319
5, 0, 92, 0, 0, 0, 0, 0, 30, 31,
320
0, 0, 0, 0, 0, 3, 4, 5, 6, 0,
321
57, 0, 0, 57, 0, 9, 0, 0, 0, 11,
322
0, 12, 0, 0, 0, 0, 0, 57, 57, 15,
323
0, 0, 57, 16, 17, 18, 0, 20, 21, 22,
324
0, 0, 0, 0, 0, 85, 85, 0, 0, 85,
325
85, 85, 85, 85, 39, 85, 0, 0, 0, 0,
326
0, 0, 57, 57, 30, 31, 85, 85, 85, 0,
327
85, 85, 0, 0, 0, 0, 0, 0, 0, 0,
328
0, 0, 112, 112, 0, 0, 112, 112, 112, 112,
329
112, 0, 112, 57, 0, 0, 0, 0, 0, 0,
330
0, 85, 85, 112, 112, 112, 0, 112, 112, 0,
331
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
332
24, 0, 0, 0, 97, 97, 97, 97, 97, 97,
333
97, 97, 85, 97, 97, 0, 0, 0, 112, 112,
334
87, 74, 0, 0, 114, 85, 83, 68, 84, 0,
335
86, 97, 97, 97, 97, 97, 97, 97, 97, 0,
336
97, 97, 0, 77, 0, 78, 69, 87, 74, 112,
337
0, 0, 85, 83, 68, 84, 0, 86, 92, 92,
338
92, 92, 92, 92, 92, 92, 0, 92, 92, 0,
339
77, 0, 78, 69, 87, 74, 0, 73, 144, 85,
340
83, 68, 84, 0, 86, 87, 74, 0, 0, 147,
341
85, 83, 68, 84, 0, 86, 0, 77, 0, 78,
342
69, 0, 0, 143, 73, 0, 0, 72, 77, 0,
343
78, 69, 0, 0, 0, 0, 0, 0, 0, 0,
344
87, 74, 0, 0, 151, 85, 83, 68, 84, 0,
345
86, 73, 0, 0, 72, 0, 0, 0, 0, 0,
346
0, 0, 73, 77, 24, 78, 69, 29, 24, 0,
347
0, 0, 0, 110, 0, 110, 0, 87, 74, 57,
348
57, 72, 85, 83, 68, 84, 0, 86, 0, 0,
349
0, 0, 72, 0, 0, 0, 0, 73, 166, 0,
350
77, 0, 78, 69, 0, 0, 112, 112, 0, 0,
351
0, 112, 112, 112, 112, 0, 112, 0, 85, 85,
352
85, 85, 85, 85, 85, 85, 0, 72, 112, 112,
353
0, 112, 112, 0, 73, 0, 0, 0, 0, 0,
354
0, 0, 87, 74, 0, 0, 0, 85, 83, 68,
355
84, 0, 86, 0, 0, 112, 112, 112, 112, 112,
356
112, 112, 112, 112, 72, 77, 0, 78, 69, 87,
357
74, 0, 0, 0, 85, 83, 0, 84, 0, 86,
358
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
359
0, 0, 77, 112, 78, 69, 0, 0, 0, 73,
360
87, 74, 0, 0, 0, 85, 83, 0, 84, 0,
361
86, 0, 0, 70, 71, 75, 76, 79, 80, 81,
362
82, 0, 0, 77, 0, 78, 73, 87, 74, 72,
363
0, 0, 85, 83, 0, 84, 0, 86, 0, 0,
364
70, 71, 75, 76, 79, 80, 81, 82, 0, 0,
365
77, 0, 78, 0, 0, 0, 72, 73, 0, 0,
366
0, 0, 0, 0, 0, 0, 0, 70, 71, 75,
367
76, 79, 80, 81, 82, 0, 0, 0, 70, 71,
368
75, 76, 79, 80, 81, 82, 0, 72, 0, 0,
369
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
370
0, 87, 74, 0, 0, 0, 85, 83, 0, 84,
371
0, 86, 0, 70, 71, 75, 76, 79, 80, 81,
372
82, 0, 87, 0, 77, 0, 78, 85, 83, 0,
373
84, 0, 86, 0, 0, 0, 0, 0, 0, 0,
374
0, 0, 0, 48, 0, 77, 48, 78, 0, 48,
375
70, 71, 75, 76, 79, 80, 81, 82, 73, 0,
376
0, 0, 0, 48, 48, 48, 0, 48, 48, 58,
377
0, 0, 58, 0, 58, 58, 58, 0, 0, 112,
378
112, 112, 112, 112, 112, 112, 112, 0, 72, 58,
379
58, 58, 0, 58, 58, 0, 0, 0, 48, 48,
380
0, 0, 0, 0, 0, 0, 44, 0, 0, 44,
381
0, 44, 44, 44, 0, 70, 71, 75, 76, 79,
382
80, 81, 82, 0, 58, 58, 44, 44, 44, 48,
383
44, 44, 49, 0, 0, 49, 0, 0, 49, 0,
384
0, 0, 70, 71, 75, 76, 79, 80, 81, 82,
385
0, 0, 49, 49, 49, 58, 49, 49, 0, 0,
386
0, 44, 44, 0, 43, 0, 0, 43, 0, 0,
387
43, 0, 0, 0, 71, 75, 76, 79, 80, 81,
388
82, 0, 0, 0, 43, 43, 0, 49, 49, 43,
389
0, 0, 44, 0, 0, 0, 0, 0, 0, 0,
390
0, 0, 75, 76, 79, 80, 81, 82, 50, 0,
391
0, 50, 0, 0, 50, 0, 0, 0, 49, 43,
392
43, 0, 0, 0, 0, 0, 0, 0, 50, 50,
393
0, 0, 0, 50, 0, 0, 0, 51, 0, 0,
394
51, 0, 0, 51, 0, 0, 0, 0, 52, 0,
395
43, 52, 0, 0, 52, 0, 0, 51, 51, 0,
396
0, 0, 51, 50, 50, 0, 0, 0, 52, 52,
397
0, 0, 0, 52, 0, 0, 75, 76, 79, 80,
398
81, 82, 0, 0, 0, 0, 0, 0, 0, 0,
399
0, 0, 51, 51, 50, 0, 0, 75, 76, 79,
400
80, 81, 82, 52, 52, 55, 0, 53, 55, 0,
401
53, 55, 0, 53, 0, 48, 48, 48, 48, 48,
402
48, 48, 48, 51, 0, 55, 55, 53, 53, 0,
403
55, 0, 53, 54, 52, 0, 54, 0, 0, 54,
404
0, 58, 58, 58, 58, 58, 58, 58, 58, 0,
405
0, 0, 0, 54, 54, 0, 0, 0, 54, 0,
406
55, 55, 53, 53, 0, 0, 0, 0, 0, 0,
407
0, 0, 0, 0, 0, 0, 0, 0, 44, 44,
408
44, 44, 44, 44, 44, 44, 0, 0, 54, 54,
409
0, 55, 0, 53, 0, 0, 0, 0, 0, 0,
410
0, 0, 0, 0, 49, 49, 49, 49, 49, 49,
411
49, 49, 0, 0, 0, 0, 0, 0, 0, 54,
412
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
413
0, 0, 0, 0, 0, 0, 43, 43, 43, 43,
414
0, 0, 0, 0, 0, 58, 59, 60, 61, 0,
415
0, 65, 0, 0, 0, 0, 0, 0, 0, 0,
416
0, 0, 0, 0, 0, 0, 102, 0, 103, 0,
417
106, 108, 0, 111, 112, 0, 0, 0, 0, 0,
418
50, 50, 50, 50, 0, 0, 0, 116, 0, 118,
419
119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
420
129, 130, 131, 132, 133, 134, 135, 136, 0, 51,
421
51, 51, 51, 108, 108, 0, 0, 0, 0, 0,
422
52, 52, 52, 52, 0, 0, 0, 0, 0, 0,
423
0, 0, 152, 0, 0, 0, 153, 0, 0, 0,
424
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
425
0, 0, 0, 0, 0, 0, 108, 0, 0, 0,
426
0, 0, 0, 0, 0, 0, 0, 163, 0, 0,
427
0, 0, 0, 0, 0, 0, 0, 55, 55, 53,
428
53, 0, 0, 0, 0, 0, 0, 0, 0, 0,
429
0, 0, 0, 0, 0, 184, 0, 0, 0, 0,
430
0, 0, 0, 0, 0, 54, 54,
431
};
432
short excheck[] = { 61,
433
0, 41, 41, 59, 93, 41, 37, 59, 94, 95,
434
40, 42, 43, 8, 45, 10, 47, 37, 41, 33,
435
41, 46, 42, 44, 19, 146, 147, 47, 91, 274,
436
151, 61, 41, 33, 40, 44, 59, 125, 38, 284,
437
40, 40, 25, 43, 41, 45, 40, 30, 31, 58,
438
59, 137, 173, 40, 63, 50, 25, 44, 44, 59,
439
40, 30, 31, 44, 61, 280, 274, 188, 41, 284,
440
33, 44, 59, 59, 61, 38, 284, 40, 59, 269,
441
43, 50, 45, 273, 93, 58, 59, 278, 40, 280,
442
179, 41, 37, 278, 44, 280, 59, 42, 43, 40,
443
45, 41, 47, 59, 44, 40, 40, 33, 58, 59,
444
282, 280, 38, 63, 40, 59, 59, 43, 280, 45,
445
93, 59, 41, 123, 41, 125, 126, 44, 260, 261,
446
262, 263, 40, 272, 58, 44, 59, 41, 270, 0,
447
46, 58, 59, 93, 33, 159, 41, 37, 38, 38,
448
145, 40, 42, 43, 43, 45, 45, 47, 41, 37,
449
123, 41, 125, 126, 42, 43, 41, 45, 59, 47,
450
60, 275, 62, 41, 124, 158, 93, 172, 91, 193,
451
272, 269, 60, 93, 62, 273, 123, 58, 58, 41,
452
44, 41, 44, 272, 177, 123, 280, 123, 59, 125,
453
126, 0, 41, 41, 94, 46, 58, 59, 222, 41,
454
41, 63, 41, 33, 196, 44, 272, 177, 38, 189,
455
40, 193, 278, 43, 280, 45, 278, 215, 280, 58,
456
59, -1, -1, -1, 123, 274, 125, 126, 278, -1,
457
280, 93, 278, -1, 280, 284, -1, -1, -1, -1,
458
-1, -1, -1, -1, -1, -1, -1, 319, 320, -1,
459
260, 261, 262, 263, 93, 265, -1, 267, -1, 269,
460
270, 271, 272, 273, 274, -1, 276, 277, 278, -1,
461
280, 281, 282, -1, 284, 316, 317, -1, 288, 289,
462
290, 291, 292, 293, 294, 295, 296, 260, 261, 262,
463
263, 310, 265, 123, 267, -1, 126, 270, 271, 272,
464
-1, 274, -1, 276, 277, 278, -1, 280, 281, 319,
465
320, 284, 319, 320, -1, 288, 289, 290, 291, 292,
466
293, 294, 295, 296, 260, 261, 262, 263, 0, 265,
467
-1, 267, 33, -1, 270, 271, -1, 38, 274, 40,
468
276, 277, 43, -1, 45, 281, 319, 320, 284, -1,
469
310, 311, 288, 289, 290, 291, 292, 293, 294, 295,
470
296, 260, 261, 262, 263, -1, 265, -1, 267, -1,
471
-1, 270, 271, -1, -1, 274, -1, 276, 277, -1,
472
-1, -1, 281, 319, 320, 284, -1, 59, -1, 288,
473
289, 290, 291, 292, 293, 294, 295, 296, 33, -1,
474
-1, 272, -1, 38, -1, 40, -1, 278, 43, 280,
475
45, 282, 312, 313, 314, 315, 316, 317, -1, -1,
476
319, 320, -1, -1, -1, 126, 314, 315, 316, 317,
477
260, 261, 262, 263, -1, 265, -1, 267, -1, -1,
478
270, 271, -1, -1, 274, -1, 276, 277, 310, 311,
479
-1, 281, -1, -1, 284, -1, -1, -1, 288, 289,
480
290, 291, 292, 293, 294, 295, 296, -1, -1, -1,
481
-1, 37, 38, -1, -1, 41, 42, 43, 44, 45,
482
46, 47, -1, -1, -1, -1, -1, -1, -1, 319,
483
320, 126, 58, 59, 60, 61, 62, 63, 37, 38,
484
-1, -1, 41, 42, 43, 44, 45, -1, 47, -1,
485
-1, -1, -1, -1, -1, -1, -1, -1, -1, 58,
486
59, 60, 61, 62, 63, 37, 38, 93, 94, 41,
487
42, 43, 44, 45, -1, 47, -1, -1, -1, -1,
488
-1, -1, -1, -1, -1, -1, 58, 59, 60, 61,
489
62, 63, -1, -1, 93, 94, -1, -1, 124, 260,
490
261, 262, 263, -1, -1, -1, -1, -1, -1, 270,
491
-1, 272, -1, 274, -1, 276, -1, -1, -1, -1,
492
-1, 93, 94, 284, -1, 124, -1, 288, 289, 290,
493
-1, 292, 293, 294, -1, -1, -1, -1, -1, -1,
494
272, -1, -1, -1, -1, -1, 278, -1, 280, -1,
495
282, -1, 124, -1, -1, -1, -1, -1, 319, 320,
496
-1, -1, -1, -1, -1, 260, 261, 262, 263, -1,
497
41, -1, -1, 44, -1, 270, -1, -1, -1, 274,
498
-1, 276, -1, -1, -1, -1, -1, 58, 59, 284,
499
-1, -1, 63, 288, 289, 290, -1, 292, 293, 294,
500
-1, -1, -1, -1, -1, 37, 38, -1, -1, 41,
501
42, 43, 44, 45, 59, 47, -1, -1, -1, -1,
502
-1, -1, 93, 94, 319, 320, 58, 59, 60, -1,
503
62, 63, -1, -1, -1, -1, -1, -1, -1, -1,
504
-1, -1, 37, 38, -1, -1, 41, 42, 43, 44,
505
45, -1, 47, 124, -1, -1, -1, -1, -1, -1,
506
-1, 93, 94, 58, 59, 60, -1, 62, 63, -1,
507
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
508
125, -1, -1, -1, 310, 311, 312, 313, 314, 315,
509
316, 317, 124, 319, 320, -1, -1, -1, 93, 94,
510
37, 38, -1, -1, 41, 42, 43, 44, 45, -1,
511
47, 310, 311, 312, 313, 314, 315, 316, 317, -1,
512
319, 320, -1, 60, -1, 62, 63, 37, 38, 124,
513
-1, -1, 42, 43, 44, 45, -1, 47, 310, 311,
514
312, 313, 314, 315, 316, 317, -1, 319, 320, -1,
515
60, -1, 62, 63, 37, 38, -1, 94, 41, 42,
516
43, 44, 45, -1, 47, 37, 38, -1, -1, 41,
517
42, 43, 44, 45, -1, 47, -1, 60, -1, 62,
518
63, -1, -1, 93, 94, -1, -1, 124, 60, -1,
519
62, 63, -1, -1, -1, -1, -1, -1, -1, -1,
520
37, 38, -1, -1, 41, 42, 43, 44, 45, -1,
521
47, 94, -1, -1, 124, -1, -1, -1, -1, -1,
522
-1, -1, 94, 60, 269, 62, 63, 272, 273, -1,
523
-1, -1, -1, 278, -1, 280, -1, 37, 38, 310,
524
311, 124, 42, 43, 44, 45, -1, 47, -1, -1,
525
-1, -1, 124, -1, -1, -1, -1, 94, 58, -1,
526
60, -1, 62, 63, -1, -1, 37, 38, -1, -1,
527
-1, 42, 43, 44, 45, -1, 47, -1, 310, 311,
528
312, 313, 314, 315, 316, 317, -1, 124, 59, 60,
529
-1, 62, 63, -1, 94, -1, -1, -1, -1, -1,
530
-1, -1, 37, 38, -1, -1, -1, 42, 43, 44,
531
45, -1, 47, -1, -1, 310, 311, 312, 313, 314,
532
315, 316, 317, 94, 124, 60, -1, 62, 63, 37,
533
38, -1, -1, -1, 42, 43, -1, 45, -1, 47,
534
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
535
-1, -1, 60, 124, 62, 63, -1, -1, -1, 94,
536
37, 38, -1, -1, -1, 42, 43, -1, 45, -1,
537
47, -1, -1, 310, 311, 312, 313, 314, 315, 316,
538
317, -1, -1, 60, -1, 62, 94, 37, 38, 124,
539
-1, -1, 42, 43, -1, 45, -1, 47, -1, -1,
540
310, 311, 312, 313, 314, 315, 316, 317, -1, -1,
541
60, -1, 62, -1, -1, -1, 124, 94, -1, -1,
542
-1, -1, -1, -1, -1, -1, -1, 310, 311, 312,
543
313, 314, 315, 316, 317, -1, -1, -1, 310, 311,
544
312, 313, 314, 315, 316, 317, -1, 124, -1, -1,
545
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
546
-1, 37, 38, -1, -1, -1, 42, 43, -1, 45,
547
-1, 47, -1, 310, 311, 312, 313, 314, 315, 316,
548
317, -1, 37, -1, 60, -1, 62, 42, 43, -1,
549
45, -1, 47, -1, -1, -1, -1, -1, -1, -1,
550
-1, -1, -1, 38, -1, 60, 41, 62, -1, 44,
551
310, 311, 312, 313, 314, 315, 316, 317, 94, -1,
552
-1, -1, -1, 58, 59, 60, -1, 62, 63, 38,
553
-1, -1, 41, -1, 43, 44, 45, -1, -1, 310,
554
311, 312, 313, 314, 315, 316, 317, -1, 124, 58,
555
59, 60, -1, 62, 63, -1, -1, -1, 93, 94,
556
-1, -1, -1, -1, -1, -1, 38, -1, -1, 41,
557
-1, 43, 44, 45, -1, 310, 311, 312, 313, 314,
558
315, 316, 317, -1, 93, 94, 58, 59, 60, 124,
559
62, 63, 38, -1, -1, 41, -1, -1, 44, -1,
560
-1, -1, 310, 311, 312, 313, 314, 315, 316, 317,
561
-1, -1, 58, 59, 60, 124, 62, 63, -1, -1,
562
-1, 93, 94, -1, 38, -1, -1, 41, -1, -1,
563
44, -1, -1, -1, 311, 312, 313, 314, 315, 316,
564
317, -1, -1, -1, 58, 59, -1, 93, 94, 63,
565
-1, -1, 124, -1, -1, -1, -1, -1, -1, -1,
566
-1, -1, 312, 313, 314, 315, 316, 317, 38, -1,
567
-1, 41, -1, -1, 44, -1, -1, -1, 124, 93,
568
94, -1, -1, -1, -1, -1, -1, -1, 58, 59,
569
-1, -1, -1, 63, -1, -1, -1, 38, -1, -1,
570
41, -1, -1, 44, -1, -1, -1, -1, 38, -1,
571
124, 41, -1, -1, 44, -1, -1, 58, 59, -1,
572
-1, -1, 63, 93, 94, -1, -1, -1, 58, 59,
573
-1, -1, -1, 63, -1, -1, 312, 313, 314, 315,
574
316, 317, -1, -1, -1, -1, -1, -1, -1, -1,
575
-1, -1, 93, 94, 124, -1, -1, 312, 313, 314,
576
315, 316, 317, 93, 94, 38, -1, 38, 41, -1,
577
41, 44, -1, 44, -1, 310, 311, 312, 313, 314,
578
315, 316, 317, 124, -1, 58, 59, 58, 59, -1,
579
63, -1, 63, 38, 124, -1, 41, -1, -1, 44,
580
-1, 310, 311, 312, 313, 314, 315, 316, 317, -1,
581
-1, -1, -1, 58, 59, -1, -1, -1, 63, -1,
582
93, 94, 93, 94, -1, -1, -1, -1, -1, -1,
583
-1, -1, -1, -1, -1, -1, -1, -1, 310, 311,
584
312, 313, 314, 315, 316, 317, -1, -1, 93, 94,
585
-1, 124, -1, 124, -1, -1, -1, -1, -1, -1,
586
-1, -1, -1, -1, 310, 311, 312, 313, 314, 315,
587
316, 317, -1, -1, -1, -1, -1, -1, -1, 124,
588
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
589
-1, -1, -1, -1, -1, -1, 310, 311, 312, 313,
590
-1, -1, -1, -1, -1, 26, 27, 28, 29, -1,
591
-1, 32, -1, -1, -1, -1, -1, -1, -1, -1,
592
-1, -1, -1, -1, -1, -1, 47, -1, 49, -1,
593
51, 52, -1, 54, 55, -1, -1, -1, -1, -1,
594
310, 311, 312, 313, -1, -1, -1, 68, -1, 70,
595
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
596
81, 82, 83, 84, 85, 86, 87, 88, -1, 310,
597
311, 312, 313, 94, 95, -1, -1, -1, -1, -1,
598
310, 311, 312, 313, -1, -1, -1, -1, -1, -1,
599
-1, -1, 113, -1, -1, -1, 117, -1, -1, -1,
600
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
601
-1, -1, -1, -1, -1, -1, 137, -1, -1, -1,
602
-1, -1, -1, -1, -1, -1, -1, 148, -1, -1,
603
-1, -1, -1, -1, -1, -1, -1, 310, 311, 310,
604
311, -1, -1, -1, -1, -1, -1, -1, -1, -1,
605
-1, -1, -1, -1, -1, 176, -1, -1, -1, -1,
606
-1, -1, -1, -1, -1, 310, 311,
607
};
608
#define EXFINAL 1
609
#ifndef EXDEBUG
610
#define EXDEBUG 0
611
#endif
612
#define EXMAXTOKEN 322
613
#if EXDEBUG
614
char *exname[] = {
615
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
616
"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,
617
0,0,0,0,0,0,0,"':'","';'","'<'","'='","'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
618
0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
619
0,0,0,0,0,0,0,0,0,0,"'{'","'|'","'}'","'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
620
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
621
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
622
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"MINTOKEN",
623
"CHAR","INT","INTEGER","UNSIGNED","FLOATING","STRING","VOID","STATIC","ADDRESS",
624
"BREAK","CALL","CASE","CONSTANT","CONTINUE","DECLARE","DEFAULT","DYNAMIC",
625
"ELSE","EXIT","FOR","FUNCTION","ITERATE","ID","IF","LABEL","MEMBER","NAME",
626
"POS","PRAGMA","PRE","PRINTF","PROCEDURE","QUERY","RETURN","SCANF","SPRINTF",
627
"SSCANF","SWITCH","WHILE","F2I","F2S","I2F","I2S","S2B","S2F","S2I","F2X","I2X",
628
"S2X","X2F","X2I","X2S","OR","AND","EQ","NE","LE","GE","LS","RS","UNARY","INC",
629
"DEC","CAST","MAXTOKEN",
630
};
631
char *exrule[] = {
632
"$accept : program",
633
"program : statement_list action_list",
634
"action_list :",
635
"action_list : action_list action",
636
"$$1 :",
637
"action : LABEL ':' $$1 statement_list",
638
"statement_list :",
639
"statement_list : statement_list statement",
640
"statement : '{' statement_list '}'",
641
"statement : expr_opt ';'",
642
"$$2 :",
643
"$$3 :",
644
"statement : static $$2 DECLARE $$3 dcl_list ';'",
645
"statement : IF '(' expr ')' statement else_opt",
646
"statement : FOR '(' variable ')' statement",
647
"statement : FOR '(' expr_opt ';' expr_opt ';' expr_opt ')' statement",
648
"statement : WHILE '(' expr ')' statement",
649
"$$4 :",
650
"statement : SWITCH '(' expr $$4 ')' '{' switch_list '}'",
651
"statement : BREAK expr_opt ';'",
652
"statement : CONTINUE expr_opt ';'",
653
"statement : RETURN expr_opt ';'",
654
"switch_list :",
655
"switch_list : switch_list switch_item",
656
"switch_item : case_list statement_list",
657
"case_list : case_item",
658
"case_list : case_list case_item",
659
"case_item : CASE constant ':'",
660
"case_item : DEFAULT ':'",
661
"static :",
662
"static : STATIC",
663
"dcl_list : dcl_item",
664
"dcl_list : dcl_list ',' dcl_item",
665
"$$5 :",
666
"dcl_item : reference NAME $$5 array initialize",
667
"name : NAME",
668
"name : DYNAMIC",
669
"else_opt :",
670
"else_opt : ELSE statement",
671
"expr_opt :",
672
"expr_opt : expr",
673
"expr : '(' expr ')'",
674
"expr : '(' DECLARE ')' expr",
675
"expr : expr '<' expr",
676
"expr : expr '-' expr",
677
"expr : expr '*' expr",
678
"expr : expr '/' expr",
679
"expr : expr '%' expr",
680
"expr : expr LS expr",
681
"expr : expr RS expr",
682
"expr : expr '>' expr",
683
"expr : expr LE expr",
684
"expr : expr GE expr",
685
"expr : expr EQ expr",
686
"expr : expr NE expr",
687
"expr : expr '&' expr",
688
"expr : expr '|' expr",
689
"expr : expr '^' expr",
690
"expr : expr '+' expr",
691
"expr : expr AND expr",
692
"expr : expr OR expr",
693
"expr : expr ',' expr",
694
"$$6 :",
695
"$$7 :",
696
"expr : expr '?' $$6 expr ':' $$7 expr",
697
"expr : '!' expr",
698
"expr : '~' expr",
699
"expr : '-' expr",
700
"expr : '+' expr",
701
"expr : '&' variable",
702
"expr : reference FUNCTION '(' args ')'",
703
"expr : EXIT '(' expr ')'",
704
"expr : PROCEDURE '(' args ')'",
705
"expr : print '(' args ')'",
706
"expr : scan '(' args ')'",
707
"expr : STRING '.' ID",
708
"expr : variable assign",
709
"expr : INC variable",
710
"expr : variable INC",
711
"expr : DEC variable",
712
"expr : variable DEC",
713
"expr : constant",
714
"constant : CONSTANT",
715
"constant : FLOATING",
716
"constant : INTEGER",
717
"constant : STRING",
718
"constant : UNSIGNED",
719
"print : PRINTF",
720
"print : QUERY",
721
"print : SPRINTF",
722
"scan : SCANF",
723
"scan : SSCANF",
724
"variable : reference ID index",
725
"variable : DYNAMIC index",
726
"variable : NAME",
727
"array :",
728
"array : '[' ']'",
729
"index :",
730
"index : '[' expr ']'",
731
"args :",
732
"args : arg_list",
733
"arg_list : expr",
734
"arg_list : arg_list ',' expr",
735
"formals :",
736
"formals : DECLARE",
737
"formals : formal_list",
738
"formal_list : formal_item",
739
"formal_list : formal_list ',' formal_item",
740
"$$8 :",
741
"formal_item : DECLARE $$8 name",
742
"reference :",
743
"reference : reference ID index '.'",
744
"assign :",
745
"assign : '=' expr",
746
"initialize : assign",
747
"$$9 :",
748
"$$10 :",
749
"initialize : '(' $$9 formals $$10 ')' '{' statement_list '}'",
750
};
751
#endif
752
#if EXDEBUG
753
#include <stdio.h>
754
#endif
755
756
/* define the initial stack-sizes */
757
#ifdef EXSTACKSIZE
758
#undef EXMAXDEPTH
759
#define EXMAXDEPTH EXSTACKSIZE
760
#else
761
#ifdef EXMAXDEPTH
762
#define EXSTACKSIZE EXMAXDEPTH
763
#else
764
#define EXSTACKSIZE 10000
765
#define EXMAXDEPTH 10000
766
#endif
767
#endif
768
769
#define EXINITSTACKSIZE 500
770
771
int exdebug;
772
int exnerrs;
773
int exerrflag;
774
int exchar;
775
short *exssp;
776
EXSTYPE *exvsp;
777
EXSTYPE exval;
778
EXSTYPE exlval;
779
780
/* variables for the parser stack */
781
static short *exss;
782
static short *exsslim;
783
static EXSTYPE *exvs;
784
static int exstacksize;
785
/* #line 1104 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
786
787
#include "exgram.h"
788
/* #line 768 "y.tab.c" */
789
/* allocate initial stack or double stack size, up to EXMAXDEPTH */
790
static int exgrowstack(void)
791
{
792
int newsize, i;
793
short *newss;
794
EXSTYPE *newvs;
795
796
if ((newsize = exstacksize) == 0)
797
newsize = EXINITSTACKSIZE;
798
else if (newsize >= EXMAXDEPTH)
799
return -1;
800
else if ((newsize *= 2) > EXMAXDEPTH)
801
newsize = EXMAXDEPTH;
802
803
i = exssp - exss;
804
newss = (exss != 0)
805
? (short *)realloc(exss, newsize * sizeof(*newss))
806
: (short *)malloc(newsize * sizeof(*newss));
807
if (newss == 0)
808
return -1;
809
810
exss = newss;
811
exssp = newss + i;
812
newvs = (exvs != 0)
813
? (EXSTYPE *)realloc(exvs, newsize * sizeof(*newvs))
814
: (EXSTYPE *)malloc(newsize * sizeof(*newvs));
815
if (newvs == 0)
816
return -1;
817
818
exvs = newvs;
819
exvsp = newvs + i;
820
exstacksize = newsize;
821
exsslim = exss + newsize - 1;
822
return 0;
823
}
824
825
#define EXABORT goto exabort
826
#define EXREJECT goto exabort
827
#define EXACCEPT goto exaccept
828
#define EXERROR goto exerrlab
829
int
830
exparse(void)
831
{
832
register int exm, exn, exstate;
833
#if EXDEBUG
834
register const char *exs;
835
836
if ((exs = getenv("EXDEBUG")) != 0)
837
{
838
exn = *exs;
839
if (exn >= '0' && exn <= '9')
840
exdebug = exn - '0';
841
}
842
#endif
843
844
exnerrs = 0;
845
exerrflag = 0;
846
exchar = EXEMPTY;
847
848
if (exss == NULL && exgrowstack()) goto exoverflow;
849
exssp = exss;
850
exvsp = exvs;
851
*exssp = exstate = 0;
852
853
exloop:
854
if ((exn = exdefred[exstate]) != 0) goto exreduce;
855
if (exchar < 0)
856
{
857
if ((exchar = exlex()) < 0) exchar = 0;
858
#if EXDEBUG
859
if (exdebug)
860
{
861
exs = 0;
862
if (exchar <= EXMAXTOKEN) exs = exname[exchar];
863
if (!exs) exs = "illegal-symbol";
864
printf("%sdebug: state %d, reading %d (%s)\n",
865
EXPREFIX, exstate, exchar, exs);
866
}
867
#endif
868
}
869
if ((exn = exsindex[exstate]) && (exn += exchar) >= 0 &&
870
exn <= EXTABLESIZE && excheck[exn] == exchar)
871
{
872
#if EXDEBUG
873
if (exdebug)
874
printf("%sdebug: state %d, shifting to state %d\n",
875
EXPREFIX, exstate, extable[exn]);
876
#endif
877
if (exssp >= exsslim && exgrowstack())
878
{
879
goto exoverflow;
880
}
881
*++exssp = exstate = extable[exn];
882
*++exvsp = exlval;
883
exchar = EXEMPTY;
884
if (exerrflag > 0) --exerrflag;
885
goto exloop;
886
}
887
if ((exn = exrindex[exstate]) && (exn += exchar) >= 0 &&
888
exn <= EXTABLESIZE && excheck[exn] == exchar)
889
{
890
exn = extable[exn];
891
goto exreduce;
892
}
893
if (exerrflag) goto exinrecovery;
894
895
exerror("syntax error");
896
897
#ifdef lint
898
goto exerrlab;
899
#endif
900
901
exerrlab:
902
++exnerrs;
903
904
exinrecovery:
905
if (exerrflag < 3)
906
{
907
exerrflag = 3;
908
for (;;)
909
{
910
if ((exn = exsindex[*exssp]) && (exn += EXERRCODE) >= 0 &&
911
exn <= EXTABLESIZE && excheck[exn] == EXERRCODE)
912
{
913
#if EXDEBUG
914
if (exdebug)
915
printf("%sdebug: state %d, error recovery shifting\
916
to state %d\n", EXPREFIX, *exssp, extable[exn]);
917
#endif
918
if (exssp >= exsslim && exgrowstack())
919
{
920
goto exoverflow;
921
}
922
*++exssp = exstate = extable[exn];
923
*++exvsp = exlval;
924
goto exloop;
925
}
926
else
927
{
928
#if EXDEBUG
929
if (exdebug)
930
printf("%sdebug: error recovery discarding state %d\n",
931
EXPREFIX, *exssp);
932
#endif
933
if (exssp <= exss) goto exabort;
934
--exssp;
935
--exvsp;
936
}
937
}
938
}
939
else
940
{
941
if (exchar == 0) goto exabort;
942
#if EXDEBUG
943
if (exdebug)
944
{
945
exs = 0;
946
if (exchar <= EXMAXTOKEN) exs = exname[exchar];
947
if (!exs) exs = "illegal-symbol";
948
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
949
EXPREFIX, exstate, exchar, exs);
950
}
951
#endif
952
exchar = EXEMPTY;
953
goto exloop;
954
}
955
956
exreduce:
957
#if EXDEBUG
958
if (exdebug)
959
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
960
EXPREFIX, exstate, exn, exrule[exn]);
961
#endif
962
exm = exlen[exn];
963
if (exm)
964
exval = exvsp[1-exm];
965
else
966
memset(&exval, 0, sizeof exval);
967
switch (exn)
968
{
969
case 1:
970
/* #line 137 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
971
{
972
if (exvsp[-1].expr && !(expr.program->disc->flags & EX_STRICT))
973
{
974
if (expr.program->main.value && !(expr.program->disc->flags & EX_RETAIN))
975
exfreenode(expr.program, expr.program->main.value);
976
if (exvsp[-1].expr->op == S2B)
977
{
978
Exnode_t* x;
979
980
x = exvsp[-1].expr;
981
exvsp[-1].expr = x->data.operand.left;
982
x->data.operand.left = 0;
983
exfreenode(expr.program, x);
984
}
985
expr.program->main.lex = PROCEDURE;
986
expr.program->main.value = exnewnode(expr.program, PROCEDURE, 1, exvsp[-1].expr->type, NiL, exvsp[-1].expr);
987
}
988
}
989
break;
990
case 4:
991
/* #line 161 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
992
{
993
register Dtdisc_t* disc;
994
995
if (expr.procedure)
996
exerror("no nested function definitions");
997
exvsp[-1].id->lex = PROCEDURE;
998
expr.procedure = exvsp[-1].id->value = exnewnode(expr.program, PROCEDURE, 1, exvsp[-1].id->type, NiL, NiL);
999
expr.procedure->type = INTEGER;
1000
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
1001
exnospace();
1002
disc->key = offsetof(Exid_t, name);
1003
if (expr.assigned && !streq(exvsp[-1].id->name, "begin"))
1004
{
1005
if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
1006
exnospace();
1007
expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
1008
}
1009
}
1010
break;
1011
case 5:
1012
/* #line 179 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1013
{
1014
expr.procedure = 0;
1015
if (expr.program->frame)
1016
{
1017
expr.program->symbols = expr.program->frame->view;
1018
dtview(expr.program->frame, NiL);
1019
expr.program->frame = 0;
1020
}
1021
if (exvsp[0].expr && exvsp[0].expr->op == S2B)
1022
{
1023
Exnode_t* x;
1024
1025
x = exvsp[0].expr;
1026
exvsp[0].expr = x->data.operand.left;
1027
x->data.operand.left = 0;
1028
exfreenode(expr.program, x);
1029
}
1030
exvsp[-3].id->value->data.operand.right = excast(expr.program, exvsp[0].expr, exvsp[-3].id->type, NiL, 0);
1031
}
1032
break;
1033
case 6:
1034
/* #line 201 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1035
{
1036
exval.expr = 0;
1037
}
1038
break;
1039
case 7:
1040
/* #line 205 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1041
{
1042
if (!exvsp[-1].expr)
1043
exval.expr = exvsp[0].expr;
1044
else if (!exvsp[0].expr)
1045
exval.expr = exvsp[-1].expr;
1046
else if (exvsp[-1].expr->op == CONSTANT)
1047
{
1048
exfreenode(expr.program, exvsp[-1].expr);
1049
exval.expr = exvsp[0].expr;
1050
}
1051
else if (exvsp[-1].expr->op == ';')
1052
{
1053
exval.expr = exvsp[-1].expr;
1054
exvsp[-1].expr->data.operand.last = exvsp[-1].expr->data.operand.last->data.operand.right = exnewnode(expr.program, ';', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
1055
}
1056
else
1057
{
1058
exval.expr = exnewnode(expr.program, ';', 1, exvsp[-1].expr->type, exvsp[-1].expr, NiL);
1059
exval.expr->data.operand.last = exval.expr->data.operand.right = exnewnode(expr.program, ';', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
1060
}
1061
}
1062
break;
1063
case 8:
1064
/* #line 229 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1065
{
1066
exval.expr = exvsp[-1].expr;
1067
}
1068
break;
1069
case 9:
1070
/* #line 233 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1071
{
1072
exval.expr = (exvsp[-1].expr && exvsp[-1].expr->type == STRING) ? exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-1].expr, NiL) : exvsp[-1].expr;
1073
}
1074
break;
1075
case 10:
1076
/* #line 236 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1077
{expr.instatic=exvsp[0].integer;}
1078
break;
1079
case 11:
1080
/* #line 236 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1081
{expr.declare=exvsp[0].id->type;}
1082
break;
1083
case 12:
1084
/* #line 237 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1085
{
1086
exval.expr = exvsp[-1].expr;
1087
expr.declare = 0;
1088
}
1089
break;
1090
case 13:
1091
/* #line 242 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1092
{
1093
if (exvsp[-3].expr->type == STRING)
1094
exvsp[-3].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-3].expr, NiL);
1095
else if (!INTEGRAL(exvsp[-3].expr->type))
1096
exvsp[-3].expr = excast(expr.program, exvsp[-3].expr, INTEGER, NiL, 0);
1097
exval.expr = exnewnode(expr.program, exvsp[-5].id->index, 1, INTEGER, exvsp[-3].expr, exnewnode(expr.program, ':', 1, exvsp[-1].expr ? exvsp[-1].expr->type : 0, exvsp[-1].expr, exvsp[0].expr));
1098
}
1099
break;
1100
case 14:
1101
/* #line 250 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1102
{
1103
exval.expr = exnewnode(expr.program, ITERATE, 0, INTEGER, NiL, NiL);
1104
exval.expr->data.generate.array = exvsp[-2].expr;
1105
if (!exvsp[-2].expr->data.variable.index || exvsp[-2].expr->data.variable.index->op != DYNAMIC)
1106
exerror("simple index variable expected");
1107
exval.expr->data.generate.index = exvsp[-2].expr->data.variable.index->data.variable.symbol;
1108
if (exvsp[-2].expr->op == ID && exval.expr->data.generate.index->type != INTEGER)
1109
exerror("integer index variable expected");
1110
exfreenode(expr.program, exvsp[-2].expr->data.variable.index);
1111
exvsp[-2].expr->data.variable.index = 0;
1112
exval.expr->data.generate.statement = exvsp[0].expr;
1113
}
1114
break;
1115
case 15:
1116
/* #line 263 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1117
{
1118
if (!exvsp[-4].expr)
1119
{
1120
exvsp[-4].expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
1121
exvsp[-4].expr->data.constant.value.integer = 1;
1122
}
1123
else if (exvsp[-4].expr->type == STRING)
1124
exvsp[-4].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-4].expr, NiL);
1125
else if (!INTEGRAL(exvsp[-4].expr->type))
1126
exvsp[-4].expr = excast(expr.program, exvsp[-4].expr, INTEGER, NiL, 0);
1127
exval.expr = exnewnode(expr.program, exvsp[-8].id->index, 1, INTEGER, exvsp[-4].expr, exnewnode(expr.program, ';', 1, 0, exvsp[-2].expr, exvsp[0].expr));
1128
if (exvsp[-6].expr)
1129
exval.expr = exnewnode(expr.program, ';', 1, INTEGER, exvsp[-6].expr, exval.expr);
1130
}
1131
break;
1132
case 16:
1133
/* #line 278 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1134
{
1135
if (exvsp[-2].expr->type == STRING)
1136
exvsp[-2].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-2].expr, NiL);
1137
else if (!INTEGRAL(exvsp[-2].expr->type))
1138
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, INTEGER, NiL, 0);
1139
exval.expr = exnewnode(expr.program, exvsp[-4].id->index, 1, INTEGER, exvsp[-2].expr, exnewnode(expr.program, ';', 1, 0, NiL, exvsp[0].expr));
1140
}
1141
break;
1142
case 17:
1143
/* #line 285 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1144
{expr.declare=exvsp[0].expr->type;}
1145
break;
1146
case 18:
1147
/* #line 286 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1148
{
1149
register Switch_t* sw = expr.swstate;
1150
1151
exval.expr = exnewnode(expr.program, exvsp[-7].id->index, 1, INTEGER, exvsp[-5].expr, exnewnode(expr.program, DEFAULT, 1, 0, sw->defcase, sw->firstcase));
1152
expr.swstate = expr.swstate->prev;
1153
if (sw->base)
1154
free(sw->base);
1155
if (sw != &swstate)
1156
free(sw);
1157
expr.declare = 0;
1158
}
1159
break;
1160
case 19:
1161
/* #line 298 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1162
{
1163
loopop:
1164
if (!exvsp[-1].expr)
1165
{
1166
exvsp[-1].expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
1167
exvsp[-1].expr->data.constant.value.integer = 1;
1168
}
1169
else if (!INTEGRAL(exvsp[-1].expr->type))
1170
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, INTEGER, NiL, 0);
1171
exval.expr = exnewnode(expr.program, exvsp[-2].id->index, 1, INTEGER, exvsp[-1].expr, NiL);
1172
}
1173
break;
1174
case 20:
1175
/* #line 310 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1176
{
1177
goto loopop;
1178
}
1179
break;
1180
case 21:
1181
/* #line 314 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1182
{
1183
if (exvsp[-1].expr)
1184
{
1185
if (expr.procedure && !expr.procedure->type)
1186
exerror("return in void function");
1187
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, expr.procedure ? expr.procedure->type : INTEGER, NiL, 0);
1188
}
1189
exval.expr = exnewnode(expr.program, RETURN, 1, exvsp[-1].expr ? exvsp[-1].expr->type : 0, exvsp[-1].expr, NiL);
1190
}
1191
break;
1192
case 22:
1193
/* #line 326 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1194
{
1195
register Switch_t* sw;
1196
int n;
1197
1198
if (expr.swstate)
1199
{
1200
if (!(sw = newof(0, Switch_t, 1, 0)))
1201
{
1202
exnospace();
1203
sw = &swstate;
1204
}
1205
sw->prev = expr.swstate;
1206
}
1207
else
1208
sw = &swstate;
1209
expr.swstate = sw;
1210
sw->type = expr.declare;
1211
sw->firstcase = 0;
1212
sw->lastcase = 0;
1213
sw->defcase = 0;
1214
sw->def = 0;
1215
n = 8;
1216
if (!(sw->base = newof(0, Extype_t*, n, 0)))
1217
{
1218
exnospace();
1219
n = 0;
1220
}
1221
sw->cur = sw->base;
1222
sw->last = sw->base + n;
1223
}
1224
break;
1225
case 24:
1226
/* #line 360 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1227
{
1228
register Switch_t* sw = expr.swstate;
1229
int n;
1230
1231
exval.expr = exnewnode(expr.program, CASE, 1, 0, exvsp[0].expr, NiL);
1232
if (sw->cur > sw->base)
1233
{
1234
if (sw->lastcase)
1235
sw->lastcase->data.select.next = exval.expr;
1236
else
1237
sw->firstcase = exval.expr;
1238
sw->lastcase = exval.expr;
1239
n = sw->cur - sw->base;
1240
sw->cur = sw->base;
1241
exval.expr->data.select.constant = (Extype_t**)exalloc(expr.program, (n + 1) * sizeof(Extype_t*));
1242
memcpy(exval.expr->data.select.constant, sw->base, n * sizeof(Extype_t*));
1243
exval.expr->data.select.constant[n] = 0;
1244
}
1245
else
1246
exval.expr->data.select.constant = 0;
1247
if (sw->def)
1248
{
1249
sw->def = 0;
1250
if (sw->defcase)
1251
exerror("duplicate default in switch");
1252
else
1253
sw->defcase = exvsp[0].expr;
1254
}
1255
}
1256
break;
1257
case 27:
1258
/* #line 396 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1259
{
1260
int n;
1261
1262
if (expr.swstate->cur >= expr.swstate->last)
1263
{
1264
n = expr.swstate->cur - expr.swstate->base;
1265
if (!(expr.swstate->base = newof(expr.swstate->base, Extype_t*, 2 * n, 0)))
1266
{
1267
exerror("too many case labels for switch");
1268
n = 0;
1269
}
1270
expr.swstate->cur = expr.swstate->base + n;
1271
expr.swstate->last = expr.swstate->base + 2 * n;
1272
}
1273
if (expr.swstate->cur)
1274
{
1275
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, expr.swstate->type, NiL, 0);
1276
*expr.swstate->cur++ = &(exvsp[-1].expr->data.constant.value);
1277
}
1278
}
1279
break;
1280
case 28:
1281
/* #line 417 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1282
{
1283
expr.swstate->def = 1;
1284
}
1285
break;
1286
case 29:
1287
/* #line 423 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1288
{
1289
exval.integer = 0;
1290
}
1291
break;
1292
case 30:
1293
/* #line 427 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1294
{
1295
exval.integer = 1;
1296
}
1297
break;
1298
case 32:
1299
/* #line 434 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1300
{
1301
if (exvsp[0].expr)
1302
exval.expr = exvsp[-2].expr ? exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[-2].expr, exvsp[0].expr) : exvsp[0].expr;
1303
}
1304
break;
1305
case 33:
1306
/* #line 440 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1307
{expr.id=exvsp[0].id;}
1308
break;
1309
case 34:
1310
/* #line 441 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1311
{
1312
exval.expr = 0;
1313
if (!exvsp[-3].id->type || expr.declare)
1314
exvsp[-3].id->type = expr.declare;
1315
if (exvsp[-4].reference)
1316
{
1317
exvsp[-3].id->index = MEMBER;
1318
if (!expr.program->disc->getf || !expr.program->symbols)
1319
exerror("%s: member references not supported", exvsp[-4].reference);
1320
else if (exvsp[0].expr)
1321
exerror("%s: member references cannot be initialized", exvsp[-3].id);
1322
else if (expr.program->disc->reff)
1323
(*expr.program->disc->reff)(expr.program, exval.expr, exvsp[-3].id, exvsp[-4].reference, NiL, EX_SCALAR, expr.program->disc);
1324
}
1325
else if (exvsp[0].expr && exvsp[0].expr->op == PROCEDURE)
1326
{
1327
exvsp[-3].id->lex = PROCEDURE;
1328
exvsp[-3].id->value = exvsp[0].expr;
1329
}
1330
else
1331
{
1332
exvsp[-3].id->lex = DYNAMIC;
1333
exvsp[-3].id->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
1334
if (exvsp[-1].integer && !exvsp[-3].id->local.pointer)
1335
{
1336
Dtdisc_t* disc;
1337
1338
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
1339
exnospace();
1340
disc->key = offsetof(Exassoc_t, name);
1341
if (!(exvsp[-3].id->local.pointer = (char*)dtopen(disc, Dtoset)))
1342
exerror("%s: cannot initialize associative array", exvsp[-3].id->name);
1343
}
1344
if (exvsp[0].expr)
1345
{
1346
if (exvsp[0].expr->type != exvsp[-3].id->type)
1347
{
1348
exvsp[0].expr->type = exvsp[-3].id->type;
1349
exvsp[0].expr->data.operand.right = excast(expr.program, exvsp[0].expr->data.operand.right, exvsp[-3].id->type, NiL, 0);
1350
}
1351
exvsp[0].expr->data.operand.left = exnewnode(expr.program, DYNAMIC, 0, exvsp[-3].id->type, NiL, NiL);
1352
exvsp[0].expr->data.operand.left->data.variable.symbol = exvsp[-3].id;
1353
exval.expr = exvsp[0].expr;
1354
if (!expr.program->frame && !expr.program->errors)
1355
{
1356
expr.assigned++;
1357
exeval(expr.program, exval.expr, NiL);
1358
}
1359
}
1360
else if (!exvsp[-1].integer)
1361
exvsp[-3].id->value->data.value = exzero(exvsp[-3].id->type);
1362
}
1363
}
1364
break;
1365
case 37:
1366
/* #line 501 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1367
{
1368
exval.expr = 0;
1369
}
1370
break;
1371
case 38:
1372
/* #line 505 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1373
{
1374
exval.expr = exvsp[0].expr;
1375
}
1376
break;
1377
case 39:
1378
/* #line 511 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1379
{
1380
exval.expr = 0;
1381
}
1382
break;
1383
case 41:
1384
/* #line 518 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1385
{
1386
exval.expr = exvsp[-1].expr;
1387
}
1388
break;
1389
case 42:
1390
/* #line 522 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1391
{
1392
exval.expr = (exvsp[0].expr->type == exvsp[-2].id->type) ? exvsp[0].expr : excast(expr.program, exvsp[0].expr, exvsp[-2].id->type, NiL, 0);
1393
}
1394
break;
1395
case 43:
1396
/* #line 526 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1397
{
1398
int rel;
1399
1400
relational:
1401
rel = INTEGER;
1402
goto coerce;
1403
binary:
1404
rel = 0;
1405
coerce:
1406
if (!exvsp[-2].expr->type)
1407
{
1408
if (!exvsp[0].expr->type)
1409
exvsp[-2].expr->type = exvsp[0].expr->type = rel ? STRING : INTEGER;
1410
else
1411
exvsp[-2].expr->type = exvsp[0].expr->type;
1412
}
1413
else if (!exvsp[0].expr->type)
1414
exvsp[0].expr->type = exvsp[-2].expr->type;
1415
if (exvsp[-2].expr->type != exvsp[0].expr->type)
1416
{
1417
if (exvsp[-2].expr->type == STRING)
1418
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, exvsp[0].expr->type, exvsp[0].expr, 0);
1419
else if (exvsp[0].expr->type == STRING)
1420
exvsp[0].expr = excast(expr.program, exvsp[0].expr, exvsp[-2].expr->type, exvsp[-2].expr, 0);
1421
else if (exvsp[-2].expr->type == FLOATING)
1422
exvsp[0].expr = excast(expr.program, exvsp[0].expr, FLOATING, exvsp[-2].expr, 0);
1423
else if (exvsp[0].expr->type == FLOATING)
1424
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, FLOATING, exvsp[0].expr, 0);
1425
}
1426
if (!rel)
1427
rel = (exvsp[-2].expr->type == STRING) ? STRING : ((exvsp[-2].expr->type == UNSIGNED) ? UNSIGNED : exvsp[0].expr->type);
1428
exval.expr = exnewnode(expr.program, exvsp[-1].op, 1, rel, exvsp[-2].expr, exvsp[0].expr);
1429
if (!expr.program->errors && exvsp[-2].expr->op == CONSTANT && exvsp[0].expr->op == CONSTANT)
1430
{
1431
exval.expr->data.constant.value = exeval(expr.program, exval.expr, NiL);
1432
exval.expr->binary = 0;
1433
exval.expr->op = CONSTANT;
1434
exfreenode(expr.program, exvsp[-2].expr);
1435
exfreenode(expr.program, exvsp[0].expr);
1436
}
1437
}
1438
break;
1439
case 44:
1440
/* #line 568 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1441
{
1442
goto binary;
1443
}
1444
break;
1445
case 45:
1446
/* #line 572 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1447
{
1448
goto binary;
1449
}
1450
break;
1451
case 46:
1452
/* #line 576 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1453
{
1454
goto binary;
1455
}
1456
break;
1457
case 47:
1458
/* #line 580 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1459
{
1460
goto binary;
1461
}
1462
break;
1463
case 48:
1464
/* #line 584 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1465
{
1466
goto binary;
1467
}
1468
break;
1469
case 49:
1470
/* #line 588 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1471
{
1472
goto binary;
1473
}
1474
break;
1475
case 50:
1476
/* #line 592 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1477
{
1478
goto relational;
1479
}
1480
break;
1481
case 51:
1482
/* #line 596 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1483
{
1484
goto relational;
1485
}
1486
break;
1487
case 52:
1488
/* #line 600 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1489
{
1490
goto relational;
1491
}
1492
break;
1493
case 53:
1494
/* #line 604 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1495
{
1496
goto relational;
1497
}
1498
break;
1499
case 54:
1500
/* #line 608 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1501
{
1502
goto relational;
1503
}
1504
break;
1505
case 55:
1506
/* #line 612 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1507
{
1508
goto binary;
1509
}
1510
break;
1511
case 56:
1512
/* #line 616 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1513
{
1514
goto binary;
1515
}
1516
break;
1517
case 57:
1518
/* #line 620 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1519
{
1520
goto binary;
1521
}
1522
break;
1523
case 58:
1524
/* #line 624 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1525
{
1526
goto binary;
1527
}
1528
break;
1529
case 59:
1530
/* #line 628 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1531
{
1532
logical:
1533
if (exvsp[-2].expr->type == STRING)
1534
exvsp[-2].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-2].expr, NiL);
1535
if (exvsp[0].expr->type == STRING)
1536
exvsp[0].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[0].expr, NiL);
1537
goto binary;
1538
}
1539
break;
1540
case 60:
1541
/* #line 637 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1542
{
1543
goto logical;
1544
}
1545
break;
1546
case 61:
1547
/* #line 641 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1548
{
1549
if (exvsp[-2].expr->op == CONSTANT)
1550
{
1551
exfreenode(expr.program, exvsp[-2].expr);
1552
exval.expr = exvsp[0].expr;
1553
}
1554
else
1555
exval.expr = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[-2].expr, exvsp[0].expr);
1556
}
1557
break;
1558
case 62:
1559
/* #line 650 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1560
{expr.nolabel=1;}
1561
break;
1562
case 63:
1563
/* #line 650 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1564
{expr.nolabel=0;}
1565
break;
1566
case 64:
1567
/* #line 651 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1568
{
1569
if (!exvsp[-3].expr->type)
1570
{
1571
if (!exvsp[0].expr->type)
1572
exvsp[-3].expr->type = exvsp[0].expr->type = INTEGER;
1573
else
1574
exvsp[-3].expr->type = exvsp[0].expr->type;
1575
}
1576
else if (!exvsp[0].expr->type)
1577
exvsp[0].expr->type = exvsp[-3].expr->type;
1578
if (exvsp[-6].expr->type == STRING)
1579
exvsp[-6].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-6].expr, NiL);
1580
else if (!INTEGRAL(exvsp[-6].expr->type))
1581
exvsp[-6].expr = excast(expr.program, exvsp[-6].expr, INTEGER, NiL, 0);
1582
if (exvsp[-3].expr->type != exvsp[0].expr->type)
1583
{
1584
if (exvsp[-3].expr->type == STRING || exvsp[0].expr->type == STRING)
1585
exerror("if statement string type mismatch");
1586
else if (exvsp[-3].expr->type == FLOATING)
1587
exvsp[0].expr = excast(expr.program, exvsp[0].expr, FLOATING, NiL, 0);
1588
else if (exvsp[0].expr->type == FLOATING)
1589
exvsp[-3].expr = excast(expr.program, exvsp[-3].expr, FLOATING, NiL, 0);
1590
}
1591
if (exvsp[-6].expr->op == CONSTANT)
1592
{
1593
if (exvsp[-6].expr->data.constant.value.integer)
1594
{
1595
exval.expr = exvsp[-3].expr;
1596
exfreenode(expr.program, exvsp[0].expr);
1597
}
1598
else
1599
{
1600
exval.expr = exvsp[0].expr;
1601
exfreenode(expr.program, exvsp[-3].expr);
1602
}
1603
exfreenode(expr.program, exvsp[-6].expr);
1604
}
1605
else
1606
exval.expr = exnewnode(expr.program, '?', 1, exvsp[-3].expr->type, exvsp[-6].expr, exnewnode(expr.program, ':', 1, exvsp[-3].expr->type, exvsp[-3].expr, exvsp[0].expr));
1607
}
1608
break;
1609
case 65:
1610
/* #line 692 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1611
{
1612
iunary:
1613
if (exvsp[0].expr->type == STRING)
1614
exvsp[0].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[0].expr, NiL);
1615
else if (!INTEGRAL(exvsp[0].expr->type))
1616
exvsp[0].expr = excast(expr.program, exvsp[0].expr, INTEGER, NiL, 0);
1617
unary:
1618
exval.expr = exnewnode(expr.program, exvsp[-1].op, 1, exvsp[0].expr->type == UNSIGNED ? INTEGER : exvsp[0].expr->type, exvsp[0].expr, NiL);
1619
if (exvsp[0].expr->op == CONSTANT)
1620
{
1621
exval.expr->data.constant.value = exeval(expr.program, exval.expr, NiL);
1622
exval.expr->binary = 0;
1623
exval.expr->op = CONSTANT;
1624
exfreenode(expr.program, exvsp[0].expr);
1625
}
1626
}
1627
break;
1628
case 66:
1629
/* #line 709 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1630
{
1631
goto iunary;
1632
}
1633
break;
1634
case 67:
1635
/* #line 713 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1636
{
1637
goto unary;
1638
}
1639
break;
1640
case 68:
1641
/* #line 717 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1642
{
1643
exval.expr = exvsp[0].expr;
1644
}
1645
break;
1646
case 69:
1647
/* #line 721 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1648
{
1649
exval.expr = exnewnode(expr.program, ADDRESS, 0, T(exvsp[0].expr->type), exvsp[0].expr, NiL);
1650
}
1651
break;
1652
case 70:
1653
/* #line 725 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1654
{
1655
exval.expr = exnewnode(expr.program, FUNCTION, 1, T(exvsp[-3].id->type), call(exvsp[-4].reference, exvsp[-3].id, exvsp[-1].expr), exvsp[-1].expr);
1656
if (!expr.program->disc->getf)
1657
exerror("%s: function references not supported", exval.expr->data.operand.left->data.variable.symbol->name);
1658
else if (expr.program->disc->reff)
1659
(*expr.program->disc->reff)(expr.program, exval.expr->data.operand.left, exval.expr->data.operand.left->data.variable.symbol, exvsp[-4].reference, NiL, EX_CALL, expr.program->disc);
1660
}
1661
break;
1662
case 71:
1663
/* #line 733 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1664
{
1665
if (!INTEGRAL(exvsp[-1].expr->type))
1666
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, INTEGER, NiL, 0);
1667
exval.expr = exnewnode(expr.program, EXIT, 1, INTEGER, exvsp[-1].expr, NiL);
1668
}
1669
break;
1670
case 72:
1671
/* #line 739 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1672
{
1673
exval.expr = exnewnode(expr.program, CALL, 1, exvsp[-3].id->type, NiL, exvsp[-1].expr);
1674
exval.expr->data.call.procedure = exvsp[-3].id;
1675
}
1676
break;
1677
case 73:
1678
/* #line 744 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1679
{
1680
exval.expr = exnewnode(expr.program, exvsp[-3].id->index, 0, exvsp[-3].id->type, NiL, NiL);
1681
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == INTEGER)
1682
{
1683
exval.expr->data.print.descriptor = exvsp[-1].expr->data.operand.left;
1684
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
1685
}
1686
else
1687
switch (exvsp[-3].id->index)
1688
{
1689
case QUERY:
1690
exval.expr->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
1691
exval.expr->data.print.descriptor->data.constant.value.integer = 2;
1692
break;
1693
case PRINTF:
1694
exval.expr->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
1695
exval.expr->data.print.descriptor->data.constant.value.integer = 1;
1696
break;
1697
case SPRINTF:
1698
exval.expr->data.print.descriptor = 0;
1699
break;
1700
}
1701
exval.expr->data.print.args = preprint(exvsp[-1].expr);
1702
}
1703
break;
1704
case 74:
1705
/* #line 769 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1706
{
1707
register Exnode_t* x;
1708
1709
exval.expr = exnewnode(expr.program, exvsp[-3].id->index, 0, exvsp[-3].id->type, NiL, NiL);
1710
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == INTEGER)
1711
{
1712
exval.expr->data.scan.descriptor = exvsp[-1].expr->data.operand.left;
1713
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
1714
}
1715
else
1716
switch (exvsp[-3].id->index)
1717
{
1718
case SCANF:
1719
exval.expr->data.scan.descriptor = 0;
1720
break;
1721
case SSCANF:
1722
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == STRING)
1723
{
1724
exval.expr->data.scan.descriptor = exvsp[-1].expr->data.operand.left;
1725
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
1726
}
1727
else
1728
exerror("%s: string argument expected", exvsp[-3].id->name);
1729
break;
1730
}
1731
if (!exvsp[-1].expr || !exvsp[-1].expr->data.operand.left || exvsp[-1].expr->data.operand.left->type != STRING)
1732
exerror("%s: format argument expected", exvsp[-3].id->name);
1733
exval.expr->data.scan.format = exvsp[-1].expr->data.operand.left;
1734
for (x = exval.expr->data.scan.args = exvsp[-1].expr->data.operand.right; x; x = x->data.operand.right)
1735
{
1736
if (x->data.operand.left->op != ADDRESS)
1737
exerror("%s: address argument expected", exvsp[-3].id->name);
1738
x->data.operand.left = x->data.operand.left->data.operand.left;
1739
}
1740
}
1741
break;
1742
case 75:
1743
/* #line 805 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1744
{
1745
exval.expr = exnewnode(expr.program, CONSTANT, 0, exvsp[0].id->type, NiL, NiL);
1746
if (!expr.program->disc->reff)
1747
exerror("%s: qualified identifier references not supported", exvsp[0].id->name);
1748
else
1749
{
1750
exval.expr->data.constant.value = (*expr.program->disc->reff)(expr.program, exval.expr, exvsp[0].id, NiL, exvsp[-2].string, EX_SCALAR, expr.program->disc);
1751
exval.expr->data.constant.reference = exvsp[0].id;
1752
}
1753
}
1754
break;
1755
case 76:
1756
/* #line 816 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1757
{
1758
if (exvsp[0].expr)
1759
{
1760
if (exvsp[-1].expr->op == ID && !expr.program->disc->setf)
1761
exerror("%s: variable assignment not supported", exvsp[-1].expr->data.variable.symbol->name);
1762
else
1763
{
1764
if (!exvsp[-1].expr->type)
1765
exvsp[-1].expr->type = exvsp[0].expr->type;
1766
#if 0
1767
else if (exvsp[0].expr->type != exvsp[-1].expr->type && exvsp[-1].expr->type >= 0200)
1768
#else
1769
else if (exvsp[0].expr->type != exvsp[-1].expr->type)
1770
#endif
1771
{
1772
exvsp[0].expr->type = exvsp[-1].expr->type;
1773
exvsp[0].expr->data.operand.right = excast(expr.program, exvsp[0].expr->data.operand.right, exvsp[-1].expr->type, NiL, 0);
1774
}
1775
exvsp[0].expr->data.operand.left = exvsp[-1].expr;
1776
exval.expr = exvsp[0].expr;
1777
}
1778
}
1779
}
1780
break;
1781
case 77:
1782
/* #line 840 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1783
{
1784
pre:
1785
if (exvsp[0].expr->type == STRING)
1786
exerror("++ and -- invalid for string variables");
1787
exval.expr = exnewnode(expr.program, exvsp[-1].op, 0, exvsp[0].expr->type, exvsp[0].expr, NiL);
1788
exval.expr->subop = PRE;
1789
}
1790
break;
1791
case 78:
1792
/* #line 848 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1793
{
1794
pos:
1795
if (exvsp[-1].expr->type == STRING)
1796
exerror("++ and -- invalid for string variables");
1797
exval.expr = exnewnode(expr.program, exvsp[0].op, 0, exvsp[-1].expr->type, exvsp[-1].expr, NiL);
1798
exval.expr->subop = POS;
1799
}
1800
break;
1801
case 79:
1802
/* #line 856 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1803
{
1804
goto pre;
1805
}
1806
break;
1807
case 80:
1808
/* #line 860 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1809
{
1810
goto pos;
1811
}
1812
break;
1813
case 82:
1814
/* #line 867 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1815
{
1816
exval.expr = exnewnode(expr.program, CONSTANT, 0, exvsp[0].id->type, NiL, NiL);
1817
if (!expr.program->disc->reff)
1818
exerror("%s: identifier references not supported", exvsp[0].id->name);
1819
else
1820
exval.expr->data.constant.value = (*expr.program->disc->reff)(expr.program, exval.expr, exvsp[0].id, NiL, NiL, EX_SCALAR, expr.program->disc);
1821
}
1822
break;
1823
case 83:
1824
/* #line 875 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1825
{
1826
exval.expr = exnewnode(expr.program, CONSTANT, 0, FLOATING, NiL, NiL);
1827
exval.expr->data.constant.value.floating = exvsp[0].floating;
1828
}
1829
break;
1830
case 84:
1831
/* #line 880 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1832
{
1833
exval.expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
1834
exval.expr->data.constant.value.integer = exvsp[0].integer;
1835
}
1836
break;
1837
case 85:
1838
/* #line 885 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1839
{
1840
exval.expr = exnewnode(expr.program, CONSTANT, 0, STRING, NiL, NiL);
1841
exval.expr->data.constant.value.string = exvsp[0].string;
1842
}
1843
break;
1844
case 86:
1845
/* #line 890 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1846
{
1847
exval.expr = exnewnode(expr.program, CONSTANT, 0, UNSIGNED, NiL, NiL);
1848
exval.expr->data.constant.value.integer = exvsp[0].integer;
1849
}
1850
break;
1851
case 92:
1852
/* #line 906 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1853
{
1854
exval.expr = exnewnode(expr.program, ID, 0, exvsp[-1].id->type, NiL, NiL);
1855
exval.expr->data.variable.symbol = QUALIFY(exvsp[-2].reference, exvsp[-1].id);
1856
exval.expr->data.variable.reference = exvsp[-2].reference;
1857
if (exvsp[0].expr && !INTEGRAL(exvsp[0].expr->type))
1858
exvsp[0].expr = excast(expr.program, exvsp[0].expr, INTEGER, NiL, 0);
1859
exval.expr->data.variable.index = exvsp[0].expr;
1860
if (!expr.program->disc->getf)
1861
exerror("%s: identifier references not supported", exvsp[-1].id->name);
1862
else if (expr.program->disc->reff)
1863
(*expr.program->disc->reff)(expr.program, exval.expr, exval.expr->data.variable.symbol, exvsp[-2].reference, NiL, exvsp[0].expr ? 0 : EX_SCALAR, expr.program->disc);
1864
exval.expr->type = exval.expr->data.variable.symbol->type;
1865
}
1866
break;
1867
case 93:
1868
/* #line 920 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1869
{
1870
exval.expr = exnewnode(expr.program, DYNAMIC, 0, exvsp[-1].id->type, NiL, NiL);
1871
exval.expr->data.variable.symbol = exvsp[-1].id;
1872
exval.expr->data.variable.reference = 0;
1873
if (((exval.expr->data.variable.index = exvsp[0].expr) == 0) != (exvsp[-1].id->local.pointer == 0))
1874
exerror("%s: is%s an array", exvsp[-1].id->name, exvsp[-1].id->local.pointer ? "" : " not");
1875
}
1876
break;
1877
case 94:
1878
/* #line 928 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1879
{
1880
exval.expr = exnewnode(expr.program, ID, 0, 0, NiL, NiL);
1881
exval.expr->data.variable.symbol = exvsp[0].id;
1882
exval.expr->data.variable.reference = 0;
1883
exval.expr->data.variable.index = 0;
1884
if (!(expr.program->disc->flags & EX_UNDECLARED))
1885
exerror("unknown identifier");
1886
}
1887
break;
1888
case 95:
1889
/* #line 939 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1890
{
1891
exval.integer = 0;
1892
}
1893
break;
1894
case 96:
1895
/* #line 943 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1896
{
1897
exval.integer = 1;
1898
}
1899
break;
1900
case 97:
1901
/* #line 949 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1902
{
1903
exval.expr = 0;
1904
}
1905
break;
1906
case 98:
1907
/* #line 953 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1908
{
1909
exval.expr = exvsp[-1].expr;
1910
}
1911
break;
1912
case 99:
1913
/* #line 959 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1914
{
1915
exval.expr = 0;
1916
}
1917
break;
1918
case 100:
1919
/* #line 963 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1920
{
1921
exval.expr = exvsp[0].expr->data.operand.left;
1922
exvsp[0].expr->data.operand.left = exvsp[0].expr->data.operand.right = 0;
1923
exfreenode(expr.program, exvsp[0].expr);
1924
}
1925
break;
1926
case 101:
1927
/* #line 971 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1928
{
1929
exval.expr = exnewnode(expr.program, ';', 1, 0, exnewnode(expr.program, ';', 1, exvsp[0].expr->type, exvsp[0].expr, NiL), NiL);
1930
exval.expr->data.operand.right = exval.expr->data.operand.left;
1931
}
1932
break;
1933
case 102:
1934
/* #line 976 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1935
{
1936
exvsp[-2].expr->data.operand.right = exvsp[-2].expr->data.operand.right->data.operand.right = exnewnode(expr.program, ',', 1, exvsp[-2].expr->type, exvsp[0].expr, NiL);
1937
}
1938
break;
1939
case 103:
1940
/* #line 982 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1941
{
1942
exval.expr = 0;
1943
}
1944
break;
1945
case 104:
1946
/* #line 986 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1947
{
1948
exval.expr = 0;
1949
if (exvsp[0].id->type)
1950
exerror("(void) expected");
1951
}
1952
break;
1953
case 106:
1954
/* #line 995 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1955
{
1956
exval.expr = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
1957
}
1958
break;
1959
case 107:
1960
/* #line 999 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1961
{
1962
register Exnode_t* x;
1963
register Exnode_t* y;
1964
1965
exval.expr = exvsp[-2].expr;
1966
for (x = exvsp[-2].expr; y = x->data.operand.right; x = y);
1967
x->data.operand.right = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
1968
}
1969
break;
1970
case 108:
1971
/* #line 1009 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1972
{expr.declare=exvsp[0].id->type;}
1973
break;
1974
case 109:
1975
/* #line 1010 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1976
{
1977
exval.expr = exnewnode(expr.program, ID, 0, exvsp[0].id->type, NiL, NiL);
1978
exval.expr->data.variable.symbol = exvsp[0].id;
1979
exvsp[0].id->lex = DYNAMIC;
1980
exvsp[0].id->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
1981
expr.procedure->data.procedure.arity++;
1982
expr.declare = 0;
1983
}
1984
break;
1985
case 110:
1986
/* #line 1021 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1987
{
1988
exval.reference = expr.refs = expr.lastref = 0;
1989
}
1990
break;
1991
case 111:
1992
/* #line 1025 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
1993
{
1994
Exref_t* r;
1995
1996
r = ALLOCATE(expr.program, Exref_t);
1997
if (expr.lastref)
1998
{
1999
r->symbol = QUALIFY(expr.lastref, exvsp[-2].id);
2000
expr.lastref->next = r;
2001
}
2002
else
2003
{
2004
r->symbol = exvsp[-2].id;
2005
expr.refs = r;
2006
}
2007
expr.lastref = r;
2008
r->next = 0;
2009
r->index = exvsp[-1].expr;
2010
exval.reference = expr.refs;
2011
}
2012
break;
2013
case 112:
2014
/* #line 1047 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
2015
{
2016
exval.expr = 0;
2017
}
2018
break;
2019
case 113:
2020
/* #line 1051 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
2021
{
2022
exval.expr = exnewnode(expr.program, '=', 1, exvsp[0].expr->type, NiL, exvsp[0].expr);
2023
exval.expr->subop = exvsp[-1].op;
2024
}
2025
break;
2026
case 115:
2027
/* #line 1058 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
2028
{
2029
register Dtdisc_t* disc;
2030
2031
if (expr.procedure)
2032
exerror("%s: nested function definitions not supported", expr.id->name);
2033
expr.procedure = exnewnode(expr.program, PROCEDURE, 1, expr.declare, NiL, NiL);
2034
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
2035
exnospace();
2036
disc->key = offsetof(Exid_t, name);
2037
if (!streq(expr.id->name, "begin"))
2038
{
2039
if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
2040
exnospace();
2041
expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
2042
expr.program->formals = 1;
2043
}
2044
expr.declare = 0;
2045
}
2046
break;
2047
case 116:
2048
/* #line 1075 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
2049
{
2050
expr.id->lex = PROCEDURE;
2051
expr.id->type = expr.procedure->type;
2052
expr.program->formals = 0;
2053
expr.declare = 0;
2054
}
2055
break;
2056
case 117:
2057
/* #line 1081 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
2058
{
2059
exval.expr = expr.procedure;
2060
expr.procedure = 0;
2061
if (expr.program->frame)
2062
{
2063
expr.program->symbols = expr.program->frame->view;
2064
dtview(expr.program->frame, NiL);
2065
expr.program->frame = 0;
2066
}
2067
exval.expr->data.operand.left = exvsp[-5].expr;
2068
exval.expr->data.operand.right = excast(expr.program, exvsp[-1].expr, exval.expr->type, NiL, 0);
2069
2070
/*
2071
* NOTE: procedure definition was slipped into the
2072
* declaration initializer statement production,
2073
* therefore requiring the statement terminator
2074
*/
2075
2076
exunlex(expr.program, ';');
2077
}
2078
break;
2079
/* #line 2059 "y.tab.c" */
2080
}
2081
exssp -= exm;
2082
exstate = *exssp;
2083
exvsp -= exm;
2084
exm = exlhs[exn];
2085
if (exstate == 0 && exm == 0)
2086
{
2087
#if EXDEBUG
2088
if (exdebug)
2089
printf("%sdebug: after reduction, shifting from state 0 to\
2090
state %d\n", EXPREFIX, EXFINAL);
2091
#endif
2092
exstate = EXFINAL;
2093
*++exssp = EXFINAL;
2094
*++exvsp = exval;
2095
if (exchar < 0)
2096
{
2097
if ((exchar = exlex()) < 0) exchar = 0;
2098
#if EXDEBUG
2099
if (exdebug)
2100
{
2101
exs = 0;
2102
if (exchar <= EXMAXTOKEN) exs = exname[exchar];
2103
if (!exs) exs = "illegal-symbol";
2104
printf("%sdebug: state %d, reading %d (%s)\n",
2105
EXPREFIX, EXFINAL, exchar, exs);
2106
}
2107
#endif
2108
}
2109
if (exchar == 0) goto exaccept;
2110
goto exloop;
2111
}
2112
if ((exn = exgindex[exm]) && (exn += exstate) >= 0 &&
2113
exn <= EXTABLESIZE && excheck[exn] == exstate)
2114
exstate = extable[exn];
2115
else
2116
exstate = exdgoto[exm];
2117
#if EXDEBUG
2118
if (exdebug)
2119
printf("%sdebug: after reduction, shifting from state %d \
2120
to state %d\n", EXPREFIX, *exssp, exstate);
2121
#endif
2122
if (exssp >= exsslim && exgrowstack())
2123
{
2124
goto exoverflow;
2125
}
2126
*++exssp = exstate;
2127
*++exvsp = exval;
2128
goto exloop;
2129
2130
exoverflow:
2131
exerror("yacc stack overflow");
2132
2133
exabort:
2134
return (1);
2135
2136
exaccept:
2137
return (0);
2138
}
2139
2140