1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent of 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,
290 static const YYINT quote_calc_ctable[] = { -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, -1,
301 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
302 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
303 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
304 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
305 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
313 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
314 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
316 -1, -1, -1, -1, -1, -1, -1,
323 #define YYMAXTOKEN 271
324 #define YYUNDFTOKEN 277
325 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
327 static const char *const quote_calc_name[] = {
329 "$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,
330 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
331 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
332 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
333 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
334 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
335 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
336 0,0,"error","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
337 "\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
338 "$accept","list","stat","expr","number","illegal-symbol",
340 static const char *const quote_calc_rule[] = {
343 "list : list stat '\\n'",
344 "list : list error '\\n'",
346 "stat : LETTER '=' expr",
347 "expr : '(' expr ')'",
348 "expr : expr OP_ADD expr",
349 "expr : expr OP_SUB expr",
350 "expr : expr OP_MUL expr",
351 "expr : expr OP_DIV expr",
352 "expr : expr OP_MOD expr",
353 "expr : expr OP_AND expr",
354 "expr : expr '|' expr",
355 "expr : OP_SUB expr",
359 "number : number DIGIT",
371 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
372 YYLTYPE yyloc; /* position returned by actions */
373 YYLTYPE yylloc; /* position from the lexer */
376 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
377 #ifndef YYLLOC_DEFAULT
378 #define YYLLOC_DEFAULT(loc, rhs, n) \
383 (loc).first_line = ((rhs)[-1]).last_line; \
384 (loc).first_column = ((rhs)[-1]).last_column; \
385 (loc).last_line = ((rhs)[-1]).last_line; \
386 (loc).last_column = ((rhs)[-1]).last_column; \
390 (loc).first_line = ((rhs)[ 0 ]).first_line; \
391 (loc).first_column = ((rhs)[ 0 ]).first_column; \
392 (loc).last_line = ((rhs)[n-1]).last_line; \
393 (loc).last_column = ((rhs)[n-1]).last_column; \
396 #endif /* YYLLOC_DEFAULT */
397 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
400 #ifndef YYLVQUEUEGROWTH
401 #define YYLVQUEUEGROWTH 32
403 #endif /* YYBTYACC */
405 /* define the initial stack-sizes */
408 #define YYMAXDEPTH YYSTACKSIZE
411 #define YYSTACKSIZE YYMAXDEPTH
413 #define YYSTACKSIZE 10000
414 #define YYMAXDEPTH 10000
418 #ifndef YYINITSTACKSIZE
419 #define YYINITSTACKSIZE 200
429 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
436 struct YYParseState_s
438 struct YYParseState_s *save; /* Previously saved parser state */
439 YYSTACKDATA yystack; /* saved parser stack */
440 int state; /* saved parser state */
441 int errflag; /* saved error recovery status */
442 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
443 YYINT ctry; /* saved index in yyctable[] for this conflict */
445 typedef struct YYParseState_s YYParseState;
446 #endif /* YYBTYACC */
447 /* variables for the parser stack */
448 static YYSTACKDATA yystack;
451 /* Current parser state */
452 static YYParseState *yyps = 0;
454 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
455 static YYParseState *yypath = 0;
457 /* Base of the lexical value queue */
458 static YYSTYPE *yylvals = 0;
460 /* Current position at lexical value queue */
461 static YYSTYPE *yylvp = 0;
463 /* End position of lexical value queue */
464 static YYSTYPE *yylve = 0;
466 /* The last allocated position at the lexical value queue */
467 static YYSTYPE *yylvlim = 0;
469 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
470 /* Base of the lexical position queue */
471 static YYLTYPE *yylpsns = 0;
473 /* Current position at lexical position queue */
474 static YYLTYPE *yylpp = 0;
476 /* End position of lexical position queue */
477 static YYLTYPE *yylpe = 0;
479 /* The last allocated position at the lexical position queue */
480 static YYLTYPE *yylplim = 0;
483 /* Current position at lexical token queue */
484 static short *yylexp = 0;
486 static short *yylexemes = 0;
487 #endif /* YYBTYACC */
488 #line 73 "quote_calc.y"
489 /* start of programs */
494 while(!feof(stdin)) {
501 yyerror(const char *s)
503 fprintf(stderr, "%s\n", s);
508 /* lexical analysis routine */
509 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
510 /* return DIGIT for a digit, yylval = 0 through 9 */
511 /* all other characters are returned immediately */
515 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
517 /* c is now nonblank */
529 #line 530 "quote_calc.tab.c"
531 /* For use in generated program */
532 #define yydepth (int)(yystack.s_mark - yystack.s_base)
534 #define yytrial (yyps->save)
535 #endif /* YYBTYACC */
538 #include <stdio.h> /* needed for printf */
541 #include <stdlib.h> /* needed for malloc, etc */
542 #include <string.h> /* needed for memset */
544 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
545 static int yygrowstack(YYSTACKDATA *data)
551 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
555 if ((newsize = data->stacksize) == 0)
556 newsize = YYINITSTACKSIZE;
557 else if (newsize >= YYMAXDEPTH)
559 else if ((newsize *= 2) > YYMAXDEPTH)
560 newsize = YYMAXDEPTH;
562 i = (int) (data->s_mark - data->s_base);
563 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
567 data->s_base = newss;
568 data->s_mark = newss + i;
570 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
574 data->l_base = newvs;
575 data->l_mark = newvs + i;
577 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
578 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
582 data->p_base = newps;
583 data->p_mark = newps + i;
586 data->stacksize = newsize;
587 data->s_last = data->s_base + newsize - 1;
591 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
596 #if YYPURE || defined(YY_NO_LEAKS)
597 static void yyfreestack(YYSTACKDATA *data)
601 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
604 memset(data, 0, sizeof(*data));
607 #define yyfreestack(data) /* nothing */
608 #endif /* YYPURE || defined(YY_NO_LEAKS) */
611 static YYParseState *
612 yyNewState(unsigned size)
614 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
615 if (p == NULL) return NULL;
617 p->yystack.stacksize = size;
620 p->yystack.s_base = NULL;
621 p->yystack.l_base = NULL;
622 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
623 p->yystack.p_base = NULL;
627 p->yystack.s_base = (short *) malloc(size * sizeof(short));
628 if (p->yystack.s_base == NULL) return NULL;
629 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
630 if (p->yystack.l_base == NULL) return NULL;
631 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
632 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
633 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
634 if (p->yystack.p_base == NULL) return NULL;
635 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
642 yyFreeState(YYParseState *p)
644 yyfreestack(&p->yystack);
647 #endif /* YYBTYACC */
649 #define YYABORT goto yyabort
650 #define YYREJECT goto yyabort
651 #define YYACCEPT goto yyaccept
652 #define YYERROR goto yyerrlab
654 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
655 #define YYVALID_NESTED do { if (yyps->save && \
656 yyps->save->save == 0) goto yyvalid; } while(0)
657 #endif /* YYBTYACC */
662 int yym, yyn, yystate, yyresult;
665 YYParseState *yyerrctx = NULL;
666 #endif /* YYBTYACC */
667 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
668 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
673 if ((yys = getenv("YYDEBUG")) != 0)
676 if (yyn >= '0' && yyn <= '9')
680 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
684 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
686 #endif /* YYBTYACC */
693 memset(&yystack, 0, sizeof(yystack));
696 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
697 yystack.s_mark = yystack.s_base;
698 yystack.l_mark = yystack.l_base;
699 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
700 yystack.p_mark = yystack.p_base;
706 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
713 /* we're currently re-reading tokens */
715 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
723 /* in trial mode; save scanner results for future parse attempts */
724 if (yylvp == yylvlim)
725 { /* Enlarge lexical value queue */
726 size_t p = (size_t) (yylvp - yylvals);
727 size_t s = (size_t) (yylvlim - yylvals);
729 s += YYLVQUEUEGROWTH;
730 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
731 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
732 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
733 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
735 yylvp = yylve = yylvals + p;
736 yylvlim = yylvals + s;
737 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
738 yylpp = yylpe = yylpsns + p;
739 yylplim = yylpsns + s;
741 yylexp = yylexemes + p;
743 *yylexp = (short) YYLEX;
746 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
753 /* normal operation, no conflict encountered */
754 #endif /* YYBTYACC */
758 #endif /* YYBTYACC */
759 if (yychar < 0) yychar = YYEOF;
760 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
764 yys = yyname[YYTRANSLATE(yychar)];
765 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
766 YYDEBUGSTR, yydepth, yystate, yychar, yys);
767 #ifdef YYSTYPE_TOSTRING
770 #endif /* YYBTYACC */
771 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
779 /* Do we have a conflict? */
780 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
781 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
790 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
791 YYDEBUGSTR, yydepth, yystate);
793 /* Switch to the next conflict context */
798 if (save->state != yystate) YYABORT;
805 /* Unresolved conflict - start/continue trial parse */
810 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
812 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
814 fputs("Starting trial parse.\n", stderr);
817 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
818 if (save == NULL) goto yyenomem;
819 save->save = yyps->save;
820 save->state = yystate;
821 save->errflag = yyerrflag;
822 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
823 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
824 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
825 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
826 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
827 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
828 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
831 if (yyctable[ctry] == -1)
834 if (yydebug && yychar >= YYEOF)
835 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
840 if (yyps->save == NULL)
842 /* If this is a first conflict in the stack, start saving lexemes */
845 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
846 if (yylexemes == NULL) goto yyenomem;
847 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
848 if (yylvals == NULL) goto yyenomem;
849 yylvlim = yylvals + YYLVQUEUEGROWTH;
850 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
851 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
852 if (yylpsns == NULL) goto yyenomem;
853 yylplim = yylpsns + YYLVQUEUEGROWTH;
858 yylvp = yylve = yylvals;
859 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
860 yylpp = yylpe = yylpsns;
866 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
869 *yylexp = (short) yychar;
877 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
883 save->lexeme = (int) (yylvp - yylvals);
886 if (yytable[yyn] == ctry)
890 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
891 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
896 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
901 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
903 yystate = yyctable[ctry];
904 *++yystack.s_mark = (short) yystate;
905 *++yystack.l_mark = yylval;
906 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
907 *++yystack.p_mark = yylloc;
910 if (yyerrflag > 0) --yyerrflag;
915 yyn = yyctable[ctry];
918 } /* End of code dealing with conflicts */
919 #endif /* YYBTYACC */
920 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
921 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
925 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
926 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
928 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
929 yystate = yytable[yyn];
930 *++yystack.s_mark = yytable[yyn];
931 *++yystack.l_mark = yylval;
932 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
933 *++yystack.p_mark = yylloc;
936 if (yyerrflag > 0) --yyerrflag;
939 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
940 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
945 if (yyerrflag != 0) goto yyinrecovery;
958 YYParseState *save = yyps->save;
961 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
962 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
963 (int)(yylvp - yylvals - yyps->save->lexeme));
965 /* Memorize most forward-looking error state in case it's really an error. */
966 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
968 /* Free old saved error context state */
969 if (yyerrctx) yyFreeState(yyerrctx);
970 /* Create and fill out new saved error context state */
971 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
972 if (yyerrctx == NULL) goto yyenomem;
973 yyerrctx->save = yyps->save;
974 yyerrctx->state = yystate;
975 yyerrctx->errflag = yyerrflag;
976 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
977 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
978 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
979 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
980 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
981 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
982 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
984 yyerrctx->lexeme = (int) (yylvp - yylvals);
986 yylvp = yylvals + save->lexeme;
987 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
988 yylpp = yylpsns + save->lexeme;
990 yylexp = yylexemes + save->lexeme;
992 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
993 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
994 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
995 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
996 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
997 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
998 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1000 ctry = ++save->ctry;
1001 yystate = save->state;
1002 /* We tried shift, try reduce now */
1003 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1004 yyps->save = save->save;
1008 /* Nothing left on the stack -- error */
1013 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1016 /* Restore state as it was in the most forward-advanced error */
1017 yylvp = yylvals + yyerrctx->lexeme;
1018 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1019 yylpp = yylpsns + yyerrctx->lexeme;
1021 yylexp = yylexemes + yyerrctx->lexeme;
1022 yychar = yylexp[-1];
1024 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1027 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1028 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1029 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1030 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1031 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1032 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1033 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1035 yystate = yyerrctx->state;
1036 yyFreeState(yyerrctx);
1041 if (yynewerrflag == 0) goto yyinrecovery;
1042 #endif /* YYBTYACC */
1044 YYERROR_CALL("syntax error");
1045 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1046 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1061 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1062 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1066 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1067 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1069 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1070 yystate = yytable[yyn];
1071 *++yystack.s_mark = yytable[yyn];
1072 *++yystack.l_mark = yylval;
1073 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1074 /* lookahead position is error end position */
1075 yyerror_loc_range[1] = yylloc;
1076 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1077 *++yystack.p_mark = yyloc;
1085 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1086 YYDEBUGSTR, yydepth, *yystack.s_mark);
1088 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1089 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1090 /* the current TOS position is the error start position */
1091 yyerror_loc_range[0] = *yystack.p_mark;
1093 #if defined(YYDESTRUCT_CALL)
1096 #endif /* YYBTYACC */
1097 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1098 YYDESTRUCT_CALL("error: discarding state",
1099 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1101 YYDESTRUCT_CALL("error: discarding state",
1102 yystos[*yystack.s_mark], yystack.l_mark);
1103 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1104 #endif /* defined(YYDESTRUCT_CALL) */
1107 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1115 if (yychar == YYEOF) goto yyabort;
1119 yys = yyname[YYTRANSLATE(yychar)];
1120 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1121 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1124 #if defined(YYDESTRUCT_CALL)
1127 #endif /* YYBTYACC */
1128 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1129 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1131 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1132 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1133 #endif /* defined(YYDESTRUCT_CALL) */
1143 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1144 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1145 #ifdef YYSTYPE_TOSTRING
1148 #endif /* YYBTYACC */
1153 for (i = yym; i > 0; i--)
1155 if (i != yym) fputs(", ", stderr);
1156 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1157 yystack.l_mark[1-i]), stderr);
1162 fputc('\n', stderr);
1166 yyval = yystack.l_mark[1-yym];
1168 memset(&yyval, 0, sizeof yyval);
1169 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1171 /* Perform position reduction */
1172 memset(&yyloc, 0, sizeof(yyloc));
1175 #endif /* YYBTYACC */
1177 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1178 /* just in case YYERROR is invoked within the action, save
1179 the start of the rhs as the error start position */
1180 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1187 #line 35 "quote_calc.y"
1191 #line 39 "quote_calc.y"
1192 { printf("%d\n",yystack.l_mark[0]);}
1195 #line 41 "quote_calc.y"
1196 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1199 #line 45 "quote_calc.y"
1200 { yyval = yystack.l_mark[-1]; }
1203 #line 47 "quote_calc.y"
1204 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1207 #line 49 "quote_calc.y"
1208 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1211 #line 51 "quote_calc.y"
1212 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1215 #line 53 "quote_calc.y"
1216 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1219 #line 55 "quote_calc.y"
1220 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1223 #line 57 "quote_calc.y"
1224 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1227 #line 59 "quote_calc.y"
1228 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1231 #line 61 "quote_calc.y"
1232 { yyval = - yystack.l_mark[0]; }
1235 #line 63 "quote_calc.y"
1236 { yyval = regs[yystack.l_mark[0]]; }
1239 #line 68 "quote_calc.y"
1240 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1243 #line 70 "quote_calc.y"
1244 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1246 #line 1247 "quote_calc.tab.c"
1250 yystack.s_mark -= yym;
1251 yystate = *yystack.s_mark;
1252 yystack.l_mark -= yym;
1253 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1254 yystack.p_mark -= yym;
1257 if (yystate == 0 && yym == 0)
1262 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1263 #ifdef YYSTYPE_TOSTRING
1266 #endif /* YYBTYACC */
1267 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1269 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1273 *++yystack.s_mark = YYFINAL;
1274 *++yystack.l_mark = yyval;
1275 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1276 *++yystack.p_mark = yyloc;
1284 /* we're currently re-reading tokens */
1286 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1294 /* in trial mode; save scanner results for future parse attempts */
1295 if (yylvp == yylvlim)
1296 { /* Enlarge lexical value queue */
1297 size_t p = (size_t) (yylvp - yylvals);
1298 size_t s = (size_t) (yylvlim - yylvals);
1300 s += YYLVQUEUEGROWTH;
1301 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1303 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1305 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1306 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1309 yylvp = yylve = yylvals + p;
1310 yylvlim = yylvals + s;
1311 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1312 yylpp = yylpe = yylpsns + p;
1313 yylplim = yylpsns + s;
1315 yylexp = yylexemes + p;
1317 *yylexp = (short) YYLEX;
1320 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1327 /* normal operation, no conflict encountered */
1328 #endif /* YYBTYACC */
1332 #endif /* YYBTYACC */
1333 if (yychar < 0) yychar = YYEOF;
1334 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1338 yys = yyname[YYTRANSLATE(yychar)];
1339 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1340 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1344 if (yychar == YYEOF) goto yyaccept;
1347 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1348 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1349 yystate = yytable[yyn];
1351 yystate = yydgoto[yym];
1355 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1356 #ifdef YYSTYPE_TOSTRING
1359 #endif /* YYBTYACC */
1360 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1362 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1365 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1366 *++yystack.s_mark = (short) yystate;
1367 *++yystack.l_mark = yyval;
1368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1369 *++yystack.p_mark = yyloc;
1374 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1376 if (yypath) YYABORT;
1379 YYParseState *save = yyps->save;
1380 yyps->save = save->save;
1381 save->save = yypath;
1386 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1387 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1391 yyFreeState(yyerrctx);
1394 yylvp = yylvals + yypath->lexeme;
1395 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1396 yylpp = yylpsns + yypath->lexeme;
1398 yylexp = yylexemes + yypath->lexeme;
1400 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1401 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1402 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1403 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1404 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1405 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1406 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1408 yystate = yypath->state;
1410 #endif /* YYBTYACC */
1413 YYERROR_CALL("yacc stack overflow");
1417 YYERROR_CALL("memory exhausted");
1419 #endif /* YYBTYACC */
1429 if (yyps->save) goto yyvalid;
1430 #endif /* YYBTYACC */
1434 #if defined(YYDESTRUCT_CALL)
1435 if (yychar != YYEOF && yychar != YYEMPTY)
1436 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1437 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1439 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1440 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1444 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1447 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1448 YYDESTRUCT_CALL("cleanup: discarding state",
1449 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1451 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1452 YYDESTRUCT_CALL("cleanup: discarding state",
1453 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1454 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1456 #endif /* defined(YYDESTRUCT_CALL) */
1461 yyFreeState(yyerrctx);
1466 YYParseState *save = yyps;
1473 YYParseState *save = yypath;
1474 yypath = save->save;
1478 #endif /* YYBTYACC */
1479 yyfreestack(&yystack);