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 YYPREFIX "debug"
21 #define yyparse quote_calc2_parse
25 #define yylex quote_calc2_lex
29 #define yyerror quote_calc2_error
33 #define yychar quote_calc2_char
37 #define yyval quote_calc2_val
41 #define yylval quote_calc2_lval
45 #define yydebug quote_calc2_debug
49 #define yynerrs quote_calc2_nerrs
53 #define yyerrflag quote_calc2_errflag
54 #endif /* yyerrflag */
57 #define yylhs quote_calc2_lhs
61 #define yylen quote_calc2_len
65 #define yydefred quote_calc2_defred
69 #define yystos quote_calc2_stos
73 #define yydgoto quote_calc2_dgoto
77 #define yysindex quote_calc2_sindex
81 #define yyrindex quote_calc2_rindex
85 #define yygindex quote_calc2_gindex
89 #define yytable quote_calc2_table
93 #define yycheck quote_calc2_check
97 #define yyname quote_calc2_name
101 #define yyrule quote_calc2_rule
107 #define yycindex quote_calc2_cindex
108 #endif /* yycindex */
111 #define yyctable quote_calc2_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "quote_calc2_"
120 #line 2 "quote_calc2.y"
128 static void yyerror(const char *s);
130 #line 131 "quote_calc2-s.tab.c"
132 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
133 /* Default: YYSTYPE is the semantic value type. */
135 # define YYSTYPE_IS_DECLARED 1
138 /* compatibility with bison */
140 /* compatibility with FreeBSD */
141 # ifdef YYPARSE_PARAM_TYPE
142 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
144 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
147 # define YYPARSE_DECL() yyparse(void)
150 /* Parameters sent to lex. */
152 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
153 # define YYLEX yylex(YYLEX_PARAM)
155 # define YYLEX_DECL() yylex(void)
156 # define YYLEX yylex()
159 /* Parameters sent to yyerror. */
161 #define YYERROR_DECL() yyerror(const char *s)
164 #define YYERROR_CALL(msg) yyerror(msg)
167 extern int YYPARSE_DECL();
178 #define YYERRCODE 256
180 static const YYINT quote_calc2_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 quote_calc2_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 quote_calc2_defred[] = { 1,
189 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
190 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
191 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
194 static const YYINT quote_calc2_stos[] = { 0,
195 273, 256, 260, 269, 270, 40, 274, 275, 276, 10,
196 270, 275, 61, 275, 10, 258, 260, 262, 264, 266,
197 268, 124, 269, 275, 41, 275, 275, 275, 275, 275,
200 static const YYINT quote_calc2_dgoto[] = { 1,
203 static const YYINT quote_calc2_sindex[] = { 0,
204 -38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
205 0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
206 -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
209 static const YYINT quote_calc2_rindex[] = { 0,
210 0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
211 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
216 static const YYINT quote_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,
223 static const YYINT quote_calc2_gindex[] = { 0,
226 #define YYTABLESIZE 259
227 static const YYINT quote_calc2_table[] = { 16,
228 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
229 10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
230 19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
231 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
232 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
233 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
234 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
235 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
238 22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
242 18, 0, 19, 0, 20, 0, 21, 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, 0, 0, 2, 0, 0,
250 0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
251 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
252 19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
253 15, 16, 15, 16, 15, 16, 15, 16, 15,
255 static const YYINT quote_calc2_check[] = { 10,
256 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
257 10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
258 264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
259 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
260 -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
261 -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
262 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
263 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
264 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
265 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
266 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
267 -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
269 -1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
270 262, -1, 264, -1, 266, -1, 268, -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, -1, -1, -1, -1, -1,
276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
277 -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
278 -1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
279 269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
280 264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
281 260, 262, 262, 264, 264, 266, 266, 268, 268,
287 #define YYMAXTOKEN 271
288 #define YYUNDFTOKEN 277
289 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
291 static const char *const quote_calc2_name[] = {
293 "$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,
294 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
295 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
296 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
297 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
298 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
299 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
300 0,0,"error","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
301 "\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
302 "$accept","list","stat","expr","number","illegal-symbol",
304 static const char *const quote_calc2_rule[] = {
307 "list : list stat '\\n'",
308 "list : list error '\\n'",
310 "stat : LETTER '=' expr",
311 "expr : '(' expr ')'",
312 "expr : expr \"ADD\" expr",
313 "expr : expr \"SUB\" expr",
314 "expr : expr \"MUL\" expr",
315 "expr : expr \"DIV\" expr",
316 "expr : expr \"MOD\" expr",
317 "expr : expr \"AND\" expr",
318 "expr : expr '|' expr",
319 "expr : \"SUB\" expr",
323 "number : number DIGIT",
335 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
336 YYLTYPE yyloc; /* position returned by actions */
337 YYLTYPE yylloc; /* position from the lexer */
340 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
341 #ifndef YYLLOC_DEFAULT
342 #define YYLLOC_DEFAULT(loc, rhs, n) \
347 (loc).first_line = ((rhs)[-1]).last_line; \
348 (loc).first_column = ((rhs)[-1]).last_column; \
349 (loc).last_line = ((rhs)[-1]).last_line; \
350 (loc).last_column = ((rhs)[-1]).last_column; \
354 (loc).first_line = ((rhs)[ 0 ]).first_line; \
355 (loc).first_column = ((rhs)[ 0 ]).first_column; \
356 (loc).last_line = ((rhs)[n-1]).last_line; \
357 (loc).last_column = ((rhs)[n-1]).last_column; \
360 #endif /* YYLLOC_DEFAULT */
361 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
364 #ifndef YYLVQUEUEGROWTH
365 #define YYLVQUEUEGROWTH 32
367 #endif /* YYBTYACC */
369 /* define the initial stack-sizes */
372 #define YYMAXDEPTH YYSTACKSIZE
375 #define YYSTACKSIZE YYMAXDEPTH
377 #define YYSTACKSIZE 10000
378 #define YYMAXDEPTH 10000
382 #ifndef YYINITSTACKSIZE
383 #define YYINITSTACKSIZE 200
393 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
400 struct YYParseState_s
402 struct YYParseState_s *save; /* Previously saved parser state */
403 YYSTACKDATA yystack; /* saved parser stack */
404 int state; /* saved parser state */
405 int errflag; /* saved error recovery status */
406 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
407 YYINT ctry; /* saved index in yyctable[] for this conflict */
409 typedef struct YYParseState_s YYParseState;
410 #endif /* YYBTYACC */
411 /* variables for the parser stack */
412 static YYSTACKDATA yystack;
415 /* Current parser state */
416 static YYParseState *yyps = 0;
418 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
419 static YYParseState *yypath = 0;
421 /* Base of the lexical value queue */
422 static YYSTYPE *yylvals = 0;
424 /* Current position at lexical value queue */
425 static YYSTYPE *yylvp = 0;
427 /* End position of lexical value queue */
428 static YYSTYPE *yylve = 0;
430 /* The last allocated position at the lexical value queue */
431 static YYSTYPE *yylvlim = 0;
433 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
434 /* Base of the lexical position queue */
435 static YYLTYPE *yylpsns = 0;
437 /* Current position at lexical position queue */
438 static YYLTYPE *yylpp = 0;
440 /* End position of lexical position queue */
441 static YYLTYPE *yylpe = 0;
443 /* The last allocated position at the lexical position queue */
444 static YYLTYPE *yylplim = 0;
447 /* Current position at lexical token queue */
448 static short *yylexp = 0;
450 static short *yylexemes = 0;
451 #endif /* YYBTYACC */
452 #line 73 "quote_calc2.y"
453 /* start of programs */
458 while(!feof(stdin)) {
465 yyerror(const char *s)
467 fprintf(stderr, "%s\n", s);
472 /* lexical analysis routine */
473 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
474 /* return DIGIT for a digit, yylval = 0 through 9 */
475 /* all other characters are returned immediately */
479 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
481 /* c is now nonblank */
493 #line 494 "quote_calc2-s.tab.c"
495 /* For use in generated program */
496 #define yydepth (int)(yystack.s_mark - yystack.s_base)
498 #define yytrial (yyps->save)
499 #endif /* YYBTYACC */
502 #include <stdio.h> /* needed for printf */
505 #include <stdlib.h> /* needed for malloc, etc */
506 #include <string.h> /* needed for memset */
508 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
509 static int yygrowstack(YYSTACKDATA *data)
515 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
519 if ((newsize = data->stacksize) == 0)
520 newsize = YYINITSTACKSIZE;
521 else if (newsize >= YYMAXDEPTH)
523 else if ((newsize *= 2) > YYMAXDEPTH)
524 newsize = YYMAXDEPTH;
526 i = (int) (data->s_mark - data->s_base);
527 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
531 data->s_base = newss;
532 data->s_mark = newss + i;
534 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
538 data->l_base = newvs;
539 data->l_mark = newvs + i;
541 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
542 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
546 data->p_base = newps;
547 data->p_mark = newps + i;
550 data->stacksize = newsize;
551 data->s_last = data->s_base + newsize - 1;
555 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
560 #if YYPURE || defined(YY_NO_LEAKS)
561 static void yyfreestack(YYSTACKDATA *data)
565 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
568 memset(data, 0, sizeof(*data));
571 #define yyfreestack(data) /* nothing */
572 #endif /* YYPURE || defined(YY_NO_LEAKS) */
575 static YYParseState *
576 yyNewState(unsigned size)
578 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
579 if (p == NULL) return NULL;
581 p->yystack.stacksize = size;
584 p->yystack.s_base = NULL;
585 p->yystack.l_base = NULL;
586 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
587 p->yystack.p_base = NULL;
591 p->yystack.s_base = (short *) malloc(size * sizeof(short));
592 if (p->yystack.s_base == NULL) return NULL;
593 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
594 if (p->yystack.l_base == NULL) return NULL;
595 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
596 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
597 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
598 if (p->yystack.p_base == NULL) return NULL;
599 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
606 yyFreeState(YYParseState *p)
608 yyfreestack(&p->yystack);
611 #endif /* YYBTYACC */
613 #define YYABORT goto yyabort
614 #define YYREJECT goto yyabort
615 #define YYACCEPT goto yyaccept
616 #define YYERROR goto yyerrlab
618 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
619 #define YYVALID_NESTED do { if (yyps->save && \
620 yyps->save->save == 0) goto yyvalid; } while(0)
621 #endif /* YYBTYACC */
626 int yym, yyn, yystate, yyresult;
629 YYParseState *yyerrctx = NULL;
630 #endif /* YYBTYACC */
631 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
632 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
637 if ((yys = getenv("YYDEBUG")) != 0)
640 if (yyn >= '0' && yyn <= '9')
644 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
648 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
650 #endif /* YYBTYACC */
657 memset(&yystack, 0, sizeof(yystack));
660 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
661 yystack.s_mark = yystack.s_base;
662 yystack.l_mark = yystack.l_base;
663 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
664 yystack.p_mark = yystack.p_base;
670 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
677 /* we're currently re-reading tokens */
679 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
687 /* in trial mode; save scanner results for future parse attempts */
688 if (yylvp == yylvlim)
689 { /* Enlarge lexical value queue */
690 int p = yylvp - yylvals;
691 int s = yylvlim - yylvals;
693 s += YYLVQUEUEGROWTH;
694 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
695 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
696 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
697 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
699 yylvp = yylve = yylvals + p;
700 yylvlim = yylvals + s;
701 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
702 yylpp = yylpe = yylpsns + p;
703 yylplim = yylpsns + s;
705 yylexp = yylexemes + p;
707 *yylexp = (short) YYLEX;
710 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
717 /* normal operation, no conflict encountered */
718 #endif /* YYBTYACC */
722 #endif /* YYBTYACC */
723 if (yychar < 0) yychar = YYEOF;
724 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
728 yys = yyname[YYTRANSLATE(yychar)];
729 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
730 YYDEBUGSTR, yydepth, yystate, yychar, yys);
731 #ifdef YYSTYPE_TOSTRING
734 #endif /* YYBTYACC */
735 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
743 /* Do we have a conflict? */
744 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
745 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
754 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
755 YYDEBUGSTR, yydepth, yystate);
757 /* Switch to the next conflict context */
762 if (save->state != yystate) YYABORT;
769 /* Unresolved conflict - start/continue trial parse */
774 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
776 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
778 fputs("Starting trial parse.\n", stderr);
781 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
782 if (save == NULL) goto yyenomem;
783 save->save = yyps->save;
784 save->state = yystate;
785 save->errflag = yyerrflag;
786 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
787 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
788 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
789 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
790 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
791 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
792 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
795 if (yyctable[ctry] == -1)
798 if (yydebug && yychar >= YYEOF)
799 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
804 if (yyps->save == NULL)
806 /* If this is a first conflict in the stack, start saving lexemes */
809 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
810 if (yylexemes == NULL) goto yyenomem;
811 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
812 if (yylvals == NULL) goto yyenomem;
813 yylvlim = yylvals + YYLVQUEUEGROWTH;
814 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
815 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
816 if (yylpsns == NULL) goto yyenomem;
817 yylplim = yylpsns + YYLVQUEUEGROWTH;
822 yylvp = yylve = yylvals;
823 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
824 yylpp = yylpe = yylpsns;
830 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
833 *yylexp = (short) yychar;
841 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
847 save->lexeme = yylvp - yylvals;
850 if (yytable[yyn] == ctry)
854 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
855 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
860 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
865 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
867 yystate = yyctable[ctry];
868 *++yystack.s_mark = (short) yystate;
869 *++yystack.l_mark = yylval;
870 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
871 *++yystack.p_mark = yylloc;
874 if (yyerrflag > 0) --yyerrflag;
879 yyn = yyctable[ctry];
882 } /* End of code dealing with conflicts */
883 #endif /* YYBTYACC */
884 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
885 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
889 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
890 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
892 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
893 yystate = yytable[yyn];
894 *++yystack.s_mark = yytable[yyn];
895 *++yystack.l_mark = yylval;
896 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
897 *++yystack.p_mark = yylloc;
900 if (yyerrflag > 0) --yyerrflag;
903 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
904 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
909 if (yyerrflag != 0) goto yyinrecovery;
922 YYParseState *save = yyps->save;
925 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
926 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
927 (int)(yylvp - yylvals - yyps->save->lexeme));
929 /* Memorize most forward-looking error state in case it's really an error. */
930 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
932 /* Free old saved error context state */
933 if (yyerrctx) yyFreeState(yyerrctx);
934 /* Create and fill out new saved error context state */
935 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
936 if (yyerrctx == NULL) goto yyenomem;
937 yyerrctx->save = yyps->save;
938 yyerrctx->state = yystate;
939 yyerrctx->errflag = yyerrflag;
940 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
941 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
942 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
943 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
944 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
945 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
946 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
948 yyerrctx->lexeme = yylvp - yylvals;
950 yylvp = yylvals + save->lexeme;
951 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
952 yylpp = yylpsns + save->lexeme;
954 yylexp = yylexemes + save->lexeme;
956 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
957 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
958 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
959 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
960 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
961 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
962 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
965 yystate = save->state;
966 /* We tried shift, try reduce now */
967 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
968 yyps->save = save->save;
972 /* Nothing left on the stack -- error */
977 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
980 /* Restore state as it was in the most forward-advanced error */
981 yylvp = yylvals + yyerrctx->lexeme;
982 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
983 yylpp = yylpsns + yyerrctx->lexeme;
985 yylexp = yylexemes + yyerrctx->lexeme;
988 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
991 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
992 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
993 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
994 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
995 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
996 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
997 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
999 yystate = yyerrctx->state;
1000 yyFreeState(yyerrctx);
1005 if (yynewerrflag == 0) goto yyinrecovery;
1006 #endif /* YYBTYACC */
1008 YYERROR_CALL("syntax error");
1009 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1010 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1025 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1026 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1030 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1031 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1033 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1034 yystate = yytable[yyn];
1035 *++yystack.s_mark = yytable[yyn];
1036 *++yystack.l_mark = yylval;
1037 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1038 /* lookahead position is error end position */
1039 yyerror_loc_range[1] = yylloc;
1040 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1041 *++yystack.p_mark = yyloc;
1049 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1050 YYDEBUGSTR, yydepth, *yystack.s_mark);
1052 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1053 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1054 /* the current TOS position is the error start position */
1055 yyerror_loc_range[0] = *yystack.p_mark;
1057 #if defined(YYDESTRUCT_CALL)
1060 #endif /* YYBTYACC */
1061 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1062 YYDESTRUCT_CALL("error: discarding state",
1063 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1065 YYDESTRUCT_CALL("error: discarding state",
1066 yystos[*yystack.s_mark], yystack.l_mark);
1067 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1068 #endif /* defined(YYDESTRUCT_CALL) */
1071 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1079 if (yychar == YYEOF) goto yyabort;
1083 yys = yyname[YYTRANSLATE(yychar)];
1084 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1085 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1088 #if defined(YYDESTRUCT_CALL)
1091 #endif /* YYBTYACC */
1092 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1093 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1095 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1096 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1097 #endif /* defined(YYDESTRUCT_CALL) */
1107 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1108 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1109 #ifdef YYSTYPE_TOSTRING
1112 #endif /* YYBTYACC */
1117 for (i = yym; i > 0; i--)
1119 if (i != yym) fputs(", ", stderr);
1120 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1121 yystack.l_mark[1-i]), stderr);
1126 fputc('\n', stderr);
1130 yyval = yystack.l_mark[1-yym];
1132 memset(&yyval, 0, sizeof yyval);
1133 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1135 /* Perform position reduction */
1136 memset(&yyloc, 0, sizeof(yyloc));
1139 #endif /* YYBTYACC */
1141 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1142 /* just in case YYERROR is invoked within the action, save
1143 the start of the rhs as the error start position */
1144 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1151 #line 35 "quote_calc2.y"
1155 #line 39 "quote_calc2.y"
1156 { printf("%d\n",yystack.l_mark[0]);}
1159 #line 41 "quote_calc2.y"
1160 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1163 #line 45 "quote_calc2.y"
1164 { yyval = yystack.l_mark[-1]; }
1167 #line 47 "quote_calc2.y"
1168 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1171 #line 49 "quote_calc2.y"
1172 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1175 #line 51 "quote_calc2.y"
1176 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1179 #line 53 "quote_calc2.y"
1180 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1183 #line 55 "quote_calc2.y"
1184 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1187 #line 57 "quote_calc2.y"
1188 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1191 #line 59 "quote_calc2.y"
1192 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1195 #line 61 "quote_calc2.y"
1196 { yyval = - yystack.l_mark[0]; }
1199 #line 63 "quote_calc2.y"
1200 { yyval = regs[yystack.l_mark[0]]; }
1203 #line 68 "quote_calc2.y"
1204 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1207 #line 70 "quote_calc2.y"
1208 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1210 #line 1211 "quote_calc2-s.tab.c"
1214 yystack.s_mark -= yym;
1215 yystate = *yystack.s_mark;
1216 yystack.l_mark -= yym;
1217 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1218 yystack.p_mark -= yym;
1221 if (yystate == 0 && yym == 0)
1226 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1227 #ifdef YYSTYPE_TOSTRING
1230 #endif /* YYBTYACC */
1231 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1233 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1237 *++yystack.s_mark = YYFINAL;
1238 *++yystack.l_mark = yyval;
1239 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1240 *++yystack.p_mark = yyloc;
1248 /* we're currently re-reading tokens */
1250 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1258 /* in trial mode; save scanner results for future parse attempts */
1259 if (yylvp == yylvlim)
1260 { /* Enlarge lexical value queue */
1261 int p = yylvp - yylvals;
1262 int s = yylvlim - yylvals;
1264 s += YYLVQUEUEGROWTH;
1265 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1267 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1269 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1270 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1273 yylvp = yylve = yylvals + p;
1274 yylvlim = yylvals + s;
1275 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1276 yylpp = yylpe = yylpsns + p;
1277 yylplim = yylpsns + s;
1279 yylexp = yylexemes + p;
1281 *yylexp = (short) YYLEX;
1284 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1291 /* normal operation, no conflict encountered */
1292 #endif /* YYBTYACC */
1296 #endif /* YYBTYACC */
1297 if (yychar < 0) yychar = YYEOF;
1298 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1302 yys = yyname[YYTRANSLATE(yychar)];
1303 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1304 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1308 if (yychar == YYEOF) goto yyaccept;
1311 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1312 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1313 yystate = yytable[yyn];
1315 yystate = yydgoto[yym];
1319 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1320 #ifdef YYSTYPE_TOSTRING
1323 #endif /* YYBTYACC */
1324 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1326 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1329 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1330 *++yystack.s_mark = (short) yystate;
1331 *++yystack.l_mark = yyval;
1332 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1333 *++yystack.p_mark = yyloc;
1338 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1340 if (yypath) YYABORT;
1343 YYParseState *save = yyps->save;
1344 yyps->save = save->save;
1345 save->save = yypath;
1350 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1351 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1355 yyFreeState(yyerrctx);
1358 yylvp = yylvals + yypath->lexeme;
1359 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1360 yylpp = yylpsns + yypath->lexeme;
1362 yylexp = yylexemes + yypath->lexeme;
1364 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1365 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1366 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1367 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1369 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1370 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1372 yystate = yypath->state;
1374 #endif /* YYBTYACC */
1377 YYERROR_CALL("yacc stack overflow");
1381 YYERROR_CALL("memory exhausted");
1383 #endif /* YYBTYACC */
1393 if (yyps->save) goto yyvalid;
1394 #endif /* YYBTYACC */
1398 #if defined(YYDESTRUCT_CALL)
1399 if (yychar != YYEOF && yychar != YYEMPTY)
1400 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1401 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1403 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1404 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1408 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1411 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1412 YYDESTRUCT_CALL("cleanup: discarding state",
1413 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1415 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1416 YYDESTRUCT_CALL("cleanup: discarding state",
1417 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1418 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1420 #endif /* defined(YYDESTRUCT_CALL) */
1425 yyFreeState(yyerrctx);
1430 YYParseState *save = yyps;
1437 YYParseState *save = yypath;
1438 yypath = save->save;
1442 #endif /* YYBTYACC */
1443 yyfreestack(&yystack);