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 ok_syntax1_parse
25 #define yylex ok_syntax1_lex
29 #define yyerror ok_syntax1_error
33 #define yychar ok_syntax1_char
37 #define yyval ok_syntax1_val
41 #define yylval ok_syntax1_lval
45 #define yydebug ok_syntax1_debug
49 #define yynerrs ok_syntax1_nerrs
53 #define yyerrflag ok_syntax1_errflag
54 #endif /* yyerrflag */
57 #define yylhs ok_syntax1_lhs
61 #define yylen ok_syntax1_len
65 #define yydefred ok_syntax1_defred
69 #define yystos ok_syntax1_stos
73 #define yydgoto ok_syntax1_dgoto
77 #define yysindex ok_syntax1_sindex
81 #define yyrindex ok_syntax1_rindex
85 #define yygindex ok_syntax1_gindex
89 #define yytable ok_syntax1_table
93 #define yycheck ok_syntax1_check
97 #define yyname ok_syntax1_name
101 #define yyrule ok_syntax1_rule
107 #define yycindex ok_syntax1_cindex
108 #endif /* yycindex */
111 #define yyctable ok_syntax1_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "ok_syntax1_"
120 #line 9 "ok_syntax1.y"
126 #define YYLEX_PARAM base
127 #define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM)
128 #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
130 static void YYERROR_DECL();
133 #line 43 "ok_syntax1.y"
135 #undef YYSTYPE_IS_DECLARED
136 #define YYSTYPE_IS_DECLARED 1
138 #ifndef YYSTYPE_IS_DECLARED
139 #define YYSTYPE_IS_DECLARED 1
146 #endif /* !YYSTYPE_IS_DECLARED */
147 #line 148 "ok_syntax1.tab.c"
149 /* compatibility with bison */
151 /* compatibility with FreeBSD */
152 # ifdef YYPARSE_PARAM_TYPE
153 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
155 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
158 # define YYPARSE_DECL() yyparse(int regs[26], int * base)
161 /* Parameters sent to lex. */
163 # ifdef YYLEX_PARAM_TYPE
164 # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
166 # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
168 # define YYLEX yylex(&yylval, YYLEX_PARAM)
170 # define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base)
171 # define YYLEX yylex(&yylval, base)
174 /* Parameters sent to yyerror. */
176 #define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
179 #define YYERROR_CALL(msg) yyerror(regs, base, msg)
182 extern int YYPARSE_DECL();
200 #define YYERRCODE 256
202 static const YYINT ok_syntax1_lhs[] = { -1,
203 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
204 2, 2, 2, 2, 2, 2, 3, 3,
206 static const YYINT ok_syntax1_len[] = { 2,
207 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
208 3, 3, 3, 2, 1, 1, 1, 2,
210 static const YYINT ok_syntax1_defred[] = { 1,
211 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
212 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
213 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
216 static const YYINT ok_syntax1_stos[] = { 0,
217 275, 256, 257, 258, 45, 40, 276, 277, 278, 10,
218 61, 258, 277, 277, 10, 124, 38, 43, 45, 42,
219 47, 37, 257, 277, 41, 277, 277, 277, 277, 277,
222 static const YYINT ok_syntax1_dgoto[] = { 1,
225 static const YYINT ok_syntax1_sindex[] = { 0,
226 -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
227 -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
228 -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
231 static const YYINT ok_syntax1_rindex[] = { 0,
232 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
234 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
238 static const YYINT ok_syntax1_cindex[] = { 0,
239 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
245 static const YYINT ok_syntax1_gindex[] = { 0,
248 #define YYTABLESIZE 220
249 static const YYINT ok_syntax1_table[] = { 6,
250 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
251 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
252 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
253 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
254 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
255 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
256 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
257 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
258 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
259 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
260 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
261 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
262 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
263 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
264 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
271 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
273 static const YYINT ok_syntax1_check[] = { 40,
274 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
275 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
276 -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
277 -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
278 -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
279 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
280 -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
281 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
282 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
283 -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
284 -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
285 -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
286 -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
287 -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
288 -1, -1, -1, -1, -1, 124, -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, 256, 257, 258, 257, 258,
301 #define YYMAXTOKEN 273
302 #define YYUNDFTOKEN 279
303 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
305 static const char *const ok_syntax1_name[] = {
307 "$end",0,0,0,0,0,0,"'\\a'","'\\b'","'\\t'","'\\n'","'\\v'","'\\f'","'\\r'",0,0,
308 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'#'",0,"'%'","'&'",0,"'('","')'","'*'",
309 "'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,"'@'",0,0,0,0,0,0,0,0,
310 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
311 0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,"'~'","'\\177'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
312 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
313 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
314 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'\\377'",
315 "error","DIGIT","LETTER","OCT1","HEX1","HEX2","HEX3","STR1",
316 "\"\\177\\177\\\\\\n\"","STR2","BELL","BS","NL","LF","CR","TAB","VT","UMINUS",
317 "$accept","list","stat","expr","number","illegal-symbol",
319 static const char *const ok_syntax1_rule[] = {
322 "list : list stat '\\n'",
323 "list : list error '\\n'",
325 "stat : LETTER '=' expr",
326 "expr : '(' expr ')'",
327 "expr : expr '+' expr",
328 "expr : expr '-' expr",
329 "expr : expr '*' expr",
330 "expr : expr '/' expr",
331 "expr : expr '%' expr",
332 "expr : expr '&' expr",
333 "expr : expr '|' expr",
338 "number : number DIGIT",
346 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
347 #ifndef YYLLOC_DEFAULT
348 #define YYLLOC_DEFAULT(loc, rhs, n) \
353 (loc).first_line = ((rhs)[-1]).last_line; \
354 (loc).first_column = ((rhs)[-1]).last_column; \
355 (loc).last_line = ((rhs)[-1]).last_line; \
356 (loc).last_column = ((rhs)[-1]).last_column; \
360 (loc).first_line = ((rhs)[ 0 ]).first_line; \
361 (loc).first_column = ((rhs)[ 0 ]).first_column; \
362 (loc).last_line = ((rhs)[n-1]).last_line; \
363 (loc).last_column = ((rhs)[n-1]).last_column; \
366 #endif /* YYLLOC_DEFAULT */
367 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
370 #ifndef YYLVQUEUEGROWTH
371 #define YYLVQUEUEGROWTH 32
373 #endif /* YYBTYACC */
375 /* define the initial stack-sizes */
378 #define YYMAXDEPTH YYSTACKSIZE
381 #define YYSTACKSIZE YYMAXDEPTH
383 #define YYSTACKSIZE 10000
384 #define YYMAXDEPTH 10000
388 #ifndef YYINITSTACKSIZE
389 #define YYINITSTACKSIZE 200
399 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
406 struct YYParseState_s
408 struct YYParseState_s *save; /* Previously saved parser state */
409 YYSTACKDATA yystack; /* saved parser stack */
410 int state; /* saved parser state */
411 int errflag; /* saved error recovery status */
412 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
413 YYINT ctry; /* saved index in yyctable[] for this conflict */
415 typedef struct YYParseState_s YYParseState;
416 #endif /* YYBTYACC */
417 #line 104 "ok_syntax1.y"
418 /* start of programs */
421 extern int YYLEX_DECL();
430 while(!feof(stdin)) {
431 yyparse(regs, &base);
436 #define UNUSED(x) ((void)(x))
441 UNUSED(regs); /* %parse-param regs is not actually used here */
442 UNUSED(base); /* %parse-param base is not actually used here */
443 fprintf(stderr, "%s\n", s);
449 /* lexical analysis routine */
450 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
451 /* return DIGIT for a digit, yylval = 0 through 9 */
452 /* all other characters are returned immediately */
456 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
458 /* c is now nonblank */
461 yylval->ival = (c - 'a');
465 yylval->ival = (c - '0') % (*base);
470 #line 471 "ok_syntax1.tab.c"
472 /* For use in generated program */
473 #define yydepth (int)(yystack.s_mark - yystack.s_base)
475 #define yytrial (yyps->save)
476 #endif /* YYBTYACC */
479 #include <stdio.h> /* needed for printf */
482 #include <stdlib.h> /* needed for malloc, etc */
483 #include <string.h> /* needed for memset */
485 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
486 static int yygrowstack(YYSTACKDATA *data)
492 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
496 if ((newsize = data->stacksize) == 0)
497 newsize = YYINITSTACKSIZE;
498 else if (newsize >= YYMAXDEPTH)
500 else if ((newsize *= 2) > YYMAXDEPTH)
501 newsize = YYMAXDEPTH;
503 i = (int) (data->s_mark - data->s_base);
504 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
508 data->s_base = newss;
509 data->s_mark = newss + i;
511 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
515 data->l_base = newvs;
516 data->l_mark = newvs + i;
518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
519 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
523 data->p_base = newps;
524 data->p_mark = newps + i;
527 data->stacksize = newsize;
528 data->s_last = data->s_base + newsize - 1;
532 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
537 #if YYPURE || defined(YY_NO_LEAKS)
538 static void yyfreestack(YYSTACKDATA *data)
542 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
545 memset(data, 0, sizeof(*data));
548 #define yyfreestack(data) /* nothing */
549 #endif /* YYPURE || defined(YY_NO_LEAKS) */
552 static YYParseState *
553 yyNewState(unsigned size)
555 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
556 if (p == NULL) return NULL;
558 p->yystack.stacksize = size;
561 p->yystack.s_base = NULL;
562 p->yystack.l_base = NULL;
563 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
564 p->yystack.p_base = NULL;
568 p->yystack.s_base = (short *) malloc(size * sizeof(short));
569 if (p->yystack.s_base == NULL) return NULL;
570 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
571 if (p->yystack.l_base == NULL) return NULL;
572 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
573 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
574 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
575 if (p->yystack.p_base == NULL) return NULL;
576 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
583 yyFreeState(YYParseState *p)
585 yyfreestack(&p->yystack);
588 #endif /* YYBTYACC */
590 #define YYABORT goto yyabort
591 #define YYREJECT goto yyabort
592 #define YYACCEPT goto yyaccept
593 #define YYERROR goto yyerrlab
595 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
596 #define YYVALID_NESTED do { if (yyps->save && \
597 yyps->save->save == 0) goto yyvalid; } while(0)
598 #endif /* YYBTYACC */
607 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
608 YYLTYPE yyloc; /* position returned by actions */
609 YYLTYPE yylloc; /* position from the lexer */
612 /* variables for the parser stack */
616 /* Current parser state */
617 static YYParseState *yyps = 0;
619 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
620 static YYParseState *yypath = 0;
622 /* Base of the lexical value queue */
623 static YYSTYPE *yylvals = 0;
625 /* Current position at lexical value queue */
626 static YYSTYPE *yylvp = 0;
628 /* End position of lexical value queue */
629 static YYSTYPE *yylve = 0;
631 /* The last allocated position at the lexical value queue */
632 static YYSTYPE *yylvlim = 0;
634 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
635 /* Base of the lexical position queue */
636 static YYLTYPE *yylpsns = 0;
638 /* Current position at lexical position queue */
639 static YYLTYPE *yylpp = 0;
641 /* End position of lexical position queue */
642 static YYLTYPE *yylpe = 0;
644 /* The last allocated position at the lexical position queue */
645 static YYLTYPE *yylplim = 0;
648 /* Current position at lexical token queue */
649 static short *yylexp = 0;
651 static short *yylexemes = 0;
652 #endif /* YYBTYACC */
653 int yym, yyn, yystate, yyresult;
656 YYParseState *yyerrctx = NULL;
657 #endif /* YYBTYACC */
658 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
659 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
664 if ((yys = getenv("YYDEBUG")) != 0)
667 if (yyn >= '0' && yyn <= '9')
671 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
675 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
677 #endif /* YYBTYACC */
684 memset(&yystack, 0, sizeof(yystack));
687 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
688 yystack.s_mark = yystack.s_base;
689 yystack.l_mark = yystack.l_base;
690 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
691 yystack.p_mark = yystack.p_base;
697 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
704 /* we're currently re-reading tokens */
706 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
714 /* in trial mode; save scanner results for future parse attempts */
715 if (yylvp == yylvlim)
716 { /* Enlarge lexical value queue */
717 int p = yylvp - yylvals;
718 int s = yylvlim - yylvals;
720 s += YYLVQUEUEGROWTH;
721 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
722 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
723 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
724 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
726 yylvp = yylve = yylvals + p;
727 yylvlim = yylvals + s;
728 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
729 yylpp = yylpe = yylpsns + p;
730 yylplim = yylpsns + s;
732 yylexp = yylexemes + p;
734 *yylexp = (short) YYLEX;
737 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
744 /* normal operation, no conflict encountered */
745 #endif /* YYBTYACC */
749 #endif /* YYBTYACC */
750 if (yychar < 0) yychar = YYEOF;
751 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
755 yys = yyname[YYTRANSLATE(yychar)];
756 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
757 YYDEBUGSTR, yydepth, yystate, yychar, yys);
758 #ifdef YYSTYPE_TOSTRING
761 #endif /* YYBTYACC */
762 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
770 /* Do we have a conflict? */
771 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
772 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
781 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
782 YYDEBUGSTR, yydepth, yystate);
784 /* Switch to the next conflict context */
789 if (save->state != yystate) YYABORT;
796 /* Unresolved conflict - start/continue trial parse */
801 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
803 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
805 fputs("Starting trial parse.\n", stderr);
808 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
809 if (save == NULL) goto yyenomem;
810 save->save = yyps->save;
811 save->state = yystate;
812 save->errflag = yyerrflag;
813 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
814 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
815 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
816 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
817 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
818 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
819 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
822 if (yyctable[ctry] == -1)
825 if (yydebug && yychar >= YYEOF)
826 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
831 if (yyps->save == NULL)
833 /* If this is a first conflict in the stack, start saving lexemes */
836 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
837 if (yylexemes == NULL) goto yyenomem;
838 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
839 if (yylvals == NULL) goto yyenomem;
840 yylvlim = yylvals + YYLVQUEUEGROWTH;
841 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
842 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
843 if (yylpsns == NULL) goto yyenomem;
844 yylplim = yylpsns + YYLVQUEUEGROWTH;
849 yylvp = yylve = yylvals;
850 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
851 yylpp = yylpe = yylpsns;
857 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
860 *yylexp = (short) yychar;
868 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
874 save->lexeme = yylvp - yylvals;
877 if (yytable[yyn] == ctry)
881 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
882 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
887 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
892 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
894 yystate = yyctable[ctry];
895 *++yystack.s_mark = (short) yystate;
896 *++yystack.l_mark = yylval;
897 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
898 *++yystack.p_mark = yylloc;
901 if (yyerrflag > 0) --yyerrflag;
906 yyn = yyctable[ctry];
909 } /* End of code dealing with conflicts */
910 #endif /* YYBTYACC */
911 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
912 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
916 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
917 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
919 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
920 yystate = yytable[yyn];
921 *++yystack.s_mark = yytable[yyn];
922 *++yystack.l_mark = yylval;
923 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
924 *++yystack.p_mark = yylloc;
927 if (yyerrflag > 0) --yyerrflag;
930 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
931 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
936 if (yyerrflag != 0) goto yyinrecovery;
949 YYParseState *save = yyps->save;
952 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
953 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
954 (int)(yylvp - yylvals - yyps->save->lexeme));
956 /* Memorize most forward-looking error state in case it's really an error. */
957 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
959 /* Free old saved error context state */
960 if (yyerrctx) yyFreeState(yyerrctx);
961 /* Create and fill out new saved error context state */
962 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
963 if (yyerrctx == NULL) goto yyenomem;
964 yyerrctx->save = yyps->save;
965 yyerrctx->state = yystate;
966 yyerrctx->errflag = yyerrflag;
967 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
968 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
969 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
970 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
971 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
972 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
973 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
975 yyerrctx->lexeme = yylvp - yylvals;
977 yylvp = yylvals + save->lexeme;
978 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
979 yylpp = yylpsns + save->lexeme;
981 yylexp = yylexemes + save->lexeme;
983 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
984 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
985 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
986 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
987 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
988 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
989 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
992 yystate = save->state;
993 /* We tried shift, try reduce now */
994 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
995 yyps->save = save->save;
999 /* Nothing left on the stack -- error */
1004 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1007 /* Restore state as it was in the most forward-advanced error */
1008 yylvp = yylvals + yyerrctx->lexeme;
1009 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1010 yylpp = yylpsns + yyerrctx->lexeme;
1012 yylexp = yylexemes + yyerrctx->lexeme;
1013 yychar = yylexp[-1];
1015 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1018 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1019 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1020 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1021 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1022 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1023 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1024 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1026 yystate = yyerrctx->state;
1027 yyFreeState(yyerrctx);
1032 if (yynewerrflag == 0) goto yyinrecovery;
1033 #endif /* YYBTYACC */
1035 YYERROR_CALL("syntax error");
1036 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1037 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1052 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1053 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1057 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1058 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1060 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1061 yystate = yytable[yyn];
1062 *++yystack.s_mark = yytable[yyn];
1063 *++yystack.l_mark = yylval;
1064 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1065 /* lookahead position is error end position */
1066 yyerror_loc_range[1] = yylloc;
1067 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1068 *++yystack.p_mark = yyloc;
1076 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1077 YYDEBUGSTR, yydepth, *yystack.s_mark);
1079 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1080 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1081 /* the current TOS position is the error start position */
1082 yyerror_loc_range[0] = *yystack.p_mark;
1084 #if defined(YYDESTRUCT_CALL)
1087 #endif /* YYBTYACC */
1088 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1089 YYDESTRUCT_CALL("error: discarding state",
1090 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1092 YYDESTRUCT_CALL("error: discarding state",
1093 yystos[*yystack.s_mark], yystack.l_mark);
1094 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1095 #endif /* defined(YYDESTRUCT_CALL) */
1098 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1106 if (yychar == YYEOF) goto yyabort;
1110 yys = yyname[YYTRANSLATE(yychar)];
1111 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1112 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1115 #if defined(YYDESTRUCT_CALL)
1118 #endif /* YYBTYACC */
1119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1120 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1122 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1123 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1124 #endif /* defined(YYDESTRUCT_CALL) */
1134 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1135 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1136 #ifdef YYSTYPE_TOSTRING
1139 #endif /* YYBTYACC */
1144 for (i = yym; i > 0; i--)
1146 if (i != yym) fputs(", ", stderr);
1147 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1148 yystack.l_mark[1-i]), stderr);
1153 fputc('\n', stderr);
1157 yyval = yystack.l_mark[1-yym];
1159 memset(&yyval, 0, sizeof yyval);
1160 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1162 /* Perform position reduction */
1163 memset(&yyloc, 0, sizeof(yyloc));
1166 #endif /* YYBTYACC */
1168 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1169 /* just in case YYERROR is invoked within the action, save
1170 the start of the rhs as the error start position */
1171 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1178 #line 66 "ok_syntax1.y"
1182 #line 70 "ok_syntax1.y"
1183 { printf("%d\n",yystack.l_mark[0].ival);}
1186 #line 72 "ok_syntax1.y"
1187 { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; }
1190 #line 76 "ok_syntax1.y"
1191 { yyval.ival = yystack.l_mark[-1].ival; }
1194 #line 78 "ok_syntax1.y"
1195 { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; }
1198 #line 80 "ok_syntax1.y"
1199 { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; }
1202 #line 82 "ok_syntax1.y"
1203 { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; }
1206 #line 84 "ok_syntax1.y"
1207 { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; }
1210 #line 86 "ok_syntax1.y"
1211 { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; }
1214 #line 88 "ok_syntax1.y"
1215 { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; }
1218 #line 90 "ok_syntax1.y"
1219 { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; }
1222 #line 92 "ok_syntax1.y"
1223 { yyval.ival = - yystack.l_mark[0].ival; }
1226 #line 94 "ok_syntax1.y"
1227 { yyval.ival = regs[yystack.l_mark[0].ival]; }
1230 #line 99 "ok_syntax1.y"
1231 { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; }
1234 #line 101 "ok_syntax1.y"
1235 { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; }
1237 #line 1238 "ok_syntax1.tab.c"
1241 yystack.s_mark -= yym;
1242 yystate = *yystack.s_mark;
1243 yystack.l_mark -= yym;
1244 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1245 yystack.p_mark -= yym;
1248 if (yystate == 0 && yym == 0)
1253 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1254 #ifdef YYSTYPE_TOSTRING
1257 #endif /* YYBTYACC */
1258 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1260 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1264 *++yystack.s_mark = YYFINAL;
1265 *++yystack.l_mark = yyval;
1266 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1267 *++yystack.p_mark = yyloc;
1275 /* we're currently re-reading tokens */
1277 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1285 /* in trial mode; save scanner results for future parse attempts */
1286 if (yylvp == yylvlim)
1287 { /* Enlarge lexical value queue */
1288 int p = yylvp - yylvals;
1289 int s = yylvlim - yylvals;
1291 s += YYLVQUEUEGROWTH;
1292 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1294 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1296 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1297 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1300 yylvp = yylve = yylvals + p;
1301 yylvlim = yylvals + s;
1302 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1303 yylpp = yylpe = yylpsns + p;
1304 yylplim = yylpsns + s;
1306 yylexp = yylexemes + p;
1308 *yylexp = (short) YYLEX;
1311 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1318 /* normal operation, no conflict encountered */
1319 #endif /* YYBTYACC */
1323 #endif /* YYBTYACC */
1324 if (yychar < 0) yychar = YYEOF;
1325 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1329 yys = yyname[YYTRANSLATE(yychar)];
1330 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1331 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1335 if (yychar == YYEOF) goto yyaccept;
1338 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1339 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1340 yystate = yytable[yyn];
1342 yystate = yydgoto[yym];
1346 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1347 #ifdef YYSTYPE_TOSTRING
1350 #endif /* YYBTYACC */
1351 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1353 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1356 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1357 *++yystack.s_mark = (short) yystate;
1358 *++yystack.l_mark = yyval;
1359 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1360 *++yystack.p_mark = yyloc;
1365 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1367 if (yypath) YYABORT;
1370 YYParseState *save = yyps->save;
1371 yyps->save = save->save;
1372 save->save = yypath;
1377 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1378 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1382 yyFreeState(yyerrctx);
1385 yylvp = yylvals + yypath->lexeme;
1386 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1387 yylpp = yylpsns + yypath->lexeme;
1389 yylexp = yylexemes + yypath->lexeme;
1391 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1392 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1393 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1394 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1395 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1396 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1397 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1399 yystate = yypath->state;
1401 #endif /* YYBTYACC */
1404 YYERROR_CALL("yacc stack overflow");
1408 YYERROR_CALL("memory exhausted");
1410 #endif /* YYBTYACC */
1420 if (yyps->save) goto yyvalid;
1421 #endif /* YYBTYACC */
1425 #if defined(YYDESTRUCT_CALL)
1426 if (yychar != YYEOF && yychar != YYEMPTY)
1427 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1428 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1430 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1431 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1435 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1438 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1439 YYDESTRUCT_CALL("cleanup: discarding state",
1440 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1442 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1443 YYDESTRUCT_CALL("cleanup: discarding state",
1444 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1445 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1447 #endif /* defined(YYDESTRUCT_CALL) */
1452 yyFreeState(yyerrctx);
1457 YYParseState *save = yyps;
1464 YYParseState *save = yypath;
1465 yypath = save->save;
1469 #endif /* YYBTYACC */
1470 yyfreestack(&yystack);