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-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_calc_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_calc_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_calc_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 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
195 static const YYINT quote_calc_stos[] = { 0,
196 273, 256, 259, 269, 270, 40, 274, 275, 276, 10,
197 270, 275, 61, 275, 10, 257, 259, 261, 263, 265,
198 267, 124, 269, 275, 41, 275, 275, 275, 275, 275,
201 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
202 static const YYINT quote_calc_dgoto[] = { 1,
205 static const YYINT quote_calc_sindex[] = { 0,
206 -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
207 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
208 -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
211 static const YYINT quote_calc_rindex[] = { 0,
212 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
213 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
214 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
218 static const YYINT quote_calc_cindex[] = { 0,
219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
225 static const YYINT quote_calc_gindex[] = { 0,
228 #define YYTABLESIZE 258
229 static const YYINT quote_calc_table[] = { 16,
230 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
231 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
232 23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
233 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
234 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
235 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
236 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
238 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
240 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
244 0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
251 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
252 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
253 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
254 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
255 16, 15, 16, 15, 16, 15, 16, 15,
257 static const YYINT quote_calc_check[] = { 10,
258 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
259 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
260 269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
261 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
262 -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
263 -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
264 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
265 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
266 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
267 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
268 -1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
269 -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
270 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
271 -1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
272 -1, 263, -1, 265, -1, 267, -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, -1, -1, -1,
278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
279 -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
280 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
281 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
282 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
283 261, 261, 263, 263, 265, 265, 267, 267,
286 static const YYINT quote_calc_ctable[] = { -1,
287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
296 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
297 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
298 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
300 -1, -1, -1, -1, -1, -1, -1, -1, -1, -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,
319 #define YYMAXTOKEN 271
320 #define YYUNDFTOKEN 277
321 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
323 static const char *const quote_calc_name[] = {
325 "$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,
326 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
327 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
328 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
329 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,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,0,0,0,
332 0,0,"error","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
333 "\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
334 "$accept","list","stat","expr","number","illegal-symbol",
336 static const char *const quote_calc_rule[] = {
339 "list : list stat '\\n'",
340 "list : list error '\\n'",
342 "stat : LETTER '=' expr",
343 "expr : '(' expr ')'",
344 "expr : expr OP_ADD expr",
345 "expr : expr OP_SUB expr",
346 "expr : expr OP_MUL expr",
347 "expr : expr OP_DIV expr",
348 "expr : expr OP_MOD expr",
349 "expr : expr OP_AND expr",
350 "expr : expr '|' expr",
351 "expr : OP_SUB expr",
355 "number : number DIGIT",
367 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
368 YYLTYPE yyloc; /* position returned by actions */
369 YYLTYPE yylloc; /* position from the lexer */
372 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
373 #ifndef YYLLOC_DEFAULT
374 #define YYLLOC_DEFAULT(loc, rhs, n) \
379 (loc).first_line = ((rhs)[-1]).last_line; \
380 (loc).first_column = ((rhs)[-1]).last_column; \
381 (loc).last_line = ((rhs)[-1]).last_line; \
382 (loc).last_column = ((rhs)[-1]).last_column; \
386 (loc).first_line = ((rhs)[ 0 ]).first_line; \
387 (loc).first_column = ((rhs)[ 0 ]).first_column; \
388 (loc).last_line = ((rhs)[n-1]).last_line; \
389 (loc).last_column = ((rhs)[n-1]).last_column; \
392 #endif /* YYLLOC_DEFAULT */
393 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
396 #ifndef YYLVQUEUEGROWTH
397 #define YYLVQUEUEGROWTH 32
399 #endif /* YYBTYACC */
401 /* define the initial stack-sizes */
404 #define YYMAXDEPTH YYSTACKSIZE
407 #define YYSTACKSIZE YYMAXDEPTH
409 #define YYSTACKSIZE 10000
410 #define YYMAXDEPTH 10000
414 #ifndef YYINITSTACKSIZE
415 #define YYINITSTACKSIZE 200
425 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
432 struct YYParseState_s
434 struct YYParseState_s *save; /* Previously saved parser state */
435 YYSTACKDATA yystack; /* saved parser stack */
436 int state; /* saved parser state */
437 int errflag; /* saved error recovery status */
438 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
439 YYINT ctry; /* saved index in yyctable[] for this conflict */
441 typedef struct YYParseState_s YYParseState;
442 #endif /* YYBTYACC */
443 /* variables for the parser stack */
444 static YYSTACKDATA yystack;
447 /* Current parser state */
448 static YYParseState *yyps = 0;
450 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
451 static YYParseState *yypath = 0;
453 /* Base of the lexical value queue */
454 static YYSTYPE *yylvals = 0;
456 /* Current position at lexical value queue */
457 static YYSTYPE *yylvp = 0;
459 /* End position of lexical value queue */
460 static YYSTYPE *yylve = 0;
462 /* The last allocated position at the lexical value queue */
463 static YYSTYPE *yylvlim = 0;
465 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
466 /* Base of the lexical position queue */
467 static YYLTYPE *yylpsns = 0;
469 /* Current position at lexical position queue */
470 static YYLTYPE *yylpp = 0;
472 /* End position of lexical position queue */
473 static YYLTYPE *yylpe = 0;
475 /* The last allocated position at the lexical position queue */
476 static YYLTYPE *yylplim = 0;
479 /* Current position at lexical token queue */
480 static YYINT *yylexp = 0;
482 static YYINT *yylexemes = 0;
483 #endif /* YYBTYACC */
484 #line 73 "quote_calc.y"
485 /* start of programs */
490 while(!feof(stdin)) {
497 yyerror(const char *s)
499 fprintf(stderr, "%s\n", s);
504 /* lexical analysis routine */
505 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
506 /* return DIGIT for a digit, yylval = 0 through 9 */
507 /* all other characters are returned immediately */
511 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
513 /* c is now nonblank */
525 #line 526 "quote_calc-s.tab.c"
527 /* For use in generated program */
528 #define yydepth (int)(yystack.s_mark - yystack.s_base)
530 #define yytrial (yyps->save)
531 #endif /* YYBTYACC */
534 #include <stdio.h> /* needed for printf */
537 #include <stdlib.h> /* needed for malloc, etc */
538 #include <string.h> /* needed for memset */
540 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
541 static int yygrowstack(YYSTACKDATA *data)
547 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
551 if ((newsize = data->stacksize) == 0)
552 newsize = YYINITSTACKSIZE;
553 else if (newsize >= YYMAXDEPTH)
555 else if ((newsize *= 2) > YYMAXDEPTH)
556 newsize = YYMAXDEPTH;
558 i = (int) (data->s_mark - data->s_base);
559 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
563 data->s_base = newss;
564 data->s_mark = newss + i;
566 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
570 data->l_base = newvs;
571 data->l_mark = newvs + i;
573 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
574 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
578 data->p_base = newps;
579 data->p_mark = newps + i;
582 data->stacksize = newsize;
583 data->s_last = data->s_base + newsize - 1;
587 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
592 #if YYPURE || defined(YY_NO_LEAKS)
593 static void yyfreestack(YYSTACKDATA *data)
597 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
600 memset(data, 0, sizeof(*data));
603 #define yyfreestack(data) /* nothing */
604 #endif /* YYPURE || defined(YY_NO_LEAKS) */
607 static YYParseState *
608 yyNewState(unsigned size)
610 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
611 if (p == NULL) return NULL;
613 p->yystack.stacksize = size;
616 p->yystack.s_base = NULL;
617 p->yystack.l_base = NULL;
618 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
619 p->yystack.p_base = NULL;
623 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
624 if (p->yystack.s_base == NULL) return NULL;
625 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
626 if (p->yystack.l_base == NULL) return NULL;
627 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
628 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
629 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
630 if (p->yystack.p_base == NULL) return NULL;
631 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
638 yyFreeState(YYParseState *p)
640 yyfreestack(&p->yystack);
643 #endif /* YYBTYACC */
645 #define YYABORT goto yyabort
646 #define YYREJECT goto yyabort
647 #define YYACCEPT goto yyaccept
648 #define YYERROR goto yyerrlab
650 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
651 #define YYVALID_NESTED do { if (yyps->save && \
652 yyps->save->save == 0) goto yyvalid; } while(0)
653 #endif /* YYBTYACC */
658 int yym, yyn, yystate, yyresult;
661 YYParseState *yyerrctx = NULL;
662 #endif /* YYBTYACC */
663 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
664 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
669 if ((yys = getenv("YYDEBUG")) != 0)
672 if (yyn >= '0' && yyn <= '9')
676 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
678 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
679 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
683 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
685 #endif /* YYBTYACC */
694 memset(&yystack, 0, sizeof(yystack));
697 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
698 yystack.s_mark = yystack.s_base;
699 yystack.l_mark = yystack.l_base;
700 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
701 yystack.p_mark = yystack.p_base;
707 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
714 /* we're currently re-reading tokens */
716 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
724 /* in trial mode; save scanner results for future parse attempts */
725 if (yylvp == yylvlim)
726 { /* Enlarge lexical value queue */
727 size_t p = (size_t) (yylvp - yylvals);
728 size_t s = (size_t) (yylvlim - yylvals);
730 s += YYLVQUEUEGROWTH;
731 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
732 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
733 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
734 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
736 yylvp = yylve = yylvals + p;
737 yylvlim = yylvals + s;
738 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
739 yylpp = yylpe = yylpsns + p;
740 yylplim = yylpsns + s;
742 yylexp = yylexemes + p;
744 *yylexp = (YYINT) YYLEX;
747 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
754 /* normal operation, no conflict encountered */
755 #endif /* YYBTYACC */
759 #endif /* YYBTYACC */
760 if (yychar < 0) yychar = YYEOF;
764 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
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(YYINT));
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 = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
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 = (YYINT) 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 = (YYINT) 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;
950 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
953 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
954 * before looking for error recovery */
955 yystack.s_mark -= yym;
956 yystate = *yystack.s_mark;
957 yystack.l_mark -= yym;
958 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
959 yystack.p_mark -= yym;
967 YYParseState *save = yyps->save;
970 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
971 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
972 (int)(yylvp - yylvals - yyps->save->lexeme));
974 /* Memorize most forward-looking error state in case it's really an error. */
975 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
977 /* Free old saved error context state */
978 if (yyerrctx) yyFreeState(yyerrctx);
979 /* Create and fill out new saved error context state */
980 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
981 if (yyerrctx == NULL) goto yyenomem;
982 yyerrctx->save = yyps->save;
983 yyerrctx->state = yystate;
984 yyerrctx->errflag = yyerrflag;
985 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
986 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
987 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
988 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
989 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
990 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
991 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
993 yyerrctx->lexeme = (int) (yylvp - yylvals);
995 yylvp = yylvals + save->lexeme;
996 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
997 yylpp = yylpsns + save->lexeme;
999 yylexp = yylexemes + save->lexeme;
1001 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1002 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1003 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1004 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1005 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1006 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1007 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1009 ctry = ++save->ctry;
1010 yystate = save->state;
1011 /* We tried shift, try reduce now */
1012 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1013 yyps->save = save->save;
1017 /* Nothing left on the stack -- error */
1022 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1025 /* Restore state as it was in the most forward-advanced error */
1026 yylvp = yylvals + yyerrctx->lexeme;
1027 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1028 yylpp = yylpsns + yyerrctx->lexeme;
1030 yylexp = yylexemes + yyerrctx->lexeme;
1031 yychar = yylexp[-1];
1033 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1036 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1037 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1038 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1039 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1040 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1041 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1042 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1044 yystate = yyerrctx->state;
1045 yyFreeState(yyerrctx);
1050 if (yynewerrflag == 0) goto yyinrecovery;
1051 #endif /* YYBTYACC */
1053 YYERROR_CALL("syntax error");
1054 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1055 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1059 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1070 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1071 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1075 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1076 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1078 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1079 yystate = yytable[yyn];
1080 *++yystack.s_mark = yytable[yyn];
1081 *++yystack.l_mark = yylval;
1082 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1083 /* lookahead position is error end position */
1084 yyerror_loc_range[1] = yylloc;
1085 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1086 *++yystack.p_mark = yyloc;
1094 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1095 YYDEBUGSTR, yydepth, *yystack.s_mark);
1097 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1098 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1099 /* the current TOS position is the error start position */
1100 yyerror_loc_range[0] = *yystack.p_mark;
1102 #if defined(YYDESTRUCT_CALL)
1105 #endif /* YYBTYACC */
1106 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1107 YYDESTRUCT_CALL("error: discarding state",
1108 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1110 YYDESTRUCT_CALL("error: discarding state",
1111 yystos[*yystack.s_mark], yystack.l_mark);
1112 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1113 #endif /* defined(YYDESTRUCT_CALL) */
1116 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1124 if (yychar == YYEOF) goto yyabort;
1128 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1129 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1130 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1133 #if defined(YYDESTRUCT_CALL)
1136 #endif /* YYBTYACC */
1137 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1138 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1140 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1141 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1142 #endif /* defined(YYDESTRUCT_CALL) */
1152 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1153 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1154 #ifdef YYSTYPE_TOSTRING
1157 #endif /* YYBTYACC */
1162 for (i = yym; i > 0; i--)
1164 if (i != yym) fputs(", ", stderr);
1165 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1166 yystack.l_mark[1-i]), stderr);
1171 fputc('\n', stderr);
1175 yyval = yystack.l_mark[1-yym];
1177 memset(&yyval, 0, sizeof yyval);
1178 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1180 /* Perform position reduction */
1181 memset(&yyloc, 0, sizeof(yyloc));
1184 #endif /* YYBTYACC */
1186 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1187 /* just in case YYERROR is invoked within the action, save
1188 the start of the rhs as the error start position */
1189 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1196 #line 35 "quote_calc.y"
1200 #line 39 "quote_calc.y"
1201 { printf("%d\n",yystack.l_mark[0]);}
1204 #line 41 "quote_calc.y"
1205 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1208 #line 45 "quote_calc.y"
1209 { yyval = yystack.l_mark[-1]; }
1212 #line 47 "quote_calc.y"
1213 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1216 #line 49 "quote_calc.y"
1217 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1220 #line 51 "quote_calc.y"
1221 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1224 #line 53 "quote_calc.y"
1225 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1228 #line 55 "quote_calc.y"
1229 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1232 #line 57 "quote_calc.y"
1233 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1236 #line 59 "quote_calc.y"
1237 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1240 #line 61 "quote_calc.y"
1241 { yyval = - yystack.l_mark[0]; }
1244 #line 63 "quote_calc.y"
1245 { yyval = regs[yystack.l_mark[0]]; }
1248 #line 68 "quote_calc.y"
1249 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1252 #line 70 "quote_calc.y"
1253 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1255 #line 1256 "quote_calc-s.tab.c"
1259 yystack.s_mark -= yym;
1260 yystate = *yystack.s_mark;
1261 yystack.l_mark -= yym;
1262 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1263 yystack.p_mark -= yym;
1266 if (yystate == 0 && yym == 0)
1271 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1272 #ifdef YYSTYPE_TOSTRING
1275 #endif /* YYBTYACC */
1276 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1278 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1282 *++yystack.s_mark = YYFINAL;
1283 *++yystack.l_mark = yyval;
1284 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1285 *++yystack.p_mark = yyloc;
1293 /* we're currently re-reading tokens */
1295 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1303 /* in trial mode; save scanner results for future parse attempts */
1304 if (yylvp == yylvlim)
1305 { /* Enlarge lexical value queue */
1306 size_t p = (size_t) (yylvp - yylvals);
1307 size_t s = (size_t) (yylvlim - yylvals);
1309 s += YYLVQUEUEGROWTH;
1310 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1312 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1314 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1315 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1318 yylvp = yylve = yylvals + p;
1319 yylvlim = yylvals + s;
1320 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1321 yylpp = yylpe = yylpsns + p;
1322 yylplim = yylpsns + s;
1324 yylexp = yylexemes + p;
1326 *yylexp = (YYINT) YYLEX;
1329 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1336 /* normal operation, no conflict encountered */
1337 #endif /* YYBTYACC */
1341 #endif /* YYBTYACC */
1342 if (yychar < 0) yychar = YYEOF;
1346 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1347 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1348 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1352 if (yychar == YYEOF) goto yyaccept;
1355 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1356 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1357 yystate = yytable[yyn];
1359 yystate = yydgoto[yym];
1363 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1364 #ifdef YYSTYPE_TOSTRING
1367 #endif /* YYBTYACC */
1368 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1370 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1373 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1374 *++yystack.s_mark = (YYINT) yystate;
1375 *++yystack.l_mark = yyval;
1376 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1377 *++yystack.p_mark = yyloc;
1382 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1384 if (yypath) YYABORT;
1387 YYParseState *save = yyps->save;
1388 yyps->save = save->save;
1389 save->save = yypath;
1394 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1395 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1399 yyFreeState(yyerrctx);
1402 yylvp = yylvals + yypath->lexeme;
1403 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1404 yylpp = yylpsns + yypath->lexeme;
1406 yylexp = yylexemes + yypath->lexeme;
1408 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1409 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1410 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1411 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1412 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1413 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1414 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1416 yystate = yypath->state;
1418 #endif /* YYBTYACC */
1421 YYERROR_CALL("yacc stack overflow");
1425 YYERROR_CALL("memory exhausted");
1427 #endif /* YYBTYACC */
1437 if (yyps->save) goto yyvalid;
1438 #endif /* YYBTYACC */
1442 #if defined(YYDESTRUCT_CALL)
1443 if (yychar != YYEOF && yychar != YYEMPTY)
1444 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1445 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1447 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1448 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1452 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1455 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1456 YYDESTRUCT_CALL("cleanup: discarding state",
1457 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1459 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1460 YYDESTRUCT_CALL("cleanup: discarding state",
1461 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1462 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1464 #endif /* defined(YYDESTRUCT_CALL) */
1469 yyFreeState(yyerrctx);
1474 YYParseState *save = yyps;
1481 YYParseState *save = yypath;
1482 yypath = save->save;
1486 #endif /* YYBTYACC */
1487 yyfreestack(&yystack);