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_calc4_parse
25 #define yylex quote_calc4_lex
29 #define yyerror quote_calc4_error
33 #define yychar quote_calc4_char
37 #define yyval quote_calc4_val
41 #define yylval quote_calc4_lval
45 #define yydebug quote_calc4_debug
49 #define yynerrs quote_calc4_nerrs
53 #define yyerrflag quote_calc4_errflag
54 #endif /* yyerrflag */
57 #define yylhs quote_calc4_lhs
61 #define yylen quote_calc4_len
65 #define yydefred quote_calc4_defred
69 #define yystos quote_calc4_stos
73 #define yydgoto quote_calc4_dgoto
77 #define yysindex quote_calc4_sindex
81 #define yyrindex quote_calc4_rindex
85 #define yygindex quote_calc4_gindex
89 #define yytable quote_calc4_table
93 #define yycheck quote_calc4_check
97 #define yyname quote_calc4_name
101 #define yyrule quote_calc4_rule
107 #define yycindex quote_calc4_cindex
108 #endif /* yycindex */
111 #define yyctable quote_calc4_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "quote_calc4_"
120 #line 2 "quote_calc4.y"
128 static void yyerror(const char *s);
130 #line 131 "quote_calc4-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_calc4_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_calc4_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_calc4_defred[] = { 1,
189 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
190 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
191 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
194 static const YYINT quote_calc4_stos[] = { 0,
195 273, 256, 260, 269, 270, 40, 274, 275, 276, 10,
196 270, 275, 61, 275, 10, 258, 260, 262, 264, 266,
197 268, 124, 269, 275, 41, 275, 275, 275, 275, 275,
200 static const YYINT quote_calc4_dgoto[] = { 1,
203 static const YYINT quote_calc4_sindex[] = { 0,
204 -38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
205 0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
206 -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
209 static const YYINT quote_calc4_rindex[] = { 0,
210 0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
211 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
216 static const YYINT quote_calc4_cindex[] = { 0,
217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
218 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
223 static const YYINT quote_calc4_gindex[] = { 0,
226 #define YYTABLESIZE 259
227 static const YYINT quote_calc4_table[] = { 16,
228 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
229 10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
230 19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
231 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
232 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
233 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
234 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
235 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
238 22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
242 18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
250 0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
251 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
252 19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
253 15, 16, 15, 16, 15, 16, 15, 16, 15,
255 static const YYINT quote_calc4_check[] = { 10,
256 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
257 10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
258 264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
259 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
260 -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
261 -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
262 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
263 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
264 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
265 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
266 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
267 -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
269 -1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
270 262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
271 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
272 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
273 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
274 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
275 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
277 -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
278 -1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
279 269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
280 264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
281 260, 262, 262, 264, 264, 266, 266, 268, 268,
284 static const YYINT quote_calc4_ctable[] = { -1,
285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
296 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
297 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
298 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
300 -1, -1, -1, -1, -1, -1, -1, -1, -1, -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,
317 #define YYMAXTOKEN 271
318 #define YYUNDFTOKEN 277
319 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
321 static const char *const quote_calc4_name[] = {
323 "$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,
324 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
325 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,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,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,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,"error","OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
331 "\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
332 "OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS","$accept","list","stat",
333 "expr","number","illegal-symbol",
335 static const char *const quote_calc4_rule[] = {
338 "list : list stat '\\n'",
339 "list : list error '\\n'",
341 "stat : LETTER '=' expr",
342 "expr : '(' expr ')'",
343 "expr : expr \"ADD-operator\" expr",
344 "expr : expr \"SUB-operator\" expr",
345 "expr : expr \"MUL-operator\" expr",
346 "expr : expr \"DIV-operator\" expr",
347 "expr : expr \"MOD-operator\" expr",
348 "expr : expr \"AND-operator\" expr",
349 "expr : expr '|' expr",
350 "expr : \"SUB-operator\" expr",
354 "number : number DIGIT",
366 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
367 YYLTYPE yyloc; /* position returned by actions */
368 YYLTYPE yylloc; /* position from the lexer */
371 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
372 #ifndef YYLLOC_DEFAULT
373 #define YYLLOC_DEFAULT(loc, rhs, n) \
378 (loc).first_line = ((rhs)[-1]).last_line; \
379 (loc).first_column = ((rhs)[-1]).last_column; \
380 (loc).last_line = ((rhs)[-1]).last_line; \
381 (loc).last_column = ((rhs)[-1]).last_column; \
385 (loc).first_line = ((rhs)[ 0 ]).first_line; \
386 (loc).first_column = ((rhs)[ 0 ]).first_column; \
387 (loc).last_line = ((rhs)[n-1]).last_line; \
388 (loc).last_column = ((rhs)[n-1]).last_column; \
391 #endif /* YYLLOC_DEFAULT */
392 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
395 #ifndef YYLVQUEUEGROWTH
396 #define YYLVQUEUEGROWTH 32
398 #endif /* YYBTYACC */
400 /* define the initial stack-sizes */
403 #define YYMAXDEPTH YYSTACKSIZE
406 #define YYSTACKSIZE YYMAXDEPTH
408 #define YYSTACKSIZE 10000
409 #define YYMAXDEPTH 10000
413 #ifndef YYINITSTACKSIZE
414 #define YYINITSTACKSIZE 200
424 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
431 struct YYParseState_s
433 struct YYParseState_s *save; /* Previously saved parser state */
434 YYSTACKDATA yystack; /* saved parser stack */
435 int state; /* saved parser state */
436 int errflag; /* saved error recovery status */
437 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
438 YYINT ctry; /* saved index in yyctable[] for this conflict */
440 typedef struct YYParseState_s YYParseState;
441 #endif /* YYBTYACC */
442 /* variables for the parser stack */
443 static YYSTACKDATA yystack;
446 /* Current parser state */
447 static YYParseState *yyps = 0;
449 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
450 static YYParseState *yypath = 0;
452 /* Base of the lexical value queue */
453 static YYSTYPE *yylvals = 0;
455 /* Current position at lexical value queue */
456 static YYSTYPE *yylvp = 0;
458 /* End position of lexical value queue */
459 static YYSTYPE *yylve = 0;
461 /* The last allocated position at the lexical value queue */
462 static YYSTYPE *yylvlim = 0;
464 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
465 /* Base of the lexical position queue */
466 static YYLTYPE *yylpsns = 0;
468 /* Current position at lexical position queue */
469 static YYLTYPE *yylpp = 0;
471 /* End position of lexical position queue */
472 static YYLTYPE *yylpe = 0;
474 /* The last allocated position at the lexical position queue */
475 static YYLTYPE *yylplim = 0;
478 /* Current position at lexical token queue */
479 static short *yylexp = 0;
481 static short *yylexemes = 0;
482 #endif /* YYBTYACC */
483 #line 73 "quote_calc4.y"
484 /* start of programs */
489 while(!feof(stdin)) {
496 yyerror(const char *s)
498 fprintf(stderr, "%s\n", s);
503 /* lexical analysis routine */
504 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
505 /* return DIGIT for a digit, yylval = 0 through 9 */
506 /* all other characters are returned immediately */
510 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
512 /* c is now nonblank */
524 #line 525 "quote_calc4-s.tab.c"
526 /* For use in generated program */
527 #define yydepth (int)(yystack.s_mark - yystack.s_base)
529 #define yytrial (yyps->save)
530 #endif /* YYBTYACC */
533 #include <stdio.h> /* needed for printf */
536 #include <stdlib.h> /* needed for malloc, etc */
537 #include <string.h> /* needed for memset */
539 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
540 static int yygrowstack(YYSTACKDATA *data)
546 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
550 if ((newsize = data->stacksize) == 0)
551 newsize = YYINITSTACKSIZE;
552 else if (newsize >= YYMAXDEPTH)
554 else if ((newsize *= 2) > YYMAXDEPTH)
555 newsize = YYMAXDEPTH;
557 i = (int) (data->s_mark - data->s_base);
558 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
562 data->s_base = newss;
563 data->s_mark = newss + i;
565 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
569 data->l_base = newvs;
570 data->l_mark = newvs + i;
572 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
573 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
577 data->p_base = newps;
578 data->p_mark = newps + i;
581 data->stacksize = newsize;
582 data->s_last = data->s_base + newsize - 1;
586 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
591 #if YYPURE || defined(YY_NO_LEAKS)
592 static void yyfreestack(YYSTACKDATA *data)
596 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
599 memset(data, 0, sizeof(*data));
602 #define yyfreestack(data) /* nothing */
603 #endif /* YYPURE || defined(YY_NO_LEAKS) */
606 static YYParseState *
607 yyNewState(unsigned size)
609 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
610 if (p == NULL) return NULL;
612 p->yystack.stacksize = size;
615 p->yystack.s_base = NULL;
616 p->yystack.l_base = NULL;
617 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
618 p->yystack.p_base = NULL;
622 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
623 if (p->yystack.s_base == NULL) return NULL;
624 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
625 if (p->yystack.l_base == NULL) return NULL;
626 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
627 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
628 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
629 if (p->yystack.p_base == NULL) return NULL;
630 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
637 yyFreeState(YYParseState *p)
639 yyfreestack(&p->yystack);
642 #endif /* YYBTYACC */
644 #define YYABORT goto yyabort
645 #define YYREJECT goto yyabort
646 #define YYACCEPT goto yyaccept
647 #define YYERROR goto yyerrlab
649 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
650 #define YYVALID_NESTED do { if (yyps->save && \
651 yyps->save->save == 0) goto yyvalid; } while(0)
652 #endif /* YYBTYACC */
657 int yym, yyn, yystate, yyresult;
660 YYParseState *yyerrctx = NULL;
661 #endif /* YYBTYACC */
662 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
663 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
668 if ((yys = getenv("YYDEBUG")) != 0)
671 if (yyn >= '0' && yyn <= '9')
675 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
679 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
681 #endif /* YYBTYACC */
690 memset(&yystack, 0, sizeof(yystack));
693 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
694 yystack.s_mark = yystack.s_base;
695 yystack.l_mark = yystack.l_base;
696 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
697 yystack.p_mark = yystack.p_base;
703 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
710 /* we're currently re-reading tokens */
712 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
720 /* in trial mode; save scanner results for future parse attempts */
721 if (yylvp == yylvlim)
722 { /* Enlarge lexical value queue */
723 size_t p = (size_t) (yylvp - yylvals);
724 size_t s = (size_t) (yylvlim - yylvals);
726 s += YYLVQUEUEGROWTH;
727 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
728 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
729 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
730 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
732 yylvp = yylve = yylvals + p;
733 yylvlim = yylvals + s;
734 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
735 yylpp = yylpe = yylpsns + p;
736 yylplim = yylpsns + s;
738 yylexp = yylexemes + p;
740 *yylexp = (short) YYLEX;
743 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
750 /* normal operation, no conflict encountered */
751 #endif /* YYBTYACC */
755 #endif /* YYBTYACC */
756 if (yychar < 0) yychar = YYEOF;
760 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
761 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
762 YYDEBUGSTR, yydepth, yystate, yychar, yys);
763 #ifdef YYSTYPE_TOSTRING
766 #endif /* YYBTYACC */
767 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
775 /* Do we have a conflict? */
776 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
777 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
786 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
787 YYDEBUGSTR, yydepth, yystate);
789 /* Switch to the next conflict context */
794 if (save->state != yystate) YYABORT;
801 /* Unresolved conflict - start/continue trial parse */
806 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
808 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
810 fputs("Starting trial parse.\n", stderr);
813 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
814 if (save == NULL) goto yyenomem;
815 save->save = yyps->save;
816 save->state = yystate;
817 save->errflag = yyerrflag;
818 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
819 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
820 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
821 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
822 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
823 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
824 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
827 if (yyctable[ctry] == -1)
830 if (yydebug && yychar >= YYEOF)
831 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
836 if (yyps->save == NULL)
838 /* If this is a first conflict in the stack, start saving lexemes */
841 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
842 if (yylexemes == NULL) goto yyenomem;
843 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
844 if (yylvals == NULL) goto yyenomem;
845 yylvlim = yylvals + YYLVQUEUEGROWTH;
846 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
847 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
848 if (yylpsns == NULL) goto yyenomem;
849 yylplim = yylpsns + YYLVQUEUEGROWTH;
854 yylvp = yylve = yylvals;
855 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
856 yylpp = yylpe = yylpsns;
862 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
865 *yylexp = (short) yychar;
873 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
879 save->lexeme = (int) (yylvp - yylvals);
882 if (yytable[yyn] == ctry)
886 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
887 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
892 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
897 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
899 yystate = yyctable[ctry];
900 *++yystack.s_mark = (YYINT) yystate;
901 *++yystack.l_mark = yylval;
902 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
903 *++yystack.p_mark = yylloc;
906 if (yyerrflag > 0) --yyerrflag;
911 yyn = yyctable[ctry];
914 } /* End of code dealing with conflicts */
915 #endif /* YYBTYACC */
916 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
917 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
921 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
922 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
924 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
925 yystate = yytable[yyn];
926 *++yystack.s_mark = yytable[yyn];
927 *++yystack.l_mark = yylval;
928 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
929 *++yystack.p_mark = yylloc;
932 if (yyerrflag > 0) --yyerrflag;
935 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
936 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
941 if (yyerrflag != 0) goto yyinrecovery;
946 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
949 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
950 * before looking for error recovery */
951 yystack.s_mark -= yym;
952 yystate = *yystack.s_mark;
953 yystack.l_mark -= yym;
954 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
955 yystack.p_mark -= yym;
963 YYParseState *save = yyps->save;
966 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
967 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
968 (int)(yylvp - yylvals - yyps->save->lexeme));
970 /* Memorize most forward-looking error state in case it's really an error. */
971 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
973 /* Free old saved error context state */
974 if (yyerrctx) yyFreeState(yyerrctx);
975 /* Create and fill out new saved error context state */
976 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
977 if (yyerrctx == NULL) goto yyenomem;
978 yyerrctx->save = yyps->save;
979 yyerrctx->state = yystate;
980 yyerrctx->errflag = yyerrflag;
981 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
982 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
983 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
984 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
985 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
986 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
987 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
989 yyerrctx->lexeme = (int) (yylvp - yylvals);
991 yylvp = yylvals + save->lexeme;
992 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
993 yylpp = yylpsns + save->lexeme;
995 yylexp = yylexemes + save->lexeme;
997 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
998 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
999 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1000 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1001 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1002 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1003 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1005 ctry = ++save->ctry;
1006 yystate = save->state;
1007 /* We tried shift, try reduce now */
1008 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1009 yyps->save = save->save;
1013 /* Nothing left on the stack -- error */
1018 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1021 /* Restore state as it was in the most forward-advanced error */
1022 yylvp = yylvals + yyerrctx->lexeme;
1023 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1024 yylpp = yylpsns + yyerrctx->lexeme;
1026 yylexp = yylexemes + yyerrctx->lexeme;
1027 yychar = yylexp[-1];
1029 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1032 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1033 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1034 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1035 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1036 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1037 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1038 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1040 yystate = yyerrctx->state;
1041 yyFreeState(yyerrctx);
1046 if (yynewerrflag == 0) goto yyinrecovery;
1047 #endif /* YYBTYACC */
1049 YYERROR_CALL("syntax error");
1050 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1051 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1055 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1066 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1067 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1071 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1072 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1074 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1075 yystate = yytable[yyn];
1076 *++yystack.s_mark = yytable[yyn];
1077 *++yystack.l_mark = yylval;
1078 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1079 /* lookahead position is error end position */
1080 yyerror_loc_range[1] = yylloc;
1081 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1082 *++yystack.p_mark = yyloc;
1090 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1091 YYDEBUGSTR, yydepth, *yystack.s_mark);
1093 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1094 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1095 /* the current TOS position is the error start position */
1096 yyerror_loc_range[0] = *yystack.p_mark;
1098 #if defined(YYDESTRUCT_CALL)
1101 #endif /* YYBTYACC */
1102 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1103 YYDESTRUCT_CALL("error: discarding state",
1104 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1106 YYDESTRUCT_CALL("error: discarding state",
1107 yystos[*yystack.s_mark], yystack.l_mark);
1108 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1109 #endif /* defined(YYDESTRUCT_CALL) */
1112 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1120 if (yychar == YYEOF) goto yyabort;
1124 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1125 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1126 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1129 #if defined(YYDESTRUCT_CALL)
1132 #endif /* YYBTYACC */
1133 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1134 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1136 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1137 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1138 #endif /* defined(YYDESTRUCT_CALL) */
1148 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1149 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1150 #ifdef YYSTYPE_TOSTRING
1153 #endif /* YYBTYACC */
1158 for (i = yym; i > 0; i--)
1160 if (i != yym) fputs(", ", stderr);
1161 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1162 yystack.l_mark[1-i]), stderr);
1167 fputc('\n', stderr);
1171 yyval = yystack.l_mark[1-yym];
1173 memset(&yyval, 0, sizeof yyval);
1174 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1176 /* Perform position reduction */
1177 memset(&yyloc, 0, sizeof(yyloc));
1180 #endif /* YYBTYACC */
1182 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1183 /* just in case YYERROR is invoked within the action, save
1184 the start of the rhs as the error start position */
1185 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1192 #line 35 "quote_calc4.y"
1196 #line 39 "quote_calc4.y"
1197 { printf("%d\n",yystack.l_mark[0]);}
1200 #line 41 "quote_calc4.y"
1201 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1204 #line 45 "quote_calc4.y"
1205 { yyval = yystack.l_mark[-1]; }
1208 #line 47 "quote_calc4.y"
1209 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1212 #line 49 "quote_calc4.y"
1213 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1216 #line 51 "quote_calc4.y"
1217 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1220 #line 53 "quote_calc4.y"
1221 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1224 #line 55 "quote_calc4.y"
1225 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1228 #line 57 "quote_calc4.y"
1229 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1232 #line 59 "quote_calc4.y"
1233 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1236 #line 61 "quote_calc4.y"
1237 { yyval = - yystack.l_mark[0]; }
1240 #line 63 "quote_calc4.y"
1241 { yyval = regs[yystack.l_mark[0]]; }
1244 #line 68 "quote_calc4.y"
1245 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1248 #line 70 "quote_calc4.y"
1249 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1251 #line 1252 "quote_calc4-s.tab.c"
1255 yystack.s_mark -= yym;
1256 yystate = *yystack.s_mark;
1257 yystack.l_mark -= yym;
1258 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1259 yystack.p_mark -= yym;
1262 if (yystate == 0 && yym == 0)
1267 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1268 #ifdef YYSTYPE_TOSTRING
1271 #endif /* YYBTYACC */
1272 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1274 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1278 *++yystack.s_mark = YYFINAL;
1279 *++yystack.l_mark = yyval;
1280 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1281 *++yystack.p_mark = yyloc;
1289 /* we're currently re-reading tokens */
1291 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1299 /* in trial mode; save scanner results for future parse attempts */
1300 if (yylvp == yylvlim)
1301 { /* Enlarge lexical value queue */
1302 size_t p = (size_t) (yylvp - yylvals);
1303 size_t s = (size_t) (yylvlim - yylvals);
1305 s += YYLVQUEUEGROWTH;
1306 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1308 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1310 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1311 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1314 yylvp = yylve = yylvals + p;
1315 yylvlim = yylvals + s;
1316 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1317 yylpp = yylpe = yylpsns + p;
1318 yylplim = yylpsns + s;
1320 yylexp = yylexemes + p;
1322 *yylexp = (short) YYLEX;
1325 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1332 /* normal operation, no conflict encountered */
1333 #endif /* YYBTYACC */
1337 #endif /* YYBTYACC */
1338 if (yychar < 0) yychar = YYEOF;
1342 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1343 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1344 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1348 if (yychar == YYEOF) goto yyaccept;
1351 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1352 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1353 yystate = yytable[yyn];
1355 yystate = yydgoto[yym];
1359 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1360 #ifdef YYSTYPE_TOSTRING
1363 #endif /* YYBTYACC */
1364 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1366 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1369 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1370 *++yystack.s_mark = (YYINT) yystate;
1371 *++yystack.l_mark = yyval;
1372 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1373 *++yystack.p_mark = yyloc;
1378 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1380 if (yypath) YYABORT;
1383 YYParseState *save = yyps->save;
1384 yyps->save = save->save;
1385 save->save = yypath;
1390 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1391 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1395 yyFreeState(yyerrctx);
1398 yylvp = yylvals + yypath->lexeme;
1399 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1400 yylpp = yylpsns + yypath->lexeme;
1402 yylexp = yylexemes + yypath->lexeme;
1404 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1405 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1406 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1407 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1408 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1409 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1410 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1412 yystate = yypath->state;
1414 #endif /* YYBTYACC */
1417 YYERROR_CALL("yacc stack overflow");
1421 YYERROR_CALL("memory exhausted");
1423 #endif /* YYBTYACC */
1433 if (yyps->save) goto yyvalid;
1434 #endif /* YYBTYACC */
1438 #if defined(YYDESTRUCT_CALL)
1439 if (yychar != YYEOF && yychar != YYEMPTY)
1440 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1441 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1443 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1444 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1448 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1451 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1452 YYDESTRUCT_CALL("cleanup: discarding state",
1453 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1455 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1456 YYDESTRUCT_CALL("cleanup: discarding state",
1457 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1458 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1460 #endif /* defined(YYDESTRUCT_CALL) */
1465 yyFreeState(yyerrctx);
1470 YYParseState *save = yyps;
1477 YYParseState *save = yypath;
1478 yypath = save->save;
1482 #endif /* YYBTYACC */
1483 yyfreestack(&yystack);