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_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 = (short *)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 = (short *) malloc(size * sizeof(short));
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 */
688 memset(&yystack, 0, sizeof(yystack));
691 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
692 yystack.s_mark = yystack.s_base;
693 yystack.l_mark = yystack.l_base;
694 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
695 yystack.p_mark = yystack.p_base;
701 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
708 /* we're currently re-reading tokens */
710 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
718 /* in trial mode; save scanner results for future parse attempts */
719 if (yylvp == yylvlim)
720 { /* Enlarge lexical value queue */
721 size_t p = (size_t) (yylvp - yylvals);
722 size_t s = (size_t) (yylvlim - yylvals);
724 s += YYLVQUEUEGROWTH;
725 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
726 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
727 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
728 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
730 yylvp = yylve = yylvals + p;
731 yylvlim = yylvals + s;
732 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
733 yylpp = yylpe = yylpsns + p;
734 yylplim = yylpsns + s;
736 yylexp = yylexemes + p;
738 *yylexp = (short) YYLEX;
741 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
748 /* normal operation, no conflict encountered */
749 #endif /* YYBTYACC */
753 #endif /* YYBTYACC */
754 if (yychar < 0) yychar = YYEOF;
755 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
759 yys = yyname[YYTRANSLATE(yychar)];
760 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
761 YYDEBUGSTR, yydepth, yystate, yychar, yys);
762 #ifdef YYSTYPE_TOSTRING
765 #endif /* YYBTYACC */
766 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
774 /* Do we have a conflict? */
775 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
776 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
785 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
786 YYDEBUGSTR, yydepth, yystate);
788 /* Switch to the next conflict context */
793 if (save->state != yystate) YYABORT;
800 /* Unresolved conflict - start/continue trial parse */
805 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
807 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
809 fputs("Starting trial parse.\n", stderr);
812 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
813 if (save == NULL) goto yyenomem;
814 save->save = yyps->save;
815 save->state = yystate;
816 save->errflag = yyerrflag;
817 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
818 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
819 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
820 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
821 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
822 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
823 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
826 if (yyctable[ctry] == -1)
829 if (yydebug && yychar >= YYEOF)
830 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
835 if (yyps->save == NULL)
837 /* If this is a first conflict in the stack, start saving lexemes */
840 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
841 if (yylexemes == NULL) goto yyenomem;
842 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
843 if (yylvals == NULL) goto yyenomem;
844 yylvlim = yylvals + YYLVQUEUEGROWTH;
845 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
846 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
847 if (yylpsns == NULL) goto yyenomem;
848 yylplim = yylpsns + YYLVQUEUEGROWTH;
853 yylvp = yylve = yylvals;
854 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
855 yylpp = yylpe = yylpsns;
861 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
864 *yylexp = (short) yychar;
872 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
878 save->lexeme = (int) (yylvp - yylvals);
881 if (yytable[yyn] == ctry)
885 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
886 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
891 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
896 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
898 yystate = yyctable[ctry];
899 *++yystack.s_mark = (short) yystate;
900 *++yystack.l_mark = yylval;
901 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
902 *++yystack.p_mark = yylloc;
905 if (yyerrflag > 0) --yyerrflag;
910 yyn = yyctable[ctry];
913 } /* End of code dealing with conflicts */
914 #endif /* YYBTYACC */
915 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
916 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
920 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
921 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
923 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
924 yystate = yytable[yyn];
925 *++yystack.s_mark = yytable[yyn];
926 *++yystack.l_mark = yylval;
927 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
928 *++yystack.p_mark = yylloc;
931 if (yyerrflag > 0) --yyerrflag;
934 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
935 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
940 if (yyerrflag != 0) goto yyinrecovery;
953 YYParseState *save = yyps->save;
956 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
957 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
958 (int)(yylvp - yylvals - yyps->save->lexeme));
960 /* Memorize most forward-looking error state in case it's really an error. */
961 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
963 /* Free old saved error context state */
964 if (yyerrctx) yyFreeState(yyerrctx);
965 /* Create and fill out new saved error context state */
966 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
967 if (yyerrctx == NULL) goto yyenomem;
968 yyerrctx->save = yyps->save;
969 yyerrctx->state = yystate;
970 yyerrctx->errflag = yyerrflag;
971 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
972 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
973 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
974 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
975 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
976 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
977 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
979 yyerrctx->lexeme = (int) (yylvp - yylvals);
981 yylvp = yylvals + save->lexeme;
982 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
983 yylpp = yylpsns + save->lexeme;
985 yylexp = yylexemes + save->lexeme;
987 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
988 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
989 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
990 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
991 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
992 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
993 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
996 yystate = save->state;
997 /* We tried shift, try reduce now */
998 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
999 yyps->save = save->save;
1003 /* Nothing left on the stack -- error */
1008 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1011 /* Restore state as it was in the most forward-advanced error */
1012 yylvp = yylvals + yyerrctx->lexeme;
1013 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1014 yylpp = yylpsns + yyerrctx->lexeme;
1016 yylexp = yylexemes + yyerrctx->lexeme;
1017 yychar = yylexp[-1];
1019 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1022 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1023 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1024 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1025 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1026 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1027 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1028 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1030 yystate = yyerrctx->state;
1031 yyFreeState(yyerrctx);
1036 if (yynewerrflag == 0) goto yyinrecovery;
1037 #endif /* YYBTYACC */
1039 YYERROR_CALL("syntax error");
1040 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1041 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1056 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1057 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1061 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1062 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1064 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1065 yystate = yytable[yyn];
1066 *++yystack.s_mark = yytable[yyn];
1067 *++yystack.l_mark = yylval;
1068 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1069 /* lookahead position is error end position */
1070 yyerror_loc_range[1] = yylloc;
1071 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1072 *++yystack.p_mark = yyloc;
1080 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1081 YYDEBUGSTR, yydepth, *yystack.s_mark);
1083 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1084 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1085 /* the current TOS position is the error start position */
1086 yyerror_loc_range[0] = *yystack.p_mark;
1088 #if defined(YYDESTRUCT_CALL)
1091 #endif /* YYBTYACC */
1092 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1093 YYDESTRUCT_CALL("error: discarding state",
1094 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1096 YYDESTRUCT_CALL("error: discarding state",
1097 yystos[*yystack.s_mark], yystack.l_mark);
1098 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1099 #endif /* defined(YYDESTRUCT_CALL) */
1102 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1110 if (yychar == YYEOF) goto yyabort;
1114 yys = yyname[YYTRANSLATE(yychar)];
1115 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1116 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1119 #if defined(YYDESTRUCT_CALL)
1122 #endif /* YYBTYACC */
1123 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1124 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1126 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1127 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1128 #endif /* defined(YYDESTRUCT_CALL) */
1138 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1139 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1140 #ifdef YYSTYPE_TOSTRING
1143 #endif /* YYBTYACC */
1148 for (i = yym; i > 0; i--)
1150 if (i != yym) fputs(", ", stderr);
1151 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1152 yystack.l_mark[1-i]), stderr);
1157 fputc('\n', stderr);
1161 yyval = yystack.l_mark[1-yym];
1163 memset(&yyval, 0, sizeof yyval);
1164 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1166 /* Perform position reduction */
1167 memset(&yyloc, 0, sizeof(yyloc));
1170 #endif /* YYBTYACC */
1172 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1173 /* just in case YYERROR is invoked within the action, save
1174 the start of the rhs as the error start position */
1175 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1182 #line 35 "quote_calc4.y"
1186 #line 39 "quote_calc4.y"
1187 { printf("%d\n",yystack.l_mark[0]);}
1190 #line 41 "quote_calc4.y"
1191 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1194 #line 45 "quote_calc4.y"
1195 { yyval = yystack.l_mark[-1]; }
1198 #line 47 "quote_calc4.y"
1199 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1202 #line 49 "quote_calc4.y"
1203 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1206 #line 51 "quote_calc4.y"
1207 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1210 #line 53 "quote_calc4.y"
1211 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1214 #line 55 "quote_calc4.y"
1215 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1218 #line 57 "quote_calc4.y"
1219 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1222 #line 59 "quote_calc4.y"
1223 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1226 #line 61 "quote_calc4.y"
1227 { yyval = - yystack.l_mark[0]; }
1230 #line 63 "quote_calc4.y"
1231 { yyval = regs[yystack.l_mark[0]]; }
1234 #line 68 "quote_calc4.y"
1235 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1238 #line 70 "quote_calc4.y"
1239 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1241 #line 1242 "quote_calc4-s.tab.c"
1245 yystack.s_mark -= yym;
1246 yystate = *yystack.s_mark;
1247 yystack.l_mark -= yym;
1248 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1249 yystack.p_mark -= yym;
1252 if (yystate == 0 && yym == 0)
1257 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1258 #ifdef YYSTYPE_TOSTRING
1261 #endif /* YYBTYACC */
1262 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1264 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1268 *++yystack.s_mark = YYFINAL;
1269 *++yystack.l_mark = yyval;
1270 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1271 *++yystack.p_mark = yyloc;
1279 /* we're currently re-reading tokens */
1281 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1289 /* in trial mode; save scanner results for future parse attempts */
1290 if (yylvp == yylvlim)
1291 { /* Enlarge lexical value queue */
1292 size_t p = (size_t) (yylvp - yylvals);
1293 size_t s = (size_t) (yylvlim - yylvals);
1295 s += YYLVQUEUEGROWTH;
1296 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1298 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1300 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1301 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1304 yylvp = yylve = yylvals + p;
1305 yylvlim = yylvals + s;
1306 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1307 yylpp = yylpe = yylpsns + p;
1308 yylplim = yylpsns + s;
1310 yylexp = yylexemes + p;
1312 *yylexp = (short) YYLEX;
1315 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1322 /* normal operation, no conflict encountered */
1323 #endif /* YYBTYACC */
1327 #endif /* YYBTYACC */
1328 if (yychar < 0) yychar = YYEOF;
1329 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1333 yys = yyname[YYTRANSLATE(yychar)];
1334 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1335 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1339 if (yychar == YYEOF) goto yyaccept;
1342 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1343 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1344 yystate = yytable[yyn];
1346 yystate = yydgoto[yym];
1350 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1351 #ifdef YYSTYPE_TOSTRING
1354 #endif /* YYBTYACC */
1355 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1357 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1360 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1361 *++yystack.s_mark = (short) yystate;
1362 *++yystack.l_mark = yyval;
1363 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1364 *++yystack.p_mark = yyloc;
1369 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1371 if (yypath) YYABORT;
1374 YYParseState *save = yyps->save;
1375 yyps->save = save->save;
1376 save->save = yypath;
1381 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1382 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1386 yyFreeState(yyerrctx);
1389 yylvp = yylvals + yypath->lexeme;
1390 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1391 yylpp = yylpsns + yypath->lexeme;
1393 yylexp = yylexemes + yypath->lexeme;
1395 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1396 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1397 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1398 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1399 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1400 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1401 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1403 yystate = yypath->state;
1405 #endif /* YYBTYACC */
1408 YYERROR_CALL("yacc stack overflow");
1412 YYERROR_CALL("memory exhausted");
1414 #endif /* YYBTYACC */
1424 if (yyps->save) goto yyvalid;
1425 #endif /* YYBTYACC */
1429 #if defined(YYDESTRUCT_CALL)
1430 if (yychar != YYEOF && yychar != YYEMPTY)
1431 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1432 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1434 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1435 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1439 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1442 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1443 YYDESTRUCT_CALL("cleanup: discarding state",
1444 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1446 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1447 YYDESTRUCT_CALL("cleanup: discarding state",
1448 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1449 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1451 #endif /* defined(YYDESTRUCT_CALL) */
1456 yyFreeState(yyerrctx);
1461 YYParseState *save = yyps;
1468 YYParseState *save = yypath;
1469 yypath = save->save;
1473 #endif /* YYBTYACC */
1474 yyfreestack(&yystack);