calc2.tab.c revision 1.2.4.1 1 /* $NetBSD: calc2.tab.c,v 1.2.4.1 2017/07/18 18:09:43 snj Exp $ */
2
3 /* original parser id follows */
4 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
5 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
6
7 #define YYBYACC 1
8 #define YYMAJOR 1
9 #define YYMINOR 9
10 #define YYCHECK "yyyymmdd"
11
12 #define YYEMPTY (-1)
13 #define yyclearin (yychar = YYEMPTY)
14 #define yyerrok (yyerrflag = 0)
15 #define YYRECOVERING() (yyerrflag != 0)
16 #define YYENOMEM (-2)
17 #define YYEOF 0
18 #undef YYBTYACC
19 #define YYBTYACC 0
20 #define YYDEBUGSTR YYPREFIX "debug"
21
22 #ifndef yyparse
23 #define yyparse calc2_parse
24 #endif /* yyparse */
25
26 #ifndef yylex
27 #define yylex calc2_lex
28 #endif /* yylex */
29
30 #ifndef yyerror
31 #define yyerror calc2_error
32 #endif /* yyerror */
33
34 #ifndef yychar
35 #define yychar calc2_char
36 #endif /* yychar */
37
38 #ifndef yyval
39 #define yyval calc2_val
40 #endif /* yyval */
41
42 #ifndef yylval
43 #define yylval calc2_lval
44 #endif /* yylval */
45
46 #ifndef yydebug
47 #define yydebug calc2_debug
48 #endif /* yydebug */
49
50 #ifndef yynerrs
51 #define yynerrs calc2_nerrs
52 #endif /* yynerrs */
53
54 #ifndef yyerrflag
55 #define yyerrflag calc2_errflag
56 #endif /* yyerrflag */
57
58 #ifndef yylhs
59 #define yylhs calc2_lhs
60 #endif /* yylhs */
61
62 #ifndef yylen
63 #define yylen calc2_len
64 #endif /* yylen */
65
66 #ifndef yydefred
67 #define yydefred calc2_defred
68 #endif /* yydefred */
69
70 #ifndef yystos
71 #define yystos calc2_stos
72 #endif /* yystos */
73
74 #ifndef yydgoto
75 #define yydgoto calc2_dgoto
76 #endif /* yydgoto */
77
78 #ifndef yysindex
79 #define yysindex calc2_sindex
80 #endif /* yysindex */
81
82 #ifndef yyrindex
83 #define yyrindex calc2_rindex
84 #endif /* yyrindex */
85
86 #ifndef yygindex
87 #define yygindex calc2_gindex
88 #endif /* yygindex */
89
90 #ifndef yytable
91 #define yytable calc2_table
92 #endif /* yytable */
93
94 #ifndef yycheck
95 #define yycheck calc2_check
96 #endif /* yycheck */
97
98 #ifndef yyname
99 #define yyname calc2_name
100 #endif /* yyname */
101
102 #ifndef yyrule
103 #define yyrule calc2_rule
104 #endif /* yyrule */
105
106 #if YYBTYACC
107
108 #ifndef yycindex
109 #define yycindex calc2_cindex
110 #endif /* yycindex */
111
112 #ifndef yyctable
113 #define yyctable calc2_ctable
114 #endif /* yyctable */
115
116 #endif /* YYBTYACC */
117
118 #define YYPREFIX "calc2_"
119
120 #define YYPURE 0
121
122 #line 7 "calc2.y"
123 # include <stdio.h>
124 # include <ctype.h>
125
126 #ifdef YYBISON
127 #define YYLEX_PARAM base
128 #define YYLEX_DECL() yylex(int *YYLEX_PARAM)
129 #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
130 int YYLEX_DECL();
131 static void YYERROR_DECL();
132 #endif
133
134 #line 133 "calc2.tab.c"
135
136 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
137 /* Default: YYSTYPE is the semantic value type. */
138 typedef int YYSTYPE;
139 # define YYSTYPE_IS_DECLARED 1
140 #endif
141
142 /* compatibility with bison */
143 #ifdef YYPARSE_PARAM
144 /* compatibility with FreeBSD */
145 # ifdef YYPARSE_PARAM_TYPE
146 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
147 # else
148 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
149 # endif
150 #else
151 # define YYPARSE_DECL() yyparse(int regs[26], int *base)
152 #endif
153
154 /* Parameters sent to lex. */
155 #ifdef YYLEX_PARAM
156 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
157 # define YYLEX yylex(YYLEX_PARAM)
158 #else
159 # define YYLEX_DECL() yylex(int *base)
160 # define YYLEX yylex(base)
161 #endif
162
163 /* Parameters sent to yyerror. */
164 #ifndef YYERROR_DECL
165 #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
166 #endif
167 #ifndef YYERROR_CALL
168 #define YYERROR_CALL(msg) yyerror(regs, base, msg)
169 #endif
170
171 extern int YYPARSE_DECL();
172
173 #define DIGIT 257
174 #define LETTER 258
175 #define UMINUS 259
176 #define YYERRCODE 256
177 typedef short YYINT;
178 static const YYINT calc2_lhs[] = { -1,
179 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
180 2, 2, 2, 2, 2, 2, 3, 3,
181 };
182 static const YYINT calc2_len[] = { 2,
183 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
184 3, 3, 3, 2, 1, 1, 1, 2,
185 };
186 static const YYINT calc2_defred[] = { 1,
187 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
188 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
189 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
190 10, 11,
191 };
192 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
193 static const YYINT calc2_stos[] = { 0,
194 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
195 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
196 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
197 263, 263,
198 };
199 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
200 static const YYINT calc2_dgoto[] = { 1,
201 7, 8, 9,
202 };
203 static const YYINT calc2_sindex[] = { 0,
204 -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
205 -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
206 -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
207 0, 0,
208 };
209 static const YYINT calc2_rindex[] = { 0,
210 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
213 0, 0,
214 };
215 #if YYBTYACC
216 static const YYINT calc2_cindex[] = { 0,
217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
218 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
220 0, 0,
221 };
222 #endif
223 static const YYINT calc2_gindex[] = { 0,
224 0, 65, 0,
225 };
226 #define YYTABLESIZE 220
227 static const YYINT calc2_table[] = { 6,
228 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
229 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
230 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
231 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
232 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
233 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
234 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
235 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
236 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
237 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
238 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
239 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
240 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
241 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
242 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
250 };
251 static const YYINT calc2_check[] = { 40,
252 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
253 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
254 -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
255 -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
256 -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
257 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
258 -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
259 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
260 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
261 -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
262 -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
263 -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
264 -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
265 -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
266 -1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
267 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
269 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
270 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
271 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
272 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
273 -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
274 };
275 #if YYBTYACC
276 static const YYINT calc2_ctable[] = { -1,
277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
279 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
280 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
281 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
282 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
296 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
297 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
298 -1, -1, -1, -1, -1, -1, -1, -1, -1,
299 };
300 #endif
301 #define YYFINAL 1
302 #ifndef YYDEBUG
303 #define YYDEBUG 0
304 #endif
305 #define YYMAXTOKEN 259
306 #define YYUNDFTOKEN 265
307 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
308 #if YYDEBUG
309 static const char *const calc2_name[] = {
310
311 "$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
312 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
313 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
314 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
315 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
316 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
317 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
318 0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
319 "illegal-symbol",
320 };
321 static const char *const calc2_rule[] = {
322 "$accept : list",
323 "list :",
324 "list : list stat '\\n'",
325 "list : list error '\\n'",
326 "stat : expr",
327 "stat : LETTER '=' expr",
328 "expr : '(' expr ')'",
329 "expr : expr '+' expr",
330 "expr : expr '-' expr",
331 "expr : expr '*' expr",
332 "expr : expr '/' expr",
333 "expr : expr '%' expr",
334 "expr : expr '&' expr",
335 "expr : expr '|' expr",
336 "expr : '-' expr",
337 "expr : LETTER",
338 "expr : number",
339 "number : DIGIT",
340 "number : number DIGIT",
341
342 };
343 #endif
344
345 int yydebug;
346 int yynerrs;
347
348 int yyerrflag;
349 int yychar;
350 YYSTYPE yyval;
351 YYSTYPE yylval;
352 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
353 YYLTYPE yyloc; /* position returned by actions */
354 YYLTYPE yylloc; /* position from the lexer */
355 #endif
356
357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
358 #ifndef YYLLOC_DEFAULT
359 #define YYLLOC_DEFAULT(loc, rhs, n) \
360 do \
361 { \
362 if (n == 0) \
363 { \
364 (loc).first_line = ((rhs)[-1]).last_line; \
365 (loc).first_column = ((rhs)[-1]).last_column; \
366 (loc).last_line = ((rhs)[-1]).last_line; \
367 (loc).last_column = ((rhs)[-1]).last_column; \
368 } \
369 else \
370 { \
371 (loc).first_line = ((rhs)[ 0 ]).first_line; \
372 (loc).first_column = ((rhs)[ 0 ]).first_column; \
373 (loc).last_line = ((rhs)[n-1]).last_line; \
374 (loc).last_column = ((rhs)[n-1]).last_column; \
375 } \
376 } while (0)
377 #endif /* YYLLOC_DEFAULT */
378 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
379 #if YYBTYACC
380
381 #ifndef YYLVQUEUEGROWTH
382 #define YYLVQUEUEGROWTH 32
383 #endif
384 #endif /* YYBTYACC */
385
386 /* define the initial stack-sizes */
387 #ifdef YYSTACKSIZE
388 #undef YYMAXDEPTH
389 #define YYMAXDEPTH YYSTACKSIZE
390 #else
391 #ifdef YYMAXDEPTH
392 #define YYSTACKSIZE YYMAXDEPTH
393 #else
394 #define YYSTACKSIZE 10000
395 #define YYMAXDEPTH 10000
396 #endif
397 #endif
398
399 #ifndef YYINITSTACKSIZE
400 #define YYINITSTACKSIZE 200
401 #endif
402
403 typedef struct {
404 unsigned stacksize;
405 YYINT *s_base;
406 YYINT *s_mark;
407 YYINT *s_last;
408 YYSTYPE *l_base;
409 YYSTYPE *l_mark;
410 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
411 YYLTYPE *p_base;
412 YYLTYPE *p_mark;
413 #endif
414 } YYSTACKDATA;
415 #if YYBTYACC
416
417 struct YYParseState_s
418 {
419 struct YYParseState_s *save; /* Previously saved parser state */
420 YYSTACKDATA yystack; /* saved parser stack */
421 int state; /* saved parser state */
422 int errflag; /* saved error recovery status */
423 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
424 YYINT ctry; /* saved index in yyctable[] for this conflict */
425 };
426 typedef struct YYParseState_s YYParseState;
427 #endif /* YYBTYACC */
428 /* variables for the parser stack */
429 static YYSTACKDATA yystack;
430 #if YYBTYACC
431
432 /* Current parser state */
433 static YYParseState *yyps = 0;
434
435 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
436 static YYParseState *yypath = 0;
437
438 /* Base of the lexical value queue */
439 static YYSTYPE *yylvals = 0;
440
441 /* Current position at lexical value queue */
442 static YYSTYPE *yylvp = 0;
443
444 /* End position of lexical value queue */
445 static YYSTYPE *yylve = 0;
446
447 /* The last allocated position at the lexical value queue */
448 static YYSTYPE *yylvlim = 0;
449
450 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
451 /* Base of the lexical position queue */
452 static YYLTYPE *yylpsns = 0;
453
454 /* Current position at lexical position queue */
455 static YYLTYPE *yylpp = 0;
456
457 /* End position of lexical position queue */
458 static YYLTYPE *yylpe = 0;
459
460 /* The last allocated position at the lexical position queue */
461 static YYLTYPE *yylplim = 0;
462 #endif
463
464 /* Current position at lexical token queue */
465 static YYINT *yylexp = 0;
466
467 static YYINT *yylexemes = 0;
468 #endif /* YYBTYACC */
469 #line 73 "calc2.y"
470 /* start of programs */
471
472 #ifdef YYBYACC
473 extern int YYLEX_DECL();
474 #endif
475
476 int
477 main (void)
478 {
479 int regs[26];
480 int base = 10;
481
482 while(!feof(stdin)) {
483 yyparse(regs, &base);
484 }
485 return 0;
486 }
487
488 #define UNUSED(x) ((void)(x))
489
490 static void
491 YYERROR_DECL()
492 {
493 UNUSED(regs); /* %parse-param regs is not actually used here */
494 UNUSED(base); /* %parse-param base is not actually used here */
495 fprintf(stderr, "%s\n", s);
496 }
497
498 int
499 YYLEX_DECL()
500 {
501 /* lexical analysis routine */
502 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
503 /* return DIGIT for a digit, yylval = 0 through 9 */
504 /* all other characters are returned immediately */
505
506 int c;
507
508 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
509
510 /* c is now nonblank */
511
512 if( islower( c )) {
513 yylval = c - 'a';
514 return ( LETTER );
515 }
516 if( isdigit( c )) {
517 yylval = (c - '0') % (*base);
518 return ( DIGIT );
519 }
520 return( c );
521 }
522 #line 521 "calc2.tab.c"
523
524 /* For use in generated program */
525 #define yydepth (int)(yystack.s_mark - yystack.s_base)
526 #if YYBTYACC
527 #define yytrial (yyps->save)
528 #endif /* YYBTYACC */
529
530 #if YYDEBUG
531 #include <stdio.h> /* needed for printf */
532 #endif
533
534 #include <stdlib.h> /* needed for malloc, etc */
535 #include <string.h> /* needed for memset */
536
537 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
538 static int yygrowstack(YYSTACKDATA *data)
539 {
540 int i;
541 unsigned newsize;
542 YYINT *newss;
543 YYSTYPE *newvs;
544 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
545 YYLTYPE *newps;
546 #endif
547
548 if ((newsize = data->stacksize) == 0)
549 newsize = YYINITSTACKSIZE;
550 else if (newsize >= YYMAXDEPTH)
551 return YYENOMEM;
552 else if ((newsize *= 2) > YYMAXDEPTH)
553 newsize = YYMAXDEPTH;
554
555 i = (int) (data->s_mark - data->s_base);
556 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
557 if (newss == 0)
558 return YYENOMEM;
559
560 data->s_base = newss;
561 data->s_mark = newss + i;
562
563 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
564 if (newvs == 0)
565 return YYENOMEM;
566
567 data->l_base = newvs;
568 data->l_mark = newvs + i;
569
570 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
571 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
572 if (newps == 0)
573 return YYENOMEM;
574
575 data->p_base = newps;
576 data->p_mark = newps + i;
577 #endif
578
579 data->stacksize = newsize;
580 data->s_last = data->s_base + newsize - 1;
581
582 #if YYDEBUG
583 if (yydebug)
584 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
585 #endif
586 return 0;
587 }
588
589 #if YYPURE || defined(YY_NO_LEAKS)
590 static void yyfreestack(YYSTACKDATA *data)
591 {
592 free(data->s_base);
593 free(data->l_base);
594 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
595 free(data->p_base);
596 #endif
597 memset(data, 0, sizeof(*data));
598 }
599 #else
600 #define yyfreestack(data) /* nothing */
601 #endif /* YYPURE || defined(YY_NO_LEAKS) */
602 #if YYBTYACC
603
604 static YYParseState *
605 yyNewState(unsigned size)
606 {
607 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
608 if (p == NULL) return NULL;
609
610 p->yystack.stacksize = size;
611 if (size == 0)
612 {
613 p->yystack.s_base = NULL;
614 p->yystack.l_base = NULL;
615 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
616 p->yystack.p_base = NULL;
617 #endif
618 return p;
619 }
620 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
621 if (p->yystack.s_base == NULL) return NULL;
622 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
623 if (p->yystack.l_base == NULL) return NULL;
624 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
625 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
626 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
627 if (p->yystack.p_base == NULL) return NULL;
628 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
629 #endif
630
631 return p;
632 }
633
634 static void
635 yyFreeState(YYParseState *p)
636 {
637 yyfreestack(&p->yystack);
638 free(p);
639 }
640 #endif /* YYBTYACC */
641
642 #define YYABORT goto yyabort
643 #define YYREJECT goto yyabort
644 #define YYACCEPT goto yyaccept
645 #define YYERROR goto yyerrlab
646 #if YYBTYACC
647 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
648 #define YYVALID_NESTED do { if (yyps->save && \
649 yyps->save->save == 0) goto yyvalid; } while(0)
650 #endif /* YYBTYACC */
651
652 int
653 YYPARSE_DECL()
654 {
655 int yym, yyn, yystate, yyresult;
656 #if YYBTYACC
657 int yynewerrflag;
658 YYParseState *yyerrctx = NULL;
659 #endif /* YYBTYACC */
660 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
661 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
662 #endif
663 #if YYDEBUG
664 const char *yys;
665
666 if ((yys = getenv("YYDEBUG")) != 0)
667 {
668 yyn = *yys;
669 if (yyn >= '0' && yyn <= '9')
670 yydebug = yyn - '0';
671 }
672 if (yydebug)
673 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
674 #endif
675 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
676 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
677 #endif
678
679 #if YYBTYACC
680 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
681 yyps->save = 0;
682 #endif /* YYBTYACC */
683 yym = 0;
684 yyn = 0;
685 yynerrs = 0;
686 yyerrflag = 0;
687 yychar = YYEMPTY;
688 yystate = 0;
689
690 #if YYPURE
691 memset(&yystack, 0, sizeof(yystack));
692 #endif
693
694 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
695 yystack.s_mark = yystack.s_base;
696 yystack.l_mark = yystack.l_base;
697 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
698 yystack.p_mark = yystack.p_base;
699 #endif
700 yystate = 0;
701 *yystack.s_mark = 0;
702
703 yyloop:
704 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
705 if (yychar < 0)
706 {
707 #if YYBTYACC
708 do {
709 if (yylvp < yylve)
710 {
711 /* we're currently re-reading tokens */
712 yylval = *yylvp++;
713 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
714 yylloc = *yylpp++;
715 #endif
716 yychar = *yylexp++;
717 break;
718 }
719 if (yyps->save)
720 {
721 /* in trial mode; save scanner results for future parse attempts */
722 if (yylvp == yylvlim)
723 { /* Enlarge lexical value queue */
724 size_t p = (size_t) (yylvp - yylvals);
725 size_t s = (size_t) (yylvlim - yylvals);
726
727 s += YYLVQUEUEGROWTH;
728 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
729 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
730 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
731 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
732 #endif
733 yylvp = yylve = yylvals + p;
734 yylvlim = yylvals + s;
735 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
736 yylpp = yylpe = yylpsns + p;
737 yylplim = yylpsns + s;
738 #endif
739 yylexp = yylexemes + p;
740 }
741 *yylexp = (YYINT) YYLEX;
742 *yylvp++ = yylval;
743 yylve++;
744 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
745 *yylpp++ = yylloc;
746 yylpe++;
747 #endif
748 yychar = *yylexp++;
749 break;
750 }
751 /* normal operation, no conflict encountered */
752 #endif /* YYBTYACC */
753 yychar = YYLEX;
754 #if YYBTYACC
755 } while (0);
756 #endif /* YYBTYACC */
757 if (yychar < 0) yychar = YYEOF;
758 #if YYDEBUG
759 if (yydebug)
760 {
761 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
762 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
763 YYDEBUGSTR, yydepth, yystate, yychar, yys);
764 #ifdef YYSTYPE_TOSTRING
765 #if YYBTYACC
766 if (!yytrial)
767 #endif /* YYBTYACC */
768 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
769 #endif
770 fputc('\n', stderr);
771 }
772 #endif
773 }
774 #if YYBTYACC
775
776 /* Do we have a conflict? */
777 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
778 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
779 {
780 YYINT ctry;
781
782 if (yypath)
783 {
784 YYParseState *save;
785 #if YYDEBUG
786 if (yydebug)
787 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
788 YYDEBUGSTR, yydepth, yystate);
789 #endif
790 /* Switch to the next conflict context */
791 save = yypath;
792 yypath = save->save;
793 save->save = NULL;
794 ctry = save->ctry;
795 if (save->state != yystate) YYABORT;
796 yyFreeState(save);
797
798 }
799 else
800 {
801
802 /* Unresolved conflict - start/continue trial parse */
803 YYParseState *save;
804 #if YYDEBUG
805 if (yydebug)
806 {
807 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
808 if (yyps->save)
809 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
810 else
811 fputs("Starting trial parse.\n", stderr);
812 }
813 #endif
814 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
815 if (save == NULL) goto yyenomem;
816 save->save = yyps->save;
817 save->state = yystate;
818 save->errflag = yyerrflag;
819 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
820 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
821 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
822 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
823 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
824 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
825 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
826 #endif
827 ctry = yytable[yyn];
828 if (yyctable[ctry] == -1)
829 {
830 #if YYDEBUG
831 if (yydebug && yychar >= YYEOF)
832 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
833 #endif
834 ctry++;
835 }
836 save->ctry = ctry;
837 if (yyps->save == NULL)
838 {
839 /* If this is a first conflict in the stack, start saving lexemes */
840 if (!yylexemes)
841 {
842 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
843 if (yylexemes == NULL) goto yyenomem;
844 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
845 if (yylvals == NULL) goto yyenomem;
846 yylvlim = yylvals + YYLVQUEUEGROWTH;
847 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
848 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
849 if (yylpsns == NULL) goto yyenomem;
850 yylplim = yylpsns + YYLVQUEUEGROWTH;
851 #endif
852 }
853 if (yylvp == yylve)
854 {
855 yylvp = yylve = yylvals;
856 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
857 yylpp = yylpe = yylpsns;
858 #endif
859 yylexp = yylexemes;
860 if (yychar >= YYEOF)
861 {
862 *yylve++ = yylval;
863 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
864 *yylpe++ = yylloc;
865 #endif
866 *yylexp = (YYINT) yychar;
867 yychar = YYEMPTY;
868 }
869 }
870 }
871 if (yychar >= YYEOF)
872 {
873 yylvp--;
874 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
875 yylpp--;
876 #endif
877 yylexp--;
878 yychar = YYEMPTY;
879 }
880 save->lexeme = (int) (yylvp - yylvals);
881 yyps->save = save;
882 }
883 if (yytable[yyn] == ctry)
884 {
885 #if YYDEBUG
886 if (yydebug)
887 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
888 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
889 #endif
890 if (yychar < 0)
891 {
892 yylvp++;
893 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
894 yylpp++;
895 #endif
896 yylexp++;
897 }
898 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
899 goto yyoverflow;
900 yystate = yyctable[ctry];
901 *++yystack.s_mark = (YYINT) yystate;
902 *++yystack.l_mark = yylval;
903 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
904 *++yystack.p_mark = yylloc;
905 #endif
906 yychar = YYEMPTY;
907 if (yyerrflag > 0) --yyerrflag;
908 goto yyloop;
909 }
910 else
911 {
912 yyn = yyctable[ctry];
913 goto yyreduce;
914 }
915 } /* End of code dealing with conflicts */
916 #endif /* YYBTYACC */
917 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
918 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
919 {
920 #if YYDEBUG
921 if (yydebug)
922 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
923 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
924 #endif
925 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
926 yystate = yytable[yyn];
927 *++yystack.s_mark = yytable[yyn];
928 *++yystack.l_mark = yylval;
929 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
930 *++yystack.p_mark = yylloc;
931 #endif
932 yychar = YYEMPTY;
933 if (yyerrflag > 0) --yyerrflag;
934 goto yyloop;
935 }
936 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
937 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
938 {
939 yyn = yytable[yyn];
940 goto yyreduce;
941 }
942 if (yyerrflag != 0) goto yyinrecovery;
943 #if YYBTYACC
944
945 yynewerrflag = 1;
946 goto yyerrhandler;
947 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
948
949 yyerrlab:
950 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
951 * before looking for error recovery */
952 yystack.s_mark -= yym;
953 yystate = *yystack.s_mark;
954 yystack.l_mark -= yym;
955 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
956 yystack.p_mark -= yym;
957 #endif
958
959 yynewerrflag = 0;
960 yyerrhandler:
961 while (yyps->save)
962 {
963 int ctry;
964 YYParseState *save = yyps->save;
965 #if YYDEBUG
966 if (yydebug)
967 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
968 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
969 (int)(yylvp - yylvals - yyps->save->lexeme));
970 #endif
971 /* Memorize most forward-looking error state in case it's really an error. */
972 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
973 {
974 /* Free old saved error context state */
975 if (yyerrctx) yyFreeState(yyerrctx);
976 /* Create and fill out new saved error context state */
977 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
978 if (yyerrctx == NULL) goto yyenomem;
979 yyerrctx->save = yyps->save;
980 yyerrctx->state = yystate;
981 yyerrctx->errflag = yyerrflag;
982 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
983 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
984 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
985 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
986 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
987 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
988 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
989 #endif
990 yyerrctx->lexeme = (int) (yylvp - yylvals);
991 }
992 yylvp = yylvals + save->lexeme;
993 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
994 yylpp = yylpsns + save->lexeme;
995 #endif
996 yylexp = yylexemes + save->lexeme;
997 yychar = YYEMPTY;
998 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
999 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1000 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1001 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1002 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1003 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1004 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1005 #endif
1006 ctry = ++save->ctry;
1007 yystate = save->state;
1008 /* We tried shift, try reduce now */
1009 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1010 yyps->save = save->save;
1011 save->save = NULL;
1012 yyFreeState(save);
1013
1014 /* Nothing left on the stack -- error */
1015 if (!yyps->save)
1016 {
1017 #if YYDEBUG
1018 if (yydebug)
1019 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1020 YYPREFIX, yydepth);
1021 #endif
1022 /* Restore state as it was in the most forward-advanced error */
1023 yylvp = yylvals + yyerrctx->lexeme;
1024 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1025 yylpp = yylpsns + yyerrctx->lexeme;
1026 #endif
1027 yylexp = yylexemes + yyerrctx->lexeme;
1028 yychar = yylexp[-1];
1029 yylval = yylvp[-1];
1030 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1031 yylloc = yylpp[-1];
1032 #endif
1033 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1034 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1035 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1036 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1037 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1038 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1039 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1040 #endif
1041 yystate = yyerrctx->state;
1042 yyFreeState(yyerrctx);
1043 yyerrctx = NULL;
1044 }
1045 yynewerrflag = 1;
1046 }
1047 if (yynewerrflag == 0) goto yyinrecovery;
1048 #endif /* YYBTYACC */
1049
1050 YYERROR_CALL("syntax error");
1051 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1052 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1053 #endif
1054
1055 #if !YYBTYACC
1056 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1057 yyerrlab:
1058 #endif
1059 ++yynerrs;
1060
1061 yyinrecovery:
1062 if (yyerrflag < 3)
1063 {
1064 yyerrflag = 3;
1065 for (;;)
1066 {
1067 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1068 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1069 {
1070 #if YYDEBUG
1071 if (yydebug)
1072 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1073 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1074 #endif
1075 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1076 yystate = yytable[yyn];
1077 *++yystack.s_mark = yytable[yyn];
1078 *++yystack.l_mark = yylval;
1079 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1080 /* lookahead position is error end position */
1081 yyerror_loc_range[1] = yylloc;
1082 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1083 *++yystack.p_mark = yyloc;
1084 #endif
1085 goto yyloop;
1086 }
1087 else
1088 {
1089 #if YYDEBUG
1090 if (yydebug)
1091 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1092 YYDEBUGSTR, yydepth, *yystack.s_mark);
1093 #endif
1094 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1095 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1096 /* the current TOS position is the error start position */
1097 yyerror_loc_range[0] = *yystack.p_mark;
1098 #endif
1099 #if defined(YYDESTRUCT_CALL)
1100 #if YYBTYACC
1101 if (!yytrial)
1102 #endif /* YYBTYACC */
1103 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1104 YYDESTRUCT_CALL("error: discarding state",
1105 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1106 #else
1107 YYDESTRUCT_CALL("error: discarding state",
1108 yystos[*yystack.s_mark], yystack.l_mark);
1109 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1110 #endif /* defined(YYDESTRUCT_CALL) */
1111 --yystack.s_mark;
1112 --yystack.l_mark;
1113 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1114 --yystack.p_mark;
1115 #endif
1116 }
1117 }
1118 }
1119 else
1120 {
1121 if (yychar == YYEOF) goto yyabort;
1122 #if YYDEBUG
1123 if (yydebug)
1124 {
1125 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1126 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1127 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1128 }
1129 #endif
1130 #if defined(YYDESTRUCT_CALL)
1131 #if YYBTYACC
1132 if (!yytrial)
1133 #endif /* YYBTYACC */
1134 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1135 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1136 #else
1137 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1138 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1139 #endif /* defined(YYDESTRUCT_CALL) */
1140 yychar = YYEMPTY;
1141 goto yyloop;
1142 }
1143
1144 yyreduce:
1145 yym = yylen[yyn];
1146 #if YYDEBUG
1147 if (yydebug)
1148 {
1149 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1150 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1151 #ifdef YYSTYPE_TOSTRING
1152 #if YYBTYACC
1153 if (!yytrial)
1154 #endif /* YYBTYACC */
1155 if (yym > 0)
1156 {
1157 int i;
1158 fputc('<', stderr);
1159 for (i = yym; i > 0; i--)
1160 {
1161 if (i != yym) fputs(", ", stderr);
1162 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1163 yystack.l_mark[1-i]), stderr);
1164 }
1165 fputc('>', stderr);
1166 }
1167 #endif
1168 fputc('\n', stderr);
1169 }
1170 #endif
1171 if (yym > 0)
1172 yyval = yystack.l_mark[1-yym];
1173 else
1174 memset(&yyval, 0, sizeof yyval);
1175 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1176
1177 /* Perform position reduction */
1178 memset(&yyloc, 0, sizeof(yyloc));
1179 #if YYBTYACC
1180 if (!yytrial)
1181 #endif /* YYBTYACC */
1182 {
1183 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1184 /* just in case YYERROR is invoked within the action, save
1185 the start of the rhs as the error start position */
1186 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1187 }
1188 #endif
1189
1190 switch (yyn)
1191 {
1192 case 3:
1193 #line 35 "calc2.y"
1194 { yyerrok ; }
1195 break;
1196 case 4:
1197 #line 39 "calc2.y"
1198 { printf("%d\n",yystack.l_mark[0]);}
1199 break;
1200 case 5:
1201 #line 41 "calc2.y"
1202 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1203 break;
1204 case 6:
1205 #line 45 "calc2.y"
1206 { yyval = yystack.l_mark[-1]; }
1207 break;
1208 case 7:
1209 #line 47 "calc2.y"
1210 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1211 break;
1212 case 8:
1213 #line 49 "calc2.y"
1214 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1215 break;
1216 case 9:
1217 #line 51 "calc2.y"
1218 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1219 break;
1220 case 10:
1221 #line 53 "calc2.y"
1222 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1223 break;
1224 case 11:
1225 #line 55 "calc2.y"
1226 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1227 break;
1228 case 12:
1229 #line 57 "calc2.y"
1230 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1231 break;
1232 case 13:
1233 #line 59 "calc2.y"
1234 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1235 break;
1236 case 14:
1237 #line 61 "calc2.y"
1238 { yyval = - yystack.l_mark[0]; }
1239 break;
1240 case 15:
1241 #line 63 "calc2.y"
1242 { yyval = regs[yystack.l_mark[0]]; }
1243 break;
1244 case 17:
1245 #line 68 "calc2.y"
1246 { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
1247 break;
1248 case 18:
1249 #line 70 "calc2.y"
1250 { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
1251 break;
1252 #line 1251 "calc2.tab.c"
1253 default:
1254 break;
1255 }
1256 yystack.s_mark -= yym;
1257 yystate = *yystack.s_mark;
1258 yystack.l_mark -= yym;
1259 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1260 yystack.p_mark -= yym;
1261 #endif
1262 yym = yylhs[yyn];
1263 if (yystate == 0 && yym == 0)
1264 {
1265 #if YYDEBUG
1266 if (yydebug)
1267 {
1268 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1269 #ifdef YYSTYPE_TOSTRING
1270 #if YYBTYACC
1271 if (!yytrial)
1272 #endif /* YYBTYACC */
1273 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1274 #endif
1275 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1276 }
1277 #endif
1278 yystate = YYFINAL;
1279 *++yystack.s_mark = YYFINAL;
1280 *++yystack.l_mark = yyval;
1281 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1282 *++yystack.p_mark = yyloc;
1283 #endif
1284 if (yychar < 0)
1285 {
1286 #if YYBTYACC
1287 do {
1288 if (yylvp < yylve)
1289 {
1290 /* we're currently re-reading tokens */
1291 yylval = *yylvp++;
1292 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1293 yylloc = *yylpp++;
1294 #endif
1295 yychar = *yylexp++;
1296 break;
1297 }
1298 if (yyps->save)
1299 {
1300 /* in trial mode; save scanner results for future parse attempts */
1301 if (yylvp == yylvlim)
1302 { /* Enlarge lexical value queue */
1303 size_t p = (size_t) (yylvp - yylvals);
1304 size_t s = (size_t) (yylvlim - yylvals);
1305
1306 s += YYLVQUEUEGROWTH;
1307 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1308 goto yyenomem;
1309 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1310 goto yyenomem;
1311 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1312 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1313 goto yyenomem;
1314 #endif
1315 yylvp = yylve = yylvals + p;
1316 yylvlim = yylvals + s;
1317 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1318 yylpp = yylpe = yylpsns + p;
1319 yylplim = yylpsns + s;
1320 #endif
1321 yylexp = yylexemes + p;
1322 }
1323 *yylexp = (YYINT) YYLEX;
1324 *yylvp++ = yylval;
1325 yylve++;
1326 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1327 *yylpp++ = yylloc;
1328 yylpe++;
1329 #endif
1330 yychar = *yylexp++;
1331 break;
1332 }
1333 /* normal operation, no conflict encountered */
1334 #endif /* YYBTYACC */
1335 yychar = YYLEX;
1336 #if YYBTYACC
1337 } while (0);
1338 #endif /* YYBTYACC */
1339 if (yychar < 0) yychar = YYEOF;
1340 #if YYDEBUG
1341 if (yydebug)
1342 {
1343 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1344 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1345 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1346 }
1347 #endif
1348 }
1349 if (yychar == YYEOF) goto yyaccept;
1350 goto yyloop;
1351 }
1352 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1353 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1354 yystate = yytable[yyn];
1355 else
1356 yystate = yydgoto[yym];
1357 #if YYDEBUG
1358 if (yydebug)
1359 {
1360 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1361 #ifdef YYSTYPE_TOSTRING
1362 #if YYBTYACC
1363 if (!yytrial)
1364 #endif /* YYBTYACC */
1365 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1366 #endif
1367 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1368 }
1369 #endif
1370 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1371 *++yystack.s_mark = (YYINT) yystate;
1372 *++yystack.l_mark = yyval;
1373 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1374 *++yystack.p_mark = yyloc;
1375 #endif
1376 goto yyloop;
1377 #if YYBTYACC
1378
1379 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1380 yyvalid:
1381 if (yypath) YYABORT;
1382 while (yyps->save)
1383 {
1384 YYParseState *save = yyps->save;
1385 yyps->save = save->save;
1386 save->save = yypath;
1387 yypath = save;
1388 }
1389 #if YYDEBUG
1390 if (yydebug)
1391 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1392 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1393 #endif
1394 if (yyerrctx)
1395 {
1396 yyFreeState(yyerrctx);
1397 yyerrctx = NULL;
1398 }
1399 yylvp = yylvals + yypath->lexeme;
1400 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1401 yylpp = yylpsns + yypath->lexeme;
1402 #endif
1403 yylexp = yylexemes + yypath->lexeme;
1404 yychar = YYEMPTY;
1405 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1406 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1407 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1408 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1409 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1410 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1411 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1412 #endif
1413 yystate = yypath->state;
1414 goto yyloop;
1415 #endif /* YYBTYACC */
1416
1417 yyoverflow:
1418 YYERROR_CALL("yacc stack overflow");
1419 #if YYBTYACC
1420 goto yyabort_nomem;
1421 yyenomem:
1422 YYERROR_CALL("memory exhausted");
1423 yyabort_nomem:
1424 #endif /* YYBTYACC */
1425 yyresult = 2;
1426 goto yyreturn;
1427
1428 yyabort:
1429 yyresult = 1;
1430 goto yyreturn;
1431
1432 yyaccept:
1433 #if YYBTYACC
1434 if (yyps->save) goto yyvalid;
1435 #endif /* YYBTYACC */
1436 yyresult = 0;
1437
1438 yyreturn:
1439 #if defined(YYDESTRUCT_CALL)
1440 if (yychar != YYEOF && yychar != YYEMPTY)
1441 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1442 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1443 #else
1444 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1445 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1446
1447 {
1448 YYSTYPE *pv;
1449 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1450 YYLTYPE *pp;
1451
1452 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1453 YYDESTRUCT_CALL("cleanup: discarding state",
1454 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1455 #else
1456 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1457 YYDESTRUCT_CALL("cleanup: discarding state",
1458 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1459 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1460 }
1461 #endif /* defined(YYDESTRUCT_CALL) */
1462
1463 #if YYBTYACC
1464 if (yyerrctx)
1465 {
1466 yyFreeState(yyerrctx);
1467 yyerrctx = NULL;
1468 }
1469 while (yyps)
1470 {
1471 YYParseState *save = yyps;
1472 yyps = save->save;
1473 save->save = NULL;
1474 yyFreeState(save);
1475 }
1476 while (yypath)
1477 {
1478 YYParseState *save = yypath;
1479 yypath = save->save;
1480 save->save = NULL;
1481 yyFreeState(save);
1482 }
1483 #endif /* YYBTYACC */
1484 yyfreestack(&yystack);
1485 return (yyresult);
1486 }
1487