Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/byacc/test/btyacc/btyacc_demo.tab.c
109934 views
1
/* original parser id follows */
2
/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3
/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4
5
#define YYBYACC 1
6
#define YYMAJOR 2
7
#define YYMINOR 0
8
#define YYCHECK "yyyymmdd"
9
10
#define YYEMPTY (-1)
11
#define yyclearin (yychar = YYEMPTY)
12
#define yyerrok (yyerrflag = 0)
13
#define YYRECOVERING() (yyerrflag != 0)
14
#define YYENOMEM (-2)
15
#define YYEOF 0
16
#undef YYBTYACC
17
#define YYBTYACC 1
18
#define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug")
19
20
#ifndef yyparse
21
#define yyparse demo_parse
22
#endif /* yyparse */
23
24
#ifndef yylex
25
#define yylex demo_lex
26
#endif /* yylex */
27
28
#ifndef yyerror
29
#define yyerror demo_error
30
#endif /* yyerror */
31
32
#ifndef yychar
33
#define yychar demo_char
34
#endif /* yychar */
35
36
#ifndef yyval
37
#define yyval demo_val
38
#endif /* yyval */
39
40
#ifndef yylval
41
#define yylval demo_lval
42
#endif /* yylval */
43
44
#ifndef yydebug
45
#define yydebug demo_debug
46
#endif /* yydebug */
47
48
#ifndef yynerrs
49
#define yynerrs demo_nerrs
50
#endif /* yynerrs */
51
52
#ifndef yyerrflag
53
#define yyerrflag demo_errflag
54
#endif /* yyerrflag */
55
56
#ifndef yylhs
57
#define yylhs demo_lhs
58
#endif /* yylhs */
59
60
#ifndef yylen
61
#define yylen demo_len
62
#endif /* yylen */
63
64
#ifndef yydefred
65
#define yydefred demo_defred
66
#endif /* yydefred */
67
68
#ifndef yystos
69
#define yystos demo_stos
70
#endif /* yystos */
71
72
#ifndef yydgoto
73
#define yydgoto demo_dgoto
74
#endif /* yydgoto */
75
76
#ifndef yysindex
77
#define yysindex demo_sindex
78
#endif /* yysindex */
79
80
#ifndef yyrindex
81
#define yyrindex demo_rindex
82
#endif /* yyrindex */
83
84
#ifndef yygindex
85
#define yygindex demo_gindex
86
#endif /* yygindex */
87
88
#ifndef yytable
89
#define yytable demo_table
90
#endif /* yytable */
91
92
#ifndef yycheck
93
#define yycheck demo_check
94
#endif /* yycheck */
95
96
#ifndef yyname
97
#define yyname demo_name
98
#endif /* yyname */
99
100
#ifndef yyrule
101
#define yyrule demo_rule
102
#endif /* yyrule */
103
104
#ifndef yyloc
105
#define yyloc demo_loc
106
#endif /* yyloc */
107
108
#ifndef yylloc
109
#define yylloc demo_lloc
110
#endif /* yylloc */
111
112
#if YYBTYACC
113
114
#ifndef yycindex
115
#define yycindex demo_cindex
116
#endif /* yycindex */
117
118
#ifndef yyctable
119
#define yyctable demo_ctable
120
#endif /* yyctable */
121
122
#endif /* YYBTYACC */
123
124
#define YYPREFIX "demo_"
125
126
#define YYPURE 0
127
128
#line 15 "btyacc_demo.y"
129
/* dummy types just for compile check */
130
typedef int Code;
131
typedef int Decl_List;
132
typedef int Expr;
133
typedef int Expr_List;
134
typedef int Scope;
135
typedef int Type;
136
enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF };
137
138
typedef unsigned char bool;
139
typedef struct Decl {
140
Scope *scope;
141
Type *type;
142
bool (*istype)(void);
143
} Decl;
144
145
#include "btyacc_demo.tab.h"
146
#include <stdlib.h>
147
#include <stdio.h>
148
#ifdef YYSTYPE
149
#undef YYSTYPE_IS_DECLARED
150
#define YYSTYPE_IS_DECLARED 1
151
#endif
152
#ifndef YYSTYPE_IS_DECLARED
153
#define YYSTYPE_IS_DECLARED 1
154
#line 36 "btyacc_demo.y"
155
typedef union YYSTYPE {
156
Scope *scope;
157
Expr *expr;
158
Expr_List *elist;
159
Type *type;
160
Decl *decl;
161
Decl_List *dlist;
162
Code *code;
163
char *id;
164
} YYSTYPE;
165
#endif /* !YYSTYPE_IS_DECLARED */
166
#line 167 "btyacc_demo.tab.c"
167
168
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
169
/* Default: YYLTYPE is the text position type. */
170
typedef struct YYLTYPE
171
{
172
int first_line;
173
int first_column;
174
int last_line;
175
int last_column;
176
unsigned source;
177
} YYLTYPE;
178
#define YYLTYPE_IS_DECLARED 1
179
#endif
180
#define YYRHSLOC(rhs, k) ((rhs)[k])
181
182
/* compatibility with bison */
183
#ifdef YYPARSE_PARAM
184
/* compatibility with FreeBSD */
185
# ifdef YYPARSE_PARAM_TYPE
186
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
187
# else
188
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
189
# endif
190
#else
191
# define YYPARSE_DECL() yyparse(void)
192
#endif
193
194
/* Parameters sent to lex. */
195
#ifdef YYLEX_PARAM
196
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
197
# define YYLEX yylex(YYLEX_PARAM)
198
#else
199
# define YYLEX_DECL() yylex(void)
200
# define YYLEX yylex()
201
#endif
202
203
/* Parameters sent to yyerror. */
204
#ifndef YYERROR_DECL
205
#define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s)
206
#endif
207
#ifndef YYERROR_CALL
208
#define YYERROR_CALL(msg) yyerror(&yylloc, msg)
209
#endif
210
211
#ifndef YYDESTRUCT_DECL
212
#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)
213
#endif
214
#ifndef YYDESTRUCT_CALL
215
#define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)
216
#endif
217
218
extern int YYPARSE_DECL();
219
220
#define PREFIX 257
221
#define POSTFIX 258
222
#define ID 259
223
#define CONSTANT 260
224
#define EXTERN 261
225
#define REGISTER 262
226
#define STATIC 263
227
#define CONST 264
228
#define VOLATILE 265
229
#define IF 266
230
#define THEN 267
231
#define ELSE 268
232
#define CLCL 269
233
#define YYERRCODE 256
234
typedef int YYINT;
235
static const YYINT demo_lhs[] = { -1,
236
15, 15, 15, 12, 18, 0, 4, 19, 4, 2,
237
20, 2, 10, 10, 13, 13, 11, 11, 11, 11,
238
11, 14, 14, 21, 22, 3, 3, 8, 8, 23,
239
24, 8, 8, 8, 8, 16, 16, 17, 17, 9,
240
1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
241
25, 26, 5, 5, 27, 5, 6, 6, 7,
242
};
243
static const YYINT demo_len[] = { 2,
244
0, 1, 3, 2, 0, 2, 0, 0, 3, 3,
245
0, 4, 1, 3, 0, 2, 1, 1, 1, 1,
246
1, 1, 1, 0, 0, 5, 1, 0, 1, 0,
247
0, 5, 5, 5, 6, 0, 1, 4, 1, 2,
248
4, 4, 4, 4, 4, 3, 1, 1, 1, 2,
249
0, 0, 11, 8, 0, 2, 0, 3, 4,
250
};
251
static const YYINT demo_defred[] = { 5,
252
0, 7, 0, 0, 19, 20, 21, 22, 23, 2,
253
9, 0, 13, 18, 17, 0, 15, 30, 29, 0,
254
0, 0, 0, 0, 31, 10, 24, 24, 24, 0,
255
14, 3, 16, 25, 0, 25, 0, 0, 8, 12,
256
0, 0, 0, 39, 0, 0, 0, 8, 47, 48,
257
0, 57, 0, 32, 0, 0, 15, 30, 0, 30,
258
30, 30, 30, 30, 34, 0, 0, 0, 46, 0,
259
0, 0, 0, 0, 59, 0, 38, 0, 0, 43,
260
45, 44, 0, 0, 49, 58, 0, 30, 50, 56,
261
0, 0, 0, 51, 0, 0, 52, 0, 53,
262
};
263
#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
264
static const YYINT demo_stos[] = { 0,
265
271, 289, 275, 290, 261, 262, 263, 264, 265, 269,
266
273, 281, 282, 283, 285, 286, 42, 40, 259, 274,
267
279, 290, 259, 284, 294, 59, 44, 40, 91, 291,
268
282, 269, 285, 292, 295, 292, 292, 292, 123, 278,
269
293, 279, 293, 280, 281, 287, 288, 42, 259, 260,
270
272, 290, 279, 41, 279, 279, 41, 44, 290, 43,
271
45, 42, 47, 37, 93, 277, 284, 294, 272, 294,
272
294, 294, 294, 294, 125, 290, 280, 272, 272, 272,
273
272, 272, 266, 272, 273, 276, 298, 40, 59, 278,
274
294, 272, 41, 267, 296, 276, 268, 297, 276,
275
};
276
#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
277
static const YYINT demo_dgoto[] = { 1,
278
84, 85, 20, 3, 86, 66, 40, 21, 44, 12,
279
13, 14, 24, 15, 16, 46, 47, 2, 22, 30,
280
34, 41, 25, 35, 95, 98, 87,
281
};
282
static const YYINT demo_sindex[] = { 0,
283
0, 0, 0, -103, 0, 0, 0, 0, 0, 0,
284
0, -31, 0, 0, 0, -238, 0, 0, 0, 4,
285
-36, -103, 0, -133, 0, 0, 0, 0, 0, -94,
286
0, 0, 0, 0, -40, 0, -103, -33, 0, 0,
287
-40, -25, -40, 0, -31, 8, 15, 0, 0, 0,
288
-2, 0, -36, 0, -36, -36, 0, 0, -33, 0,
289
0, 0, 0, 0, 0, -92, -133, -103, 0, -33,
290
-33, -33, -33, -33, 0, -8, 0, 23, 23, 0,
291
0, 0, 11, 75, 0, 0, -94, 0, 0, 0,
292
-33, 96, -194, 0, -8, 0, 0, -8, 0,
293
};
294
static const YYINT demo_rindex[] = { 0,
295
0, 0, 1, -181, 0, 0, 0, 0, 0, 0,
296
0, 17, 0, 0, 0, 0, 0, 0, 0, 0,
297
-39, -181, 12, -34, 0, 0, 0, 0, 0, 0,
298
0, 0, 0, 0, -5, 0, -11, 0, 0, 0,
299
-17, 0, 28, 0, -41, 0, 47, 0, 0, 0,
300
0, 0, -13, 0, 18, 70, 0, 0, 0, 0,
301
0, 0, 0, 0, 0, -19, -27, -181, 0, 0,
302
0, 0, 0, 0, 0, -29, 0, 56, 64, 0,
303
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
304
0, 0, 0, 0, -29, -30, 0, -29, 0,
305
};
306
#if YYBTYACC
307
static const YYINT demo_cindex[] = { 0,
308
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
309
0, -22, 0, 0, 0, 0, 0, 0, 0, 0,
310
0, 0, -179, 0, 0, 0, 0, 0, 0, 0,
311
0, 0, 0, 0, 52, 0, 0, 0, 0, 0,
312
58, 0, 62, 0, -21, 0, 0, 0, 0, 0,
313
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
314
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
315
0, 0, 0, 0, 0, -146, 0, 0, 0, 0,
316
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
317
0, 0, 0, 0, -143, -147, 0, -134, 0,
318
};
319
#endif
320
static const YYINT demo_gindex[] = { 0,
321
9, 143, 0, 0, 50, 0, 63, 101, 83, 7,
322
130, 0, 98, 2, 0, 0, 0, 0, 19, 0,
323
10, 117, 66, 0, 0, 0, 0,
324
};
325
#define YYTABLESIZE 286
326
static const YYINT demo_table[] = { 28,
327
6, 17, 28, 28, 27, 24, 24, 24, 48, 24,
328
17, 54, 35, 35, 28, 54, 35, 0, 0, 27,
329
23, 4, 8, 28, 24, 33, 28, 33, 39, 36,
330
33, 35, 75, 48, 64, 28, 36, 37, 38, 62,
331
60, 28, 61, 45, 63, 33, 51, 27, 57, 28,
332
88, 4, 4, 4, 29, 4, 24, 52, 58, 64,
333
28, 26, 26, 35, 62, 29, 59, 69, 33, 63,
334
4, 28, 94, 28, 45, 28, 26, 1, 78, 79,
335
80, 81, 82, 11, 76, 28, 28, 37, 24, 6,
336
65, 0, 54, 55, 54, 35, 41, 0, 41, 92,
337
41, 0, 4, 8, 42, 28, 42, 28, 42, 33,
338
40, 64, 9, 40, 41, 9, 62, 60, 28, 61,
339
12, 63, 42, 68, 9, 70, 71, 72, 73, 74,
340
8, 9, 64, 89, 4, 42, 93, 62, 60, 28,
341
61, 53, 63, 55, 96, 56, 11, 99, 41, 90,
342
77, 31, 43, 91, 67, 0, 42, 5, 6, 7,
343
8, 9, 0, 0, 0, 10, 0, 0, 0, 0,
344
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
346
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
347
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
348
0, 0, 0, 0, 0, 0, 0, 0, 19, 8,
349
8, 8, 8, 8, 24, 49, 50, 8, 54, 54,
350
54, 54, 54, 54, 54, 54, 3, 3, 54, 8,
351
8, 8, 8, 8, 8, 8, 8, 1, 0, 8,
352
0, 50, 5, 6, 7, 8, 9, 83, 0, 8,
353
10, 8, 8, 8, 8, 8, 0, 0, 0, 8,
354
4, 0, 4, 4, 4, 4, 4, 8, 8, 8,
355
8, 8, 0, 0, 0, 8,
356
};
357
static const YYINT demo_check[] = { 41,
358
0, 42, 44, 40, 44, 40, 41, 42, 42, 44,
359
42, 42, 40, 41, 40, 41, 44, 40, 40, 59,
360
259, 3, 42, 41, 59, 24, 44, 41, 123, 41,
361
44, 59, 125, 42, 37, 41, 27, 28, 29, 42,
362
43, 59, 45, 37, 47, 59, 38, 44, 41, 91,
363
40, 40, 41, 42, 91, 44, 91, 39, 44, 37,
364
44, 44, 59, 91, 42, 91, 48, 59, 67, 47,
365
59, 44, 267, 91, 68, 59, 59, 259, 70, 71,
366
72, 73, 74, 123, 66, 91, 59, 41, 123, 269,
367
93, 40, 123, 123, 125, 123, 41, 40, 43, 91,
368
45, 40, 91, 123, 41, 123, 43, 91, 45, 123,
369
41, 37, 259, 44, 59, 259, 42, 43, 91, 45,
370
268, 47, 59, 58, 259, 60, 61, 62, 63, 64,
371
264, 265, 37, 59, 123, 35, 41, 42, 43, 123,
372
45, 41, 47, 43, 95, 45, 4, 98, 93, 87,
373
68, 22, 36, 88, 57, -1, 93, 261, 262, 263,
374
264, 265, -1, -1, -1, 269, -1, -1, -1, -1,
375
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
376
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
377
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
378
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
379
-1, -1, -1, -1, -1, -1, -1, -1, 259, 261,
380
262, 263, 264, 265, 259, 259, 260, 269, 259, 260,
381
261, 262, 263, 264, 265, 266, 259, 259, 269, 259,
382
260, 261, 262, 263, 264, 265, 266, 259, -1, 269,
383
-1, 260, 261, 262, 263, 264, 265, 266, -1, 259,
384
269, 261, 262, 263, 264, 265, -1, -1, -1, 269,
385
259, -1, 261, 262, 263, 264, 265, 261, 262, 263,
386
264, 265, -1, -1, -1, 269,
387
};
388
#if YYBTYACC
389
static const YYINT demo_ctable[] = { 18,
390
28, -1, 19, 8, -1, 32, 4, -1, 49, 1,
391
-1, 97, 54, -1, -1, -1, -1, -1, -1, -1,
392
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
393
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
394
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
395
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
396
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
397
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
398
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
399
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
400
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
401
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
402
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
403
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
404
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
405
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
406
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
407
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
408
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
409
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
410
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
411
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
412
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
413
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
414
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
415
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
416
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
417
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
418
-1, -1, -1, -1, -1,
419
};
420
#endif
421
#define YYFINAL 1
422
#ifndef YYDEBUG
423
#define YYDEBUG 0
424
#endif
425
#define YYMAXTOKEN 269
426
#define YYUNDFTOKEN 299
427
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
428
#if YYDEBUG
429
static const char *const demo_name[] = {
430
431
"$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
432
"'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,
433
"';'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,
434
"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,
435
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
436
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
437
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
438
0,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN",
439
"REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept",
440
"input","expr","decl","declarator_list","decl_list","statement",
441
"statement_list","block_statement","declarator","formal_arg","decl_specs",
442
"decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list",
443
"nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8",
444
"$$9","$$10","illegal-symbol",
445
};
446
static const char *const demo_rule[] = {
447
"$accept : input",
448
"opt_scope :",
449
"opt_scope : CLCL",
450
"opt_scope : opt_scope ID CLCL",
451
"typename : opt_scope ID",
452
"$$1 :",
453
"input : $$1 decl_list",
454
"decl_list :",
455
"$$2 :",
456
"decl_list : decl_list $$2 decl",
457
"decl : decl_specs declarator_list ';'",
458
"$$3 :",
459
"decl : decl_specs declarator $$3 block_statement",
460
"decl_specs : decl_spec",
461
"decl_specs : decl_specs $$2 decl_spec",
462
"cv_quals :",
463
"cv_quals : cv_quals cv_qual",
464
"decl_spec : cv_qual",
465
"decl_spec : typename",
466
"decl_spec : EXTERN",
467
"decl_spec : REGISTER",
468
"decl_spec : STATIC",
469
"cv_qual : CONST",
470
"cv_qual : VOLATILE",
471
"$$4 :",
472
"$$5 :",
473
"declarator_list : declarator_list ',' $$4 $$5 declarator",
474
"declarator_list : declarator",
475
"declarator :",
476
"declarator : ID",
477
"$$6 :",
478
"$$7 :",
479
"declarator : '(' $$6 $$7 declarator ')'",
480
"declarator : '*' cv_quals $$4 $$5 declarator",
481
"declarator : declarator '[' $$4 expr ']'",
482
"declarator : declarator '(' $$4 formal_arg_list ')' cv_quals",
483
"formal_arg_list :",
484
"formal_arg_list : nonempty_formal_arg_list",
485
"nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg",
486
"nonempty_formal_arg_list : formal_arg",
487
"formal_arg : decl_specs declarator",
488
"expr : expr '+' $$6 expr",
489
"expr : expr '-' $$6 expr",
490
"expr : expr '*' $$6 expr",
491
"expr : expr '%' $$6 expr",
492
"expr : expr '/' $$6 expr",
493
"expr : '*' $$2 expr",
494
"expr : ID",
495
"expr : CONSTANT",
496
"statement : decl",
497
"statement : expr ';'",
498
"$$8 :",
499
"$$9 :",
500
"statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement",
501
"statement : IF '(' $$6 expr ')' THEN $$8 statement",
502
"$$10 :",
503
"statement : $$10 block_statement",
504
"statement_list :",
505
"statement_list : statement_list $$2 statement",
506
"block_statement : '{' $$2 statement_list '}'",
507
508
};
509
#endif
510
511
#if YYDEBUG
512
int yydebug;
513
#endif
514
515
int yyerrflag;
516
int yychar;
517
YYSTYPE yyval;
518
YYSTYPE yylval;
519
int yynerrs;
520
521
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
522
YYLTYPE yyloc; /* position returned by actions */
523
YYLTYPE yylloc; /* position from the lexer */
524
#endif
525
526
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
527
#ifndef YYLLOC_DEFAULT
528
#define YYLLOC_DEFAULT(loc, rhs, n) \
529
do \
530
{ \
531
if (n == 0) \
532
{ \
533
(loc).first_line = YYRHSLOC(rhs, 0).last_line; \
534
(loc).first_column = YYRHSLOC(rhs, 0).last_column; \
535
(loc).last_line = YYRHSLOC(rhs, 0).last_line; \
536
(loc).last_column = YYRHSLOC(rhs, 0).last_column; \
537
} \
538
else \
539
{ \
540
(loc).first_line = YYRHSLOC(rhs, 1).first_line; \
541
(loc).first_column = YYRHSLOC(rhs, 1).first_column; \
542
(loc).last_line = YYRHSLOC(rhs, n).last_line; \
543
(loc).last_column = YYRHSLOC(rhs, n).last_column; \
544
} \
545
} while (0)
546
#endif /* YYLLOC_DEFAULT */
547
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
548
#if YYBTYACC
549
550
#ifndef YYLVQUEUEGROWTH
551
#define YYLVQUEUEGROWTH 32
552
#endif
553
#endif /* YYBTYACC */
554
555
/* define the initial stack-sizes */
556
#ifdef YYSTACKSIZE
557
#undef YYMAXDEPTH
558
#define YYMAXDEPTH YYSTACKSIZE
559
#else
560
#ifdef YYMAXDEPTH
561
#define YYSTACKSIZE YYMAXDEPTH
562
#else
563
#define YYSTACKSIZE 10000
564
#define YYMAXDEPTH 10000
565
#endif
566
#endif
567
568
#ifndef YYINITSTACKSIZE
569
#define YYINITSTACKSIZE 200
570
#endif
571
572
typedef struct {
573
unsigned stacksize;
574
YYINT *s_base;
575
YYINT *s_mark;
576
YYINT *s_last;
577
YYSTYPE *l_base;
578
YYSTYPE *l_mark;
579
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
580
YYLTYPE *p_base;
581
YYLTYPE *p_mark;
582
#endif
583
} YYSTACKDATA;
584
#if YYBTYACC
585
586
struct YYParseState_s
587
{
588
struct YYParseState_s *save; /* Previously saved parser state */
589
YYSTACKDATA yystack; /* saved parser stack */
590
int state; /* saved parser state */
591
int errflag; /* saved error recovery status */
592
int lexeme; /* saved index of the conflict lexeme in the lexical queue */
593
YYINT ctry; /* saved index in yyctable[] for this conflict */
594
};
595
typedef struct YYParseState_s YYParseState;
596
#endif /* YYBTYACC */
597
/* variables for the parser stack */
598
static YYSTACKDATA yystack;
599
#if YYBTYACC
600
601
/* Current parser state */
602
static YYParseState *yyps = 0;
603
604
/* yypath != NULL: do the full parse, starting at *yypath parser state. */
605
static YYParseState *yypath = 0;
606
607
/* Base of the lexical value queue */
608
static YYSTYPE *yylvals = 0;
609
610
/* Current position at lexical value queue */
611
static YYSTYPE *yylvp = 0;
612
613
/* End position of lexical value queue */
614
static YYSTYPE *yylve = 0;
615
616
/* The last allocated position at the lexical value queue */
617
static YYSTYPE *yylvlim = 0;
618
619
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
620
/* Base of the lexical position queue */
621
static YYLTYPE *yylpsns = 0;
622
623
/* Current position at lexical position queue */
624
static YYLTYPE *yylpp = 0;
625
626
/* End position of lexical position queue */
627
static YYLTYPE *yylpe = 0;
628
629
/* The last allocated position at the lexical position queue */
630
static YYLTYPE *yylplim = 0;
631
#endif
632
633
/* Current position at lexical token queue */
634
static YYINT *yylexp = 0;
635
636
static YYINT *yylexemes = 0;
637
#endif /* YYBTYACC */
638
#line 200 "btyacc_demo.y"
639
640
extern int YYLEX_DECL();
641
extern void YYERROR_DECL();
642
643
extern Scope *global_scope;
644
645
extern Decl * lookup(Scope *scope, char *id);
646
extern Scope * new_scope(Scope *outer_scope);
647
extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);
648
extern void finish_fn_def(Decl *fn_decl, Code *block);
649
extern Type * type_combine(Type *specs, Type *spec);
650
extern Type * bare_extern(void);
651
extern Type * bare_register(void);
652
extern Type * bare_static(void);
653
extern Type * bare_const(void);
654
extern Type * bare_volatile(void);
655
extern Decl * declare(Scope *scope, char *id, Type *type);
656
extern Decl * make_pointer(Decl *decl, Type *type);
657
extern Decl * make_array(Type *type, Expr *expr);
658
extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);
659
extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);
660
extern Decl_List * build_dlist(Decl *decl);
661
extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);
662
extern Expr * var_expr(Scope *scope, char *id);
663
extern Code * build_expr_code(Expr *expr);
664
extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
665
extern Code * code_append(Code *stmt_list, Code *stmt);
666
#line 667 "btyacc_demo.tab.c"
667
668
/* Release memory associated with symbol. */
669
#if ! defined YYDESTRUCT_IS_DECLARED
670
static void
671
YYDESTRUCT_DECL()
672
{
673
switch (psymb)
674
{
675
case 43:
676
#line 83 "btyacc_demo.y"
677
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
678
msg,
679
(*loc).first_line, (*loc).first_column,
680
(*loc).last_line, (*loc).last_column);
681
/* in this example, we don't know what to do here */ }
682
#line 683 "btyacc_demo.tab.c"
683
break;
684
case 45:
685
#line 83 "btyacc_demo.y"
686
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
687
msg,
688
(*loc).first_line, (*loc).first_column,
689
(*loc).last_line, (*loc).last_column);
690
/* in this example, we don't know what to do here */ }
691
#line 692 "btyacc_demo.tab.c"
692
break;
693
case 42:
694
#line 83 "btyacc_demo.y"
695
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
696
msg,
697
(*loc).first_line, (*loc).first_column,
698
(*loc).last_line, (*loc).last_column);
699
/* in this example, we don't know what to do here */ }
700
#line 701 "btyacc_demo.tab.c"
701
break;
702
case 47:
703
#line 83 "btyacc_demo.y"
704
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
705
msg,
706
(*loc).first_line, (*loc).first_column,
707
(*loc).last_line, (*loc).last_column);
708
/* in this example, we don't know what to do here */ }
709
#line 710 "btyacc_demo.tab.c"
710
break;
711
case 37:
712
#line 83 "btyacc_demo.y"
713
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
714
msg,
715
(*loc).first_line, (*loc).first_column,
716
(*loc).last_line, (*loc).last_column);
717
/* in this example, we don't know what to do here */ }
718
#line 719 "btyacc_demo.tab.c"
719
break;
720
case 257:
721
#line 83 "btyacc_demo.y"
722
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
723
msg,
724
(*loc).first_line, (*loc).first_column,
725
(*loc).last_line, (*loc).last_column);
726
/* in this example, we don't know what to do here */ }
727
#line 728 "btyacc_demo.tab.c"
728
break;
729
case 258:
730
#line 83 "btyacc_demo.y"
731
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
732
msg,
733
(*loc).first_line, (*loc).first_column,
734
(*loc).last_line, (*loc).last_column);
735
/* in this example, we don't know what to do here */ }
736
#line 737 "btyacc_demo.tab.c"
737
break;
738
case 40:
739
#line 83 "btyacc_demo.y"
740
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
741
msg,
742
(*loc).first_line, (*loc).first_column,
743
(*loc).last_line, (*loc).last_column);
744
/* in this example, we don't know what to do here */ }
745
#line 746 "btyacc_demo.tab.c"
746
break;
747
case 91:
748
#line 83 "btyacc_demo.y"
749
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
750
msg,
751
(*loc).first_line, (*loc).first_column,
752
(*loc).last_line, (*loc).last_column);
753
/* in this example, we don't know what to do here */ }
754
#line 755 "btyacc_demo.tab.c"
755
break;
756
case 46:
757
#line 83 "btyacc_demo.y"
758
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
759
msg,
760
(*loc).first_line, (*loc).first_column,
761
(*loc).last_line, (*loc).last_column);
762
/* in this example, we don't know what to do here */ }
763
#line 764 "btyacc_demo.tab.c"
764
break;
765
case 259:
766
#line 78 "btyacc_demo.y"
767
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
768
msg,
769
(*loc).first_line, (*loc).first_column,
770
(*loc).last_line, (*loc).last_column);
771
free((*val).id); }
772
#line 773 "btyacc_demo.tab.c"
773
break;
774
case 260:
775
#line 78 "btyacc_demo.y"
776
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
777
msg,
778
(*loc).first_line, (*loc).first_column,
779
(*loc).last_line, (*loc).last_column);
780
free((*val).expr); }
781
#line 782 "btyacc_demo.tab.c"
782
break;
783
case 261:
784
#line 83 "btyacc_demo.y"
785
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
786
msg,
787
(*loc).first_line, (*loc).first_column,
788
(*loc).last_line, (*loc).last_column);
789
/* in this example, we don't know what to do here */ }
790
#line 791 "btyacc_demo.tab.c"
791
break;
792
case 262:
793
#line 83 "btyacc_demo.y"
794
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
795
msg,
796
(*loc).first_line, (*loc).first_column,
797
(*loc).last_line, (*loc).last_column);
798
/* in this example, we don't know what to do here */ }
799
#line 800 "btyacc_demo.tab.c"
800
break;
801
case 263:
802
#line 83 "btyacc_demo.y"
803
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
804
msg,
805
(*loc).first_line, (*loc).first_column,
806
(*loc).last_line, (*loc).last_column);
807
/* in this example, we don't know what to do here */ }
808
#line 809 "btyacc_demo.tab.c"
809
break;
810
case 264:
811
#line 83 "btyacc_demo.y"
812
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
813
msg,
814
(*loc).first_line, (*loc).first_column,
815
(*loc).last_line, (*loc).last_column);
816
/* in this example, we don't know what to do here */ }
817
#line 818 "btyacc_demo.tab.c"
818
break;
819
case 265:
820
#line 83 "btyacc_demo.y"
821
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
822
msg,
823
(*loc).first_line, (*loc).first_column,
824
(*loc).last_line, (*loc).last_column);
825
/* in this example, we don't know what to do here */ }
826
#line 827 "btyacc_demo.tab.c"
827
break;
828
case 266:
829
#line 83 "btyacc_demo.y"
830
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
831
msg,
832
(*loc).first_line, (*loc).first_column,
833
(*loc).last_line, (*loc).last_column);
834
/* in this example, we don't know what to do here */ }
835
#line 836 "btyacc_demo.tab.c"
836
break;
837
case 267:
838
#line 83 "btyacc_demo.y"
839
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
840
msg,
841
(*loc).first_line, (*loc).first_column,
842
(*loc).last_line, (*loc).last_column);
843
/* in this example, we don't know what to do here */ }
844
#line 845 "btyacc_demo.tab.c"
845
break;
846
case 268:
847
#line 83 "btyacc_demo.y"
848
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
849
msg,
850
(*loc).first_line, (*loc).first_column,
851
(*loc).last_line, (*loc).last_column);
852
/* in this example, we don't know what to do here */ }
853
#line 854 "btyacc_demo.tab.c"
854
break;
855
case 269:
856
#line 83 "btyacc_demo.y"
857
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
858
msg,
859
(*loc).first_line, (*loc).first_column,
860
(*loc).last_line, (*loc).last_column);
861
/* in this example, we don't know what to do here */ }
862
#line 863 "btyacc_demo.tab.c"
863
break;
864
case 59:
865
#line 83 "btyacc_demo.y"
866
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
867
msg,
868
(*loc).first_line, (*loc).first_column,
869
(*loc).last_line, (*loc).last_column);
870
/* in this example, we don't know what to do here */ }
871
#line 872 "btyacc_demo.tab.c"
872
break;
873
case 44:
874
#line 83 "btyacc_demo.y"
875
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
876
msg,
877
(*loc).first_line, (*loc).first_column,
878
(*loc).last_line, (*loc).last_column);
879
/* in this example, we don't know what to do here */ }
880
#line 881 "btyacc_demo.tab.c"
881
break;
882
case 41:
883
#line 83 "btyacc_demo.y"
884
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
885
msg,
886
(*loc).first_line, (*loc).first_column,
887
(*loc).last_line, (*loc).last_column);
888
/* in this example, we don't know what to do here */ }
889
#line 890 "btyacc_demo.tab.c"
890
break;
891
case 93:
892
#line 83 "btyacc_demo.y"
893
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
894
msg,
895
(*loc).first_line, (*loc).first_column,
896
(*loc).last_line, (*loc).last_column);
897
/* in this example, we don't know what to do here */ }
898
#line 899 "btyacc_demo.tab.c"
899
break;
900
case 123:
901
#line 83 "btyacc_demo.y"
902
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
903
msg,
904
(*loc).first_line, (*loc).first_column,
905
(*loc).last_line, (*loc).last_column);
906
/* in this example, we don't know what to do here */ }
907
#line 908 "btyacc_demo.tab.c"
908
break;
909
case 125:
910
#line 83 "btyacc_demo.y"
911
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
912
msg,
913
(*loc).first_line, (*loc).first_column,
914
(*loc).last_line, (*loc).last_column);
915
/* in this example, we don't know what to do here */ }
916
#line 917 "btyacc_demo.tab.c"
917
break;
918
case 270:
919
#line 83 "btyacc_demo.y"
920
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
921
msg,
922
(*loc).first_line, (*loc).first_column,
923
(*loc).last_line, (*loc).last_column);
924
/* in this example, we don't know what to do here */ }
925
#line 926 "btyacc_demo.tab.c"
926
break;
927
case 271:
928
#line 83 "btyacc_demo.y"
929
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
930
msg,
931
(*loc).first_line, (*loc).first_column,
932
(*loc).last_line, (*loc).last_column);
933
/* in this example, we don't know what to do here */ }
934
#line 935 "btyacc_demo.tab.c"
935
break;
936
case 272:
937
#line 78 "btyacc_demo.y"
938
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
939
msg,
940
(*loc).first_line, (*loc).first_column,
941
(*loc).last_line, (*loc).last_column);
942
free((*val).expr); }
943
#line 944 "btyacc_demo.tab.c"
944
break;
945
case 273:
946
#line 67 "btyacc_demo.y"
947
{ /* 'msg' is a 'char *' indicating the context of destructor invocation*/
948
printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",
949
msg,
950
(*loc).first_line, (*loc).first_column,
951
(*loc).last_line, (*loc).last_column);
952
free((*val).decl->scope); free((*val).decl->type); }
953
#line 954 "btyacc_demo.tab.c"
954
break;
955
case 274:
956
#line 83 "btyacc_demo.y"
957
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
958
msg,
959
(*loc).first_line, (*loc).first_column,
960
(*loc).last_line, (*loc).last_column);
961
/* in this example, we don't know what to do here */ }
962
#line 963 "btyacc_demo.tab.c"
963
break;
964
case 275:
965
#line 83 "btyacc_demo.y"
966
{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
967
msg,
968
(*loc).first_line, (*loc).first_column,
969
(*loc).last_line, (*loc).last_column);
970
/* in this example, we don't know what to do here */ }
971
#line 972 "btyacc_demo.tab.c"
972
break;
973
case 276:
974
#line 78 "btyacc_demo.y"
975
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
976
msg,
977
(*loc).first_line, (*loc).first_column,
978
(*loc).last_line, (*loc).last_column);
979
free((*val).code); }
980
#line 981 "btyacc_demo.tab.c"
981
break;
982
case 277:
983
#line 78 "btyacc_demo.y"
984
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
985
msg,
986
(*loc).first_line, (*loc).first_column,
987
(*loc).last_line, (*loc).last_column);
988
free((*val).code); }
989
#line 990 "btyacc_demo.tab.c"
990
break;
991
case 278:
992
#line 78 "btyacc_demo.y"
993
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
994
msg,
995
(*loc).first_line, (*loc).first_column,
996
(*loc).last_line, (*loc).last_column);
997
free((*val).code); }
998
#line 999 "btyacc_demo.tab.c"
999
break;
1000
case 279:
1001
#line 73 "btyacc_demo.y"
1002
{ printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1003
msg,
1004
(*loc).first_line, (*loc).first_column,
1005
(*loc).last_line, (*loc).last_column);
1006
free((*val).decl); }
1007
#line 1008 "btyacc_demo.tab.c"
1008
break;
1009
case 280:
1010
#line 73 "btyacc_demo.y"
1011
{ printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1012
msg,
1013
(*loc).first_line, (*loc).first_column,
1014
(*loc).last_line, (*loc).last_column);
1015
free((*val).decl); }
1016
#line 1017 "btyacc_demo.tab.c"
1017
break;
1018
case 281:
1019
#line 78 "btyacc_demo.y"
1020
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1021
msg,
1022
(*loc).first_line, (*loc).first_column,
1023
(*loc).last_line, (*loc).last_column);
1024
free((*val).type); }
1025
#line 1026 "btyacc_demo.tab.c"
1026
break;
1027
case 282:
1028
#line 78 "btyacc_demo.y"
1029
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1030
msg,
1031
(*loc).first_line, (*loc).first_column,
1032
(*loc).last_line, (*loc).last_column);
1033
free((*val).type); }
1034
#line 1035 "btyacc_demo.tab.c"
1035
break;
1036
case 283:
1037
#line 78 "btyacc_demo.y"
1038
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1039
msg,
1040
(*loc).first_line, (*loc).first_column,
1041
(*loc).last_line, (*loc).last_column);
1042
free((*val).type); }
1043
#line 1044 "btyacc_demo.tab.c"
1044
break;
1045
case 284:
1046
#line 78 "btyacc_demo.y"
1047
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1048
msg,
1049
(*loc).first_line, (*loc).first_column,
1050
(*loc).last_line, (*loc).last_column);
1051
free((*val).type); }
1052
#line 1053 "btyacc_demo.tab.c"
1053
break;
1054
case 285:
1055
#line 78 "btyacc_demo.y"
1056
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1057
msg,
1058
(*loc).first_line, (*loc).first_column,
1059
(*loc).last_line, (*loc).last_column);
1060
free((*val).type); }
1061
#line 1062 "btyacc_demo.tab.c"
1062
break;
1063
case 286:
1064
#line 78 "btyacc_demo.y"
1065
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1066
msg,
1067
(*loc).first_line, (*loc).first_column,
1068
(*loc).last_line, (*loc).last_column);
1069
free((*val).scope); }
1070
#line 1071 "btyacc_demo.tab.c"
1071
break;
1072
case 287:
1073
#line 78 "btyacc_demo.y"
1074
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1075
msg,
1076
(*loc).first_line, (*loc).first_column,
1077
(*loc).last_line, (*loc).last_column);
1078
free((*val).dlist); }
1079
#line 1080 "btyacc_demo.tab.c"
1080
break;
1081
case 288:
1082
#line 78 "btyacc_demo.y"
1083
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1084
msg,
1085
(*loc).first_line, (*loc).first_column,
1086
(*loc).last_line, (*loc).last_column);
1087
free((*val).dlist); }
1088
#line 1089 "btyacc_demo.tab.c"
1089
break;
1090
case 289:
1091
#line 78 "btyacc_demo.y"
1092
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1093
msg,
1094
(*loc).first_line, (*loc).first_column,
1095
(*loc).last_line, (*loc).last_column);
1096
free((*val).scope); }
1097
#line 1098 "btyacc_demo.tab.c"
1098
break;
1099
case 290:
1100
#line 78 "btyacc_demo.y"
1101
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1102
msg,
1103
(*loc).first_line, (*loc).first_column,
1104
(*loc).last_line, (*loc).last_column);
1105
free((*val).scope); }
1106
#line 1107 "btyacc_demo.tab.c"
1107
break;
1108
case 291:
1109
#line 78 "btyacc_demo.y"
1110
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1111
msg,
1112
(*loc).first_line, (*loc).first_column,
1113
(*loc).last_line, (*loc).last_column);
1114
free((*val).scope); }
1115
#line 1116 "btyacc_demo.tab.c"
1116
break;
1117
case 292:
1118
#line 78 "btyacc_demo.y"
1119
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1120
msg,
1121
(*loc).first_line, (*loc).first_column,
1122
(*loc).last_line, (*loc).last_column);
1123
free((*val).scope); }
1124
#line 1125 "btyacc_demo.tab.c"
1125
break;
1126
case 293:
1127
#line 78 "btyacc_demo.y"
1128
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1129
msg,
1130
(*loc).first_line, (*loc).first_column,
1131
(*loc).last_line, (*loc).last_column);
1132
free((*val).type); }
1133
#line 1134 "btyacc_demo.tab.c"
1134
break;
1135
case 294:
1136
#line 78 "btyacc_demo.y"
1137
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1138
msg,
1139
(*loc).first_line, (*loc).first_column,
1140
(*loc).last_line, (*loc).last_column);
1141
free((*val).scope); }
1142
#line 1143 "btyacc_demo.tab.c"
1143
break;
1144
case 295:
1145
#line 78 "btyacc_demo.y"
1146
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1147
msg,
1148
(*loc).first_line, (*loc).first_column,
1149
(*loc).last_line, (*loc).last_column);
1150
free((*val).type); }
1151
#line 1152 "btyacc_demo.tab.c"
1152
break;
1153
case 296:
1154
#line 78 "btyacc_demo.y"
1155
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1156
msg,
1157
(*loc).first_line, (*loc).first_column,
1158
(*loc).last_line, (*loc).last_column);
1159
free((*val).scope); }
1160
#line 1161 "btyacc_demo.tab.c"
1161
break;
1162
case 297:
1163
#line 78 "btyacc_demo.y"
1164
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1165
msg,
1166
(*loc).first_line, (*loc).first_column,
1167
(*loc).last_line, (*loc).last_column);
1168
free((*val).scope); }
1169
#line 1170 "btyacc_demo.tab.c"
1170
break;
1171
case 298:
1172
#line 78 "btyacc_demo.y"
1173
{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1174
msg,
1175
(*loc).first_line, (*loc).first_column,
1176
(*loc).last_line, (*loc).last_column);
1177
free((*val).scope); }
1178
#line 1179 "btyacc_demo.tab.c"
1179
break;
1180
}
1181
}
1182
#define YYDESTRUCT_IS_DECLARED 1
1183
#endif
1184
1185
/* For use in generated program */
1186
#define yydepth (int)(yystack.s_mark - yystack.s_base)
1187
#if YYBTYACC
1188
#define yytrial (yyps->save)
1189
#endif /* YYBTYACC */
1190
1191
#if YYDEBUG
1192
#include <stdio.h> /* needed for printf */
1193
#endif
1194
1195
#include <stdlib.h> /* needed for malloc, etc */
1196
#include <string.h> /* needed for memset */
1197
1198
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
1199
static int yygrowstack(YYSTACKDATA *data)
1200
{
1201
int i;
1202
unsigned newsize;
1203
YYINT *newss;
1204
YYSTYPE *newvs;
1205
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1206
YYLTYPE *newps;
1207
#endif
1208
1209
if ((newsize = data->stacksize) == 0)
1210
newsize = YYINITSTACKSIZE;
1211
else if (newsize >= YYMAXDEPTH)
1212
return YYENOMEM;
1213
else if ((newsize *= 2) > YYMAXDEPTH)
1214
newsize = YYMAXDEPTH;
1215
1216
i = (int) (data->s_mark - data->s_base);
1217
newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1218
if (newss == NULL)
1219
return YYENOMEM;
1220
1221
data->s_base = newss;
1222
data->s_mark = newss + i;
1223
1224
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1225
if (newvs == NULL)
1226
return YYENOMEM;
1227
1228
data->l_base = newvs;
1229
data->l_mark = newvs + i;
1230
1231
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1232
newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
1233
if (newps == NULL)
1234
return YYENOMEM;
1235
1236
data->p_base = newps;
1237
data->p_mark = newps + i;
1238
#endif
1239
1240
data->stacksize = newsize;
1241
data->s_last = data->s_base + newsize - 1;
1242
1243
#if YYDEBUG
1244
if (yydebug)
1245
fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
1246
#endif
1247
return 0;
1248
}
1249
1250
#if YYPURE || defined(YY_NO_LEAKS)
1251
static void yyfreestack(YYSTACKDATA *data)
1252
{
1253
free(data->s_base);
1254
free(data->l_base);
1255
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1256
free(data->p_base);
1257
#endif
1258
memset(data, 0, sizeof(*data));
1259
}
1260
#else
1261
#define yyfreestack(data) /* nothing */
1262
#endif /* YYPURE || defined(YY_NO_LEAKS) */
1263
#if YYBTYACC
1264
1265
static YYParseState *
1266
yyNewState(unsigned size)
1267
{
1268
YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
1269
if (p == NULL) return NULL;
1270
1271
p->yystack.stacksize = size;
1272
if (size == 0)
1273
{
1274
p->yystack.s_base = NULL;
1275
p->yystack.l_base = NULL;
1276
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1277
p->yystack.p_base = NULL;
1278
#endif
1279
return p;
1280
}
1281
p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
1282
if (p->yystack.s_base == NULL) return NULL;
1283
p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
1284
if (p->yystack.l_base == NULL) return NULL;
1285
memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
1286
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1287
p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
1288
if (p->yystack.p_base == NULL) return NULL;
1289
memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
1290
#endif
1291
1292
return p;
1293
}
1294
1295
static void
1296
yyFreeState(YYParseState *p)
1297
{
1298
yyfreestack(&p->yystack);
1299
free(p);
1300
}
1301
#endif /* YYBTYACC */
1302
1303
#define YYABORT goto yyabort
1304
#define YYREJECT goto yyabort
1305
#define YYACCEPT goto yyaccept
1306
#define YYERROR goto yyerrlab
1307
#if YYBTYACC
1308
#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
1309
#define YYVALID_NESTED do { if (yyps->save && \
1310
yyps->save->save == 0) goto yyvalid; } while(0)
1311
#endif /* YYBTYACC */
1312
1313
int
1314
YYPARSE_DECL()
1315
{
1316
int yym, yyn, yystate, yyresult;
1317
#if YYBTYACC
1318
int yynewerrflag;
1319
YYParseState *yyerrctx = NULL;
1320
#endif /* YYBTYACC */
1321
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1322
YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
1323
#endif
1324
#if YYDEBUG
1325
const char *yys;
1326
1327
if ((yys = getenv("YYDEBUG")) != NULL)
1328
{
1329
yyn = *yys;
1330
if (yyn >= '0' && yyn <= '9')
1331
yydebug = yyn - '0';
1332
}
1333
if (yydebug)
1334
fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
1335
#endif
1336
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1337
memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
1338
#endif
1339
1340
#if YYBTYACC
1341
yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1342
yyps->save = 0;
1343
#endif /* YYBTYACC */
1344
yym = 0;
1345
/* yyn is set below */
1346
yynerrs = 0;
1347
yyerrflag = 0;
1348
yychar = YYEMPTY;
1349
yystate = 0;
1350
1351
#if YYPURE
1352
memset(&yystack, 0, sizeof(yystack));
1353
#endif
1354
1355
if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1356
yystack.s_mark = yystack.s_base;
1357
yystack.l_mark = yystack.l_base;
1358
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1359
yystack.p_mark = yystack.p_base;
1360
#endif
1361
yystate = 0;
1362
*yystack.s_mark = 0;
1363
1364
yyloop:
1365
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1366
if (yychar < 0)
1367
{
1368
#if YYBTYACC
1369
do {
1370
if (yylvp < yylve)
1371
{
1372
/* we're currently re-reading tokens */
1373
yylval = *yylvp++;
1374
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1375
yylloc = *yylpp++;
1376
#endif
1377
yychar = *yylexp++;
1378
break;
1379
}
1380
if (yyps->save)
1381
{
1382
/* in trial mode; save scanner results for future parse attempts */
1383
if (yylvp == yylvlim)
1384
{ /* Enlarge lexical value queue */
1385
size_t p = (size_t) (yylvp - yylvals);
1386
size_t s = (size_t) (yylvlim - yylvals);
1387
1388
s += YYLVQUEUEGROWTH;
1389
if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
1390
if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1391
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1392
if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1393
#endif
1394
yylvp = yylve = yylvals + p;
1395
yylvlim = yylvals + s;
1396
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1397
yylpp = yylpe = yylpsns + p;
1398
yylplim = yylpsns + s;
1399
#endif
1400
yylexp = yylexemes + p;
1401
}
1402
*yylexp = (YYINT) YYLEX;
1403
*yylvp++ = yylval;
1404
yylve++;
1405
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1406
*yylpp++ = yylloc;
1407
yylpe++;
1408
#endif
1409
yychar = *yylexp++;
1410
break;
1411
}
1412
/* normal operation, no conflict encountered */
1413
#endif /* YYBTYACC */
1414
yychar = YYLEX;
1415
#if YYBTYACC
1416
} while (0);
1417
#endif /* YYBTYACC */
1418
if (yychar < 0) yychar = YYEOF;
1419
#if YYDEBUG
1420
if (yydebug)
1421
{
1422
if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1423
fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1424
YYDEBUGSTR, yydepth, yystate, yychar, yys);
1425
#ifdef YYSTYPE_TOSTRING
1426
#if YYBTYACC
1427
if (!yytrial)
1428
#endif /* YYBTYACC */
1429
fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1430
#endif
1431
fputc('\n', stderr);
1432
}
1433
#endif
1434
}
1435
#if YYBTYACC
1436
1437
/* Do we have a conflict? */
1438
if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1439
yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1440
{
1441
YYINT ctry;
1442
1443
if (yypath)
1444
{
1445
YYParseState *save;
1446
#if YYDEBUG
1447
if (yydebug)
1448
fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1449
YYDEBUGSTR, yydepth, yystate);
1450
#endif
1451
/* Switch to the next conflict context */
1452
save = yypath;
1453
yypath = save->save;
1454
save->save = NULL;
1455
ctry = save->ctry;
1456
if (save->state != yystate) YYABORT;
1457
yyFreeState(save);
1458
1459
}
1460
else
1461
{
1462
1463
/* Unresolved conflict - start/continue trial parse */
1464
YYParseState *save;
1465
#if YYDEBUG
1466
if (yydebug)
1467
{
1468
fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1469
if (yyps->save)
1470
fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1471
else
1472
fputs("Starting trial parse.\n", stderr);
1473
}
1474
#endif
1475
save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1476
if (save == NULL) goto yyenomem;
1477
save->save = yyps->save;
1478
save->state = yystate;
1479
save->errflag = yyerrflag;
1480
save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1481
memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1482
save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1483
memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1484
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1485
save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1486
memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1487
#endif
1488
ctry = yytable[yyn];
1489
if (yyctable[ctry] == -1)
1490
{
1491
#if YYDEBUG
1492
if (yydebug && yychar >= YYEOF)
1493
fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1494
#endif
1495
ctry++;
1496
}
1497
save->ctry = ctry;
1498
if (yyps->save == NULL)
1499
{
1500
/* If this is a first conflict in the stack, start saving lexemes */
1501
if (!yylexemes)
1502
{
1503
yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
1504
if (yylexemes == NULL) goto yyenomem;
1505
yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1506
if (yylvals == NULL) goto yyenomem;
1507
yylvlim = yylvals + YYLVQUEUEGROWTH;
1508
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1509
yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1510
if (yylpsns == NULL) goto yyenomem;
1511
yylplim = yylpsns + YYLVQUEUEGROWTH;
1512
#endif
1513
}
1514
if (yylvp == yylve)
1515
{
1516
yylvp = yylve = yylvals;
1517
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1518
yylpp = yylpe = yylpsns;
1519
#endif
1520
yylexp = yylexemes;
1521
if (yychar >= YYEOF)
1522
{
1523
*yylve++ = yylval;
1524
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1525
*yylpe++ = yylloc;
1526
#endif
1527
*yylexp = (YYINT) yychar;
1528
yychar = YYEMPTY;
1529
}
1530
}
1531
}
1532
if (yychar >= YYEOF)
1533
{
1534
yylvp--;
1535
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1536
yylpp--;
1537
#endif
1538
yylexp--;
1539
yychar = YYEMPTY;
1540
}
1541
save->lexeme = (int) (yylvp - yylvals);
1542
yyps->save = save;
1543
}
1544
if (yytable[yyn] == ctry)
1545
{
1546
#if YYDEBUG
1547
if (yydebug)
1548
fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1549
YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1550
#endif
1551
if (yychar < 0)
1552
{
1553
yylvp++;
1554
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1555
yylpp++;
1556
#endif
1557
yylexp++;
1558
}
1559
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1560
goto yyoverflow;
1561
yystate = yyctable[ctry];
1562
*++yystack.s_mark = (YYINT) yystate;
1563
*++yystack.l_mark = yylval;
1564
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1565
*++yystack.p_mark = yylloc;
1566
#endif
1567
yychar = YYEMPTY;
1568
if (yyerrflag > 0) --yyerrflag;
1569
goto yyloop;
1570
}
1571
else
1572
{
1573
yyn = yyctable[ctry];
1574
goto yyreduce;
1575
}
1576
} /* End of code dealing with conflicts */
1577
#endif /* YYBTYACC */
1578
if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1579
yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1580
{
1581
#if YYDEBUG
1582
if (yydebug)
1583
fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1584
YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1585
#endif
1586
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1587
yystate = yytable[yyn];
1588
*++yystack.s_mark = yytable[yyn];
1589
*++yystack.l_mark = yylval;
1590
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1591
*++yystack.p_mark = yylloc;
1592
#endif
1593
yychar = YYEMPTY;
1594
if (yyerrflag > 0) --yyerrflag;
1595
goto yyloop;
1596
}
1597
if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1598
yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1599
{
1600
yyn = yytable[yyn];
1601
goto yyreduce;
1602
}
1603
if (yyerrflag != 0) goto yyinrecovery;
1604
#if YYBTYACC
1605
1606
yynewerrflag = 1;
1607
goto yyerrhandler;
1608
goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1609
1610
yyerrlab:
1611
/* explicit YYERROR from an action -- pop the rhs of the rule reduced
1612
* before looking for error recovery */
1613
yystack.s_mark -= yym;
1614
yystate = *yystack.s_mark;
1615
yystack.l_mark -= yym;
1616
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1617
yystack.p_mark -= yym;
1618
#endif
1619
1620
yynewerrflag = 0;
1621
yyerrhandler:
1622
while (yyps->save)
1623
{
1624
int ctry;
1625
YYParseState *save = yyps->save;
1626
#if YYDEBUG
1627
if (yydebug)
1628
fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1629
YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1630
(int)(yylvp - yylvals - yyps->save->lexeme));
1631
#endif
1632
/* Memorize most forward-looking error state in case it's really an error. */
1633
if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1634
{
1635
/* Free old saved error context state */
1636
if (yyerrctx) yyFreeState(yyerrctx);
1637
/* Create and fill out new saved error context state */
1638
yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1639
if (yyerrctx == NULL) goto yyenomem;
1640
yyerrctx->save = yyps->save;
1641
yyerrctx->state = yystate;
1642
yyerrctx->errflag = yyerrflag;
1643
yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1644
memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1645
yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1646
memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1647
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1648
yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1649
memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1650
#endif
1651
yyerrctx->lexeme = (int) (yylvp - yylvals);
1652
}
1653
yylvp = yylvals + save->lexeme;
1654
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1655
yylpp = yylpsns + save->lexeme;
1656
#endif
1657
yylexp = yylexemes + save->lexeme;
1658
yychar = YYEMPTY;
1659
yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1660
memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1661
yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1662
memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1663
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1664
yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1665
memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1666
#endif
1667
ctry = ++save->ctry;
1668
yystate = save->state;
1669
/* We tried shift, try reduce now */
1670
if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1671
yyps->save = save->save;
1672
save->save = NULL;
1673
yyFreeState(save);
1674
1675
/* Nothing left on the stack -- error */
1676
if (!yyps->save)
1677
{
1678
#if YYDEBUG
1679
if (yydebug)
1680
fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1681
YYPREFIX, yydepth);
1682
#endif
1683
/* Restore state as it was in the most forward-advanced error */
1684
yylvp = yylvals + yyerrctx->lexeme;
1685
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1686
yylpp = yylpsns + yyerrctx->lexeme;
1687
#endif
1688
yylexp = yylexemes + yyerrctx->lexeme;
1689
yychar = yylexp[-1];
1690
yylval = yylvp[-1];
1691
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1692
yylloc = yylpp[-1];
1693
#endif
1694
yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1695
memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1696
yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1697
memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1698
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1699
yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1700
memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1701
#endif
1702
yystate = yyerrctx->state;
1703
yyFreeState(yyerrctx);
1704
yyerrctx = NULL;
1705
}
1706
yynewerrflag = 1;
1707
}
1708
if (yynewerrflag == 0) goto yyinrecovery;
1709
#endif /* YYBTYACC */
1710
1711
YYERROR_CALL("syntax error");
1712
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1713
yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1714
#endif
1715
1716
#if !YYBTYACC
1717
goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1718
yyerrlab:
1719
#endif
1720
++yynerrs;
1721
1722
yyinrecovery:
1723
if (yyerrflag < 3)
1724
{
1725
yyerrflag = 3;
1726
for (;;)
1727
{
1728
if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1729
yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1730
{
1731
#if YYDEBUG
1732
if (yydebug)
1733
fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1734
YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1735
#endif
1736
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1737
yystate = yytable[yyn];
1738
*++yystack.s_mark = yytable[yyn];
1739
*++yystack.l_mark = yylval;
1740
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1741
/* lookahead position is error end position */
1742
yyerror_loc_range[2] = yylloc;
1743
YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1744
*++yystack.p_mark = yyloc;
1745
#endif
1746
goto yyloop;
1747
}
1748
else
1749
{
1750
#if YYDEBUG
1751
if (yydebug)
1752
fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1753
YYDEBUGSTR, yydepth, *yystack.s_mark);
1754
#endif
1755
if (yystack.s_mark <= yystack.s_base) goto yyabort;
1756
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1757
/* the current TOS position is the error start position */
1758
yyerror_loc_range[1] = *yystack.p_mark;
1759
#endif
1760
#if defined(YYDESTRUCT_CALL)
1761
#if YYBTYACC
1762
if (!yytrial)
1763
#endif /* YYBTYACC */
1764
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1765
YYDESTRUCT_CALL("error: discarding state",
1766
yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1767
#else
1768
YYDESTRUCT_CALL("error: discarding state",
1769
yystos[*yystack.s_mark], yystack.l_mark);
1770
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1771
#endif /* defined(YYDESTRUCT_CALL) */
1772
--yystack.s_mark;
1773
--yystack.l_mark;
1774
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1775
--yystack.p_mark;
1776
#endif
1777
}
1778
}
1779
}
1780
else
1781
{
1782
if (yychar == YYEOF) goto yyabort;
1783
#if YYDEBUG
1784
if (yydebug)
1785
{
1786
if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1787
fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1788
YYDEBUGSTR, yydepth, yystate, yychar, yys);
1789
}
1790
#endif
1791
#if defined(YYDESTRUCT_CALL)
1792
#if YYBTYACC
1793
if (!yytrial)
1794
#endif /* YYBTYACC */
1795
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1796
YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1797
#else
1798
YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1799
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1800
#endif /* defined(YYDESTRUCT_CALL) */
1801
yychar = YYEMPTY;
1802
goto yyloop;
1803
}
1804
1805
yyreduce:
1806
yym = yylen[yyn];
1807
#if YYDEBUG
1808
if (yydebug)
1809
{
1810
fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1811
YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1812
#ifdef YYSTYPE_TOSTRING
1813
#if YYBTYACC
1814
if (!yytrial)
1815
#endif /* YYBTYACC */
1816
if (yym > 0)
1817
{
1818
int i;
1819
fputc('<', stderr);
1820
for (i = yym; i > 0; i--)
1821
{
1822
if (i != yym) fputs(", ", stderr);
1823
fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1824
yystack.l_mark[1-i]), stderr);
1825
}
1826
fputc('>', stderr);
1827
}
1828
#endif
1829
fputc('\n', stderr);
1830
}
1831
#endif
1832
if (yym > 0)
1833
yyval = yystack.l_mark[1-yym];
1834
else
1835
memset(&yyval, 0, sizeof yyval);
1836
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1837
1838
/* Perform position reduction */
1839
memset(&yyloc, 0, sizeof(yyloc));
1840
#if YYBTYACC
1841
if (!yytrial)
1842
#endif /* YYBTYACC */
1843
{
1844
YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1845
/* just in case YYERROR is invoked within the action, save
1846
the start of the rhs as the error start position */
1847
yyerror_loc_range[1] = yystack.p_mark[1-yym];
1848
}
1849
#endif
1850
1851
switch (yyn)
1852
{
1853
case 1:
1854
#line 93 "btyacc_demo.y"
1855
{ yyval.scope = yystack.l_mark[0].scope; }
1856
#line 1857 "btyacc_demo.tab.c"
1857
break;
1858
case 2:
1859
#line 94 "btyacc_demo.y"
1860
{ yyval.scope = global_scope; }
1861
#line 1862 "btyacc_demo.tab.c"
1862
break;
1863
case 3:
1864
#line 95 "btyacc_demo.y"
1865
{ Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1866
if (!d || !d->scope) YYERROR;
1867
yyval.scope = d->scope; }
1868
#line 1869 "btyacc_demo.tab.c"
1869
break;
1870
case 4:
1871
#line 101 "btyacc_demo.y"
1872
{ Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1873
if (d == NULL || d->istype() == 0) YYERROR;
1874
yyval.type = d->type; }
1875
#line 1876 "btyacc_demo.tab.c"
1876
break;
1877
case 5:
1878
#line 106 "btyacc_demo.y"
1879
yyval.scope = global_scope = new_scope(0);
1880
#line 1881 "btyacc_demo.tab.c"
1881
break;
1882
case 8:
1883
#line 107 "btyacc_demo.y"
1884
yyval.scope = yystack.l_mark[-1].scope;
1885
#line 1886 "btyacc_demo.tab.c"
1886
break;
1887
case 10:
1888
#line 109 "btyacc_demo.y"
1889
{YYVALID;}
1890
#line 1891 "btyacc_demo.tab.c"
1891
break;
1892
case 11:
1893
#line 110 "btyacc_demo.y"
1894
yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);
1895
#line 1896 "btyacc_demo.tab.c"
1896
break;
1897
case 12:
1898
if (!yytrial)
1899
#line 111 "btyacc_demo.y"
1900
{ /* demonstrate use of @$ & @N, although this is just the
1901
default computation and so is not necessary */
1902
yyloc.first_line = yystack.p_mark[-3].first_line;
1903
yyloc.first_column = yystack.p_mark[-3].first_column;
1904
yyloc.last_line = yystack.p_mark[0].last_line;
1905
yyloc.last_column = yystack.p_mark[0].last_column;
1906
finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1907
#line 1908 "btyacc_demo.tab.c"
1908
break;
1909
case 13:
1910
#line 121 "btyacc_demo.y"
1911
{ yyval.type = yystack.l_mark[0].type; }
1912
#line 1913 "btyacc_demo.tab.c"
1913
break;
1914
case 14:
1915
#line 122 "btyacc_demo.y"
1916
{ yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1917
#line 1918 "btyacc_demo.tab.c"
1918
break;
1919
case 15:
1920
#line 125 "btyacc_demo.y"
1921
{ yyval.type = 0; }
1922
#line 1923 "btyacc_demo.tab.c"
1923
break;
1924
case 16:
1925
#line 126 "btyacc_demo.y"
1926
{ yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1927
#line 1928 "btyacc_demo.tab.c"
1928
break;
1929
case 17:
1930
#line 130 "btyacc_demo.y"
1931
{ yyval.type = yystack.l_mark[0].type; }
1932
#line 1933 "btyacc_demo.tab.c"
1933
break;
1934
case 18:
1935
#line 131 "btyacc_demo.y"
1936
{ yyval.type = yystack.l_mark[0].type; }
1937
#line 1938 "btyacc_demo.tab.c"
1938
break;
1939
case 19:
1940
#line 132 "btyacc_demo.y"
1941
{ yyval.type = bare_extern(); }
1942
#line 1943 "btyacc_demo.tab.c"
1943
break;
1944
case 20:
1945
#line 133 "btyacc_demo.y"
1946
{ yyval.type = bare_register(); }
1947
#line 1948 "btyacc_demo.tab.c"
1948
break;
1949
case 21:
1950
#line 134 "btyacc_demo.y"
1951
{ yyval.type = bare_static(); }
1952
#line 1953 "btyacc_demo.tab.c"
1953
break;
1954
case 22:
1955
#line 138 "btyacc_demo.y"
1956
{ yyval.type = bare_const(); }
1957
#line 1958 "btyacc_demo.tab.c"
1958
break;
1959
case 23:
1960
#line 139 "btyacc_demo.y"
1961
{ yyval.type = bare_volatile(); }
1962
#line 1963 "btyacc_demo.tab.c"
1963
break;
1964
case 24:
1965
#line 143 "btyacc_demo.y"
1966
yyval.scope = yystack.l_mark[-3].scope;
1967
#line 1968 "btyacc_demo.tab.c"
1968
break;
1969
case 25:
1970
#line 143 "btyacc_demo.y"
1971
yyval.type = yystack.l_mark[-3].type;
1972
#line 1973 "btyacc_demo.tab.c"
1973
break;
1974
case 28:
1975
#line 148 "btyacc_demo.y"
1976
{ if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1977
#line 149 "btyacc_demo.y"
1978
{ yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1979
#line 1980 "btyacc_demo.tab.c"
1980
break;
1981
case 29:
1982
if (!yytrial)
1983
#line 150 "btyacc_demo.y"
1984
{ yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1985
#line 1986 "btyacc_demo.tab.c"
1986
break;
1987
case 30:
1988
#line 151 "btyacc_demo.y"
1989
yyval.scope = yystack.l_mark[-2].scope;
1990
#line 1991 "btyacc_demo.tab.c"
1991
break;
1992
case 31:
1993
#line 151 "btyacc_demo.y"
1994
yyval.type = yystack.l_mark[-2].type;
1995
#line 1996 "btyacc_demo.tab.c"
1996
break;
1997
case 32:
1998
if (!yytrial)
1999
#line 151 "btyacc_demo.y"
2000
{ yyval.decl = yystack.l_mark[-1].decl; }
2001
#line 2002 "btyacc_demo.tab.c"
2002
break;
2003
case 33:
2004
if (!yytrial)
2005
#line 153 "btyacc_demo.y"
2006
{ yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
2007
#line 2008 "btyacc_demo.tab.c"
2008
break;
2009
case 34:
2010
if (!yytrial)
2011
#line 155 "btyacc_demo.y"
2012
{ yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
2013
#line 2014 "btyacc_demo.tab.c"
2014
break;
2015
case 35:
2016
if (!yytrial)
2017
#line 157 "btyacc_demo.y"
2018
{ yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
2019
#line 2020 "btyacc_demo.tab.c"
2020
break;
2021
case 36:
2022
if (!yytrial)
2023
#line 160 "btyacc_demo.y"
2024
{ yyval.dlist = 0; }
2025
#line 2026 "btyacc_demo.tab.c"
2026
break;
2027
case 37:
2028
if (!yytrial)
2029
#line 161 "btyacc_demo.y"
2030
{ yyval.dlist = yystack.l_mark[0].dlist; }
2031
#line 2032 "btyacc_demo.tab.c"
2032
break;
2033
case 38:
2034
if (!yytrial)
2035
#line 164 "btyacc_demo.y"
2036
{ yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
2037
#line 2038 "btyacc_demo.tab.c"
2038
break;
2039
case 39:
2040
if (!yytrial)
2041
#line 165 "btyacc_demo.y"
2042
{ yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2043
#line 2044 "btyacc_demo.tab.c"
2044
break;
2045
case 40:
2046
if (!yytrial)
2047
#line 168 "btyacc_demo.y"
2048
{ yyval.decl = yystack.l_mark[0].decl; }
2049
#line 2050 "btyacc_demo.tab.c"
2050
break;
2051
case 41:
2052
if (!yytrial)
2053
#line 172 "btyacc_demo.y"
2054
{ yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2055
#line 2056 "btyacc_demo.tab.c"
2056
break;
2057
case 42:
2058
if (!yytrial)
2059
#line 173 "btyacc_demo.y"
2060
{ yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2061
#line 2062 "btyacc_demo.tab.c"
2062
break;
2063
case 43:
2064
if (!yytrial)
2065
#line 174 "btyacc_demo.y"
2066
{ yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2067
#line 2068 "btyacc_demo.tab.c"
2068
break;
2069
case 44:
2070
if (!yytrial)
2071
#line 175 "btyacc_demo.y"
2072
{ yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2073
#line 2074 "btyacc_demo.tab.c"
2074
break;
2075
case 45:
2076
if (!yytrial)
2077
#line 176 "btyacc_demo.y"
2078
{ yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2079
#line 2080 "btyacc_demo.tab.c"
2080
break;
2081
case 46:
2082
if (!yytrial)
2083
#line 177 "btyacc_demo.y"
2084
{ yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2085
#line 2086 "btyacc_demo.tab.c"
2086
break;
2087
case 47:
2088
if (!yytrial)
2089
#line 178 "btyacc_demo.y"
2090
{ yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2091
#line 2092 "btyacc_demo.tab.c"
2092
break;
2093
case 48:
2094
if (!yytrial)
2095
#line 179 "btyacc_demo.y"
2096
{ yyval.expr = yystack.l_mark[0].expr; }
2097
#line 2098 "btyacc_demo.tab.c"
2098
break;
2099
case 49:
2100
if (!yytrial)
2101
#line 183 "btyacc_demo.y"
2102
{ yyval.code = 0; }
2103
#line 2104 "btyacc_demo.tab.c"
2104
break;
2105
case 50:
2106
#line 184 "btyacc_demo.y"
2107
{YYVALID;} if (!yytrial)
2108
#line 184 "btyacc_demo.y"
2109
{ yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2110
#line 2111 "btyacc_demo.tab.c"
2111
break;
2112
case 51:
2113
#line 185 "btyacc_demo.y"
2114
yyval.scope = yystack.l_mark[-6].scope;
2115
#line 2116 "btyacc_demo.tab.c"
2116
break;
2117
case 52:
2118
#line 185 "btyacc_demo.y"
2119
yyval.scope = yystack.l_mark[-9].scope;
2120
#line 2121 "btyacc_demo.tab.c"
2121
break;
2122
case 53:
2123
#line 185 "btyacc_demo.y"
2124
{YYVALID;} if (!yytrial)
2125
#line 186 "btyacc_demo.y"
2126
{ yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2127
#line 2128 "btyacc_demo.tab.c"
2128
break;
2129
case 54:
2130
#line 187 "btyacc_demo.y"
2131
{YYVALID;} if (!yytrial)
2132
#line 188 "btyacc_demo.y"
2133
{ yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2134
#line 2135 "btyacc_demo.tab.c"
2135
break;
2136
case 55:
2137
#line 189 "btyacc_demo.y"
2138
yyval.scope = new_scope(yystack.l_mark[0].scope);
2139
#line 2140 "btyacc_demo.tab.c"
2140
break;
2141
case 56:
2142
#line 189 "btyacc_demo.y"
2143
{YYVALID;} if (!yytrial)
2144
#line 189 "btyacc_demo.y"
2145
{ yyval.code = yystack.l_mark[0].code; }
2146
#line 2147 "btyacc_demo.tab.c"
2147
break;
2148
case 57:
2149
if (!yytrial)
2150
#line 192 "btyacc_demo.y"
2151
{ yyval.code = 0; }
2152
#line 2153 "btyacc_demo.tab.c"
2153
break;
2154
case 58:
2155
if (!yytrial)
2156
#line 193 "btyacc_demo.y"
2157
{ yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2158
#line 2159 "btyacc_demo.tab.c"
2159
break;
2160
case 59:
2161
if (!yytrial)
2162
#line 197 "btyacc_demo.y"
2163
{ yyval.code = yystack.l_mark[-1].code; }
2164
#line 2165 "btyacc_demo.tab.c"
2165
break;
2166
#line 2167 "btyacc_demo.tab.c"
2167
default:
2168
break;
2169
}
2170
yystack.s_mark -= yym;
2171
yystate = *yystack.s_mark;
2172
yystack.l_mark -= yym;
2173
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2174
yystack.p_mark -= yym;
2175
#endif
2176
yym = yylhs[yyn];
2177
if (yystate == 0 && yym == 0)
2178
{
2179
#if YYDEBUG
2180
if (yydebug)
2181
{
2182
fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2183
#ifdef YYSTYPE_TOSTRING
2184
#if YYBTYACC
2185
if (!yytrial)
2186
#endif /* YYBTYACC */
2187
fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2188
#endif
2189
fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2190
}
2191
#endif
2192
yystate = YYFINAL;
2193
*++yystack.s_mark = YYFINAL;
2194
*++yystack.l_mark = yyval;
2195
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2196
*++yystack.p_mark = yyloc;
2197
#endif
2198
if (yychar < 0)
2199
{
2200
#if YYBTYACC
2201
do {
2202
if (yylvp < yylve)
2203
{
2204
/* we're currently re-reading tokens */
2205
yylval = *yylvp++;
2206
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2207
yylloc = *yylpp++;
2208
#endif
2209
yychar = *yylexp++;
2210
break;
2211
}
2212
if (yyps->save)
2213
{
2214
/* in trial mode; save scanner results for future parse attempts */
2215
if (yylvp == yylvlim)
2216
{ /* Enlarge lexical value queue */
2217
size_t p = (size_t) (yylvp - yylvals);
2218
size_t s = (size_t) (yylvlim - yylvals);
2219
2220
s += YYLVQUEUEGROWTH;
2221
if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
2222
goto yyenomem;
2223
if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2224
goto yyenomem;
2225
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2226
if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2227
goto yyenomem;
2228
#endif
2229
yylvp = yylve = yylvals + p;
2230
yylvlim = yylvals + s;
2231
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2232
yylpp = yylpe = yylpsns + p;
2233
yylplim = yylpsns + s;
2234
#endif
2235
yylexp = yylexemes + p;
2236
}
2237
*yylexp = (YYINT) YYLEX;
2238
*yylvp++ = yylval;
2239
yylve++;
2240
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2241
*yylpp++ = yylloc;
2242
yylpe++;
2243
#endif
2244
yychar = *yylexp++;
2245
break;
2246
}
2247
/* normal operation, no conflict encountered */
2248
#endif /* YYBTYACC */
2249
yychar = YYLEX;
2250
#if YYBTYACC
2251
} while (0);
2252
#endif /* YYBTYACC */
2253
if (yychar < 0) yychar = YYEOF;
2254
#if YYDEBUG
2255
if (yydebug)
2256
{
2257
if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2258
fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
2259
YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2260
}
2261
#endif
2262
}
2263
if (yychar == YYEOF) goto yyaccept;
2264
goto yyloop;
2265
}
2266
if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2267
yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2268
yystate = yytable[yyn];
2269
else
2270
yystate = yydgoto[yym];
2271
#if YYDEBUG
2272
if (yydebug)
2273
{
2274
fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2275
#ifdef YYSTYPE_TOSTRING
2276
#if YYBTYACC
2277
if (!yytrial)
2278
#endif /* YYBTYACC */
2279
fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2280
#endif
2281
fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2282
}
2283
#endif
2284
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2285
*++yystack.s_mark = (YYINT) yystate;
2286
*++yystack.l_mark = yyval;
2287
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2288
*++yystack.p_mark = yyloc;
2289
#endif
2290
goto yyloop;
2291
#if YYBTYACC
2292
2293
/* Reduction declares that this path is valid. Set yypath and do a full parse */
2294
yyvalid:
2295
if (yypath) YYABORT;
2296
while (yyps->save)
2297
{
2298
YYParseState *save = yyps->save;
2299
yyps->save = save->save;
2300
save->save = yypath;
2301
yypath = save;
2302
}
2303
#if YYDEBUG
2304
if (yydebug)
2305
fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2306
YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2307
#endif
2308
if (yyerrctx)
2309
{
2310
yyFreeState(yyerrctx);
2311
yyerrctx = NULL;
2312
}
2313
yylvp = yylvals + yypath->lexeme;
2314
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2315
yylpp = yylpsns + yypath->lexeme;
2316
#endif
2317
yylexp = yylexemes + yypath->lexeme;
2318
yychar = YYEMPTY;
2319
yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2320
memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
2321
yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2322
memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2323
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2324
yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2325
memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2326
#endif
2327
yystate = yypath->state;
2328
goto yyloop;
2329
#endif /* YYBTYACC */
2330
2331
yyoverflow:
2332
YYERROR_CALL("yacc stack overflow");
2333
#if YYBTYACC
2334
goto yyabort_nomem;
2335
yyenomem:
2336
YYERROR_CALL("memory exhausted");
2337
yyabort_nomem:
2338
#endif /* YYBTYACC */
2339
yyresult = 2;
2340
goto yyreturn;
2341
2342
yyabort:
2343
yyresult = 1;
2344
goto yyreturn;
2345
2346
yyaccept:
2347
#if YYBTYACC
2348
if (yyps->save) goto yyvalid;
2349
#endif /* YYBTYACC */
2350
yyresult = 0;
2351
2352
yyreturn:
2353
#if defined(YYDESTRUCT_CALL)
2354
if (yychar != YYEOF && yychar != YYEMPTY)
2355
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2356
YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2357
#else
2358
YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2359
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2360
2361
{
2362
YYSTYPE *pv;
2363
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2364
YYLTYPE *pp;
2365
2366
for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2367
YYDESTRUCT_CALL("cleanup: discarding state",
2368
yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2369
#else
2370
for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2371
YYDESTRUCT_CALL("cleanup: discarding state",
2372
yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2373
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2374
}
2375
#endif /* defined(YYDESTRUCT_CALL) */
2376
2377
#if YYBTYACC
2378
if (yyerrctx)
2379
{
2380
yyFreeState(yyerrctx);
2381
yyerrctx = NULL;
2382
}
2383
while (yyps)
2384
{
2385
YYParseState *save = yyps;
2386
yyps = save->save;
2387
save->save = NULL;
2388
yyFreeState(save);
2389
}
2390
while (yypath)
2391
{
2392
YYParseState *save = yypath;
2393
yypath = save->save;
2394
save->save = NULL;
2395
yyFreeState(save);
2396
}
2397
#endif /* YYBTYACC */
2398
yyfreestack(&yystack);
2399
return (yyresult);
2400
}
2401
2402