/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* http://www.eclipse.org/org/documents/epl-v10.html *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
/* : : generated by a yacc that works -- solaris take note : : */
#include "ast.h"
#ifndef lint
static const char exsccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#include <stdlib.h>
#include <string.h>
#define EXBYACC 1
#define EXMAJOR 1
#define EXMINOR 9
#define EXPATCH 20070509
#define EXEMPTY (-1)
#define exclearin (exchar = EXEMPTY)
#define exerrok (exerrflag = 0)
#define EXRECOVERING (exerrflag != 0)
extern int exparse(void);
static int exgrowstack(void);
#define EXPREFIX "ex"
/* #line 2 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
/*
* Glenn Fowler
* AT&T Research
*
* expression library grammar and compiler
*/
#include <ast.h>
#undef RS /* hp.pa <signal.h> grabs this!! */
/* #line 16 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
typedef union
{
struct Exnode_s*expr;
double floating;
struct Exref_s* reference;
struct Exid_s* id;
Sflong_t integer;
int op;
char* string;
struct Exbuf_s* buffer;
} EXSTYPE;
/* #line 129 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
#include "exgram.h"
/* #line 52 "y.tab.c" */
#define MINTOKEN 257
#define CHAR 258
#define INT 259
#define INTEGER 260
#define UNSIGNED 261
#define FLOATING 262
#define STRING 263
#define VOID 264
#define STATIC 265
#define ADDRESS 266
#define BREAK 267
#define CALL 268
#define CASE 269
#define CONSTANT 270
#define CONTINUE 271
#define DECLARE 272
#define DEFAULT 273
#define DYNAMIC 274
#define ELSE 275
#define EXIT 276
#define FOR 277
#define FUNCTION 278
#define ITERATE 279
#define ID 280
#define IF 281
#define LABEL 282
#define MEMBER 283
#define NAME 284
#define POS 285
#define PRAGMA 286
#define PRE 287
#define PRINTF 288
#define PROCEDURE 289
#define QUERY 290
#define RETURN 291
#define SCANF 292
#define SPRINTF 293
#define SSCANF 294
#define SWITCH 295
#define WHILE 296
#define F2I 297
#define F2S 298
#define I2F 299
#define I2S 300
#define S2B 301
#define S2F 302
#define S2I 303
#define F2X 304
#define I2X 305
#define S2X 306
#define X2F 307
#define X2I 308
#define X2S 309
#define OR 310
#define AND 311
#define EQ 312
#define NE 313
#define LE 314
#define GE 315
#define LS 316
#define RS 317
#define UNARY 318
#define INC 319
#define DEC 320
#define CAST 321
#define MAXTOKEN 322
#define EXERRCODE 256
short exlhs[] = { -1,
0, 25, 25, 27, 26, 2, 2, 1, 1, 28,
29, 1, 1, 1, 1, 1, 30, 1, 1, 1,
1, 31, 31, 14, 32, 32, 33, 33, 24, 24,
10, 10, 34, 11, 20, 20, 4, 4, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 35, 36, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 15, 15, 15, 15, 15, 21, 21, 21, 22,
22, 8, 8, 8, 23, 23, 12, 12, 7, 7,
3, 3, 16, 16, 16, 17, 17, 37, 18, 19,
19, 9, 9, 13, 38, 39, 13,
};
short exlen[] = { 2,
2, 0, 2, 0, 4, 0, 2, 3, 2, 0,
0, 6, 6, 5, 9, 5, 0, 8, 3, 3,
3, 0, 2, 2, 1, 2, 3, 2, 0, 1,
1, 3, 0, 5, 1, 1, 0, 2, 0, 1,
3, 4, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 0, 0, 7, 2, 2, 2, 2, 2, 5,
4, 4, 4, 4, 3, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 3, 2, 1, 0, 2, 0, 3, 0, 1,
1, 3, 0, 1, 1, 1, 3, 0, 3, 0,
4, 0, 2, 1, 0, 0, 8,
};
short exdefred[] = { 6,
0, 0, 84, 86, 83, 0, 30, 0, 82, 0,
0, 0, 0, 0, 94, 87, 0, 88, 0, 90,
89, 91, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 6, 7, 0, 0, 0, 81, 0, 0,
0, 10, 0, 0, 0, 0, 0, 93, 0, 0,
0, 0, 0, 0, 0, 69, 0, 68, 67, 65,
66, 77, 79, 0, 0, 0, 9, 0, 62, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 78, 80,
76, 0, 0, 0, 0, 0, 0, 3, 75, 19,
20, 0, 0, 0, 0, 0, 0, 0, 0, 21,
0, 0, 0, 41, 8, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 45, 46, 47, 0, 0, 0, 0, 0,
11, 4, 98, 71, 0, 0, 0, 0, 72, 0,
0, 42, 0, 0, 111, 73, 74, 110, 6, 0,
14, 0, 0, 0, 16, 63, 70, 0, 31, 0,
0, 0, 0, 13, 22, 0, 110, 12, 0, 33,
0, 38, 0, 0, 32, 0, 0, 0, 0, 0,
18, 23, 0, 25, 0, 0, 15, 85, 0, 28,
0, 26, 96, 115, 114, 34, 27, 0, 0, 116,
0, 106, 0, 0, 0, 36, 35, 109, 0, 108,
107, 6, 0, 117,
};
short exdgoto[] = { 1,
34, 2, 107, 174, 35, 36, 109, 37, 91, 168,
169, 48, 206, 192, 38, 210, 211, 212, 39, 218,
40, 41, 196, 42, 43, 98, 159, 96, 158, 150,
183, 193, 194, 187, 117, 176, 213, 208, 214,
};
short exsindex[] = { 0,
0, 181, 0, 0, 0, -24, 0, 376, 0, 376,
-62, -5, 2, 7, 0, 0, 21, 0, 376, 0,
0, 0, 49, 60, -244, 376, 376, 376, 376, -244,
-244, 310, 0, 0, 45, 936, -61, 0, -190, 66,
67, 0, -171, -168, 57, 58, 376, 0, 376, 376,
376, 376, 63, 376, 376, 0, -161, 0, 0, 0,
0, 0, 0, 82, 734, 75, 0, 376, 0, 376,
376, 376, 376, 376, 376, 376, 376, 376, 376, 376,
376, 376, 376, 376, 376, 376, 376, 376, 0, 0,
0, 93, -62, 376, 376, -138, 77, 0, 0, 0,
0, 761, 788, 78, 4, 799, 92, 963, 97, 0,
936, 834, 376, 0, 0, 963, 376, 994, 1095, 111,
1021, 1116, 123, 123, -30, -30, -30, -30, 56, 56,
-19, -19, 0, 0, 0, 963, 376, 95, 106, 118,
0, 0, 0, 0, 376, 181, 181, 376, 0, 121,
181, 0, 871, 126, 0, 0, 0, 0, 0, 110,
0, -103, 963, 64, 0, 0, 0, 15, 0, -214,
181, 376, 181, 0, 0, 376, 0, 0, -62, 0,
133, 0, -87, 963, 0, 95, 88, 181, -131, 130,
0, 0, -189, 0, 91, -29, 0, 0, 131, 0,
181, 0, 0, 0, 0, 0, 0, -91, 0, 0,
147, 0, -207, 151, -78, 0, 0, 0, 73, 0,
0, 0, 112, 0,
};
short exrindex[] = { 0,
0, 140, 0, 0, 0, 639, 0, -51, 0, -51,
472, 0, 0, 0, 0, 0, 0, 0, -51, 0,
0, 0, 0, 0, -83, -184, -184, -184, -184, -83,
-83, -184, 0, 0, 0, -22, 676, 0, 0, 0,
0, 0, 202, 0, 0, 0, -184, 0, -184, -51,
-184, -39, 0, -184, -184, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -55, 0, -184, 0, -184,
-184, -184, -184, -184, -184, -184, -184, -184, -184, -184,
-184, -184, -184, -184, -184, -184, -184, -184, 0, 0,
0, 0, 445, -39, -39, 0, 0, 0, 0, 0,
0, 0, 0, 0, 900, 0, 162, -20, 0, 0,
163, 0, -184, 0, 0, 28, -184, -8, 149, 51,
600, 1398, 1400, 1426, 1257, 1301, 1330, 1341, 1136, 1225,
1162, 1199, 0, 0, 0, 84, -39, 499, 0, 0,
0, 0, 0, 0, -51, -55, -55, -184, 0, 0,
-55, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 61, 0, 0, 0, 0, 0, 0, 0,
339, -35, -55, 0, 0, -184, 0, 0, 160, 0,
0, 0, 0, 172, 0, 0, 14, -55, 0, 0,
0, 0, 38, 0, 0, 20, 0, 0, 0, 0,
626, 0, 0, 0, 0, 0, 0, 169, -38, 0,
170, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, -55, 0,
};
short exgindex[] = { 0,
-120, -13, 0, 0, 6, 1550, -85, 32, 19, 0,
41, -88, 0, 0, 31, 0, 0, 13, 18, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 29, 0, 0, 0, 0, 0, 0,
};
#define EXTABLESIZE 1737
short extable[] = { 88,
37, 99, 104, 39, 138, 39, 87, 39, 139, 140,
204, 85, 83, 45, 84, 46, 86, 87, 40, 66,
101, 44, 85, 101, 53, 161, 162, 86, 47, 11,
165, 88, 60, 37, 49, 60, 40, 191, 37, 15,
37, 50, 57, 37, 146, 37, 51, 57, 57, 60,
60, 154, 182, 95, 60, 104, 56, 95, 177, 37,
52, 62, 63, 112, 88, 179, 216, 197, 61, 180,
6, 61, 95, 178, 95, 6, 217, 6, 112, 189,
6, 105, 6, 190, 60, 61, 61, 92, 54, 93,
186, 56, 87, 110, 56, 110, 6, 85, 83, 55,
84, 102, 86, 67, 102, 94, 95, 28, 56, 56,
97, 99, 25, 56, 32, 100, 101, 26, 93, 27,
61, 110, 113, 37, 113, 37, 37, 113, 3, 4,
5, 198, 137, 141, 142, 148, 145, 149, 9, 2,
155, 113, 113, 56, 28, 171, 156, 87, 74, 25,
160, 32, 85, 83, 26, 84, 27, 86, 157, 87,
6, 164, 6, 6, 85, 83, 167, 84, 172, 86,
77, 173, 78, 188, 56, 170, 113, 181, 195, 201,
209, 189, 77, 203, 78, 190, 175, 200, 207, 59,
215, 219, 59, 220, 170, 222, 110, 33, 39, 115,
29, 1, 100, 17, 73, 97, 59, 59, 223, 103,
105, 59, 64, 28, 205, 64, 29, 185, 25, 199,
32, 202, 110, 26, 110, 27, 110, 221, 110, 64,
64, 0, 0, 0, 33, 108, 224, 29, 110, 0,
110, 59, 110, 0, 110, 108, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 89, 90, 0,
37, 37, 37, 37, 64, 37, 0, 37, 0, 37,
37, 37, 37, 37, 37, 0, 37, 37, 37, 0,
37, 37, 37, 0, 37, 81, 82, 0, 37, 37,
37, 37, 37, 37, 37, 37, 37, 6, 6, 6,
6, 60, 6, 33, 6, 0, 29, 6, 6, 6,
0, 6, 0, 6, 6, 6, 0, 6, 6, 37,
37, 6, 89, 90, 0, 6, 6, 6, 6, 6,
6, 6, 6, 6, 3, 4, 5, 6, 5, 7,
0, 8, 28, 0, 9, 10, 0, 25, 11, 32,
12, 13, 26, 0, 27, 14, 6, 6, 15, 0,
56, 56, 16, 17, 18, 19, 20, 21, 22, 23,
24, 3, 4, 5, 6, 0, 7, 0, 8, 0,
0, 9, 10, 0, 0, 11, 0, 12, 13, 0,
0, 0, 14, 30, 31, 15, 0, 39, 0, 16,
17, 18, 19, 20, 21, 22, 23, 24, 28, 0,
0, 29, 0, 25, 0, 32, 0, 110, 26, 110,
27, 2, 75, 76, 79, 80, 81, 82, 0, 0,
30, 31, 0, 0, 0, 29, 79, 80, 81, 82,
3, 4, 5, 6, 0, 7, 0, 8, 0, 0,
9, 10, 0, 0, 11, 0, 12, 13, 59, 59,
0, 14, 0, 0, 15, 0, 0, 0, 16, 17,
18, 19, 20, 21, 22, 23, 24, 0, 0, 0,
0, 97, 97, 0, 0, 97, 97, 97, 97, 97,
97, 97, 0, 0, 0, 0, 0, 0, 0, 30,
31, 29, 97, 97, 97, 97, 97, 97, 97, 97,
0, 0, 97, 97, 97, 97, 97, 0, 97, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 97,
97, 97, 97, 97, 97, 92, 92, 97, 97, 92,
92, 92, 92, 92, 0, 92, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 92, 92, 92, 92,
92, 92, 0, 0, 97, 97, 0, 0, 97, 3,
4, 5, 6, 0, 0, 0, 0, 0, 0, 9,
0, 64, 0, 11, 0, 12, 0, 0, 0, 0,
0, 92, 92, 15, 0, 97, 0, 16, 17, 18,
0, 20, 21, 22, 0, 0, 0, 0, 0, 0,
29, 0, 0, 0, 0, 0, 110, 0, 110, 0,
5, 0, 92, 0, 0, 0, 0, 0, 30, 31,
0, 0, 0, 0, 0, 3, 4, 5, 6, 0,
57, 0, 0, 57, 0, 9, 0, 0, 0, 11,
0, 12, 0, 0, 0, 0, 0, 57, 57, 15,
0, 0, 57, 16, 17, 18, 0, 20, 21, 22,
0, 0, 0, 0, 0, 85, 85, 0, 0, 85,
85, 85, 85, 85, 39, 85, 0, 0, 0, 0,
0, 0, 57, 57, 30, 31, 85, 85, 85, 0,
85, 85, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 112, 112, 0, 0, 112, 112, 112, 112,
112, 0, 112, 57, 0, 0, 0, 0, 0, 0,
0, 85, 85, 112, 112, 112, 0, 112, 112, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24, 0, 0, 0, 97, 97, 97, 97, 97, 97,
97, 97, 85, 97, 97, 0, 0, 0, 112, 112,
87, 74, 0, 0, 114, 85, 83, 68, 84, 0,
86, 97, 97, 97, 97, 97, 97, 97, 97, 0,
97, 97, 0, 77, 0, 78, 69, 87, 74, 112,
0, 0, 85, 83, 68, 84, 0, 86, 92, 92,
92, 92, 92, 92, 92, 92, 0, 92, 92, 0,
77, 0, 78, 69, 87, 74, 0, 73, 144, 85,
83, 68, 84, 0, 86, 87, 74, 0, 0, 147,
85, 83, 68, 84, 0, 86, 0, 77, 0, 78,
69, 0, 0, 143, 73, 0, 0, 72, 77, 0,
78, 69, 0, 0, 0, 0, 0, 0, 0, 0,
87, 74, 0, 0, 151, 85, 83, 68, 84, 0,
86, 73, 0, 0, 72, 0, 0, 0, 0, 0,
0, 0, 73, 77, 24, 78, 69, 29, 24, 0,
0, 0, 0, 110, 0, 110, 0, 87, 74, 57,
57, 72, 85, 83, 68, 84, 0, 86, 0, 0,
0, 0, 72, 0, 0, 0, 0, 73, 166, 0,
77, 0, 78, 69, 0, 0, 112, 112, 0, 0,
0, 112, 112, 112, 112, 0, 112, 0, 85, 85,
85, 85, 85, 85, 85, 85, 0, 72, 112, 112,
0, 112, 112, 0, 73, 0, 0, 0, 0, 0,
0, 0, 87, 74, 0, 0, 0, 85, 83, 68,
84, 0, 86, 0, 0, 112, 112, 112, 112, 112,
112, 112, 112, 112, 72, 77, 0, 78, 69, 87,
74, 0, 0, 0, 85, 83, 0, 84, 0, 86,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 77, 112, 78, 69, 0, 0, 0, 73,
87, 74, 0, 0, 0, 85, 83, 0, 84, 0,
86, 0, 0, 70, 71, 75, 76, 79, 80, 81,
82, 0, 0, 77, 0, 78, 73, 87, 74, 72,
0, 0, 85, 83, 0, 84, 0, 86, 0, 0,
70, 71, 75, 76, 79, 80, 81, 82, 0, 0,
77, 0, 78, 0, 0, 0, 72, 73, 0, 0,
0, 0, 0, 0, 0, 0, 0, 70, 71, 75,
76, 79, 80, 81, 82, 0, 0, 0, 70, 71,
75, 76, 79, 80, 81, 82, 0, 72, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 87, 74, 0, 0, 0, 85, 83, 0, 84,
0, 86, 0, 70, 71, 75, 76, 79, 80, 81,
82, 0, 87, 0, 77, 0, 78, 85, 83, 0,
84, 0, 86, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 48, 0, 77, 48, 78, 0, 48,
70, 71, 75, 76, 79, 80, 81, 82, 73, 0,
0, 0, 0, 48, 48, 48, 0, 48, 48, 58,
0, 0, 58, 0, 58, 58, 58, 0, 0, 112,
112, 112, 112, 112, 112, 112, 112, 0, 72, 58,
58, 58, 0, 58, 58, 0, 0, 0, 48, 48,
0, 0, 0, 0, 0, 0, 44, 0, 0, 44,
0, 44, 44, 44, 0, 70, 71, 75, 76, 79,
80, 81, 82, 0, 58, 58, 44, 44, 44, 48,
44, 44, 49, 0, 0, 49, 0, 0, 49, 0,
0, 0, 70, 71, 75, 76, 79, 80, 81, 82,
0, 0, 49, 49, 49, 58, 49, 49, 0, 0,
0, 44, 44, 0, 43, 0, 0, 43, 0, 0,
43, 0, 0, 0, 71, 75, 76, 79, 80, 81,
82, 0, 0, 0, 43, 43, 0, 49, 49, 43,
0, 0, 44, 0, 0, 0, 0, 0, 0, 0,
0, 0, 75, 76, 79, 80, 81, 82, 50, 0,
0, 50, 0, 0, 50, 0, 0, 0, 49, 43,
43, 0, 0, 0, 0, 0, 0, 0, 50, 50,
0, 0, 0, 50, 0, 0, 0, 51, 0, 0,
51, 0, 0, 51, 0, 0, 0, 0, 52, 0,
43, 52, 0, 0, 52, 0, 0, 51, 51, 0,
0, 0, 51, 50, 50, 0, 0, 0, 52, 52,
0, 0, 0, 52, 0, 0, 75, 76, 79, 80,
81, 82, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 51, 51, 50, 0, 0, 75, 76, 79,
80, 81, 82, 52, 52, 55, 0, 53, 55, 0,
53, 55, 0, 53, 0, 48, 48, 48, 48, 48,
48, 48, 48, 51, 0, 55, 55, 53, 53, 0,
55, 0, 53, 54, 52, 0, 54, 0, 0, 54,
0, 58, 58, 58, 58, 58, 58, 58, 58, 0,
0, 0, 0, 54, 54, 0, 0, 0, 54, 0,
55, 55, 53, 53, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 44, 44,
44, 44, 44, 44, 44, 44, 0, 0, 54, 54,
0, 55, 0, 53, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 49, 49, 49, 49, 49, 49,
49, 49, 0, 0, 0, 0, 0, 0, 0, 54,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 43, 43, 43, 43,
0, 0, 0, 0, 0, 58, 59, 60, 61, 0,
0, 65, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 102, 0, 103, 0,
106, 108, 0, 111, 112, 0, 0, 0, 0, 0,
50, 50, 50, 50, 0, 0, 0, 116, 0, 118,
119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 136, 0, 51,
51, 51, 51, 108, 108, 0, 0, 0, 0, 0,
52, 52, 52, 52, 0, 0, 0, 0, 0, 0,
0, 0, 152, 0, 0, 0, 153, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 108, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 163, 0, 0,
0, 0, 0, 0, 0, 0, 0, 55, 55, 53,
53, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 184, 0, 0, 0, 0,
0, 0, 0, 0, 0, 54, 54,
};
short excheck[] = { 61,
0, 41, 41, 59, 93, 41, 37, 59, 94, 95,
40, 42, 43, 8, 45, 10, 47, 37, 41, 33,
41, 46, 42, 44, 19, 146, 147, 47, 91, 274,
151, 61, 41, 33, 40, 44, 59, 125, 38, 284,
40, 40, 25, 43, 41, 45, 40, 30, 31, 58,
59, 137, 173, 40, 63, 50, 25, 44, 44, 59,
40, 30, 31, 44, 61, 280, 274, 188, 41, 284,
33, 44, 59, 59, 61, 38, 284, 40, 59, 269,
43, 50, 45, 273, 93, 58, 59, 278, 40, 280,
179, 41, 37, 278, 44, 280, 59, 42, 43, 40,
45, 41, 47, 59, 44, 40, 40, 33, 58, 59,
282, 280, 38, 63, 40, 59, 59, 43, 280, 45,
93, 59, 41, 123, 41, 125, 126, 44, 260, 261,
262, 263, 40, 272, 58, 44, 59, 41, 270, 0,
46, 58, 59, 93, 33, 159, 41, 37, 38, 38,
145, 40, 42, 43, 43, 45, 45, 47, 41, 37,
123, 41, 125, 126, 42, 43, 41, 45, 59, 47,
60, 275, 62, 41, 124, 158, 93, 172, 91, 193,
272, 269, 60, 93, 62, 273, 123, 58, 58, 41,
44, 41, 44, 272, 177, 123, 280, 123, 59, 125,
126, 0, 41, 41, 94, 46, 58, 59, 222, 41,
41, 63, 41, 33, 196, 44, 272, 177, 38, 189,
40, 193, 278, 43, 280, 45, 278, 215, 280, 58,
59, -1, -1, -1, 123, 274, 125, 126, 278, -1,
280, 93, 278, -1, 280, 284, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 319, 320, -1,
260, 261, 262, 263, 93, 265, -1, 267, -1, 269,
270, 271, 272, 273, 274, -1, 276, 277, 278, -1,
280, 281, 282, -1, 284, 316, 317, -1, 288, 289,
290, 291, 292, 293, 294, 295, 296, 260, 261, 262,
263, 310, 265, 123, 267, -1, 126, 270, 271, 272,
-1, 274, -1, 276, 277, 278, -1, 280, 281, 319,
320, 284, 319, 320, -1, 288, 289, 290, 291, 292,
293, 294, 295, 296, 260, 261, 262, 263, 0, 265,
-1, 267, 33, -1, 270, 271, -1, 38, 274, 40,
276, 277, 43, -1, 45, 281, 319, 320, 284, -1,
310, 311, 288, 289, 290, 291, 292, 293, 294, 295,
296, 260, 261, 262, 263, -1, 265, -1, 267, -1,
-1, 270, 271, -1, -1, 274, -1, 276, 277, -1,
-1, -1, 281, 319, 320, 284, -1, 59, -1, 288,
289, 290, 291, 292, 293, 294, 295, 296, 33, -1,
-1, 272, -1, 38, -1, 40, -1, 278, 43, 280,
45, 282, 312, 313, 314, 315, 316, 317, -1, -1,
319, 320, -1, -1, -1, 126, 314, 315, 316, 317,
260, 261, 262, 263, -1, 265, -1, 267, -1, -1,
270, 271, -1, -1, 274, -1, 276, 277, 310, 311,
-1, 281, -1, -1, 284, -1, -1, -1, 288, 289,
290, 291, 292, 293, 294, 295, 296, -1, -1, -1,
-1, 37, 38, -1, -1, 41, 42, 43, 44, 45,
46, 47, -1, -1, -1, -1, -1, -1, -1, 319,
320, 126, 58, 59, 60, 61, 62, 63, 37, 38,
-1, -1, 41, 42, 43, 44, 45, -1, 47, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 58,
59, 60, 61, 62, 63, 37, 38, 93, 94, 41,
42, 43, 44, 45, -1, 47, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 58, 59, 60, 61,
62, 63, -1, -1, 93, 94, -1, -1, 124, 260,
261, 262, 263, -1, -1, -1, -1, -1, -1, 270,
-1, 272, -1, 274, -1, 276, -1, -1, -1, -1,
-1, 93, 94, 284, -1, 124, -1, 288, 289, 290,
-1, 292, 293, 294, -1, -1, -1, -1, -1, -1,
272, -1, -1, -1, -1, -1, 278, -1, 280, -1,
282, -1, 124, -1, -1, -1, -1, -1, 319, 320,
-1, -1, -1, -1, -1, 260, 261, 262, 263, -1,
41, -1, -1, 44, -1, 270, -1, -1, -1, 274,
-1, 276, -1, -1, -1, -1, -1, 58, 59, 284,
-1, -1, 63, 288, 289, 290, -1, 292, 293, 294,
-1, -1, -1, -1, -1, 37, 38, -1, -1, 41,
42, 43, 44, 45, 59, 47, -1, -1, -1, -1,
-1, -1, 93, 94, 319, 320, 58, 59, 60, -1,
62, 63, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 37, 38, -1, -1, 41, 42, 43, 44,
45, -1, 47, 124, -1, -1, -1, -1, -1, -1,
-1, 93, 94, 58, 59, 60, -1, 62, 63, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
125, -1, -1, -1, 310, 311, 312, 313, 314, 315,
316, 317, 124, 319, 320, -1, -1, -1, 93, 94,
37, 38, -1, -1, 41, 42, 43, 44, 45, -1,
47, 310, 311, 312, 313, 314, 315, 316, 317, -1,
319, 320, -1, 60, -1, 62, 63, 37, 38, 124,
-1, -1, 42, 43, 44, 45, -1, 47, 310, 311,
312, 313, 314, 315, 316, 317, -1, 319, 320, -1,
60, -1, 62, 63, 37, 38, -1, 94, 41, 42,
43, 44, 45, -1, 47, 37, 38, -1, -1, 41,
42, 43, 44, 45, -1, 47, -1, 60, -1, 62,
63, -1, -1, 93, 94, -1, -1, 124, 60, -1,
62, 63, -1, -1, -1, -1, -1, -1, -1, -1,
37, 38, -1, -1, 41, 42, 43, 44, 45, -1,
47, 94, -1, -1, 124, -1, -1, -1, -1, -1,
-1, -1, 94, 60, 269, 62, 63, 272, 273, -1,
-1, -1, -1, 278, -1, 280, -1, 37, 38, 310,
311, 124, 42, 43, 44, 45, -1, 47, -1, -1,
-1, -1, 124, -1, -1, -1, -1, 94, 58, -1,
60, -1, 62, 63, -1, -1, 37, 38, -1, -1,
-1, 42, 43, 44, 45, -1, 47, -1, 310, 311,
312, 313, 314, 315, 316, 317, -1, 124, 59, 60,
-1, 62, 63, -1, 94, -1, -1, -1, -1, -1,
-1, -1, 37, 38, -1, -1, -1, 42, 43, 44,
45, -1, 47, -1, -1, 310, 311, 312, 313, 314,
315, 316, 317, 94, 124, 60, -1, 62, 63, 37,
38, -1, -1, -1, 42, 43, -1, 45, -1, 47,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 60, 124, 62, 63, -1, -1, -1, 94,
37, 38, -1, -1, -1, 42, 43, -1, 45, -1,
47, -1, -1, 310, 311, 312, 313, 314, 315, 316,
317, -1, -1, 60, -1, 62, 94, 37, 38, 124,
-1, -1, 42, 43, -1, 45, -1, 47, -1, -1,
310, 311, 312, 313, 314, 315, 316, 317, -1, -1,
60, -1, 62, -1, -1, -1, 124, 94, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 310, 311, 312,
313, 314, 315, 316, 317, -1, -1, -1, 310, 311,
312, 313, 314, 315, 316, 317, -1, 124, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 37, 38, -1, -1, -1, 42, 43, -1, 45,
-1, 47, -1, 310, 311, 312, 313, 314, 315, 316,
317, -1, 37, -1, 60, -1, 62, 42, 43, -1,
45, -1, 47, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 38, -1, 60, 41, 62, -1, 44,
310, 311, 312, 313, 314, 315, 316, 317, 94, -1,
-1, -1, -1, 58, 59, 60, -1, 62, 63, 38,
-1, -1, 41, -1, 43, 44, 45, -1, -1, 310,
311, 312, 313, 314, 315, 316, 317, -1, 124, 58,
59, 60, -1, 62, 63, -1, -1, -1, 93, 94,
-1, -1, -1, -1, -1, -1, 38, -1, -1, 41,
-1, 43, 44, 45, -1, 310, 311, 312, 313, 314,
315, 316, 317, -1, 93, 94, 58, 59, 60, 124,
62, 63, 38, -1, -1, 41, -1, -1, 44, -1,
-1, -1, 310, 311, 312, 313, 314, 315, 316, 317,
-1, -1, 58, 59, 60, 124, 62, 63, -1, -1,
-1, 93, 94, -1, 38, -1, -1, 41, -1, -1,
44, -1, -1, -1, 311, 312, 313, 314, 315, 316,
317, -1, -1, -1, 58, 59, -1, 93, 94, 63,
-1, -1, 124, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 312, 313, 314, 315, 316, 317, 38, -1,
-1, 41, -1, -1, 44, -1, -1, -1, 124, 93,
94, -1, -1, -1, -1, -1, -1, -1, 58, 59,
-1, -1, -1, 63, -1, -1, -1, 38, -1, -1,
41, -1, -1, 44, -1, -1, -1, -1, 38, -1,
124, 41, -1, -1, 44, -1, -1, 58, 59, -1,
-1, -1, 63, 93, 94, -1, -1, -1, 58, 59,
-1, -1, -1, 63, -1, -1, 312, 313, 314, 315,
316, 317, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 93, 94, 124, -1, -1, 312, 313, 314,
315, 316, 317, 93, 94, 38, -1, 38, 41, -1,
41, 44, -1, 44, -1, 310, 311, 312, 313, 314,
315, 316, 317, 124, -1, 58, 59, 58, 59, -1,
63, -1, 63, 38, 124, -1, 41, -1, -1, 44,
-1, 310, 311, 312, 313, 314, 315, 316, 317, -1,
-1, -1, -1, 58, 59, -1, -1, -1, 63, -1,
93, 94, 93, 94, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 310, 311,
312, 313, 314, 315, 316, 317, -1, -1, 93, 94,
-1, 124, -1, 124, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 310, 311, 312, 313, 314, 315,
316, 317, -1, -1, -1, -1, -1, -1, -1, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 310, 311, 312, 313,
-1, -1, -1, -1, -1, 26, 27, 28, 29, -1,
-1, 32, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 47, -1, 49, -1,
51, 52, -1, 54, 55, -1, -1, -1, -1, -1,
310, 311, 312, 313, -1, -1, -1, 68, -1, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, -1, 310,
311, 312, 313, 94, 95, -1, -1, -1, -1, -1,
310, 311, 312, 313, -1, -1, -1, -1, -1, -1,
-1, -1, 113, -1, -1, -1, 117, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 137, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 148, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 310, 311, 310,
311, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 176, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 310, 311,
};
#define EXFINAL 1
#ifndef EXDEBUG
#define EXDEBUG 0
#endif
#define EXMAXTOKEN 322
#if EXDEBUG
char *exname[] = {
"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,
"'!'",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,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,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,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,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,"MINTOKEN",
"CHAR","INT","INTEGER","UNSIGNED","FLOATING","STRING","VOID","STATIC","ADDRESS",
"BREAK","CALL","CASE","CONSTANT","CONTINUE","DECLARE","DEFAULT","DYNAMIC",
"ELSE","EXIT","FOR","FUNCTION","ITERATE","ID","IF","LABEL","MEMBER","NAME",
"POS","PRAGMA","PRE","PRINTF","PROCEDURE","QUERY","RETURN","SCANF","SPRINTF",
"SSCANF","SWITCH","WHILE","F2I","F2S","I2F","I2S","S2B","S2F","S2I","F2X","I2X",
"S2X","X2F","X2I","X2S","OR","AND","EQ","NE","LE","GE","LS","RS","UNARY","INC",
"DEC","CAST","MAXTOKEN",
};
char *exrule[] = {
"$accept : program",
"program : statement_list action_list",
"action_list :",
"action_list : action_list action",
"$$1 :",
"action : LABEL ':' $$1 statement_list",
"statement_list :",
"statement_list : statement_list statement",
"statement : '{' statement_list '}'",
"statement : expr_opt ';'",
"$$2 :",
"$$3 :",
"statement : static $$2 DECLARE $$3 dcl_list ';'",
"statement : IF '(' expr ')' statement else_opt",
"statement : FOR '(' variable ')' statement",
"statement : FOR '(' expr_opt ';' expr_opt ';' expr_opt ')' statement",
"statement : WHILE '(' expr ')' statement",
"$$4 :",
"statement : SWITCH '(' expr $$4 ')' '{' switch_list '}'",
"statement : BREAK expr_opt ';'",
"statement : CONTINUE expr_opt ';'",
"statement : RETURN expr_opt ';'",
"switch_list :",
"switch_list : switch_list switch_item",
"switch_item : case_list statement_list",
"case_list : case_item",
"case_list : case_list case_item",
"case_item : CASE constant ':'",
"case_item : DEFAULT ':'",
"static :",
"static : STATIC",
"dcl_list : dcl_item",
"dcl_list : dcl_list ',' dcl_item",
"$$5 :",
"dcl_item : reference NAME $$5 array initialize",
"name : NAME",
"name : DYNAMIC",
"else_opt :",
"else_opt : ELSE statement",
"expr_opt :",
"expr_opt : expr",
"expr : '(' expr ')'",
"expr : '(' DECLARE ')' expr",
"expr : expr '<' expr",
"expr : expr '-' expr",
"expr : expr '*' expr",
"expr : expr '/' expr",
"expr : expr '%' expr",
"expr : expr LS expr",
"expr : expr RS expr",
"expr : expr '>' expr",
"expr : expr LE expr",
"expr : expr GE expr",
"expr : expr EQ expr",
"expr : expr NE expr",
"expr : expr '&' expr",
"expr : expr '|' expr",
"expr : expr '^' expr",
"expr : expr '+' expr",
"expr : expr AND expr",
"expr : expr OR expr",
"expr : expr ',' expr",
"$$6 :",
"$$7 :",
"expr : expr '?' $$6 expr ':' $$7 expr",
"expr : '!' expr",
"expr : '~' expr",
"expr : '-' expr",
"expr : '+' expr",
"expr : '&' variable",
"expr : reference FUNCTION '(' args ')'",
"expr : EXIT '(' expr ')'",
"expr : PROCEDURE '(' args ')'",
"expr : print '(' args ')'",
"expr : scan '(' args ')'",
"expr : STRING '.' ID",
"expr : variable assign",
"expr : INC variable",
"expr : variable INC",
"expr : DEC variable",
"expr : variable DEC",
"expr : constant",
"constant : CONSTANT",
"constant : FLOATING",
"constant : INTEGER",
"constant : STRING",
"constant : UNSIGNED",
"print : PRINTF",
"print : QUERY",
"print : SPRINTF",
"scan : SCANF",
"scan : SSCANF",
"variable : reference ID index",
"variable : DYNAMIC index",
"variable : NAME",
"array :",
"array : '[' ']'",
"index :",
"index : '[' expr ']'",
"args :",
"args : arg_list",
"arg_list : expr",
"arg_list : arg_list ',' expr",
"formals :",
"formals : DECLARE",
"formals : formal_list",
"formal_list : formal_item",
"formal_list : formal_list ',' formal_item",
"$$8 :",
"formal_item : DECLARE $$8 name",
"reference :",
"reference : reference ID index '.'",
"assign :",
"assign : '=' expr",
"initialize : assign",
"$$9 :",
"$$10 :",
"initialize : '(' $$9 formals $$10 ')' '{' statement_list '}'",
};
#endif
#if EXDEBUG
#include <stdio.h>
#endif
/* define the initial stack-sizes */
#ifdef EXSTACKSIZE
#undef EXMAXDEPTH
#define EXMAXDEPTH EXSTACKSIZE
#else
#ifdef EXMAXDEPTH
#define EXSTACKSIZE EXMAXDEPTH
#else
#define EXSTACKSIZE 10000
#define EXMAXDEPTH 10000
#endif
#endif
#define EXINITSTACKSIZE 500
int exdebug;
int exnerrs;
int exerrflag;
int exchar;
short *exssp;
EXSTYPE *exvsp;
EXSTYPE exval;
EXSTYPE exlval;
/* variables for the parser stack */
static short *exss;
static short *exsslim;
static EXSTYPE *exvs;
static int exstacksize;
/* #line 1104 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
#include "exgram.h"
/* #line 768 "y.tab.c" */
/* allocate initial stack or double stack size, up to EXMAXDEPTH */
static int exgrowstack(void)
{
int newsize, i;
short *newss;
EXSTYPE *newvs;
if ((newsize = exstacksize) == 0)
newsize = EXINITSTACKSIZE;
else if (newsize >= EXMAXDEPTH)
return -1;
else if ((newsize *= 2) > EXMAXDEPTH)
newsize = EXMAXDEPTH;
i = exssp - exss;
newss = (exss != 0)
? (short *)realloc(exss, newsize * sizeof(*newss))
: (short *)malloc(newsize * sizeof(*newss));
if (newss == 0)
return -1;
exss = newss;
exssp = newss + i;
newvs = (exvs != 0)
? (EXSTYPE *)realloc(exvs, newsize * sizeof(*newvs))
: (EXSTYPE *)malloc(newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
exvs = newvs;
exvsp = newvs + i;
exstacksize = newsize;
exsslim = exss + newsize - 1;
return 0;
}
#define EXABORT goto exabort
#define EXREJECT goto exabort
#define EXACCEPT goto exaccept
#define EXERROR goto exerrlab
int
exparse(void)
{
register int exm, exn, exstate;
#if EXDEBUG
register const char *exs;
if ((exs = getenv("EXDEBUG")) != 0)
{
exn = *exs;
if (exn >= '0' && exn <= '9')
exdebug = exn - '0';
}
#endif
exnerrs = 0;
exerrflag = 0;
exchar = EXEMPTY;
if (exss == NULL && exgrowstack()) goto exoverflow;
exssp = exss;
exvsp = exvs;
*exssp = exstate = 0;
exloop:
if ((exn = exdefred[exstate]) != 0) goto exreduce;
if (exchar < 0)
{
if ((exchar = exlex()) < 0) exchar = 0;
#if EXDEBUG
if (exdebug)
{
exs = 0;
if (exchar <= EXMAXTOKEN) exs = exname[exchar];
if (!exs) exs = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
EXPREFIX, exstate, exchar, exs);
}
#endif
}
if ((exn = exsindex[exstate]) && (exn += exchar) >= 0 &&
exn <= EXTABLESIZE && excheck[exn] == exchar)
{
#if EXDEBUG
if (exdebug)
printf("%sdebug: state %d, shifting to state %d\n",
EXPREFIX, exstate, extable[exn]);
#endif
if (exssp >= exsslim && exgrowstack())
{
goto exoverflow;
}
*++exssp = exstate = extable[exn];
*++exvsp = exlval;
exchar = EXEMPTY;
if (exerrflag > 0) --exerrflag;
goto exloop;
}
if ((exn = exrindex[exstate]) && (exn += exchar) >= 0 &&
exn <= EXTABLESIZE && excheck[exn] == exchar)
{
exn = extable[exn];
goto exreduce;
}
if (exerrflag) goto exinrecovery;
exerror("syntax error");
#ifdef lint
goto exerrlab;
#endif
exerrlab:
++exnerrs;
exinrecovery:
if (exerrflag < 3)
{
exerrflag = 3;
for (;;)
{
if ((exn = exsindex[*exssp]) && (exn += EXERRCODE) >= 0 &&
exn <= EXTABLESIZE && excheck[exn] == EXERRCODE)
{
#if EXDEBUG
if (exdebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", EXPREFIX, *exssp, extable[exn]);
#endif
if (exssp >= exsslim && exgrowstack())
{
goto exoverflow;
}
*++exssp = exstate = extable[exn];
*++exvsp = exlval;
goto exloop;
}
else
{
#if EXDEBUG
if (exdebug)
printf("%sdebug: error recovery discarding state %d\n",
EXPREFIX, *exssp);
#endif
if (exssp <= exss) goto exabort;
--exssp;
--exvsp;
}
}
}
else
{
if (exchar == 0) goto exabort;
#if EXDEBUG
if (exdebug)
{
exs = 0;
if (exchar <= EXMAXTOKEN) exs = exname[exchar];
if (!exs) exs = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
EXPREFIX, exstate, exchar, exs);
}
#endif
exchar = EXEMPTY;
goto exloop;
}
exreduce:
#if EXDEBUG
if (exdebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
EXPREFIX, exstate, exn, exrule[exn]);
#endif
exm = exlen[exn];
if (exm)
exval = exvsp[1-exm];
else
memset(&exval, 0, sizeof exval);
switch (exn)
{
case 1:
/* #line 137 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[-1].expr && !(expr.program->disc->flags & EX_STRICT))
{
if (expr.program->main.value && !(expr.program->disc->flags & EX_RETAIN))
exfreenode(expr.program, expr.program->main.value);
if (exvsp[-1].expr->op == S2B)
{
Exnode_t* x;
x = exvsp[-1].expr;
exvsp[-1].expr = x->data.operand.left;
x->data.operand.left = 0;
exfreenode(expr.program, x);
}
expr.program->main.lex = PROCEDURE;
expr.program->main.value = exnewnode(expr.program, PROCEDURE, 1, exvsp[-1].expr->type, NiL, exvsp[-1].expr);
}
}
break;
case 4:
/* #line 161 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Dtdisc_t* disc;
if (expr.procedure)
exerror("no nested function definitions");
exvsp[-1].id->lex = PROCEDURE;
expr.procedure = exvsp[-1].id->value = exnewnode(expr.program, PROCEDURE, 1, exvsp[-1].id->type, NiL, NiL);
expr.procedure->type = INTEGER;
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
exnospace();
disc->key = offsetof(Exid_t, name);
if (expr.assigned && !streq(exvsp[-1].id->name, "begin"))
{
if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
exnospace();
expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
}
}
break;
case 5:
/* #line 179 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
expr.procedure = 0;
if (expr.program->frame)
{
expr.program->symbols = expr.program->frame->view;
dtview(expr.program->frame, NiL);
expr.program->frame = 0;
}
if (exvsp[0].expr && exvsp[0].expr->op == S2B)
{
Exnode_t* x;
x = exvsp[0].expr;
exvsp[0].expr = x->data.operand.left;
x->data.operand.left = 0;
exfreenode(expr.program, x);
}
exvsp[-3].id->value->data.operand.right = excast(expr.program, exvsp[0].expr, exvsp[-3].id->type, NiL, 0);
}
break;
case 6:
/* #line 201 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 7:
/* #line 205 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (!exvsp[-1].expr)
exval.expr = exvsp[0].expr;
else if (!exvsp[0].expr)
exval.expr = exvsp[-1].expr;
else if (exvsp[-1].expr->op == CONSTANT)
{
exfreenode(expr.program, exvsp[-1].expr);
exval.expr = exvsp[0].expr;
}
else if (exvsp[-1].expr->op == ';')
{
exval.expr = exvsp[-1].expr;
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);
}
else
{
exval.expr = exnewnode(expr.program, ';', 1, exvsp[-1].expr->type, exvsp[-1].expr, NiL);
exval.expr->data.operand.last = exval.expr->data.operand.right = exnewnode(expr.program, ';', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
}
}
break;
case 8:
/* #line 229 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[-1].expr;
}
break;
case 9:
/* #line 233 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = (exvsp[-1].expr && exvsp[-1].expr->type == STRING) ? exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-1].expr, NiL) : exvsp[-1].expr;
}
break;
case 10:
/* #line 236 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.instatic=exvsp[0].integer;}
break;
case 11:
/* #line 236 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.declare=exvsp[0].id->type;}
break;
case 12:
/* #line 237 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[-1].expr;
expr.declare = 0;
}
break;
case 13:
/* #line 242 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[-3].expr->type == STRING)
exvsp[-3].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-3].expr, NiL);
else if (!INTEGRAL(exvsp[-3].expr->type))
exvsp[-3].expr = excast(expr.program, exvsp[-3].expr, INTEGER, NiL, 0);
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));
}
break;
case 14:
/* #line 250 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ITERATE, 0, INTEGER, NiL, NiL);
exval.expr->data.generate.array = exvsp[-2].expr;
if (!exvsp[-2].expr->data.variable.index || exvsp[-2].expr->data.variable.index->op != DYNAMIC)
exerror("simple index variable expected");
exval.expr->data.generate.index = exvsp[-2].expr->data.variable.index->data.variable.symbol;
if (exvsp[-2].expr->op == ID && exval.expr->data.generate.index->type != INTEGER)
exerror("integer index variable expected");
exfreenode(expr.program, exvsp[-2].expr->data.variable.index);
exvsp[-2].expr->data.variable.index = 0;
exval.expr->data.generate.statement = exvsp[0].expr;
}
break;
case 15:
/* #line 263 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (!exvsp[-4].expr)
{
exvsp[-4].expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exvsp[-4].expr->data.constant.value.integer = 1;
}
else if (exvsp[-4].expr->type == STRING)
exvsp[-4].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-4].expr, NiL);
else if (!INTEGRAL(exvsp[-4].expr->type))
exvsp[-4].expr = excast(expr.program, exvsp[-4].expr, INTEGER, NiL, 0);
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));
if (exvsp[-6].expr)
exval.expr = exnewnode(expr.program, ';', 1, INTEGER, exvsp[-6].expr, exval.expr);
}
break;
case 16:
/* #line 278 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[-2].expr->type == STRING)
exvsp[-2].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-2].expr, NiL);
else if (!INTEGRAL(exvsp[-2].expr->type))
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, exvsp[-4].id->index, 1, INTEGER, exvsp[-2].expr, exnewnode(expr.program, ';', 1, 0, NiL, exvsp[0].expr));
}
break;
case 17:
/* #line 285 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.declare=exvsp[0].expr->type;}
break;
case 18:
/* #line 286 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Switch_t* sw = expr.swstate;
exval.expr = exnewnode(expr.program, exvsp[-7].id->index, 1, INTEGER, exvsp[-5].expr, exnewnode(expr.program, DEFAULT, 1, 0, sw->defcase, sw->firstcase));
expr.swstate = expr.swstate->prev;
if (sw->base)
free(sw->base);
if (sw != &swstate)
free(sw);
expr.declare = 0;
}
break;
case 19:
/* #line 298 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
loopop:
if (!exvsp[-1].expr)
{
exvsp[-1].expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exvsp[-1].expr->data.constant.value.integer = 1;
}
else if (!INTEGRAL(exvsp[-1].expr->type))
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, exvsp[-2].id->index, 1, INTEGER, exvsp[-1].expr, NiL);
}
break;
case 20:
/* #line 310 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto loopop;
}
break;
case 21:
/* #line 314 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[-1].expr)
{
if (expr.procedure && !expr.procedure->type)
exerror("return in void function");
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, expr.procedure ? expr.procedure->type : INTEGER, NiL, 0);
}
exval.expr = exnewnode(expr.program, RETURN, 1, exvsp[-1].expr ? exvsp[-1].expr->type : 0, exvsp[-1].expr, NiL);
}
break;
case 22:
/* #line 326 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Switch_t* sw;
int n;
if (expr.swstate)
{
if (!(sw = newof(0, Switch_t, 1, 0)))
{
exnospace();
sw = &swstate;
}
sw->prev = expr.swstate;
}
else
sw = &swstate;
expr.swstate = sw;
sw->type = expr.declare;
sw->firstcase = 0;
sw->lastcase = 0;
sw->defcase = 0;
sw->def = 0;
n = 8;
if (!(sw->base = newof(0, Extype_t*, n, 0)))
{
exnospace();
n = 0;
}
sw->cur = sw->base;
sw->last = sw->base + n;
}
break;
case 24:
/* #line 360 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Switch_t* sw = expr.swstate;
int n;
exval.expr = exnewnode(expr.program, CASE, 1, 0, exvsp[0].expr, NiL);
if (sw->cur > sw->base)
{
if (sw->lastcase)
sw->lastcase->data.select.next = exval.expr;
else
sw->firstcase = exval.expr;
sw->lastcase = exval.expr;
n = sw->cur - sw->base;
sw->cur = sw->base;
exval.expr->data.select.constant = (Extype_t**)exalloc(expr.program, (n + 1) * sizeof(Extype_t*));
memcpy(exval.expr->data.select.constant, sw->base, n * sizeof(Extype_t*));
exval.expr->data.select.constant[n] = 0;
}
else
exval.expr->data.select.constant = 0;
if (sw->def)
{
sw->def = 0;
if (sw->defcase)
exerror("duplicate default in switch");
else
sw->defcase = exvsp[0].expr;
}
}
break;
case 27:
/* #line 396 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
int n;
if (expr.swstate->cur >= expr.swstate->last)
{
n = expr.swstate->cur - expr.swstate->base;
if (!(expr.swstate->base = newof(expr.swstate->base, Extype_t*, 2 * n, 0)))
{
exerror("too many case labels for switch");
n = 0;
}
expr.swstate->cur = expr.swstate->base + n;
expr.swstate->last = expr.swstate->base + 2 * n;
}
if (expr.swstate->cur)
{
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, expr.swstate->type, NiL, 0);
*expr.swstate->cur++ = &(exvsp[-1].expr->data.constant.value);
}
}
break;
case 28:
/* #line 417 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
expr.swstate->def = 1;
}
break;
case 29:
/* #line 423 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.integer = 0;
}
break;
case 30:
/* #line 427 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.integer = 1;
}
break;
case 32:
/* #line 434 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[0].expr)
exval.expr = exvsp[-2].expr ? exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[-2].expr, exvsp[0].expr) : exvsp[0].expr;
}
break;
case 33:
/* #line 440 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.id=exvsp[0].id;}
break;
case 34:
/* #line 441 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
if (!exvsp[-3].id->type || expr.declare)
exvsp[-3].id->type = expr.declare;
if (exvsp[-4].reference)
{
exvsp[-3].id->index = MEMBER;
if (!expr.program->disc->getf || !expr.program->symbols)
exerror("%s: member references not supported", exvsp[-4].reference);
else if (exvsp[0].expr)
exerror("%s: member references cannot be initialized", exvsp[-3].id);
else if (expr.program->disc->reff)
(*expr.program->disc->reff)(expr.program, exval.expr, exvsp[-3].id, exvsp[-4].reference, NiL, EX_SCALAR, expr.program->disc);
}
else if (exvsp[0].expr && exvsp[0].expr->op == PROCEDURE)
{
exvsp[-3].id->lex = PROCEDURE;
exvsp[-3].id->value = exvsp[0].expr;
}
else
{
exvsp[-3].id->lex = DYNAMIC;
exvsp[-3].id->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
if (exvsp[-1].integer && !exvsp[-3].id->local.pointer)
{
Dtdisc_t* disc;
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
exnospace();
disc->key = offsetof(Exassoc_t, name);
if (!(exvsp[-3].id->local.pointer = (char*)dtopen(disc, Dtoset)))
exerror("%s: cannot initialize associative array", exvsp[-3].id->name);
}
if (exvsp[0].expr)
{
if (exvsp[0].expr->type != exvsp[-3].id->type)
{
exvsp[0].expr->type = exvsp[-3].id->type;
exvsp[0].expr->data.operand.right = excast(expr.program, exvsp[0].expr->data.operand.right, exvsp[-3].id->type, NiL, 0);
}
exvsp[0].expr->data.operand.left = exnewnode(expr.program, DYNAMIC, 0, exvsp[-3].id->type, NiL, NiL);
exvsp[0].expr->data.operand.left->data.variable.symbol = exvsp[-3].id;
exval.expr = exvsp[0].expr;
if (!expr.program->frame && !expr.program->errors)
{
expr.assigned++;
exeval(expr.program, exval.expr, NiL);
}
}
else if (!exvsp[-1].integer)
exvsp[-3].id->value->data.value = exzero(exvsp[-3].id->type);
}
}
break;
case 37:
/* #line 501 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 38:
/* #line 505 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[0].expr;
}
break;
case 39:
/* #line 511 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 41:
/* #line 518 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[-1].expr;
}
break;
case 42:
/* #line 522 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
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);
}
break;
case 43:
/* #line 526 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
int rel;
relational:
rel = INTEGER;
goto coerce;
binary:
rel = 0;
coerce:
if (!exvsp[-2].expr->type)
{
if (!exvsp[0].expr->type)
exvsp[-2].expr->type = exvsp[0].expr->type = rel ? STRING : INTEGER;
else
exvsp[-2].expr->type = exvsp[0].expr->type;
}
else if (!exvsp[0].expr->type)
exvsp[0].expr->type = exvsp[-2].expr->type;
if (exvsp[-2].expr->type != exvsp[0].expr->type)
{
if (exvsp[-2].expr->type == STRING)
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, exvsp[0].expr->type, exvsp[0].expr, 0);
else if (exvsp[0].expr->type == STRING)
exvsp[0].expr = excast(expr.program, exvsp[0].expr, exvsp[-2].expr->type, exvsp[-2].expr, 0);
else if (exvsp[-2].expr->type == FLOATING)
exvsp[0].expr = excast(expr.program, exvsp[0].expr, FLOATING, exvsp[-2].expr, 0);
else if (exvsp[0].expr->type == FLOATING)
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, FLOATING, exvsp[0].expr, 0);
}
if (!rel)
rel = (exvsp[-2].expr->type == STRING) ? STRING : ((exvsp[-2].expr->type == UNSIGNED) ? UNSIGNED : exvsp[0].expr->type);
exval.expr = exnewnode(expr.program, exvsp[-1].op, 1, rel, exvsp[-2].expr, exvsp[0].expr);
if (!expr.program->errors && exvsp[-2].expr->op == CONSTANT && exvsp[0].expr->op == CONSTANT)
{
exval.expr->data.constant.value = exeval(expr.program, exval.expr, NiL);
exval.expr->binary = 0;
exval.expr->op = CONSTANT;
exfreenode(expr.program, exvsp[-2].expr);
exfreenode(expr.program, exvsp[0].expr);
}
}
break;
case 44:
/* #line 568 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 45:
/* #line 572 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 46:
/* #line 576 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 47:
/* #line 580 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 48:
/* #line 584 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 49:
/* #line 588 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 50:
/* #line 592 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto relational;
}
break;
case 51:
/* #line 596 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto relational;
}
break;
case 52:
/* #line 600 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto relational;
}
break;
case 53:
/* #line 604 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto relational;
}
break;
case 54:
/* #line 608 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto relational;
}
break;
case 55:
/* #line 612 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 56:
/* #line 616 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 57:
/* #line 620 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 58:
/* #line 624 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto binary;
}
break;
case 59:
/* #line 628 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
logical:
if (exvsp[-2].expr->type == STRING)
exvsp[-2].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-2].expr, NiL);
if (exvsp[0].expr->type == STRING)
exvsp[0].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[0].expr, NiL);
goto binary;
}
break;
case 60:
/* #line 637 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto logical;
}
break;
case 61:
/* #line 641 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[-2].expr->op == CONSTANT)
{
exfreenode(expr.program, exvsp[-2].expr);
exval.expr = exvsp[0].expr;
}
else
exval.expr = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[-2].expr, exvsp[0].expr);
}
break;
case 62:
/* #line 650 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.nolabel=1;}
break;
case 63:
/* #line 650 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.nolabel=0;}
break;
case 64:
/* #line 651 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (!exvsp[-3].expr->type)
{
if (!exvsp[0].expr->type)
exvsp[-3].expr->type = exvsp[0].expr->type = INTEGER;
else
exvsp[-3].expr->type = exvsp[0].expr->type;
}
else if (!exvsp[0].expr->type)
exvsp[0].expr->type = exvsp[-3].expr->type;
if (exvsp[-6].expr->type == STRING)
exvsp[-6].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-6].expr, NiL);
else if (!INTEGRAL(exvsp[-6].expr->type))
exvsp[-6].expr = excast(expr.program, exvsp[-6].expr, INTEGER, NiL, 0);
if (exvsp[-3].expr->type != exvsp[0].expr->type)
{
if (exvsp[-3].expr->type == STRING || exvsp[0].expr->type == STRING)
exerror("if statement string type mismatch");
else if (exvsp[-3].expr->type == FLOATING)
exvsp[0].expr = excast(expr.program, exvsp[0].expr, FLOATING, NiL, 0);
else if (exvsp[0].expr->type == FLOATING)
exvsp[-3].expr = excast(expr.program, exvsp[-3].expr, FLOATING, NiL, 0);
}
if (exvsp[-6].expr->op == CONSTANT)
{
if (exvsp[-6].expr->data.constant.value.integer)
{
exval.expr = exvsp[-3].expr;
exfreenode(expr.program, exvsp[0].expr);
}
else
{
exval.expr = exvsp[0].expr;
exfreenode(expr.program, exvsp[-3].expr);
}
exfreenode(expr.program, exvsp[-6].expr);
}
else
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));
}
break;
case 65:
/* #line 692 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
iunary:
if (exvsp[0].expr->type == STRING)
exvsp[0].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[0].expr, NiL);
else if (!INTEGRAL(exvsp[0].expr->type))
exvsp[0].expr = excast(expr.program, exvsp[0].expr, INTEGER, NiL, 0);
unary:
exval.expr = exnewnode(expr.program, exvsp[-1].op, 1, exvsp[0].expr->type == UNSIGNED ? INTEGER : exvsp[0].expr->type, exvsp[0].expr, NiL);
if (exvsp[0].expr->op == CONSTANT)
{
exval.expr->data.constant.value = exeval(expr.program, exval.expr, NiL);
exval.expr->binary = 0;
exval.expr->op = CONSTANT;
exfreenode(expr.program, exvsp[0].expr);
}
}
break;
case 66:
/* #line 709 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto iunary;
}
break;
case 67:
/* #line 713 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto unary;
}
break;
case 68:
/* #line 717 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[0].expr;
}
break;
case 69:
/* #line 721 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ADDRESS, 0, T(exvsp[0].expr->type), exvsp[0].expr, NiL);
}
break;
case 70:
/* #line 725 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
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);
if (!expr.program->disc->getf)
exerror("%s: function references not supported", exval.expr->data.operand.left->data.variable.symbol->name);
else if (expr.program->disc->reff)
(*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);
}
break;
case 71:
/* #line 733 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (!INTEGRAL(exvsp[-1].expr->type))
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, EXIT, 1, INTEGER, exvsp[-1].expr, NiL);
}
break;
case 72:
/* #line 739 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CALL, 1, exvsp[-3].id->type, NiL, exvsp[-1].expr);
exval.expr->data.call.procedure = exvsp[-3].id;
}
break;
case 73:
/* #line 744 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, exvsp[-3].id->index, 0, exvsp[-3].id->type, NiL, NiL);
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == INTEGER)
{
exval.expr->data.print.descriptor = exvsp[-1].expr->data.operand.left;
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
}
else
switch (exvsp[-3].id->index)
{
case QUERY:
exval.expr->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exval.expr->data.print.descriptor->data.constant.value.integer = 2;
break;
case PRINTF:
exval.expr->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exval.expr->data.print.descriptor->data.constant.value.integer = 1;
break;
case SPRINTF:
exval.expr->data.print.descriptor = 0;
break;
}
exval.expr->data.print.args = preprint(exvsp[-1].expr);
}
break;
case 74:
/* #line 769 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Exnode_t* x;
exval.expr = exnewnode(expr.program, exvsp[-3].id->index, 0, exvsp[-3].id->type, NiL, NiL);
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == INTEGER)
{
exval.expr->data.scan.descriptor = exvsp[-1].expr->data.operand.left;
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
}
else
switch (exvsp[-3].id->index)
{
case SCANF:
exval.expr->data.scan.descriptor = 0;
break;
case SSCANF:
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == STRING)
{
exval.expr->data.scan.descriptor = exvsp[-1].expr->data.operand.left;
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
}
else
exerror("%s: string argument expected", exvsp[-3].id->name);
break;
}
if (!exvsp[-1].expr || !exvsp[-1].expr->data.operand.left || exvsp[-1].expr->data.operand.left->type != STRING)
exerror("%s: format argument expected", exvsp[-3].id->name);
exval.expr->data.scan.format = exvsp[-1].expr->data.operand.left;
for (x = exval.expr->data.scan.args = exvsp[-1].expr->data.operand.right; x; x = x->data.operand.right)
{
if (x->data.operand.left->op != ADDRESS)
exerror("%s: address argument expected", exvsp[-3].id->name);
x->data.operand.left = x->data.operand.left->data.operand.left;
}
}
break;
case 75:
/* #line 805 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, exvsp[0].id->type, NiL, NiL);
if (!expr.program->disc->reff)
exerror("%s: qualified identifier references not supported", exvsp[0].id->name);
else
{
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);
exval.expr->data.constant.reference = exvsp[0].id;
}
}
break;
case 76:
/* #line 816 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
if (exvsp[0].expr)
{
if (exvsp[-1].expr->op == ID && !expr.program->disc->setf)
exerror("%s: variable assignment not supported", exvsp[-1].expr->data.variable.symbol->name);
else
{
if (!exvsp[-1].expr->type)
exvsp[-1].expr->type = exvsp[0].expr->type;
#if 0
else if (exvsp[0].expr->type != exvsp[-1].expr->type && exvsp[-1].expr->type >= 0200)
#else
else if (exvsp[0].expr->type != exvsp[-1].expr->type)
#endif
{
exvsp[0].expr->type = exvsp[-1].expr->type;
exvsp[0].expr->data.operand.right = excast(expr.program, exvsp[0].expr->data.operand.right, exvsp[-1].expr->type, NiL, 0);
}
exvsp[0].expr->data.operand.left = exvsp[-1].expr;
exval.expr = exvsp[0].expr;
}
}
}
break;
case 77:
/* #line 840 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
pre:
if (exvsp[0].expr->type == STRING)
exerror("++ and -- invalid for string variables");
exval.expr = exnewnode(expr.program, exvsp[-1].op, 0, exvsp[0].expr->type, exvsp[0].expr, NiL);
exval.expr->subop = PRE;
}
break;
case 78:
/* #line 848 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
pos:
if (exvsp[-1].expr->type == STRING)
exerror("++ and -- invalid for string variables");
exval.expr = exnewnode(expr.program, exvsp[0].op, 0, exvsp[-1].expr->type, exvsp[-1].expr, NiL);
exval.expr->subop = POS;
}
break;
case 79:
/* #line 856 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto pre;
}
break;
case 80:
/* #line 860 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
goto pos;
}
break;
case 82:
/* #line 867 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, exvsp[0].id->type, NiL, NiL);
if (!expr.program->disc->reff)
exerror("%s: identifier references not supported", exvsp[0].id->name);
else
exval.expr->data.constant.value = (*expr.program->disc->reff)(expr.program, exval.expr, exvsp[0].id, NiL, NiL, EX_SCALAR, expr.program->disc);
}
break;
case 83:
/* #line 875 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, FLOATING, NiL, NiL);
exval.expr->data.constant.value.floating = exvsp[0].floating;
}
break;
case 84:
/* #line 880 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exval.expr->data.constant.value.integer = exvsp[0].integer;
}
break;
case 85:
/* #line 885 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, STRING, NiL, NiL);
exval.expr->data.constant.value.string = exvsp[0].string;
}
break;
case 86:
/* #line 890 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, UNSIGNED, NiL, NiL);
exval.expr->data.constant.value.integer = exvsp[0].integer;
}
break;
case 92:
/* #line 906 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ID, 0, exvsp[-1].id->type, NiL, NiL);
exval.expr->data.variable.symbol = QUALIFY(exvsp[-2].reference, exvsp[-1].id);
exval.expr->data.variable.reference = exvsp[-2].reference;
if (exvsp[0].expr && !INTEGRAL(exvsp[0].expr->type))
exvsp[0].expr = excast(expr.program, exvsp[0].expr, INTEGER, NiL, 0);
exval.expr->data.variable.index = exvsp[0].expr;
if (!expr.program->disc->getf)
exerror("%s: identifier references not supported", exvsp[-1].id->name);
else if (expr.program->disc->reff)
(*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);
exval.expr->type = exval.expr->data.variable.symbol->type;
}
break;
case 93:
/* #line 920 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, DYNAMIC, 0, exvsp[-1].id->type, NiL, NiL);
exval.expr->data.variable.symbol = exvsp[-1].id;
exval.expr->data.variable.reference = 0;
if (((exval.expr->data.variable.index = exvsp[0].expr) == 0) != (exvsp[-1].id->local.pointer == 0))
exerror("%s: is%s an array", exvsp[-1].id->name, exvsp[-1].id->local.pointer ? "" : " not");
}
break;
case 94:
/* #line 928 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ID, 0, 0, NiL, NiL);
exval.expr->data.variable.symbol = exvsp[0].id;
exval.expr->data.variable.reference = 0;
exval.expr->data.variable.index = 0;
if (!(expr.program->disc->flags & EX_UNDECLARED))
exerror("unknown identifier");
}
break;
case 95:
/* #line 939 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.integer = 0;
}
break;
case 96:
/* #line 943 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.integer = 1;
}
break;
case 97:
/* #line 949 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 98:
/* #line 953 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[-1].expr;
}
break;
case 99:
/* #line 959 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 100:
/* #line 963 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exvsp[0].expr->data.operand.left;
exvsp[0].expr->data.operand.left = exvsp[0].expr->data.operand.right = 0;
exfreenode(expr.program, exvsp[0].expr);
}
break;
case 101:
/* #line 971 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ';', 1, 0, exnewnode(expr.program, ';', 1, exvsp[0].expr->type, exvsp[0].expr, NiL), NiL);
exval.expr->data.operand.right = exval.expr->data.operand.left;
}
break;
case 102:
/* #line 976 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
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);
}
break;
case 103:
/* #line 982 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 104:
/* #line 986 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
if (exvsp[0].id->type)
exerror("(void) expected");
}
break;
case 106:
/* #line 995 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
}
break;
case 107:
/* #line 999 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Exnode_t* x;
register Exnode_t* y;
exval.expr = exvsp[-2].expr;
for (x = exvsp[-2].expr; y = x->data.operand.right; x = y);
x->data.operand.right = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
}
break;
case 108:
/* #line 1009 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{expr.declare=exvsp[0].id->type;}
break;
case 109:
/* #line 1010 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, ID, 0, exvsp[0].id->type, NiL, NiL);
exval.expr->data.variable.symbol = exvsp[0].id;
exvsp[0].id->lex = DYNAMIC;
exvsp[0].id->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
expr.procedure->data.procedure.arity++;
expr.declare = 0;
}
break;
case 110:
/* #line 1021 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.reference = expr.refs = expr.lastref = 0;
}
break;
case 111:
/* #line 1025 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
Exref_t* r;
r = ALLOCATE(expr.program, Exref_t);
if (expr.lastref)
{
r->symbol = QUALIFY(expr.lastref, exvsp[-2].id);
expr.lastref->next = r;
}
else
{
r->symbol = exvsp[-2].id;
expr.refs = r;
}
expr.lastref = r;
r->next = 0;
r->index = exvsp[-1].expr;
exval.reference = expr.refs;
}
break;
case 112:
/* #line 1047 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = 0;
}
break;
case 113:
/* #line 1051 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = exnewnode(expr.program, '=', 1, exvsp[0].expr->type, NiL, exvsp[0].expr);
exval.expr->subop = exvsp[-1].op;
}
break;
case 115:
/* #line 1058 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
register Dtdisc_t* disc;
if (expr.procedure)
exerror("%s: nested function definitions not supported", expr.id->name);
expr.procedure = exnewnode(expr.program, PROCEDURE, 1, expr.declare, NiL, NiL);
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
exnospace();
disc->key = offsetof(Exid_t, name);
if (!streq(expr.id->name, "begin"))
{
if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
exnospace();
expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
expr.program->formals = 1;
}
expr.declare = 0;
}
break;
case 116:
/* #line 1075 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
expr.id->lex = PROCEDURE;
expr.id->type = expr.procedure->type;
expr.program->formals = 0;
expr.declare = 0;
}
break;
case 117:
/* #line 1081 "/home/gsf/tst/package/ast-2012-07-27/src/lib/libexpr/exparse.y" */
{
exval.expr = expr.procedure;
expr.procedure = 0;
if (expr.program->frame)
{
expr.program->symbols = expr.program->frame->view;
dtview(expr.program->frame, NiL);
expr.program->frame = 0;
}
exval.expr->data.operand.left = exvsp[-5].expr;
exval.expr->data.operand.right = excast(expr.program, exvsp[-1].expr, exval.expr->type, NiL, 0);
/*
* NOTE: procedure definition was slipped into the
* declaration initializer statement production,
* therefore requiring the statement terminator
*/
exunlex(expr.program, ';');
}
break;
/* #line 2059 "y.tab.c" */
}
exssp -= exm;
exstate = *exssp;
exvsp -= exm;
exm = exlhs[exn];
if (exstate == 0 && exm == 0)
{
#if EXDEBUG
if (exdebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", EXPREFIX, EXFINAL);
#endif
exstate = EXFINAL;
*++exssp = EXFINAL;
*++exvsp = exval;
if (exchar < 0)
{
if ((exchar = exlex()) < 0) exchar = 0;
#if EXDEBUG
if (exdebug)
{
exs = 0;
if (exchar <= EXMAXTOKEN) exs = exname[exchar];
if (!exs) exs = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
EXPREFIX, EXFINAL, exchar, exs);
}
#endif
}
if (exchar == 0) goto exaccept;
goto exloop;
}
if ((exn = exgindex[exm]) && (exn += exstate) >= 0 &&
exn <= EXTABLESIZE && excheck[exn] == exstate)
exstate = extable[exn];
else
exstate = exdgoto[exm];
#if EXDEBUG
if (exdebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", EXPREFIX, *exssp, exstate);
#endif
if (exssp >= exsslim && exgrowstack())
{
goto exoverflow;
}
*++exssp = exstate;
*++exvsp = exval;
goto exloop;
exoverflow:
exerror("yacc stack overflow");
exabort:
return (1);
exaccept:
return (0);
}