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)
17 /* %code "top" block start */
18 #line 5 "calc_code_all.y"
20 /* %code "top" block end */
21 #line 22 "calc_code_all.tab.c"
24 #define YYDEBUGSTR YYPREFIX "debug"
27 #define yyparse calc_code_all_parse
31 #define yylex calc_code_all_lex
35 #define yyerror calc_code_all_error
39 #define yychar calc_code_all_char
43 #define yyval calc_code_all_val
47 #define yylval calc_code_all_lval
51 #define yydebug calc_code_all_debug
55 #define yynerrs calc_code_all_nerrs
59 #define yyerrflag calc_code_all_errflag
60 #endif /* yyerrflag */
63 #define yylhs calc_code_all_lhs
67 #define yylen calc_code_all_len
71 #define yydefred calc_code_all_defred
75 #define yystos calc_code_all_stos
79 #define yydgoto calc_code_all_dgoto
83 #define yysindex calc_code_all_sindex
87 #define yyrindex calc_code_all_rindex
91 #define yygindex calc_code_all_gindex
95 #define yytable calc_code_all_table
99 #define yycheck calc_code_all_check
103 #define yyname calc_code_all_name
107 #define yyrule calc_code_all_rule
113 #define yycindex calc_code_all_cindex
114 #endif /* yycindex */
117 #define yyctable calc_code_all_ctable
118 #endif /* yyctable */
120 #endif /* YYBTYACC */
122 #define YYPREFIX "calc_code_all_"
126 #line 9 "calc_code_all.y"
133 extern int yylex(void);
134 static void yyerror(const char *s);
136 #line 137 "calc_code_all.tab.c"
138 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
139 /* Default: YYSTYPE is the semantic value type. */
141 # define YYSTYPE_IS_DECLARED 1
144 /* compatibility with bison */
146 /* compatibility with FreeBSD */
147 # ifdef YYPARSE_PARAM_TYPE
148 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
150 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
153 # define YYPARSE_DECL() yyparse(void)
156 /* Parameters sent to lex. */
158 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
159 # define YYLEX yylex(YYLEX_PARAM)
161 # define YYLEX_DECL() yylex(void)
162 # define YYLEX yylex()
165 /* Parameters sent to yyerror. */
167 #define YYERROR_DECL() yyerror(const char *s)
170 #define YYERROR_CALL(msg) yyerror(msg)
173 extern int YYPARSE_DECL();
178 #define YYERRCODE 256
180 static const YYINT calc_code_all_lhs[] = { -1,
181 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
182 2, 2, 2, 2, 2, 2, 3, 3,
184 static const YYINT calc_code_all_len[] = { 2,
185 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
186 3, 3, 3, 2, 1, 1, 1, 2,
188 static const YYINT calc_code_all_defred[] = { 1,
189 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
190 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
191 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
194 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
195 static const YYINT calc_code_all_stos[] = { 0,
196 261, 256, 257, 258, 45, 40, 262, 263, 264, 10,
197 61, 258, 263, 263, 10, 124, 38, 43, 45, 42,
198 47, 37, 257, 263, 41, 263, 263, 263, 263, 263,
201 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
202 static const YYINT calc_code_all_dgoto[] = { 1,
205 static const YYINT calc_code_all_sindex[] = { 0,
206 -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
207 -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
208 -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
211 static const YYINT calc_code_all_rindex[] = { 0,
212 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
214 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
218 static const YYINT calc_code_all_cindex[] = { 0,
219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
225 static const YYINT calc_code_all_gindex[] = { 0,
228 #define YYTABLESIZE 220
229 static const YYINT calc_code_all_table[] = { 6,
230 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
231 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
232 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
233 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
234 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
235 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
236 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
237 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
238 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
239 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
240 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
241 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
242 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
243 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
244 0, 0, 0, 0, 0, 16, 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, 0, 0, 0, 0, 0,
250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
251 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
253 static const YYINT calc_code_all_check[] = { 40,
254 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
255 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
256 -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
257 -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
258 -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
259 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
260 -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
261 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
262 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
263 -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
264 -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
265 -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
266 -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
267 -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
268 -1, -1, -1, -1, -1, 124, -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, -1, -1, -1, -1, -1,
274 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
275 -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
278 static const YYINT calc_code_all_ctable[] = { -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, -1,
299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
300 -1, -1, -1, -1, -1, -1, -1, -1, -1,
307 #define YYMAXTOKEN 259
308 #define YYUNDFTOKEN 265
309 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
311 static const char *const calc_code_all_name[] = {
313 "$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,
314 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,
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,
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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
319 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
320 0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
323 static const char *const calc_code_all_rule[] = {
326 "list : list stat '\\n'",
327 "list : list error '\\n'",
329 "stat : LETTER '=' expr",
330 "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 '&' expr",
337 "expr : expr '|' expr",
342 "number : number DIGIT",
357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
358 YYLTYPE yyloc; /* position returned by actions */
359 YYLTYPE yylloc; /* position from the lexer */
362 /* %code "requires" block start */
363 #line 3 "calc_code_all.y"
365 /* %code "requires" block end */
366 #line 367 "calc_code_all.tab.c"
368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
369 #ifndef YYLLOC_DEFAULT
370 #define YYLLOC_DEFAULT(loc, rhs, n) \
375 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
376 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
377 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
378 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
382 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
383 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
384 (loc).last_line = YYRHSLOC(rhs, n).last_line; \
385 (loc).last_column = YYRHSLOC(rhs, n).last_column; \
388 #endif /* YYLLOC_DEFAULT */
389 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
392 #ifndef YYLVQUEUEGROWTH
393 #define YYLVQUEUEGROWTH 32
395 #endif /* YYBTYACC */
397 /* define the initial stack-sizes */
400 #define YYMAXDEPTH YYSTACKSIZE
403 #define YYSTACKSIZE YYMAXDEPTH
405 #define YYSTACKSIZE 10000
406 #define YYMAXDEPTH 10000
410 #ifndef YYINITSTACKSIZE
411 #define YYINITSTACKSIZE 200
421 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
428 struct YYParseState_s
430 struct YYParseState_s *save; /* Previously saved parser state */
431 YYSTACKDATA yystack; /* saved parser stack */
432 int state; /* saved parser state */
433 int errflag; /* saved error recovery status */
434 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
435 YYINT ctry; /* saved index in yyctable[] for this conflict */
437 typedef struct YYParseState_s YYParseState;
438 #endif /* YYBTYACC */
439 /* variables for the parser stack */
440 static YYSTACKDATA yystack;
443 /* Current parser state */
444 static YYParseState *yyps = 0;
446 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
447 static YYParseState *yypath = 0;
449 /* Base of the lexical value queue */
450 static YYSTYPE *yylvals = 0;
452 /* Current position at lexical value queue */
453 static YYSTYPE *yylvp = 0;
455 /* End position of lexical value queue */
456 static YYSTYPE *yylve = 0;
458 /* The last allocated position at the lexical value queue */
459 static YYSTYPE *yylvlim = 0;
461 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
462 /* Base of the lexical position queue */
463 static YYLTYPE *yylpsns = 0;
465 /* Current position at lexical position queue */
466 static YYLTYPE *yylpp = 0;
468 /* End position of lexical position queue */
469 static YYLTYPE *yylpe = 0;
471 /* The last allocated position at the lexical position queue */
472 static YYLTYPE *yylplim = 0;
475 /* Current position at lexical token queue */
476 static YYINT *yylexp = 0;
478 static YYINT *yylexemes = 0;
479 #endif /* YYBTYACC */
481 /* %code "provides" block start */
482 #line 4 "calc_code_all.y"
484 #line 6 "calc_code_all.y"
486 /* %code "provides" block end */
487 #line 488 "calc_code_all.tab.c"
489 /* %code "" block start */
490 #line 1 "calc_code_all.y"
492 #line 2 "calc_code_all.y"
494 /* %code "" block end */
495 #line 496 "calc_code_all.tab.c"
496 #line 73 "calc_code_all.y"
497 /* start of programs */
502 while(!feof(stdin)) {
509 yyerror(const char *s)
511 fprintf(stderr, "%s\n", s);
517 /* lexical analysis routine */
518 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
519 /* return DIGIT for a digit, yylval = 0 through 9 */
520 /* all other characters are returned immediately */
524 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
526 /* c is now nonblank */
538 #line 539 "calc_code_all.tab.c"
540 /* For use in generated program */
541 #define yydepth (int)(yystack.s_mark - yystack.s_base)
543 #define yytrial (yyps->save)
544 #endif /* YYBTYACC */
547 #include <stdio.h> /* needed for printf */
550 #include <stdlib.h> /* needed for malloc, etc */
551 #include <string.h> /* needed for memset */
553 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
554 static int yygrowstack(YYSTACKDATA *data)
560 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
564 if ((newsize = data->stacksize) == 0)
565 newsize = YYINITSTACKSIZE;
566 else if (newsize >= YYMAXDEPTH)
568 else if ((newsize *= 2) > YYMAXDEPTH)
569 newsize = YYMAXDEPTH;
571 i = (int) (data->s_mark - data->s_base);
572 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
576 data->s_base = newss;
577 data->s_mark = newss + i;
579 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
583 data->l_base = newvs;
584 data->l_mark = newvs + i;
586 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
587 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
591 data->p_base = newps;
592 data->p_mark = newps + i;
595 data->stacksize = newsize;
596 data->s_last = data->s_base + newsize - 1;
600 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
605 #if YYPURE || defined(YY_NO_LEAKS)
606 static void yyfreestack(YYSTACKDATA *data)
610 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
613 memset(data, 0, sizeof(*data));
616 #define yyfreestack(data) /* nothing */
617 #endif /* YYPURE || defined(YY_NO_LEAKS) */
620 static YYParseState *
621 yyNewState(unsigned size)
623 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
624 if (p == NULL) return NULL;
626 p->yystack.stacksize = size;
629 p->yystack.s_base = NULL;
630 p->yystack.l_base = NULL;
631 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
632 p->yystack.p_base = NULL;
636 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
637 if (p->yystack.s_base == NULL) return NULL;
638 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
639 if (p->yystack.l_base == NULL) return NULL;
640 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
642 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
643 if (p->yystack.p_base == NULL) return NULL;
644 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
651 yyFreeState(YYParseState *p)
653 yyfreestack(&p->yystack);
656 #endif /* YYBTYACC */
658 #define YYABORT goto yyabort
659 #define YYREJECT goto yyabort
660 #define YYACCEPT goto yyaccept
661 #define YYERROR goto yyerrlab
663 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
664 #define YYVALID_NESTED do { if (yyps->save && \
665 yyps->save->save == 0) goto yyvalid; } while(0)
666 #endif /* YYBTYACC */
671 int yym, yyn, yystate, yyresult;
674 YYParseState *yyerrctx = NULL;
675 #endif /* YYBTYACC */
676 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
677 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
682 if ((yys = getenv("YYDEBUG")) != 0)
685 if (yyn >= '0' && yyn <= '9')
689 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
691 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
692 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
696 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
698 #endif /* YYBTYACC */
707 memset(&yystack, 0, sizeof(yystack));
710 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
711 yystack.s_mark = yystack.s_base;
712 yystack.l_mark = yystack.l_base;
713 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
714 yystack.p_mark = yystack.p_base;
720 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
727 /* we're currently re-reading tokens */
729 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
737 /* in trial mode; save scanner results for future parse attempts */
738 if (yylvp == yylvlim)
739 { /* Enlarge lexical value queue */
740 size_t p = (size_t) (yylvp - yylvals);
741 size_t s = (size_t) (yylvlim - yylvals);
743 s += YYLVQUEUEGROWTH;
744 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
745 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
746 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
747 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
749 yylvp = yylve = yylvals + p;
750 yylvlim = yylvals + s;
751 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
752 yylpp = yylpe = yylpsns + p;
753 yylplim = yylpsns + s;
755 yylexp = yylexemes + p;
757 *yylexp = (YYINT) YYLEX;
760 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
767 /* normal operation, no conflict encountered */
768 #endif /* YYBTYACC */
772 #endif /* YYBTYACC */
773 if (yychar < 0) yychar = YYEOF;
777 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
778 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
779 YYDEBUGSTR, yydepth, yystate, yychar, yys);
780 #ifdef YYSTYPE_TOSTRING
783 #endif /* YYBTYACC */
784 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
792 /* Do we have a conflict? */
793 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
794 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
803 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
804 YYDEBUGSTR, yydepth, yystate);
806 /* Switch to the next conflict context */
811 if (save->state != yystate) YYABORT;
818 /* Unresolved conflict - start/continue trial parse */
823 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
825 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
827 fputs("Starting trial parse.\n", stderr);
830 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
831 if (save == NULL) goto yyenomem;
832 save->save = yyps->save;
833 save->state = yystate;
834 save->errflag = yyerrflag;
835 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
836 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
837 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
838 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
839 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
840 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
841 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
844 if (yyctable[ctry] == -1)
847 if (yydebug && yychar >= YYEOF)
848 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
853 if (yyps->save == NULL)
855 /* If this is a first conflict in the stack, start saving lexemes */
858 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
859 if (yylexemes == NULL) goto yyenomem;
860 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
861 if (yylvals == NULL) goto yyenomem;
862 yylvlim = yylvals + YYLVQUEUEGROWTH;
863 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
864 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
865 if (yylpsns == NULL) goto yyenomem;
866 yylplim = yylpsns + YYLVQUEUEGROWTH;
871 yylvp = yylve = yylvals;
872 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
873 yylpp = yylpe = yylpsns;
879 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
882 *yylexp = (YYINT) yychar;
890 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
896 save->lexeme = (int) (yylvp - yylvals);
899 if (yytable[yyn] == ctry)
903 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
904 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
909 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
914 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
916 yystate = yyctable[ctry];
917 *++yystack.s_mark = (YYINT) yystate;
918 *++yystack.l_mark = yylval;
919 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
920 *++yystack.p_mark = yylloc;
923 if (yyerrflag > 0) --yyerrflag;
928 yyn = yyctable[ctry];
931 } /* End of code dealing with conflicts */
932 #endif /* YYBTYACC */
933 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
934 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
938 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
939 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
941 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
942 yystate = yytable[yyn];
943 *++yystack.s_mark = yytable[yyn];
944 *++yystack.l_mark = yylval;
945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
946 *++yystack.p_mark = yylloc;
949 if (yyerrflag > 0) --yyerrflag;
952 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
953 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
958 if (yyerrflag != 0) goto yyinrecovery;
963 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
966 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
967 * before looking for error recovery */
968 yystack.s_mark -= yym;
969 yystate = *yystack.s_mark;
970 yystack.l_mark -= yym;
971 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
972 yystack.p_mark -= yym;
980 YYParseState *save = yyps->save;
983 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
984 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
985 (int)(yylvp - yylvals - yyps->save->lexeme));
987 /* Memorize most forward-looking error state in case it's really an error. */
988 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
990 /* Free old saved error context state */
991 if (yyerrctx) yyFreeState(yyerrctx);
992 /* Create and fill out new saved error context state */
993 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
994 if (yyerrctx == NULL) goto yyenomem;
995 yyerrctx->save = yyps->save;
996 yyerrctx->state = yystate;
997 yyerrctx->errflag = yyerrflag;
998 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
999 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1000 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1001 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1002 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1003 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1004 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1006 yyerrctx->lexeme = (int) (yylvp - yylvals);
1008 yylvp = yylvals + save->lexeme;
1009 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1010 yylpp = yylpsns + save->lexeme;
1012 yylexp = yylexemes + save->lexeme;
1014 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1015 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1016 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1017 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1018 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1019 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1020 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1022 ctry = ++save->ctry;
1023 yystate = save->state;
1024 /* We tried shift, try reduce now */
1025 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1026 yyps->save = save->save;
1030 /* Nothing left on the stack -- error */
1035 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1038 /* Restore state as it was in the most forward-advanced error */
1039 yylvp = yylvals + yyerrctx->lexeme;
1040 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1041 yylpp = yylpsns + yyerrctx->lexeme;
1043 yylexp = yylexemes + yyerrctx->lexeme;
1044 yychar = yylexp[-1];
1046 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1049 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1050 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1051 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1052 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1053 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1054 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1055 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1057 yystate = yyerrctx->state;
1058 yyFreeState(yyerrctx);
1063 if (yynewerrflag == 0) goto yyinrecovery;
1064 #endif /* YYBTYACC */
1066 YYERROR_CALL("syntax error");
1067 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1068 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1072 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1083 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1084 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1088 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1089 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1091 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1092 yystate = yytable[yyn];
1093 *++yystack.s_mark = yytable[yyn];
1094 *++yystack.l_mark = yylval;
1095 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1096 /* lookahead position is error end position */
1097 yyerror_loc_range[2] = yylloc;
1098 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1099 *++yystack.p_mark = yyloc;
1107 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1108 YYDEBUGSTR, yydepth, *yystack.s_mark);
1110 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1111 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1112 /* the current TOS position is the error start position */
1113 yyerror_loc_range[1] = *yystack.p_mark;
1115 #if defined(YYDESTRUCT_CALL)
1118 #endif /* YYBTYACC */
1119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1120 YYDESTRUCT_CALL("error: discarding state",
1121 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1123 YYDESTRUCT_CALL("error: discarding state",
1124 yystos[*yystack.s_mark], yystack.l_mark);
1125 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1126 #endif /* defined(YYDESTRUCT_CALL) */
1129 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1137 if (yychar == YYEOF) goto yyabort;
1141 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1142 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1143 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1146 #if defined(YYDESTRUCT_CALL)
1149 #endif /* YYBTYACC */
1150 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1151 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1153 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1154 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1155 #endif /* defined(YYDESTRUCT_CALL) */
1165 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1166 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1167 #ifdef YYSTYPE_TOSTRING
1170 #endif /* YYBTYACC */
1175 for (i = yym; i > 0; i--)
1177 if (i != yym) fputs(", ", stderr);
1178 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1179 yystack.l_mark[1-i]), stderr);
1184 fputc('\n', stderr);
1188 yyval = yystack.l_mark[1-yym];
1190 memset(&yyval, 0, sizeof yyval);
1191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1193 /* Perform position reduction */
1194 memset(&yyloc, 0, sizeof(yyloc));
1197 #endif /* YYBTYACC */
1199 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1200 /* just in case YYERROR is invoked within the action, save
1201 the start of the rhs as the error start position */
1202 yyerror_loc_range[1] = yystack.p_mark[1-yym];
1209 #line 35 "calc_code_all.y"
1213 #line 39 "calc_code_all.y"
1214 { printf("%d\n",yystack.l_mark[0]);}
1217 #line 41 "calc_code_all.y"
1218 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1221 #line 45 "calc_code_all.y"
1222 { yyval = yystack.l_mark[-1]; }
1225 #line 47 "calc_code_all.y"
1226 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1229 #line 49 "calc_code_all.y"
1230 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1233 #line 51 "calc_code_all.y"
1234 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1237 #line 53 "calc_code_all.y"
1238 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1241 #line 55 "calc_code_all.y"
1242 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1245 #line 57 "calc_code_all.y"
1246 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1249 #line 59 "calc_code_all.y"
1250 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1253 #line 61 "calc_code_all.y"
1254 { yyval = - yystack.l_mark[0]; }
1257 #line 63 "calc_code_all.y"
1258 { yyval = regs[yystack.l_mark[0]]; }
1261 #line 68 "calc_code_all.y"
1262 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1265 #line 70 "calc_code_all.y"
1266 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1268 #line 1269 "calc_code_all.tab.c"
1272 yystack.s_mark -= yym;
1273 yystate = *yystack.s_mark;
1274 yystack.l_mark -= yym;
1275 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1276 yystack.p_mark -= yym;
1279 if (yystate == 0 && yym == 0)
1284 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1285 #ifdef YYSTYPE_TOSTRING
1288 #endif /* YYBTYACC */
1289 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1291 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1295 *++yystack.s_mark = YYFINAL;
1296 *++yystack.l_mark = yyval;
1297 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1298 *++yystack.p_mark = yyloc;
1306 /* we're currently re-reading tokens */
1308 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1316 /* in trial mode; save scanner results for future parse attempts */
1317 if (yylvp == yylvlim)
1318 { /* Enlarge lexical value queue */
1319 size_t p = (size_t) (yylvp - yylvals);
1320 size_t s = (size_t) (yylvlim - yylvals);
1322 s += YYLVQUEUEGROWTH;
1323 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1325 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1327 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1328 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1331 yylvp = yylve = yylvals + p;
1332 yylvlim = yylvals + s;
1333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1334 yylpp = yylpe = yylpsns + p;
1335 yylplim = yylpsns + s;
1337 yylexp = yylexemes + p;
1339 *yylexp = (YYINT) YYLEX;
1342 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1349 /* normal operation, no conflict encountered */
1350 #endif /* YYBTYACC */
1354 #endif /* YYBTYACC */
1355 if (yychar < 0) yychar = YYEOF;
1359 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1360 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1361 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1365 if (yychar == YYEOF) goto yyaccept;
1368 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1369 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1370 yystate = yytable[yyn];
1372 yystate = yydgoto[yym];
1376 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1377 #ifdef YYSTYPE_TOSTRING
1380 #endif /* YYBTYACC */
1381 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1383 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1386 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1387 *++yystack.s_mark = (YYINT) yystate;
1388 *++yystack.l_mark = yyval;
1389 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1390 *++yystack.p_mark = yyloc;
1395 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1397 if (yypath) YYABORT;
1400 YYParseState *save = yyps->save;
1401 yyps->save = save->save;
1402 save->save = yypath;
1407 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1408 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1412 yyFreeState(yyerrctx);
1415 yylvp = yylvals + yypath->lexeme;
1416 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1417 yylpp = yylpsns + yypath->lexeme;
1419 yylexp = yylexemes + yypath->lexeme;
1421 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1422 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1423 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1424 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1425 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1426 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1427 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1429 yystate = yypath->state;
1431 #endif /* YYBTYACC */
1434 YYERROR_CALL("yacc stack overflow");
1438 YYERROR_CALL("memory exhausted");
1440 #endif /* YYBTYACC */
1450 if (yyps->save) goto yyvalid;
1451 #endif /* YYBTYACC */
1455 #if defined(YYDESTRUCT_CALL)
1456 if (yychar != YYEOF && yychar != YYEMPTY)
1457 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1458 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1460 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1461 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1465 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1468 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1469 YYDESTRUCT_CALL("cleanup: discarding state",
1470 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1472 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1473 YYDESTRUCT_CALL("cleanup: discarding state",
1474 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1475 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1477 #endif /* defined(YYDESTRUCT_CALL) */
1482 yyFreeState(yyerrctx);
1487 YYParseState *save = yyps;
1494 YYParseState *save = yypath;
1495 yypath = save->save;
1499 #endif /* YYBTYACC */
1500 yyfreestack(&yystack);