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_calc3_parse
25 #define yylex quote_calc3_lex
29 #define yyerror quote_calc3_error
33 #define yychar quote_calc3_char
37 #define yyval quote_calc3_val
41 #define yylval quote_calc3_lval
45 #define yydebug quote_calc3_debug
49 #define yynerrs quote_calc3_nerrs
53 #define yyerrflag quote_calc3_errflag
54 #endif /* yyerrflag */
57 #define yylhs quote_calc3_lhs
61 #define yylen quote_calc3_len
65 #define yydefred quote_calc3_defred
69 #define yystos quote_calc3_stos
73 #define yydgoto quote_calc3_dgoto
77 #define yysindex quote_calc3_sindex
81 #define yyrindex quote_calc3_rindex
85 #define yygindex quote_calc3_gindex
89 #define yytable quote_calc3_table
93 #define yycheck quote_calc3_check
97 #define yyname quote_calc3_name
101 #define yyrule quote_calc3_rule
107 #define yycindex quote_calc3_cindex
108 #endif /* yycindex */
111 #define yyctable quote_calc3_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "quote_calc3_"
120 #line 2 "quote_calc3.y"
128 static void yyerror(const char *s);
130 #line 131 "quote_calc3.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_calc3_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_calc3_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_calc3_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_calc3_stos[] = { 0,
195 273, 256, 259, 269, 270, 40, 274, 275, 276, 10,
196 270, 275, 61, 275, 10, 257, 259, 261, 263, 265,
197 267, 124, 269, 275, 41, 275, 275, 275, 275, 275,
200 static const YYINT quote_calc3_dgoto[] = { 1,
203 static const YYINT quote_calc3_sindex[] = { 0,
204 -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
205 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
206 -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
209 static const YYINT quote_calc3_rindex[] = { 0,
210 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
211 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
216 static const YYINT quote_calc3_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_calc3_gindex[] = { 0,
226 #define YYTABLESIZE 258
227 static const YYINT quote_calc3_table[] = { 16,
228 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
229 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
230 23, 20, 4, 21, 5, 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 0, 22, 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, 16, 0, 17, 0, 18,
242 0, 19, 0, 20, 0, 21, 0, 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 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
251 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
252 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
253 16, 15, 16, 15, 16, 15, 16, 15,
255 static const YYINT quote_calc3_check[] = { 10,
256 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
257 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
258 269, 265, 10, 267, 10, -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 -1, 124, -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, 257, -1, 259, -1, 261,
270 -1, 263, -1, 265, -1, 267, -1, -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 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
279 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
280 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
281 261, 261, 263, 263, 265, 265, 267, 267,
287 #define YYMAXTOKEN 271
288 #define YYUNDFTOKEN 277
289 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
291 static const char *const quote_calc3_name[] = {
293 "$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,
294 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
295 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
296 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
297 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
298 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
299 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
300 0,0,"error","OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
301 "\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
302 "OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS","$accept","list","stat",
303 "expr","number","illegal-symbol",
305 static const char *const quote_calc3_rule[] = {
308 "list : list stat '\\n'",
309 "list : list error '\\n'",
311 "stat : LETTER '=' expr",
312 "expr : '(' expr ')'",
313 "expr : expr OP_ADD expr",
314 "expr : expr OP_SUB expr",
315 "expr : expr OP_MUL expr",
316 "expr : expr OP_DIV expr",
317 "expr : expr OP_MOD expr",
318 "expr : expr OP_AND expr",
319 "expr : expr '|' expr",
320 "expr : OP_SUB expr",
324 "number : number DIGIT",
336 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
337 YYLTYPE yyloc; /* position returned by actions */
338 YYLTYPE yylloc; /* position from the lexer */
341 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
342 #ifndef YYLLOC_DEFAULT
343 #define YYLLOC_DEFAULT(loc, rhs, n) \
348 (loc).first_line = ((rhs)[-1]).last_line; \
349 (loc).first_column = ((rhs)[-1]).last_column; \
350 (loc).last_line = ((rhs)[-1]).last_line; \
351 (loc).last_column = ((rhs)[-1]).last_column; \
355 (loc).first_line = ((rhs)[ 0 ]).first_line; \
356 (loc).first_column = ((rhs)[ 0 ]).first_column; \
357 (loc).last_line = ((rhs)[n-1]).last_line; \
358 (loc).last_column = ((rhs)[n-1]).last_column; \
361 #endif /* YYLLOC_DEFAULT */
362 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
365 #ifndef YYLVQUEUEGROWTH
366 #define YYLVQUEUEGROWTH 32
368 #endif /* YYBTYACC */
370 /* define the initial stack-sizes */
373 #define YYMAXDEPTH YYSTACKSIZE
376 #define YYSTACKSIZE YYMAXDEPTH
378 #define YYSTACKSIZE 10000
379 #define YYMAXDEPTH 10000
383 #ifndef YYINITSTACKSIZE
384 #define YYINITSTACKSIZE 200
394 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
401 struct YYParseState_s
403 struct YYParseState_s *save; /* Previously saved parser state */
404 YYSTACKDATA yystack; /* saved parser stack */
405 int state; /* saved parser state */
406 int errflag; /* saved error recovery status */
407 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
408 YYINT ctry; /* saved index in yyctable[] for this conflict */
410 typedef struct YYParseState_s YYParseState;
411 #endif /* YYBTYACC */
412 /* variables for the parser stack */
413 static YYSTACKDATA yystack;
416 /* Current parser state */
417 static YYParseState *yyps = 0;
419 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
420 static YYParseState *yypath = 0;
422 /* Base of the lexical value queue */
423 static YYSTYPE *yylvals = 0;
425 /* Current position at lexical value queue */
426 static YYSTYPE *yylvp = 0;
428 /* End position of lexical value queue */
429 static YYSTYPE *yylve = 0;
431 /* The last allocated position at the lexical value queue */
432 static YYSTYPE *yylvlim = 0;
434 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
435 /* Base of the lexical position queue */
436 static YYLTYPE *yylpsns = 0;
438 /* Current position at lexical position queue */
439 static YYLTYPE *yylpp = 0;
441 /* End position of lexical position queue */
442 static YYLTYPE *yylpe = 0;
444 /* The last allocated position at the lexical position queue */
445 static YYLTYPE *yylplim = 0;
448 /* Current position at lexical token queue */
449 static short *yylexp = 0;
451 static short *yylexemes = 0;
452 #endif /* YYBTYACC */
453 #line 73 "quote_calc3.y"
454 /* start of programs */
459 while(!feof(stdin)) {
466 yyerror(const char *s)
468 fprintf(stderr, "%s\n", s);
473 /* lexical analysis routine */
474 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
475 /* return DIGIT for a digit, yylval = 0 through 9 */
476 /* all other characters are returned immediately */
480 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
482 /* c is now nonblank */
494 #line 495 "quote_calc3.tab.c"
496 /* For use in generated program */
497 #define yydepth (int)(yystack.s_mark - yystack.s_base)
499 #define yytrial (yyps->save)
500 #endif /* YYBTYACC */
503 #include <stdio.h> /* needed for printf */
506 #include <stdlib.h> /* needed for malloc, etc */
507 #include <string.h> /* needed for memset */
509 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
510 static int yygrowstack(YYSTACKDATA *data)
516 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
520 if ((newsize = data->stacksize) == 0)
521 newsize = YYINITSTACKSIZE;
522 else if (newsize >= YYMAXDEPTH)
524 else if ((newsize *= 2) > YYMAXDEPTH)
525 newsize = YYMAXDEPTH;
527 i = (int) (data->s_mark - data->s_base);
528 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
532 data->s_base = newss;
533 data->s_mark = newss + i;
535 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
539 data->l_base = newvs;
540 data->l_mark = newvs + i;
542 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
543 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
547 data->p_base = newps;
548 data->p_mark = newps + i;
551 data->stacksize = newsize;
552 data->s_last = data->s_base + newsize - 1;
556 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
561 #if YYPURE || defined(YY_NO_LEAKS)
562 static void yyfreestack(YYSTACKDATA *data)
566 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
569 memset(data, 0, sizeof(*data));
572 #define yyfreestack(data) /* nothing */
573 #endif /* YYPURE || defined(YY_NO_LEAKS) */
576 static YYParseState *
577 yyNewState(unsigned size)
579 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
580 if (p == NULL) return NULL;
582 p->yystack.stacksize = size;
585 p->yystack.s_base = NULL;
586 p->yystack.l_base = NULL;
587 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
588 p->yystack.p_base = NULL;
592 p->yystack.s_base = (short *) malloc(size * sizeof(short));
593 if (p->yystack.s_base == NULL) return NULL;
594 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
595 if (p->yystack.l_base == NULL) return NULL;
596 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
597 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
598 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
599 if (p->yystack.p_base == NULL) return NULL;
600 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
607 yyFreeState(YYParseState *p)
609 yyfreestack(&p->yystack);
612 #endif /* YYBTYACC */
614 #define YYABORT goto yyabort
615 #define YYREJECT goto yyabort
616 #define YYACCEPT goto yyaccept
617 #define YYERROR goto yyerrlab
619 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
620 #define YYVALID_NESTED do { if (yyps->save && \
621 yyps->save->save == 0) goto yyvalid; } while(0)
622 #endif /* YYBTYACC */
627 int yym, yyn, yystate, yyresult;
630 YYParseState *yyerrctx = NULL;
631 #endif /* YYBTYACC */
632 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
633 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
638 if ((yys = getenv("YYDEBUG")) != 0)
641 if (yyn >= '0' && yyn <= '9')
645 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
649 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
651 #endif /* YYBTYACC */
658 memset(&yystack, 0, sizeof(yystack));
661 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
662 yystack.s_mark = yystack.s_base;
663 yystack.l_mark = yystack.l_base;
664 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
665 yystack.p_mark = yystack.p_base;
671 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
678 /* we're currently re-reading tokens */
680 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
688 /* in trial mode; save scanner results for future parse attempts */
689 if (yylvp == yylvlim)
690 { /* Enlarge lexical value queue */
691 int p = yylvp - yylvals;
692 int s = yylvlim - yylvals;
694 s += YYLVQUEUEGROWTH;
695 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
696 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
697 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
698 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
700 yylvp = yylve = yylvals + p;
701 yylvlim = yylvals + s;
702 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
703 yylpp = yylpe = yylpsns + p;
704 yylplim = yylpsns + s;
706 yylexp = yylexemes + p;
708 *yylexp = (short) YYLEX;
711 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
718 /* normal operation, no conflict encountered */
719 #endif /* YYBTYACC */
723 #endif /* YYBTYACC */
724 if (yychar < 0) yychar = YYEOF;
725 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
729 yys = yyname[YYTRANSLATE(yychar)];
730 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
731 YYDEBUGSTR, yydepth, yystate, yychar, yys);
732 #ifdef YYSTYPE_TOSTRING
735 #endif /* YYBTYACC */
736 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
744 /* Do we have a conflict? */
745 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
746 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
755 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
756 YYDEBUGSTR, yydepth, yystate);
758 /* Switch to the next conflict context */
763 if (save->state != yystate) YYABORT;
770 /* Unresolved conflict - start/continue trial parse */
775 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
777 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
779 fputs("Starting trial parse.\n", stderr);
782 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
783 if (save == NULL) goto yyenomem;
784 save->save = yyps->save;
785 save->state = yystate;
786 save->errflag = yyerrflag;
787 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
788 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
789 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
790 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
791 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
792 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
793 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
796 if (yyctable[ctry] == -1)
799 if (yydebug && yychar >= YYEOF)
800 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
805 if (yyps->save == NULL)
807 /* If this is a first conflict in the stack, start saving lexemes */
810 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
811 if (yylexemes == NULL) goto yyenomem;
812 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
813 if (yylvals == NULL) goto yyenomem;
814 yylvlim = yylvals + YYLVQUEUEGROWTH;
815 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
816 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
817 if (yylpsns == NULL) goto yyenomem;
818 yylplim = yylpsns + YYLVQUEUEGROWTH;
823 yylvp = yylve = yylvals;
824 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
825 yylpp = yylpe = yylpsns;
831 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
834 *yylexp = (short) yychar;
842 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
848 save->lexeme = yylvp - yylvals;
851 if (yytable[yyn] == ctry)
855 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
856 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
861 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
866 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
868 yystate = yyctable[ctry];
869 *++yystack.s_mark = (short) yystate;
870 *++yystack.l_mark = yylval;
871 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
872 *++yystack.p_mark = yylloc;
875 if (yyerrflag > 0) --yyerrflag;
880 yyn = yyctable[ctry];
883 } /* End of code dealing with conflicts */
884 #endif /* YYBTYACC */
885 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
886 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
890 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
891 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
893 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
894 yystate = yytable[yyn];
895 *++yystack.s_mark = yytable[yyn];
896 *++yystack.l_mark = yylval;
897 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
898 *++yystack.p_mark = yylloc;
901 if (yyerrflag > 0) --yyerrflag;
904 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
905 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
910 if (yyerrflag != 0) goto yyinrecovery;
923 YYParseState *save = yyps->save;
926 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
927 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
928 (int)(yylvp - yylvals - yyps->save->lexeme));
930 /* Memorize most forward-looking error state in case it's really an error. */
931 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
933 /* Free old saved error context state */
934 if (yyerrctx) yyFreeState(yyerrctx);
935 /* Create and fill out new saved error context state */
936 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
937 if (yyerrctx == NULL) goto yyenomem;
938 yyerrctx->save = yyps->save;
939 yyerrctx->state = yystate;
940 yyerrctx->errflag = yyerrflag;
941 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
942 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
943 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
944 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
946 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
947 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
949 yyerrctx->lexeme = yylvp - yylvals;
951 yylvp = yylvals + save->lexeme;
952 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
953 yylpp = yylpsns + save->lexeme;
955 yylexp = yylexemes + save->lexeme;
957 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
958 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
959 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
960 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
961 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
962 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
963 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
966 yystate = save->state;
967 /* We tried shift, try reduce now */
968 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
969 yyps->save = save->save;
973 /* Nothing left on the stack -- error */
978 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
981 /* Restore state as it was in the most forward-advanced error */
982 yylvp = yylvals + yyerrctx->lexeme;
983 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
984 yylpp = yylpsns + yyerrctx->lexeme;
986 yylexp = yylexemes + yyerrctx->lexeme;
989 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
992 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
993 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
994 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
995 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
996 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
997 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
998 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1000 yystate = yyerrctx->state;
1001 yyFreeState(yyerrctx);
1006 if (yynewerrflag == 0) goto yyinrecovery;
1007 #endif /* YYBTYACC */
1009 YYERROR_CALL("syntax error");
1010 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1011 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1026 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1027 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1031 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1032 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1034 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1035 yystate = yytable[yyn];
1036 *++yystack.s_mark = yytable[yyn];
1037 *++yystack.l_mark = yylval;
1038 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1039 /* lookahead position is error end position */
1040 yyerror_loc_range[1] = yylloc;
1041 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1042 *++yystack.p_mark = yyloc;
1050 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1051 YYDEBUGSTR, yydepth, *yystack.s_mark);
1053 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1054 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1055 /* the current TOS position is the error start position */
1056 yyerror_loc_range[0] = *yystack.p_mark;
1058 #if defined(YYDESTRUCT_CALL)
1061 #endif /* YYBTYACC */
1062 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1063 YYDESTRUCT_CALL("error: discarding state",
1064 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1066 YYDESTRUCT_CALL("error: discarding state",
1067 yystos[*yystack.s_mark], yystack.l_mark);
1068 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1069 #endif /* defined(YYDESTRUCT_CALL) */
1072 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1080 if (yychar == YYEOF) goto yyabort;
1084 yys = yyname[YYTRANSLATE(yychar)];
1085 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1086 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1089 #if defined(YYDESTRUCT_CALL)
1092 #endif /* YYBTYACC */
1093 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1094 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1096 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1097 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1098 #endif /* defined(YYDESTRUCT_CALL) */
1108 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1109 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1110 #ifdef YYSTYPE_TOSTRING
1113 #endif /* YYBTYACC */
1118 for (i = yym; i > 0; i--)
1120 if (i != yym) fputs(", ", stderr);
1121 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1122 yystack.l_mark[1-i]), stderr);
1127 fputc('\n', stderr);
1131 yyval = yystack.l_mark[1-yym];
1133 memset(&yyval, 0, sizeof yyval);
1134 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1136 /* Perform position reduction */
1137 memset(&yyloc, 0, sizeof(yyloc));
1140 #endif /* YYBTYACC */
1142 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1143 /* just in case YYERROR is invoked within the action, save
1144 the start of the rhs as the error start position */
1145 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1152 #line 35 "quote_calc3.y"
1156 #line 39 "quote_calc3.y"
1157 { printf("%d\n",yystack.l_mark[0]);}
1160 #line 41 "quote_calc3.y"
1161 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1164 #line 45 "quote_calc3.y"
1165 { yyval = yystack.l_mark[-1]; }
1168 #line 47 "quote_calc3.y"
1169 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1172 #line 49 "quote_calc3.y"
1173 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1176 #line 51 "quote_calc3.y"
1177 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1180 #line 53 "quote_calc3.y"
1181 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1184 #line 55 "quote_calc3.y"
1185 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1188 #line 57 "quote_calc3.y"
1189 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1192 #line 59 "quote_calc3.y"
1193 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1196 #line 61 "quote_calc3.y"
1197 { yyval = - yystack.l_mark[0]; }
1200 #line 63 "quote_calc3.y"
1201 { yyval = regs[yystack.l_mark[0]]; }
1204 #line 68 "quote_calc3.y"
1205 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1208 #line 70 "quote_calc3.y"
1209 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1211 #line 1212 "quote_calc3.tab.c"
1215 yystack.s_mark -= yym;
1216 yystate = *yystack.s_mark;
1217 yystack.l_mark -= yym;
1218 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1219 yystack.p_mark -= yym;
1222 if (yystate == 0 && yym == 0)
1227 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1228 #ifdef YYSTYPE_TOSTRING
1231 #endif /* YYBTYACC */
1232 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1234 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1238 *++yystack.s_mark = YYFINAL;
1239 *++yystack.l_mark = yyval;
1240 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1241 *++yystack.p_mark = yyloc;
1249 /* we're currently re-reading tokens */
1251 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1259 /* in trial mode; save scanner results for future parse attempts */
1260 if (yylvp == yylvlim)
1261 { /* Enlarge lexical value queue */
1262 int p = yylvp - yylvals;
1263 int s = yylvlim - yylvals;
1265 s += YYLVQUEUEGROWTH;
1266 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1268 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1270 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1271 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1274 yylvp = yylve = yylvals + p;
1275 yylvlim = yylvals + s;
1276 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1277 yylpp = yylpe = yylpsns + p;
1278 yylplim = yylpsns + s;
1280 yylexp = yylexemes + p;
1282 *yylexp = (short) YYLEX;
1285 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1292 /* normal operation, no conflict encountered */
1293 #endif /* YYBTYACC */
1297 #endif /* YYBTYACC */
1298 if (yychar < 0) yychar = YYEOF;
1299 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1303 yys = yyname[YYTRANSLATE(yychar)];
1304 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1305 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1309 if (yychar == YYEOF) goto yyaccept;
1312 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1313 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1314 yystate = yytable[yyn];
1316 yystate = yydgoto[yym];
1320 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1321 #ifdef YYSTYPE_TOSTRING
1324 #endif /* YYBTYACC */
1325 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1327 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1330 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1331 *++yystack.s_mark = (short) yystate;
1332 *++yystack.l_mark = yyval;
1333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1334 *++yystack.p_mark = yyloc;
1339 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1341 if (yypath) YYABORT;
1344 YYParseState *save = yyps->save;
1345 yyps->save = save->save;
1346 save->save = yypath;
1351 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1352 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1356 yyFreeState(yyerrctx);
1359 yylvp = yylvals + yypath->lexeme;
1360 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1361 yylpp = yylpsns + yypath->lexeme;
1363 yylexp = yylexemes + yypath->lexeme;
1365 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1366 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1367 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1368 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1369 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1370 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1371 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1373 yystate = yypath->state;
1375 #endif /* YYBTYACC */
1378 YYERROR_CALL("yacc stack overflow");
1382 YYERROR_CALL("memory exhausted");
1384 #endif /* YYBTYACC */
1394 if (yyps->save) goto yyvalid;
1395 #endif /* YYBTYACC */
1399 #if defined(YYDESTRUCT_CALL)
1400 if (yychar != YYEOF && yychar != YYEMPTY)
1401 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1402 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1404 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1405 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1409 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1412 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1413 YYDESTRUCT_CALL("cleanup: discarding state",
1414 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1416 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1417 YYDESTRUCT_CALL("cleanup: discarding state",
1418 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1419 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1421 #endif /* defined(YYDESTRUCT_CALL) */
1426 yyFreeState(yyerrctx);
1431 YYParseState *save = yyps;
1438 YYParseState *save = yypath;
1439 yypath = save->save;
1443 #endif /* YYBTYACC */
1444 yyfreestack(&yystack);