1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
8 #define YYCHECK "yyyymmdd"
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
18 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug")
21 #define yyparse demo_parse
25 #define yylex demo_lex
29 #define yyerror demo_error
33 #define yychar demo_char
37 #define yyval demo_val
41 #define yylval demo_lval
45 #define yydebug demo_debug
49 #define yynerrs demo_nerrs
53 #define yyerrflag demo_errflag
54 #endif /* yyerrflag */
57 #define yylhs demo_lhs
61 #define yylen demo_len
65 #define yydefred demo_defred
69 #define yystos demo_stos
73 #define yydgoto demo_dgoto
77 #define yysindex demo_sindex
81 #define yyrindex demo_rindex
85 #define yygindex demo_gindex
89 #define yytable demo_table
93 #define yycheck demo_check
97 #define yyname demo_name
101 #define yyrule demo_rule
105 #define yyloc demo_loc
109 #define yylloc demo_lloc
115 #define yycindex demo_cindex
116 #endif /* yycindex */
119 #define yyctable demo_ctable
120 #endif /* yyctable */
122 #endif /* YYBTYACC */
124 #define YYPREFIX "demo_"
128 #line 15 "btyacc_demo.y"
129 /* dummy types just for compile check */
131 typedef int Decl_List;
133 typedef int Expr_List;
136 enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF };
138 typedef unsigned char bool;
139 typedef struct Decl {
142 bool (*istype)(void);
145 #include "btyacc_demo.tab.h"
149 #undef YYSTYPE_IS_DECLARED
150 #define YYSTYPE_IS_DECLARED 1
152 #ifndef YYSTYPE_IS_DECLARED
153 #define YYSTYPE_IS_DECLARED 1
154 #line 36 "btyacc_demo.y"
165 #endif /* !YYSTYPE_IS_DECLARED */
166 #line 167 "btyacc_demo.tab.c"
168 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
169 /* Default: YYLTYPE is the text position type. */
170 typedef struct YYLTYPE
177 #define YYLTYPE_IS_DECLARED 1
180 /* compatibility with bison */
182 /* compatibility with FreeBSD */
183 # ifdef YYPARSE_PARAM_TYPE
184 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
186 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
189 # define YYPARSE_DECL() yyparse(void)
192 /* Parameters sent to lex. */
194 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
195 # define YYLEX yylex(YYLEX_PARAM)
197 # define YYLEX_DECL() yylex(void)
198 # define YYLEX yylex()
201 /* Parameters sent to yyerror. */
203 #define YYERROR_DECL() yyerror(YYLTYPE loc, const char *s)
206 #define YYERROR_CALL(msg) yyerror(yylloc, msg)
209 #ifndef YYDESTRUCT_DECL
210 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)
212 #ifndef YYDESTRUCT_CALL
213 #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)
216 extern int YYPARSE_DECL();
231 #define YYERRCODE 256
233 static const YYINT demo_lhs[] = { -1,
234 15, 15, 15, 12, 18, 0, 4, 19, 4, 2,
235 20, 2, 10, 10, 13, 13, 11, 11, 11, 11,
236 11, 14, 14, 21, 22, 3, 3, 8, 8, 23,
237 24, 8, 8, 8, 8, 16, 16, 17, 17, 9,
238 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
239 25, 26, 5, 5, 27, 5, 6, 6, 7,
241 static const YYINT demo_len[] = { 2,
242 0, 1, 3, 2, 0, 2, 0, 0, 3, 3,
243 0, 4, 1, 3, 0, 2, 1, 1, 1, 1,
244 1, 1, 1, 0, 0, 5, 1, 0, 1, 0,
245 0, 5, 5, 5, 6, 0, 1, 4, 1, 2,
246 4, 4, 4, 4, 4, 3, 1, 1, 1, 2,
247 0, 0, 11, 8, 0, 2, 0, 3, 4,
249 static const YYINT demo_defred[] = { 5,
250 0, 7, 0, 0, 19, 20, 21, 22, 23, 2,
251 9, 0, 13, 18, 17, 0, 15, 30, 29, 0,
252 0, 0, 0, 0, 31, 10, 24, 24, 24, 0,
253 14, 3, 16, 25, 0, 25, 0, 0, 8, 12,
254 0, 0, 0, 39, 0, 0, 0, 8, 47, 48,
255 0, 57, 0, 32, 0, 0, 15, 30, 0, 30,
256 30, 30, 30, 30, 34, 0, 0, 0, 46, 0,
257 0, 0, 0, 0, 59, 0, 38, 0, 0, 43,
258 45, 44, 0, 0, 49, 58, 0, 30, 50, 56,
259 0, 0, 0, 51, 0, 0, 52, 0, 53,
261 static const YYINT demo_stos[] = { 0,
262 271, 289, 275, 290, 261, 262, 263, 264, 265, 269,
263 273, 281, 282, 283, 285, 286, 42, 40, 259, 274,
264 279, 290, 259, 284, 294, 59, 44, 40, 91, 291,
265 282, 269, 285, 292, 295, 292, 292, 292, 123, 278,
266 293, 279, 293, 280, 281, 287, 288, 42, 259, 260,
267 272, 290, 279, 41, 279, 279, 41, 44, 290, 43,
268 45, 42, 47, 37, 93, 277, 284, 294, 272, 294,
269 294, 294, 294, 294, 125, 290, 280, 272, 272, 272,
270 272, 272, 266, 272, 273, 276, 298, 40, 59, 278,
271 294, 272, 41, 267, 296, 276, 268, 297, 276,
273 static const YYINT demo_dgoto[] = { 1,
274 84, 85, 20, 3, 86, 66, 40, 21, 44, 12,
275 13, 14, 24, 15, 16, 46, 47, 2, 22, 30,
276 34, 41, 25, 35, 95, 98, 87,
278 static const YYINT demo_sindex[] = { 0,
279 0, 0, 0, -103, 0, 0, 0, 0, 0, 0,
280 0, -31, 0, 0, 0, -238, 0, 0, 0, 4,
281 -36, -103, 0, -133, 0, 0, 0, 0, 0, -94,
282 0, 0, 0, 0, -40, 0, -103, -33, 0, 0,
283 -40, -25, -40, 0, -31, 8, 15, 0, 0, 0,
284 -2, 0, -36, 0, -36, -36, 0, 0, -33, 0,
285 0, 0, 0, 0, 0, -92, -133, -103, 0, -33,
286 -33, -33, -33, -33, 0, -8, 0, 23, 23, 0,
287 0, 0, 11, 75, 0, 0, -94, 0, 0, 0,
288 -33, 96, -194, 0, -8, 0, 0, -8, 0,
290 static const YYINT demo_rindex[] = { 0,
291 0, 0, 1, -181, 0, 0, 0, 0, 0, 0,
292 0, 17, 0, 0, 0, 0, 0, 0, 0, 0,
293 -39, -181, 12, -34, 0, 0, 0, 0, 0, 0,
294 0, 0, 0, 0, -5, 0, -11, 0, 0, 0,
295 -17, 0, 28, 0, -41, 0, 47, 0, 0, 0,
296 0, 0, -13, 0, 18, 70, 0, 0, 0, 0,
297 0, 0, 0, 0, 0, -19, -27, -181, 0, 0,
298 0, 0, 0, 0, 0, -29, 0, 56, 64, 0,
299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
300 0, 0, 0, 0, -29, -30, 0, -29, 0,
303 static const YYINT demo_cindex[] = { 0,
304 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
305 0, -22, 0, 0, 0, 0, 0, 0, 0, 0,
306 0, 0, -179, 0, 0, 0, 0, 0, 0, 0,
307 0, 0, 0, 0, 52, 0, 0, 0, 0, 0,
308 58, 0, 62, 0, -21, 0, 0, 0, 0, 0,
309 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
310 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311 0, 0, 0, 0, 0, -146, 0, 0, 0, 0,
312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
313 0, 0, 0, 0, -143, -147, 0, -134, 0,
316 static const YYINT demo_gindex[] = { 0,
317 9, 143, 0, 0, 50, 0, 63, 101, 83, 7,
318 130, 0, 98, 2, 0, 0, 0, 0, 19, 0,
319 10, 117, 66, 0, 0, 0, 0,
321 #define YYTABLESIZE 286
322 static const YYINT demo_table[] = { 28,
323 6, 17, 28, 28, 27, 24, 24, 24, 48, 24,
324 17, 54, 35, 35, 28, 54, 35, 0, 0, 27,
325 23, 4, 8, 28, 24, 33, 28, 33, 39, 36,
326 33, 35, 75, 48, 64, 28, 36, 37, 38, 62,
327 60, 28, 61, 45, 63, 33, 51, 27, 57, 28,
328 88, 4, 4, 4, 29, 4, 24, 52, 58, 64,
329 28, 26, 26, 35, 62, 29, 59, 69, 33, 63,
330 4, 28, 94, 28, 45, 28, 26, 1, 78, 79,
331 80, 81, 82, 11, 76, 28, 28, 37, 24, 6,
332 65, 0, 54, 55, 54, 35, 41, 0, 41, 92,
333 41, 0, 4, 8, 42, 28, 42, 28, 42, 33,
334 40, 64, 9, 40, 41, 9, 62, 60, 28, 61,
335 12, 63, 42, 68, 9, 70, 71, 72, 73, 74,
336 8, 9, 64, 89, 4, 42, 93, 62, 60, 28,
337 61, 53, 63, 55, 96, 56, 11, 99, 41, 90,
338 77, 31, 43, 91, 67, 0, 42, 5, 6, 7,
339 8, 9, 0, 0, 0, 10, 0, 0, 0, 0,
340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
342 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
344 0, 0, 0, 0, 0, 0, 0, 0, 19, 8,
345 8, 8, 8, 8, 24, 49, 50, 8, 54, 54,
346 54, 54, 54, 54, 54, 54, 3, 3, 54, 8,
347 8, 8, 8, 8, 8, 8, 8, 1, 0, 8,
348 0, 50, 5, 6, 7, 8, 9, 83, 0, 8,
349 10, 8, 8, 8, 8, 8, 0, 0, 0, 8,
350 4, 0, 4, 4, 4, 4, 4, 8, 8, 8,
353 static const YYINT demo_check[] = { 41,
354 0, 42, 44, 40, 44, 40, 41, 42, 42, 44,
355 42, 42, 40, 41, 40, 41, 44, 40, 40, 59,
356 259, 3, 42, 41, 59, 24, 44, 41, 123, 41,
357 44, 59, 125, 42, 37, 41, 27, 28, 29, 42,
358 43, 59, 45, 37, 47, 59, 38, 44, 41, 91,
359 40, 40, 41, 42, 91, 44, 91, 39, 44, 37,
360 44, 44, 59, 91, 42, 91, 48, 59, 67, 47,
361 59, 44, 267, 91, 68, 59, 59, 259, 70, 71,
362 72, 73, 74, 123, 66, 91, 59, 41, 123, 269,
363 93, 40, 123, 123, 125, 123, 41, 40, 43, 91,
364 45, 40, 91, 123, 41, 123, 43, 91, 45, 123,
365 41, 37, 259, 44, 59, 259, 42, 43, 91, 45,
366 268, 47, 59, 58, 259, 60, 61, 62, 63, 64,
367 264, 265, 37, 59, 123, 35, 41, 42, 43, 123,
368 45, 41, 47, 43, 95, 45, 4, 98, 93, 87,
369 68, 22, 36, 88, 57, -1, 93, 261, 262, 263,
370 264, 265, -1, -1, -1, 269, -1, -1, -1, -1,
371 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
372 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
373 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
374 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
375 -1, -1, -1, -1, -1, -1, -1, -1, 259, 261,
376 262, 263, 264, 265, 259, 259, 260, 269, 259, 260,
377 261, 262, 263, 264, 265, 266, 259, 259, 269, 259,
378 260, 261, 262, 263, 264, 265, 266, 259, -1, 269,
379 -1, 260, 261, 262, 263, 264, 265, 266, -1, 259,
380 269, 261, 262, 263, 264, 265, -1, -1, -1, 269,
381 259, -1, 261, 262, 263, 264, 265, 261, 262, 263,
382 264, 265, -1, -1, -1, 269,
385 static const YYINT demo_ctable[] = { 18,
386 28, -1, 19, 8, -1, 32, 4, -1, 49, 1,
387 -1, 97, 54, -1, -1, -1, -1, -1, -1, -1,
388 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
389 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
390 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
391 -1, -1, -1, -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,
421 #define YYMAXTOKEN 269
422 #define YYUNDFTOKEN 299
423 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
425 static const char *const demo_name[] = {
427 "$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,
428 "'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,
429 "';'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,
430 "']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,
431 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,
434 0,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN",
435 "REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept",
436 "input","expr","decl","declarator_list","decl_list","statement",
437 "statement_list","block_statement","declarator","formal_arg","decl_specs",
438 "decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list",
439 "nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8",
440 "$$9","$$10","illegal-symbol",
442 static const char *const demo_rule[] = {
446 "opt_scope : opt_scope ID CLCL",
447 "typename : opt_scope ID",
449 "input : $$1 decl_list",
452 "decl_list : decl_list $$2 decl",
453 "decl : decl_specs declarator_list ';'",
455 "decl : decl_specs declarator $$3 block_statement",
456 "decl_specs : decl_spec",
457 "decl_specs : decl_specs $$2 decl_spec",
459 "cv_quals : cv_quals cv_qual",
460 "decl_spec : cv_qual",
461 "decl_spec : typename",
462 "decl_spec : EXTERN",
463 "decl_spec : REGISTER",
464 "decl_spec : STATIC",
466 "cv_qual : VOLATILE",
469 "declarator_list : declarator_list ',' $$4 $$5 declarator",
470 "declarator_list : declarator",
475 "declarator : '(' $$6 $$7 declarator ')'",
476 "declarator : '*' cv_quals $$4 $$5 declarator",
477 "declarator : declarator '[' $$4 expr ']'",
478 "declarator : declarator '(' $$4 formal_arg_list ')' cv_quals",
480 "formal_arg_list : nonempty_formal_arg_list",
481 "nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg",
482 "nonempty_formal_arg_list : formal_arg",
483 "formal_arg : decl_specs declarator",
484 "expr : expr '+' $$6 expr",
485 "expr : expr '-' $$6 expr",
486 "expr : expr '*' $$6 expr",
487 "expr : expr '%' $$6 expr",
488 "expr : expr '/' $$6 expr",
489 "expr : '*' $$2 expr",
493 "statement : expr ';'",
496 "statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement",
497 "statement : IF '(' $$6 expr ')' THEN $$8 statement",
499 "statement : $$10 block_statement",
501 "statement_list : statement_list $$2 statement",
502 "block_statement : '{' $$2 statement_list '}'",
514 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
515 YYLTYPE yyloc; /* position returned by actions */
516 YYLTYPE yylloc; /* position from the lexer */
519 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
520 #ifndef YYLLOC_DEFAULT
521 #define YYLLOC_DEFAULT(loc, rhs, n) \
526 (loc).first_line = ((rhs)[-1]).last_line; \
527 (loc).first_column = ((rhs)[-1]).last_column; \
528 (loc).last_line = ((rhs)[-1]).last_line; \
529 (loc).last_column = ((rhs)[-1]).last_column; \
533 (loc).first_line = ((rhs)[ 0 ]).first_line; \
534 (loc).first_column = ((rhs)[ 0 ]).first_column; \
535 (loc).last_line = ((rhs)[n-1]).last_line; \
536 (loc).last_column = ((rhs)[n-1]).last_column; \
539 #endif /* YYLLOC_DEFAULT */
540 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
543 #ifndef YYLVQUEUEGROWTH
544 #define YYLVQUEUEGROWTH 32
546 #endif /* YYBTYACC */
548 /* define the initial stack-sizes */
551 #define YYMAXDEPTH YYSTACKSIZE
554 #define YYSTACKSIZE YYMAXDEPTH
556 #define YYSTACKSIZE 10000
557 #define YYMAXDEPTH 10000
561 #ifndef YYINITSTACKSIZE
562 #define YYINITSTACKSIZE 200
572 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
579 struct YYParseState_s
581 struct YYParseState_s *save; /* Previously saved parser state */
582 YYSTACKDATA yystack; /* saved parser stack */
583 int state; /* saved parser state */
584 int errflag; /* saved error recovery status */
585 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
586 YYINT ctry; /* saved index in yyctable[] for this conflict */
588 typedef struct YYParseState_s YYParseState;
589 #endif /* YYBTYACC */
590 /* variables for the parser stack */
591 static YYSTACKDATA yystack;
594 /* Current parser state */
595 static YYParseState *yyps = 0;
597 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
598 static YYParseState *yypath = 0;
600 /* Base of the lexical value queue */
601 static YYSTYPE *yylvals = 0;
603 /* Current position at lexical value queue */
604 static YYSTYPE *yylvp = 0;
606 /* End position of lexical value queue */
607 static YYSTYPE *yylve = 0;
609 /* The last allocated position at the lexical value queue */
610 static YYSTYPE *yylvlim = 0;
612 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
613 /* Base of the lexical position queue */
614 static YYLTYPE *yylpsns = 0;
616 /* Current position at lexical position queue */
617 static YYLTYPE *yylpp = 0;
619 /* End position of lexical position queue */
620 static YYLTYPE *yylpe = 0;
622 /* The last allocated position at the lexical position queue */
623 static YYLTYPE *yylplim = 0;
626 /* Current position at lexical token queue */
627 static short *yylexp = 0;
629 static short *yylexemes = 0;
630 #endif /* YYBTYACC */
631 #line 200 "btyacc_demo.y"
633 extern int YYLEX_DECL();
634 extern void YYERROR_DECL();
636 extern Scope *global_scope;
638 extern Decl * lookup(Scope *scope, char *id);
639 extern Scope * new_scope(Scope *outer_scope);
640 extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);
641 extern void finish_fn_def(Decl *fn_decl, Code *block);
642 extern Type * type_combine(Type *specs, Type *spec);
643 extern Type * bare_extern(void);
644 extern Type * bare_register(void);
645 extern Type * bare_static(void);
646 extern Type * bare_const(void);
647 extern Type * bare_volatile(void);
648 extern Decl * declare(Scope *scope, char *id, Type *type);
649 extern Decl * make_pointer(Decl *decl, Type *type);
650 extern Decl * make_array(Type *type, Expr *expr);
651 extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);
652 extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);
653 extern Decl_List * build_dlist(Decl *decl);
654 extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);
655 extern Expr * var_expr(Scope *scope, char *id);
656 extern Code * build_expr_code(Expr *expr);
657 extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
658 extern Code * code_append(Code *stmt_list, Code *stmt);
659 #line 660 "btyacc_demo.tab.c"
661 /* Release memory associated with symbol. */
662 #if ! defined YYDESTRUCT_IS_DECLARED
669 #line 83 "btyacc_demo.y"
670 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
672 (*loc).first_line, (*loc).first_column,
673 (*loc).last_line, (*loc).last_column);
674 /* in this example, we don't know what to do here */ }
676 #line 677 "btyacc_demo.tab.c"
678 #line 83 "btyacc_demo.y"
679 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
681 (*loc).first_line, (*loc).first_column,
682 (*loc).last_line, (*loc).last_column);
683 /* in this example, we don't know what to do here */ }
685 #line 686 "btyacc_demo.tab.c"
687 #line 83 "btyacc_demo.y"
688 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
690 (*loc).first_line, (*loc).first_column,
691 (*loc).last_line, (*loc).last_column);
692 /* in this example, we don't know what to do here */ }
694 #line 695 "btyacc_demo.tab.c"
696 #line 83 "btyacc_demo.y"
697 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
699 (*loc).first_line, (*loc).first_column,
700 (*loc).last_line, (*loc).last_column);
701 /* in this example, we don't know what to do here */ }
703 #line 704 "btyacc_demo.tab.c"
705 #line 83 "btyacc_demo.y"
706 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
708 (*loc).first_line, (*loc).first_column,
709 (*loc).last_line, (*loc).last_column);
710 /* in this example, we don't know what to do here */ }
712 #line 713 "btyacc_demo.tab.c"
714 #line 83 "btyacc_demo.y"
715 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
717 (*loc).first_line, (*loc).first_column,
718 (*loc).last_line, (*loc).last_column);
719 /* in this example, we don't know what to do here */ }
721 #line 722 "btyacc_demo.tab.c"
723 #line 83 "btyacc_demo.y"
724 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
726 (*loc).first_line, (*loc).first_column,
727 (*loc).last_line, (*loc).last_column);
728 /* in this example, we don't know what to do here */ }
730 #line 731 "btyacc_demo.tab.c"
732 #line 83 "btyacc_demo.y"
733 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
735 (*loc).first_line, (*loc).first_column,
736 (*loc).last_line, (*loc).last_column);
737 /* in this example, we don't know what to do here */ }
739 #line 740 "btyacc_demo.tab.c"
741 #line 83 "btyacc_demo.y"
742 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
744 (*loc).first_line, (*loc).first_column,
745 (*loc).last_line, (*loc).last_column);
746 /* in this example, we don't know what to do here */ }
748 #line 749 "btyacc_demo.tab.c"
750 #line 83 "btyacc_demo.y"
751 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
753 (*loc).first_line, (*loc).first_column,
754 (*loc).last_line, (*loc).last_column);
755 /* in this example, we don't know what to do here */ }
757 #line 758 "btyacc_demo.tab.c"
759 #line 78 "btyacc_demo.y"
760 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
762 (*loc).first_line, (*loc).first_column,
763 (*loc).last_line, (*loc).last_column);
766 #line 767 "btyacc_demo.tab.c"
768 #line 78 "btyacc_demo.y"
769 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
771 (*loc).first_line, (*loc).first_column,
772 (*loc).last_line, (*loc).last_column);
775 #line 776 "btyacc_demo.tab.c"
777 #line 83 "btyacc_demo.y"
778 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
780 (*loc).first_line, (*loc).first_column,
781 (*loc).last_line, (*loc).last_column);
782 /* in this example, we don't know what to do here */ }
784 #line 785 "btyacc_demo.tab.c"
786 #line 83 "btyacc_demo.y"
787 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
789 (*loc).first_line, (*loc).first_column,
790 (*loc).last_line, (*loc).last_column);
791 /* in this example, we don't know what to do here */ }
793 #line 794 "btyacc_demo.tab.c"
795 #line 83 "btyacc_demo.y"
796 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
798 (*loc).first_line, (*loc).first_column,
799 (*loc).last_line, (*loc).last_column);
800 /* in this example, we don't know what to do here */ }
802 #line 803 "btyacc_demo.tab.c"
804 #line 83 "btyacc_demo.y"
805 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
807 (*loc).first_line, (*loc).first_column,
808 (*loc).last_line, (*loc).last_column);
809 /* in this example, we don't know what to do here */ }
811 #line 812 "btyacc_demo.tab.c"
813 #line 83 "btyacc_demo.y"
814 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
816 (*loc).first_line, (*loc).first_column,
817 (*loc).last_line, (*loc).last_column);
818 /* in this example, we don't know what to do here */ }
820 #line 821 "btyacc_demo.tab.c"
822 #line 83 "btyacc_demo.y"
823 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
825 (*loc).first_line, (*loc).first_column,
826 (*loc).last_line, (*loc).last_column);
827 /* in this example, we don't know what to do here */ }
829 #line 830 "btyacc_demo.tab.c"
831 #line 83 "btyacc_demo.y"
832 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
834 (*loc).first_line, (*loc).first_column,
835 (*loc).last_line, (*loc).last_column);
836 /* in this example, we don't know what to do here */ }
838 #line 839 "btyacc_demo.tab.c"
840 #line 83 "btyacc_demo.y"
841 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
843 (*loc).first_line, (*loc).first_column,
844 (*loc).last_line, (*loc).last_column);
845 /* in this example, we don't know what to do here */ }
847 #line 848 "btyacc_demo.tab.c"
849 #line 83 "btyacc_demo.y"
850 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
852 (*loc).first_line, (*loc).first_column,
853 (*loc).last_line, (*loc).last_column);
854 /* in this example, we don't know what to do here */ }
856 #line 857 "btyacc_demo.tab.c"
858 #line 83 "btyacc_demo.y"
859 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
861 (*loc).first_line, (*loc).first_column,
862 (*loc).last_line, (*loc).last_column);
863 /* in this example, we don't know what to do here */ }
865 #line 866 "btyacc_demo.tab.c"
867 #line 83 "btyacc_demo.y"
868 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
870 (*loc).first_line, (*loc).first_column,
871 (*loc).last_line, (*loc).last_column);
872 /* in this example, we don't know what to do here */ }
874 #line 875 "btyacc_demo.tab.c"
876 #line 83 "btyacc_demo.y"
877 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
879 (*loc).first_line, (*loc).first_column,
880 (*loc).last_line, (*loc).last_column);
881 /* in this example, we don't know what to do here */ }
883 #line 884 "btyacc_demo.tab.c"
885 #line 83 "btyacc_demo.y"
886 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
888 (*loc).first_line, (*loc).first_column,
889 (*loc).last_line, (*loc).last_column);
890 /* in this example, we don't know what to do here */ }
892 #line 893 "btyacc_demo.tab.c"
894 #line 83 "btyacc_demo.y"
895 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
897 (*loc).first_line, (*loc).first_column,
898 (*loc).last_line, (*loc).last_column);
899 /* in this example, we don't know what to do here */ }
901 #line 902 "btyacc_demo.tab.c"
903 #line 83 "btyacc_demo.y"
904 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
906 (*loc).first_line, (*loc).first_column,
907 (*loc).last_line, (*loc).last_column);
908 /* in this example, we don't know what to do here */ }
910 #line 911 "btyacc_demo.tab.c"
912 #line 83 "btyacc_demo.y"
913 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
915 (*loc).first_line, (*loc).first_column,
916 (*loc).last_line, (*loc).last_column);
917 /* in this example, we don't know what to do here */ }
919 #line 920 "btyacc_demo.tab.c"
921 #line 83 "btyacc_demo.y"
922 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
924 (*loc).first_line, (*loc).first_column,
925 (*loc).last_line, (*loc).last_column);
926 /* in this example, we don't know what to do here */ }
928 #line 929 "btyacc_demo.tab.c"
930 #line 78 "btyacc_demo.y"
931 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
933 (*loc).first_line, (*loc).first_column,
934 (*loc).last_line, (*loc).last_column);
937 #line 938 "btyacc_demo.tab.c"
939 #line 67 "btyacc_demo.y"
940 { /* 'msg' is a 'char *' indicating the context of destructor invocation*/
941 printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",
943 (*loc).first_line, (*loc).first_column,
944 (*loc).last_line, (*loc).last_column);
945 free((*val).decl->scope); free((*val).decl->type); }
947 #line 948 "btyacc_demo.tab.c"
949 #line 83 "btyacc_demo.y"
950 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
952 (*loc).first_line, (*loc).first_column,
953 (*loc).last_line, (*loc).last_column);
954 /* in this example, we don't know what to do here */ }
956 #line 957 "btyacc_demo.tab.c"
958 #line 83 "btyacc_demo.y"
959 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
961 (*loc).first_line, (*loc).first_column,
962 (*loc).last_line, (*loc).last_column);
963 /* in this example, we don't know what to do here */ }
965 #line 966 "btyacc_demo.tab.c"
967 #line 78 "btyacc_demo.y"
968 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
970 (*loc).first_line, (*loc).first_column,
971 (*loc).last_line, (*loc).last_column);
974 #line 975 "btyacc_demo.tab.c"
976 #line 78 "btyacc_demo.y"
977 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
979 (*loc).first_line, (*loc).first_column,
980 (*loc).last_line, (*loc).last_column);
983 #line 984 "btyacc_demo.tab.c"
985 #line 78 "btyacc_demo.y"
986 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
988 (*loc).first_line, (*loc).first_column,
989 (*loc).last_line, (*loc).last_column);
992 #line 993 "btyacc_demo.tab.c"
994 #line 73 "btyacc_demo.y"
995 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
997 (*loc).first_line, (*loc).first_column,
998 (*loc).last_line, (*loc).last_column);
1001 #line 1002 "btyacc_demo.tab.c"
1003 #line 73 "btyacc_demo.y"
1004 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1006 (*loc).first_line, (*loc).first_column,
1007 (*loc).last_line, (*loc).last_column);
1008 free((*val).decl); }
1010 #line 1011 "btyacc_demo.tab.c"
1012 #line 78 "btyacc_demo.y"
1013 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1015 (*loc).first_line, (*loc).first_column,
1016 (*loc).last_line, (*loc).last_column);
1017 free((*val).type); }
1019 #line 1020 "btyacc_demo.tab.c"
1021 #line 78 "btyacc_demo.y"
1022 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1024 (*loc).first_line, (*loc).first_column,
1025 (*loc).last_line, (*loc).last_column);
1026 free((*val).type); }
1028 #line 1029 "btyacc_demo.tab.c"
1030 #line 78 "btyacc_demo.y"
1031 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1033 (*loc).first_line, (*loc).first_column,
1034 (*loc).last_line, (*loc).last_column);
1035 free((*val).type); }
1037 #line 1038 "btyacc_demo.tab.c"
1039 #line 78 "btyacc_demo.y"
1040 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1042 (*loc).first_line, (*loc).first_column,
1043 (*loc).last_line, (*loc).last_column);
1044 free((*val).type); }
1046 #line 1047 "btyacc_demo.tab.c"
1048 #line 78 "btyacc_demo.y"
1049 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1051 (*loc).first_line, (*loc).first_column,
1052 (*loc).last_line, (*loc).last_column);
1053 free((*val).type); }
1055 #line 1056 "btyacc_demo.tab.c"
1057 #line 78 "btyacc_demo.y"
1058 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1060 (*loc).first_line, (*loc).first_column,
1061 (*loc).last_line, (*loc).last_column);
1062 free((*val).scope); }
1064 #line 1065 "btyacc_demo.tab.c"
1066 #line 78 "btyacc_demo.y"
1067 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1069 (*loc).first_line, (*loc).first_column,
1070 (*loc).last_line, (*loc).last_column);
1071 free((*val).dlist); }
1073 #line 1074 "btyacc_demo.tab.c"
1075 #line 78 "btyacc_demo.y"
1076 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1078 (*loc).first_line, (*loc).first_column,
1079 (*loc).last_line, (*loc).last_column);
1080 free((*val).dlist); }
1082 #line 1083 "btyacc_demo.tab.c"
1084 #line 78 "btyacc_demo.y"
1085 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1087 (*loc).first_line, (*loc).first_column,
1088 (*loc).last_line, (*loc).last_column);
1089 free((*val).scope); }
1091 #line 1092 "btyacc_demo.tab.c"
1093 #line 78 "btyacc_demo.y"
1094 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1096 (*loc).first_line, (*loc).first_column,
1097 (*loc).last_line, (*loc).last_column);
1098 free((*val).scope); }
1100 #line 1101 "btyacc_demo.tab.c"
1102 #line 78 "btyacc_demo.y"
1103 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1105 (*loc).first_line, (*loc).first_column,
1106 (*loc).last_line, (*loc).last_column);
1107 free((*val).scope); }
1109 #line 1110 "btyacc_demo.tab.c"
1111 #line 78 "btyacc_demo.y"
1112 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1114 (*loc).first_line, (*loc).first_column,
1115 (*loc).last_line, (*loc).last_column);
1116 free((*val).scope); }
1118 #line 1119 "btyacc_demo.tab.c"
1120 #line 78 "btyacc_demo.y"
1121 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1123 (*loc).first_line, (*loc).first_column,
1124 (*loc).last_line, (*loc).last_column);
1125 free((*val).type); }
1127 #line 1128 "btyacc_demo.tab.c"
1129 #line 78 "btyacc_demo.y"
1130 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1132 (*loc).first_line, (*loc).first_column,
1133 (*loc).last_line, (*loc).last_column);
1134 free((*val).scope); }
1136 #line 1137 "btyacc_demo.tab.c"
1138 #line 78 "btyacc_demo.y"
1139 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1141 (*loc).first_line, (*loc).first_column,
1142 (*loc).last_line, (*loc).last_column);
1143 free((*val).type); }
1145 #line 1146 "btyacc_demo.tab.c"
1147 #line 78 "btyacc_demo.y"
1148 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1150 (*loc).first_line, (*loc).first_column,
1151 (*loc).last_line, (*loc).last_column);
1152 free((*val).scope); }
1154 #line 1155 "btyacc_demo.tab.c"
1156 #line 78 "btyacc_demo.y"
1157 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1159 (*loc).first_line, (*loc).first_column,
1160 (*loc).last_line, (*loc).last_column);
1161 free((*val).scope); }
1163 #line 1164 "btyacc_demo.tab.c"
1165 #line 78 "btyacc_demo.y"
1166 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1168 (*loc).first_line, (*loc).first_column,
1169 (*loc).last_line, (*loc).last_column);
1170 free((*val).scope); }
1172 #line 1173 "btyacc_demo.tab.c"
1175 #define YYDESTRUCT_IS_DECLARED 1
1178 /* For use in generated program */
1179 #define yydepth (int)(yystack.s_mark - yystack.s_base)
1181 #define yytrial (yyps->save)
1182 #endif /* YYBTYACC */
1185 #include <stdio.h> /* needed for printf */
1188 #include <stdlib.h> /* needed for malloc, etc */
1189 #include <string.h> /* needed for memset */
1191 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1192 static int yygrowstack(YYSTACKDATA *data)
1198 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1202 if ((newsize = data->stacksize) == 0)
1203 newsize = YYINITSTACKSIZE;
1204 else if (newsize >= YYMAXDEPTH)
1206 else if ((newsize *= 2) > YYMAXDEPTH)
1207 newsize = YYMAXDEPTH;
1209 i = (int) (data->s_mark - data->s_base);
1210 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1214 data->s_base = newss;
1215 data->s_mark = newss + i;
1217 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1221 data->l_base = newvs;
1222 data->l_mark = newvs + i;
1224 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1225 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
1229 data->p_base = newps;
1230 data->p_mark = newps + i;
1233 data->stacksize = newsize;
1234 data->s_last = data->s_base + newsize - 1;
1238 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
1243 #if YYPURE || defined(YY_NO_LEAKS)
1244 static void yyfreestack(YYSTACKDATA *data)
1248 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1251 memset(data, 0, sizeof(*data));
1254 #define yyfreestack(data) /* nothing */
1255 #endif /* YYPURE || defined(YY_NO_LEAKS) */
1258 static YYParseState *
1259 yyNewState(unsigned size)
1261 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
1262 if (p == NULL) return NULL;
1264 p->yystack.stacksize = size;
1267 p->yystack.s_base = NULL;
1268 p->yystack.l_base = NULL;
1269 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1270 p->yystack.p_base = NULL;
1274 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
1275 if (p->yystack.s_base == NULL) return NULL;
1276 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
1277 if (p->yystack.l_base == NULL) return NULL;
1278 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
1279 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1280 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
1281 if (p->yystack.p_base == NULL) return NULL;
1282 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
1289 yyFreeState(YYParseState *p)
1291 yyfreestack(&p->yystack);
1294 #endif /* YYBTYACC */
1296 #define YYABORT goto yyabort
1297 #define YYREJECT goto yyabort
1298 #define YYACCEPT goto yyaccept
1299 #define YYERROR goto yyerrlab
1301 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
1302 #define YYVALID_NESTED do { if (yyps->save && \
1303 yyps->save->save == 0) goto yyvalid; } while(0)
1304 #endif /* YYBTYACC */
1309 int yym, yyn, yystate, yyresult;
1312 YYParseState *yyerrctx = NULL;
1313 #endif /* YYBTYACC */
1314 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1315 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
1320 if ((yys = getenv("YYDEBUG")) != 0)
1323 if (yyn >= '0' && yyn <= '9')
1324 yydebug = yyn - '0';
1327 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
1331 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1333 #endif /* YYBTYACC */
1342 memset(&yystack, 0, sizeof(yystack));
1345 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1346 yystack.s_mark = yystack.s_base;
1347 yystack.l_mark = yystack.l_base;
1348 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1349 yystack.p_mark = yystack.p_base;
1352 *yystack.s_mark = 0;
1355 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1362 /* we're currently re-reading tokens */
1364 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1372 /* in trial mode; save scanner results for future parse attempts */
1373 if (yylvp == yylvlim)
1374 { /* Enlarge lexical value queue */
1375 size_t p = (size_t) (yylvp - yylvals);
1376 size_t s = (size_t) (yylvlim - yylvals);
1378 s += YYLVQUEUEGROWTH;
1379 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
1380 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1381 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1382 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1384 yylvp = yylve = yylvals + p;
1385 yylvlim = yylvals + s;
1386 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1387 yylpp = yylpe = yylpsns + p;
1388 yylplim = yylpsns + s;
1390 yylexp = yylexemes + p;
1392 *yylexp = (short) YYLEX;
1395 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1402 /* normal operation, no conflict encountered */
1403 #endif /* YYBTYACC */
1407 #endif /* YYBTYACC */
1408 if (yychar < 0) yychar = YYEOF;
1412 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1413 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1414 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1415 #ifdef YYSTYPE_TOSTRING
1418 #endif /* YYBTYACC */
1419 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1421 fputc('\n', stderr);
1427 /* Do we have a conflict? */
1428 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1429 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1438 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1439 YYDEBUGSTR, yydepth, yystate);
1441 /* Switch to the next conflict context */
1443 yypath = save->save;
1446 if (save->state != yystate) YYABORT;
1453 /* Unresolved conflict - start/continue trial parse */
1458 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1460 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1462 fputs("Starting trial parse.\n", stderr);
1465 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1466 if (save == NULL) goto yyenomem;
1467 save->save = yyps->save;
1468 save->state = yystate;
1469 save->errflag = yyerrflag;
1470 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1471 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1472 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1473 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1474 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1475 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1476 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1478 ctry = yytable[yyn];
1479 if (yyctable[ctry] == -1)
1482 if (yydebug && yychar >= YYEOF)
1483 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1488 if (yyps->save == NULL)
1490 /* If this is a first conflict in the stack, start saving lexemes */
1493 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
1494 if (yylexemes == NULL) goto yyenomem;
1495 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1496 if (yylvals == NULL) goto yyenomem;
1497 yylvlim = yylvals + YYLVQUEUEGROWTH;
1498 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1499 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1500 if (yylpsns == NULL) goto yyenomem;
1501 yylplim = yylpsns + YYLVQUEUEGROWTH;
1506 yylvp = yylve = yylvals;
1507 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1508 yylpp = yylpe = yylpsns;
1511 if (yychar >= YYEOF)
1514 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1517 *yylexp = (short) yychar;
1522 if (yychar >= YYEOF)
1525 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1531 save->lexeme = (int) (yylvp - yylvals);
1534 if (yytable[yyn] == ctry)
1538 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1539 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1544 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1549 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1551 yystate = yyctable[ctry];
1552 *++yystack.s_mark = (YYINT) yystate;
1553 *++yystack.l_mark = yylval;
1554 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1555 *++yystack.p_mark = yylloc;
1558 if (yyerrflag > 0) --yyerrflag;
1563 yyn = yyctable[ctry];
1566 } /* End of code dealing with conflicts */
1567 #endif /* YYBTYACC */
1568 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1569 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1573 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1574 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1576 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1577 yystate = yytable[yyn];
1578 *++yystack.s_mark = yytable[yyn];
1579 *++yystack.l_mark = yylval;
1580 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1581 *++yystack.p_mark = yylloc;
1584 if (yyerrflag > 0) --yyerrflag;
1587 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1588 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1593 if (yyerrflag != 0) goto yyinrecovery;
1598 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1601 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1602 * before looking for error recovery */
1603 yystack.s_mark -= yym;
1604 yystate = *yystack.s_mark;
1605 yystack.l_mark -= yym;
1606 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1607 yystack.p_mark -= yym;
1615 YYParseState *save = yyps->save;
1618 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1619 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1620 (int)(yylvp - yylvals - yyps->save->lexeme));
1622 /* Memorize most forward-looking error state in case it's really an error. */
1623 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1625 /* Free old saved error context state */
1626 if (yyerrctx) yyFreeState(yyerrctx);
1627 /* Create and fill out new saved error context state */
1628 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1629 if (yyerrctx == NULL) goto yyenomem;
1630 yyerrctx->save = yyps->save;
1631 yyerrctx->state = yystate;
1632 yyerrctx->errflag = yyerrflag;
1633 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1634 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1635 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1636 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1637 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1638 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1639 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1641 yyerrctx->lexeme = (int) (yylvp - yylvals);
1643 yylvp = yylvals + save->lexeme;
1644 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1645 yylpp = yylpsns + save->lexeme;
1647 yylexp = yylexemes + save->lexeme;
1649 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1650 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1651 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1652 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1653 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1654 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1655 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1657 ctry = ++save->ctry;
1658 yystate = save->state;
1659 /* We tried shift, try reduce now */
1660 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1661 yyps->save = save->save;
1665 /* Nothing left on the stack -- error */
1670 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1673 /* Restore state as it was in the most forward-advanced error */
1674 yylvp = yylvals + yyerrctx->lexeme;
1675 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1676 yylpp = yylpsns + yyerrctx->lexeme;
1678 yylexp = yylexemes + yyerrctx->lexeme;
1679 yychar = yylexp[-1];
1681 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1684 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1685 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1686 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1687 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1688 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1689 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1690 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1692 yystate = yyerrctx->state;
1693 yyFreeState(yyerrctx);
1698 if (yynewerrflag == 0) goto yyinrecovery;
1699 #endif /* YYBTYACC */
1701 YYERROR_CALL("syntax error");
1702 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1703 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1707 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1718 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1719 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1723 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1724 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1726 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1727 yystate = yytable[yyn];
1728 *++yystack.s_mark = yytable[yyn];
1729 *++yystack.l_mark = yylval;
1730 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1731 /* lookahead position is error end position */
1732 yyerror_loc_range[1] = yylloc;
1733 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1734 *++yystack.p_mark = yyloc;
1742 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1743 YYDEBUGSTR, yydepth, *yystack.s_mark);
1745 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1746 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1747 /* the current TOS position is the error start position */
1748 yyerror_loc_range[0] = *yystack.p_mark;
1750 #if defined(YYDESTRUCT_CALL)
1753 #endif /* YYBTYACC */
1754 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1755 YYDESTRUCT_CALL("error: discarding state",
1756 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1758 YYDESTRUCT_CALL("error: discarding state",
1759 yystos[*yystack.s_mark], yystack.l_mark);
1760 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1761 #endif /* defined(YYDESTRUCT_CALL) */
1764 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1772 if (yychar == YYEOF) goto yyabort;
1776 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1777 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1778 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1781 #if defined(YYDESTRUCT_CALL)
1784 #endif /* YYBTYACC */
1785 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1786 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1788 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1789 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1790 #endif /* defined(YYDESTRUCT_CALL) */
1800 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1801 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1802 #ifdef YYSTYPE_TOSTRING
1805 #endif /* YYBTYACC */
1810 for (i = yym; i > 0; i--)
1812 if (i != yym) fputs(", ", stderr);
1813 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1814 yystack.l_mark[1-i]), stderr);
1819 fputc('\n', stderr);
1823 yyval = yystack.l_mark[1-yym];
1825 memset(&yyval, 0, sizeof yyval);
1826 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1828 /* Perform position reduction */
1829 memset(&yyloc, 0, sizeof(yyloc));
1832 #endif /* YYBTYACC */
1834 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1835 /* just in case YYERROR is invoked within the action, save
1836 the start of the rhs as the error start position */
1837 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1844 #line 93 "btyacc_demo.y"
1845 { yyval.scope = yystack.l_mark[0].scope; }
1848 #line 94 "btyacc_demo.y"
1849 { yyval.scope = global_scope; }
1852 #line 95 "btyacc_demo.y"
1853 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1854 if (!d || !d->scope) YYERROR;
1855 yyval.scope = d->scope; }
1858 #line 101 "btyacc_demo.y"
1859 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1860 if (d == NULL || d->istype() == 0) YYERROR;
1861 yyval.type = d->type; }
1864 #line 106 "btyacc_demo.y"
1865 yyval.scope = global_scope = new_scope(0);
1868 #line 107 "btyacc_demo.y"
1869 yyval.scope = yystack.l_mark[-1].scope;
1872 #line 109 "btyacc_demo.y"
1876 #line 110 "btyacc_demo.y"
1877 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);
1881 #line 111 "btyacc_demo.y"
1882 { /* demonstrate use of @$ & @N, although this is just the
1883 default computation and so is not necessary */
1884 yyloc.first_line = yystack.p_mark[-3].first_line;
1885 yyloc.first_column = yystack.p_mark[-3].first_column;
1886 yyloc.last_line = yystack.p_mark[0].last_line;
1887 yyloc.last_column = yystack.p_mark[0].last_column;
1888 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1891 #line 121 "btyacc_demo.y"
1892 { yyval.type = yystack.l_mark[0].type; }
1895 #line 122 "btyacc_demo.y"
1896 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1899 #line 125 "btyacc_demo.y"
1903 #line 126 "btyacc_demo.y"
1904 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1907 #line 130 "btyacc_demo.y"
1908 { yyval.type = yystack.l_mark[0].type; }
1911 #line 131 "btyacc_demo.y"
1912 { yyval.type = yystack.l_mark[0].type; }
1915 #line 132 "btyacc_demo.y"
1916 { yyval.type = bare_extern(); }
1919 #line 133 "btyacc_demo.y"
1920 { yyval.type = bare_register(); }
1923 #line 134 "btyacc_demo.y"
1924 { yyval.type = bare_static(); }
1927 #line 138 "btyacc_demo.y"
1928 { yyval.type = bare_const(); }
1931 #line 139 "btyacc_demo.y"
1932 { yyval.type = bare_volatile(); }
1935 #line 143 "btyacc_demo.y"
1936 yyval.scope = yystack.l_mark[-3].scope;
1939 #line 143 "btyacc_demo.y"
1940 yyval.type = yystack.l_mark[-3].type;
1943 #line 148 "btyacc_demo.y"
1944 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1945 #line 149 "btyacc_demo.y"
1946 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1950 #line 150 "btyacc_demo.y"
1951 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1954 #line 151 "btyacc_demo.y"
1955 yyval.scope = yystack.l_mark[-2].scope;
1958 #line 151 "btyacc_demo.y"
1959 yyval.type = yystack.l_mark[-2].type;
1963 #line 151 "btyacc_demo.y"
1964 { yyval.decl = yystack.l_mark[-1].decl; }
1968 #line 153 "btyacc_demo.y"
1969 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
1973 #line 155 "btyacc_demo.y"
1974 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
1978 #line 157 "btyacc_demo.y"
1979 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
1983 #line 160 "btyacc_demo.y"
1984 { yyval.dlist = 0; }
1988 #line 161 "btyacc_demo.y"
1989 { yyval.dlist = yystack.l_mark[0].dlist; }
1993 #line 164 "btyacc_demo.y"
1994 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
1998 #line 165 "btyacc_demo.y"
1999 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2003 #line 168 "btyacc_demo.y"
2004 { yyval.decl = yystack.l_mark[0].decl; }
2008 #line 172 "btyacc_demo.y"
2009 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2013 #line 173 "btyacc_demo.y"
2014 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2018 #line 174 "btyacc_demo.y"
2019 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2023 #line 175 "btyacc_demo.y"
2024 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2028 #line 176 "btyacc_demo.y"
2029 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2033 #line 177 "btyacc_demo.y"
2034 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2038 #line 178 "btyacc_demo.y"
2039 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2043 #line 179 "btyacc_demo.y"
2044 { yyval.expr = yystack.l_mark[0].expr; }
2048 #line 183 "btyacc_demo.y"
2052 #line 184 "btyacc_demo.y"
2053 {YYVALID;} if (!yytrial)
2054 #line 184 "btyacc_demo.y"
2055 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2058 #line 185 "btyacc_demo.y"
2059 yyval.scope = yystack.l_mark[-6].scope;
2062 #line 185 "btyacc_demo.y"
2063 yyval.scope = yystack.l_mark[-9].scope;
2066 #line 185 "btyacc_demo.y"
2067 {YYVALID;} if (!yytrial)
2068 #line 186 "btyacc_demo.y"
2069 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2072 #line 187 "btyacc_demo.y"
2073 {YYVALID;} if (!yytrial)
2074 #line 188 "btyacc_demo.y"
2075 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2078 #line 189 "btyacc_demo.y"
2079 yyval.scope = new_scope(yystack.l_mark[0].scope);
2082 #line 189 "btyacc_demo.y"
2083 {YYVALID;} if (!yytrial)
2084 #line 189 "btyacc_demo.y"
2085 { yyval.code = yystack.l_mark[0].code; }
2089 #line 192 "btyacc_demo.y"
2094 #line 193 "btyacc_demo.y"
2095 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2099 #line 197 "btyacc_demo.y"
2100 { yyval.code = yystack.l_mark[-1].code; }
2102 #line 2103 "btyacc_demo.tab.c"
2106 yystack.s_mark -= yym;
2107 yystate = *yystack.s_mark;
2108 yystack.l_mark -= yym;
2109 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2110 yystack.p_mark -= yym;
2113 if (yystate == 0 && yym == 0)
2118 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2119 #ifdef YYSTYPE_TOSTRING
2122 #endif /* YYBTYACC */
2123 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2125 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2129 *++yystack.s_mark = YYFINAL;
2130 *++yystack.l_mark = yyval;
2131 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2132 *++yystack.p_mark = yyloc;
2140 /* we're currently re-reading tokens */
2142 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2150 /* in trial mode; save scanner results for future parse attempts */
2151 if (yylvp == yylvlim)
2152 { /* Enlarge lexical value queue */
2153 size_t p = (size_t) (yylvp - yylvals);
2154 size_t s = (size_t) (yylvlim - yylvals);
2156 s += YYLVQUEUEGROWTH;
2157 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
2159 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2161 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2162 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2165 yylvp = yylve = yylvals + p;
2166 yylvlim = yylvals + s;
2167 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2168 yylpp = yylpe = yylpsns + p;
2169 yylplim = yylpsns + s;
2171 yylexp = yylexemes + p;
2173 *yylexp = (short) YYLEX;
2176 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2183 /* normal operation, no conflict encountered */
2184 #endif /* YYBTYACC */
2188 #endif /* YYBTYACC */
2189 if (yychar < 0) yychar = YYEOF;
2193 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2194 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
2195 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2199 if (yychar == YYEOF) goto yyaccept;
2202 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2203 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2204 yystate = yytable[yyn];
2206 yystate = yydgoto[yym];
2210 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2211 #ifdef YYSTYPE_TOSTRING
2214 #endif /* YYBTYACC */
2215 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2217 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2220 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2221 *++yystack.s_mark = (YYINT) yystate;
2222 *++yystack.l_mark = yyval;
2223 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2224 *++yystack.p_mark = yyloc;
2229 /* Reduction declares that this path is valid. Set yypath and do a full parse */
2231 if (yypath) YYABORT;
2234 YYParseState *save = yyps->save;
2235 yyps->save = save->save;
2236 save->save = yypath;
2241 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2242 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2246 yyFreeState(yyerrctx);
2249 yylvp = yylvals + yypath->lexeme;
2250 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2251 yylpp = yylpsns + yypath->lexeme;
2253 yylexp = yylexemes + yypath->lexeme;
2255 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2256 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
2257 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2258 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2259 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2260 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2261 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2263 yystate = yypath->state;
2265 #endif /* YYBTYACC */
2268 YYERROR_CALL("yacc stack overflow");
2272 YYERROR_CALL("memory exhausted");
2274 #endif /* YYBTYACC */
2284 if (yyps->save) goto yyvalid;
2285 #endif /* YYBTYACC */
2289 #if defined(YYDESTRUCT_CALL)
2290 if (yychar != YYEOF && yychar != YYEMPTY)
2291 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2292 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2294 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2295 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2299 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2302 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2303 YYDESTRUCT_CALL("cleanup: discarding state",
2304 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2306 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2307 YYDESTRUCT_CALL("cleanup: discarding state",
2308 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2309 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2311 #endif /* defined(YYDESTRUCT_CALL) */
2316 yyFreeState(yyerrctx);
2321 YYParseState *save = yyps;
2328 YYParseState *save = yypath;
2329 yypath = save->save;
2333 #endif /* YYBTYACC */
2334 yyfreestack(&yystack);