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_calc_parse
25 #define yylex quote_calc_lex
29 #define yyerror quote_calc_error
33 #define yychar quote_calc_char
37 #define yyval quote_calc_val
41 #define yylval quote_calc_lval
45 #define yydebug quote_calc_debug
49 #define yynerrs quote_calc_nerrs
53 #define yyerrflag quote_calc_errflag
54 #endif /* yyerrflag */
57 #define yylhs quote_calc_lhs
61 #define yylen quote_calc_len
65 #define yydefred quote_calc_defred
69 #define yystos quote_calc_stos
73 #define yydgoto quote_calc_dgoto
77 #define yysindex quote_calc_sindex
81 #define yyrindex quote_calc_rindex
85 #define yygindex quote_calc_gindex
89 #define yytable quote_calc_table
93 #define yycheck quote_calc_check
97 #define yyname quote_calc_name
101 #define yyrule quote_calc_rule
107 #define yycindex quote_calc_cindex
108 #endif /* yycindex */
111 #define yyctable quote_calc_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "quote_calc_"
120 #line 2 "quote_calc.y"
128 static void yyerror(const char *s);
130 #line 131 "quote_calc.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();
184 #define YYERRCODE 256
186 static const YYINT quote_calc_lhs[] = { -1,
187 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 3, 3,
190 static const YYINT quote_calc_len[] = { 2,
191 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
192 3, 3, 3, 2, 1, 1, 1, 2,
194 static const YYINT quote_calc_defred[] = { 1,
195 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
196 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
197 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
200 static const YYINT quote_calc_stos[] = { 0,
201 273, 256, 259, 269, 270, 40, 274, 275, 276, 10,
202 270, 275, 61, 275, 10, 257, 259, 261, 263, 265,
203 267, 124, 269, 275, 41, 275, 275, 275, 275, 275,
206 static const YYINT quote_calc_dgoto[] = { 1,
209 static const YYINT quote_calc_sindex[] = { 0,
210 -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
211 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
212 -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
215 static const YYINT quote_calc_rindex[] = { 0,
216 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
217 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
218 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
222 static const YYINT quote_calc_cindex[] = { 0,
223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
229 static const YYINT quote_calc_gindex[] = { 0,
232 #define YYTABLESIZE 258
233 static const YYINT quote_calc_table[] = { 16,
234 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
235 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
236 23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
237 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
238 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
239 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
240 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
244 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
245 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
247 0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
248 0, 19, 0, 20, 0, 21, 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, 0, 0, 0, 0, 0,
252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
255 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
256 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
257 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
258 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
259 16, 15, 16, 15, 16, 15, 16, 15,
261 static const YYINT quote_calc_check[] = { 10,
262 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
263 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
264 269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
265 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
266 -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
267 -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
268 19, 20, 21, 22, -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, 124, -1, -1, -1, -1, -1, -1, -1, -1,
273 -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
274 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
275 -1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
276 -1, 263, -1, 265, -1, 267, -1, -1, -1, -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, 256, -1, -1,
284 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
285 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
286 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
287 261, 261, 263, 263, 265, 265, 267, 267,
293 #define YYMAXTOKEN 271
294 #define YYUNDFTOKEN 277
295 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
297 static const char *const quote_calc_name[] = {
299 "$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,
300 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
301 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
302 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
303 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
304 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
305 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
306 0,0,"error","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
307 "\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
308 "$accept","list","stat","expr","number","illegal-symbol",
310 static const char *const quote_calc_rule[] = {
313 "list : list stat '\\n'",
314 "list : list error '\\n'",
316 "stat : LETTER '=' expr",
317 "expr : '(' expr ')'",
318 "expr : expr OP_ADD expr",
319 "expr : expr OP_SUB expr",
320 "expr : expr OP_MUL expr",
321 "expr : expr OP_DIV expr",
322 "expr : expr OP_MOD expr",
323 "expr : expr OP_AND expr",
324 "expr : expr '|' expr",
325 "expr : OP_SUB expr",
329 "number : number DIGIT",
341 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
342 YYLTYPE yyloc; /* position returned by actions */
343 YYLTYPE yylloc; /* position from the lexer */
346 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
347 #ifndef YYLLOC_DEFAULT
348 #define YYLLOC_DEFAULT(loc, rhs, n) \
353 (loc).first_line = ((rhs)[-1]).last_line; \
354 (loc).first_column = ((rhs)[-1]).last_column; \
355 (loc).last_line = ((rhs)[-1]).last_line; \
356 (loc).last_column = ((rhs)[-1]).last_column; \
360 (loc).first_line = ((rhs)[ 0 ]).first_line; \
361 (loc).first_column = ((rhs)[ 0 ]).first_column; \
362 (loc).last_line = ((rhs)[n-1]).last_line; \
363 (loc).last_column = ((rhs)[n-1]).last_column; \
366 #endif /* YYLLOC_DEFAULT */
367 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
370 #ifndef YYLVQUEUEGROWTH
371 #define YYLVQUEUEGROWTH 32
373 #endif /* YYBTYACC */
375 /* define the initial stack-sizes */
378 #define YYMAXDEPTH YYSTACKSIZE
381 #define YYSTACKSIZE YYMAXDEPTH
383 #define YYSTACKSIZE 10000
384 #define YYMAXDEPTH 10000
388 #ifndef YYINITSTACKSIZE
389 #define YYINITSTACKSIZE 200
399 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
406 struct YYParseState_s
408 struct YYParseState_s *save; /* Previously saved parser state */
409 YYSTACKDATA yystack; /* saved parser stack */
410 int state; /* saved parser state */
411 int errflag; /* saved error recovery status */
412 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
413 YYINT ctry; /* saved index in yyctable[] for this conflict */
415 typedef struct YYParseState_s YYParseState;
416 #endif /* YYBTYACC */
417 /* variables for the parser stack */
418 static YYSTACKDATA yystack;
421 /* Current parser state */
422 static YYParseState *yyps = 0;
424 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
425 static YYParseState *yypath = 0;
427 /* Base of the lexical value queue */
428 static YYSTYPE *yylvals = 0;
430 /* Current position at lexical value queue */
431 static YYSTYPE *yylvp = 0;
433 /* End position of lexical value queue */
434 static YYSTYPE *yylve = 0;
436 /* The last allocated position at the lexical value queue */
437 static YYSTYPE *yylvlim = 0;
439 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
440 /* Base of the lexical position queue */
441 static YYLTYPE *yylpsns = 0;
443 /* Current position at lexical position queue */
444 static YYLTYPE *yylpp = 0;
446 /* End position of lexical position queue */
447 static YYLTYPE *yylpe = 0;
449 /* The last allocated position at the lexical position queue */
450 static YYLTYPE *yylplim = 0;
453 /* Current position at lexical token queue */
454 static short *yylexp = 0;
456 static short *yylexemes = 0;
457 #endif /* YYBTYACC */
458 #line 73 "quote_calc.y"
459 /* start of programs */
464 while(!feof(stdin)) {
471 yyerror(const char *s)
473 fprintf(stderr, "%s\n", s);
478 /* lexical analysis routine */
479 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
480 /* return DIGIT for a digit, yylval = 0 through 9 */
481 /* all other characters are returned immediately */
485 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
487 /* c is now nonblank */
499 #line 500 "quote_calc.tab.c"
501 /* For use in generated program */
502 #define yydepth (int)(yystack.s_mark - yystack.s_base)
504 #define yytrial (yyps->save)
505 #endif /* YYBTYACC */
508 #include <stdio.h> /* needed for printf */
511 #include <stdlib.h> /* needed for malloc, etc */
512 #include <string.h> /* needed for memset */
514 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
515 static int yygrowstack(YYSTACKDATA *data)
521 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
525 if ((newsize = data->stacksize) == 0)
526 newsize = YYINITSTACKSIZE;
527 else if (newsize >= YYMAXDEPTH)
529 else if ((newsize *= 2) > YYMAXDEPTH)
530 newsize = YYMAXDEPTH;
532 i = (int) (data->s_mark - data->s_base);
533 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
537 data->s_base = newss;
538 data->s_mark = newss + i;
540 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
544 data->l_base = newvs;
545 data->l_mark = newvs + i;
547 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
548 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
552 data->p_base = newps;
553 data->p_mark = newps + i;
556 data->stacksize = newsize;
557 data->s_last = data->s_base + newsize - 1;
561 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
566 #if YYPURE || defined(YY_NO_LEAKS)
567 static void yyfreestack(YYSTACKDATA *data)
571 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
574 memset(data, 0, sizeof(*data));
577 #define yyfreestack(data) /* nothing */
578 #endif /* YYPURE || defined(YY_NO_LEAKS) */
581 static YYParseState *
582 yyNewState(unsigned size)
584 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
585 if (p == NULL) return NULL;
587 p->yystack.stacksize = size;
590 p->yystack.s_base = NULL;
591 p->yystack.l_base = NULL;
592 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
593 p->yystack.p_base = NULL;
597 p->yystack.s_base = (short *) malloc(size * sizeof(short));
598 if (p->yystack.s_base == NULL) return NULL;
599 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
600 if (p->yystack.l_base == NULL) return NULL;
601 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
602 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
603 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
604 if (p->yystack.p_base == NULL) return NULL;
605 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
612 yyFreeState(YYParseState *p)
614 yyfreestack(&p->yystack);
617 #endif /* YYBTYACC */
619 #define YYABORT goto yyabort
620 #define YYREJECT goto yyabort
621 #define YYACCEPT goto yyaccept
622 #define YYERROR goto yyerrlab
624 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
625 #define YYVALID_NESTED do { if (yyps->save && \
626 yyps->save->save == 0) goto yyvalid; } while(0)
627 #endif /* YYBTYACC */
632 int yym, yyn, yystate, yyresult;
635 YYParseState *yyerrctx = NULL;
636 #endif /* YYBTYACC */
637 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
638 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
643 if ((yys = getenv("YYDEBUG")) != 0)
646 if (yyn >= '0' && yyn <= '9')
650 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
654 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
656 #endif /* YYBTYACC */
663 memset(&yystack, 0, sizeof(yystack));
666 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
667 yystack.s_mark = yystack.s_base;
668 yystack.l_mark = yystack.l_base;
669 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
670 yystack.p_mark = yystack.p_base;
676 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
683 /* we're currently re-reading tokens */
685 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
693 /* in trial mode; save scanner results for future parse attempts */
694 if (yylvp == yylvlim)
695 { /* Enlarge lexical value queue */
696 int p = yylvp - yylvals;
697 int s = yylvlim - yylvals;
699 s += YYLVQUEUEGROWTH;
700 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
701 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
702 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
703 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
705 yylvp = yylve = yylvals + p;
706 yylvlim = yylvals + s;
707 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
708 yylpp = yylpe = yylpsns + p;
709 yylplim = yylpsns + s;
711 yylexp = yylexemes + p;
713 *yylexp = (short) YYLEX;
716 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
723 /* normal operation, no conflict encountered */
724 #endif /* YYBTYACC */
728 #endif /* YYBTYACC */
729 if (yychar < 0) yychar = YYEOF;
730 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
734 yys = yyname[YYTRANSLATE(yychar)];
735 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
736 YYDEBUGSTR, yydepth, yystate, yychar, yys);
737 #ifdef YYSTYPE_TOSTRING
740 #endif /* YYBTYACC */
741 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
749 /* Do we have a conflict? */
750 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
751 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
760 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
761 YYDEBUGSTR, yydepth, yystate);
763 /* Switch to the next conflict context */
768 if (save->state != yystate) YYABORT;
775 /* Unresolved conflict - start/continue trial parse */
780 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
782 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
784 fputs("Starting trial parse.\n", stderr);
787 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
788 if (save == NULL) goto yyenomem;
789 save->save = yyps->save;
790 save->state = yystate;
791 save->errflag = yyerrflag;
792 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
793 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
794 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
795 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
796 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
797 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
798 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
801 if (yyctable[ctry] == -1)
804 if (yydebug && yychar >= YYEOF)
805 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
810 if (yyps->save == NULL)
812 /* If this is a first conflict in the stack, start saving lexemes */
815 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
816 if (yylexemes == NULL) goto yyenomem;
817 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
818 if (yylvals == NULL) goto yyenomem;
819 yylvlim = yylvals + YYLVQUEUEGROWTH;
820 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
821 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
822 if (yylpsns == NULL) goto yyenomem;
823 yylplim = yylpsns + YYLVQUEUEGROWTH;
828 yylvp = yylve = yylvals;
829 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
830 yylpp = yylpe = yylpsns;
836 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
839 *yylexp = (short) yychar;
847 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
853 save->lexeme = yylvp - yylvals;
856 if (yytable[yyn] == ctry)
860 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
861 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
866 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
871 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
873 yystate = yyctable[ctry];
874 *++yystack.s_mark = (short) yystate;
875 *++yystack.l_mark = yylval;
876 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
877 *++yystack.p_mark = yylloc;
880 if (yyerrflag > 0) --yyerrflag;
885 yyn = yyctable[ctry];
888 } /* End of code dealing with conflicts */
889 #endif /* YYBTYACC */
890 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
891 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
895 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
896 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
898 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
899 yystate = yytable[yyn];
900 *++yystack.s_mark = yytable[yyn];
901 *++yystack.l_mark = yylval;
902 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
903 *++yystack.p_mark = yylloc;
906 if (yyerrflag > 0) --yyerrflag;
909 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
910 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
915 if (yyerrflag != 0) goto yyinrecovery;
928 YYParseState *save = yyps->save;
931 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
932 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
933 (int)(yylvp - yylvals - yyps->save->lexeme));
935 /* Memorize most forward-looking error state in case it's really an error. */
936 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
938 /* Free old saved error context state */
939 if (yyerrctx) yyFreeState(yyerrctx);
940 /* Create and fill out new saved error context state */
941 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
942 if (yyerrctx == NULL) goto yyenomem;
943 yyerrctx->save = yyps->save;
944 yyerrctx->state = yystate;
945 yyerrctx->errflag = yyerrflag;
946 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
947 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
948 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
949 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
950 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
951 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
952 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
954 yyerrctx->lexeme = yylvp - yylvals;
956 yylvp = yylvals + save->lexeme;
957 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
958 yylpp = yylpsns + save->lexeme;
960 yylexp = yylexemes + save->lexeme;
962 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
963 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
964 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
965 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
966 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
967 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
968 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
971 yystate = save->state;
972 /* We tried shift, try reduce now */
973 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
974 yyps->save = save->save;
978 /* Nothing left on the stack -- error */
983 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
986 /* Restore state as it was in the most forward-advanced error */
987 yylvp = yylvals + yyerrctx->lexeme;
988 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
989 yylpp = yylpsns + yyerrctx->lexeme;
991 yylexp = yylexemes + yyerrctx->lexeme;
994 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
997 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
998 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
999 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1000 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1001 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1002 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1003 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1005 yystate = yyerrctx->state;
1006 yyFreeState(yyerrctx);
1011 if (yynewerrflag == 0) goto yyinrecovery;
1012 #endif /* YYBTYACC */
1014 YYERROR_CALL("syntax error");
1015 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1016 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1031 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1032 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1036 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1037 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1039 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1040 yystate = yytable[yyn];
1041 *++yystack.s_mark = yytable[yyn];
1042 *++yystack.l_mark = yylval;
1043 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1044 /* lookahead position is error end position */
1045 yyerror_loc_range[1] = yylloc;
1046 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1047 *++yystack.p_mark = yyloc;
1055 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1056 YYDEBUGSTR, yydepth, *yystack.s_mark);
1058 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1059 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1060 /* the current TOS position is the error start position */
1061 yyerror_loc_range[0] = *yystack.p_mark;
1063 #if defined(YYDESTRUCT_CALL)
1066 #endif /* YYBTYACC */
1067 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1068 YYDESTRUCT_CALL("error: discarding state",
1069 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1071 YYDESTRUCT_CALL("error: discarding state",
1072 yystos[*yystack.s_mark], yystack.l_mark);
1073 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1074 #endif /* defined(YYDESTRUCT_CALL) */
1077 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1085 if (yychar == YYEOF) goto yyabort;
1089 yys = yyname[YYTRANSLATE(yychar)];
1090 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1091 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1094 #if defined(YYDESTRUCT_CALL)
1097 #endif /* YYBTYACC */
1098 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1099 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1101 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1102 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1103 #endif /* defined(YYDESTRUCT_CALL) */
1113 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1114 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1115 #ifdef YYSTYPE_TOSTRING
1118 #endif /* YYBTYACC */
1123 for (i = yym; i > 0; i--)
1125 if (i != yym) fputs(", ", stderr);
1126 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1127 yystack.l_mark[1-i]), stderr);
1132 fputc('\n', stderr);
1136 yyval = yystack.l_mark[1-yym];
1138 memset(&yyval, 0, sizeof yyval);
1139 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1141 /* Perform position reduction */
1142 memset(&yyloc, 0, sizeof(yyloc));
1145 #endif /* YYBTYACC */
1147 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1148 /* just in case YYERROR is invoked within the action, save
1149 the start of the rhs as the error start position */
1150 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1157 #line 35 "quote_calc.y"
1161 #line 39 "quote_calc.y"
1162 { printf("%d\n",yystack.l_mark[0]);}
1165 #line 41 "quote_calc.y"
1166 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1169 #line 45 "quote_calc.y"
1170 { yyval = yystack.l_mark[-1]; }
1173 #line 47 "quote_calc.y"
1174 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1177 #line 49 "quote_calc.y"
1178 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1181 #line 51 "quote_calc.y"
1182 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1185 #line 53 "quote_calc.y"
1186 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1189 #line 55 "quote_calc.y"
1190 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1193 #line 57 "quote_calc.y"
1194 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1197 #line 59 "quote_calc.y"
1198 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1201 #line 61 "quote_calc.y"
1202 { yyval = - yystack.l_mark[0]; }
1205 #line 63 "quote_calc.y"
1206 { yyval = regs[yystack.l_mark[0]]; }
1209 #line 68 "quote_calc.y"
1210 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1213 #line 70 "quote_calc.y"
1214 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1216 #line 1217 "quote_calc.tab.c"
1220 yystack.s_mark -= yym;
1221 yystate = *yystack.s_mark;
1222 yystack.l_mark -= yym;
1223 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1224 yystack.p_mark -= yym;
1227 if (yystate == 0 && yym == 0)
1232 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1233 #ifdef YYSTYPE_TOSTRING
1236 #endif /* YYBTYACC */
1237 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1239 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1243 *++yystack.s_mark = YYFINAL;
1244 *++yystack.l_mark = yyval;
1245 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1246 *++yystack.p_mark = yyloc;
1254 /* we're currently re-reading tokens */
1256 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1264 /* in trial mode; save scanner results for future parse attempts */
1265 if (yylvp == yylvlim)
1266 { /* Enlarge lexical value queue */
1267 int p = yylvp - yylvals;
1268 int s = yylvlim - yylvals;
1270 s += YYLVQUEUEGROWTH;
1271 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1273 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1275 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1276 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1279 yylvp = yylve = yylvals + p;
1280 yylvlim = yylvals + s;
1281 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1282 yylpp = yylpe = yylpsns + p;
1283 yylplim = yylpsns + s;
1285 yylexp = yylexemes + p;
1287 *yylexp = (short) YYLEX;
1290 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1297 /* normal operation, no conflict encountered */
1298 #endif /* YYBTYACC */
1302 #endif /* YYBTYACC */
1303 if (yychar < 0) yychar = YYEOF;
1304 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1308 yys = yyname[YYTRANSLATE(yychar)];
1309 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1310 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1314 if (yychar == YYEOF) goto yyaccept;
1317 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1318 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1319 yystate = yytable[yyn];
1321 yystate = yydgoto[yym];
1325 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1326 #ifdef YYSTYPE_TOSTRING
1329 #endif /* YYBTYACC */
1330 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1332 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1335 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1336 *++yystack.s_mark = (short) yystate;
1337 *++yystack.l_mark = yyval;
1338 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1339 *++yystack.p_mark = yyloc;
1344 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1346 if (yypath) YYABORT;
1349 YYParseState *save = yyps->save;
1350 yyps->save = save->save;
1351 save->save = yypath;
1356 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1357 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1361 yyFreeState(yyerrctx);
1364 yylvp = yylvals + yypath->lexeme;
1365 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1366 yylpp = yylpsns + yypath->lexeme;
1368 yylexp = yylexemes + yypath->lexeme;
1370 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1371 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1372 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1373 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1374 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1375 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1376 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1378 yystate = yypath->state;
1380 #endif /* YYBTYACC */
1383 YYERROR_CALL("yacc stack overflow");
1387 YYERROR_CALL("memory exhausted");
1389 #endif /* YYBTYACC */
1399 if (yyps->save) goto yyvalid;
1400 #endif /* YYBTYACC */
1404 #if defined(YYDESTRUCT_CALL)
1405 if (yychar != YYEOF && yychar != YYEMPTY)
1406 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1407 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1409 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1410 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1414 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1417 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1418 YYDESTRUCT_CALL("cleanup: discarding state",
1419 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1421 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1422 YYDESTRUCT_CALL("cleanup: discarding state",
1423 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1424 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1426 #endif /* defined(YYDESTRUCT_CALL) */
1431 yyFreeState(yyerrctx);
1436 YYParseState *save = yyps;
1443 YYParseState *save = yypath;
1444 yypath = save->save;
1448 #endif /* YYBTYACC */
1449 yyfreestack(&yystack);