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 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,
298 static const YYINT ok_syntax1_ctable[] = { -1,
299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
300 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
301 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
302 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
303 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
304 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
305 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
313 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
314 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
317 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
318 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
319 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
320 -1, -1, -1, -1, -1, -1, -1, -1, -1,
327 #define YYMAXTOKEN 273
328 #define YYUNDFTOKEN 279
329 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
331 static const char *const ok_syntax1_name[] = {
333 "$end",0,0,0,0,0,0,"'\\a'","'\\b'","'\\t'","'\\n'","'\\v'","'\\f'","'\\r'",0,0,
334 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'#'",0,"'%'","'&'",0,"'('","')'","'*'",
335 "'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,"'@'",0,0,0,0,0,0,0,0,
336 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
337 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,
338 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
339 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
340 0,0,0,0,0,0,0,0,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'",
341 "error","DIGIT","LETTER","OCT1","HEX1","HEX2","HEX3","STR1",
342 "\"\\177\\177\\\\\\n\"","STR2","BELL","BS","NL","LF","CR","TAB","VT","UMINUS",
343 "$accept","list","stat","expr","number","illegal-symbol",
345 static const char *const ok_syntax1_rule[] = {
348 "list : list stat '\\n'",
349 "list : list error '\\n'",
351 "stat : LETTER '=' expr",
352 "expr : '(' expr ')'",
353 "expr : expr '+' expr",
354 "expr : expr '-' expr",
355 "expr : expr '*' expr",
356 "expr : expr '/' expr",
357 "expr : expr '%' expr",
358 "expr : expr '&' expr",
359 "expr : expr '|' expr",
364 "number : number DIGIT",
372 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
373 #ifndef YYLLOC_DEFAULT
374 #define YYLLOC_DEFAULT(loc, rhs, n) \
379 (loc).first_line = ((rhs)[-1]).last_line; \
380 (loc).first_column = ((rhs)[-1]).last_column; \
381 (loc).last_line = ((rhs)[-1]).last_line; \
382 (loc).last_column = ((rhs)[-1]).last_column; \
386 (loc).first_line = ((rhs)[ 0 ]).first_line; \
387 (loc).first_column = ((rhs)[ 0 ]).first_column; \
388 (loc).last_line = ((rhs)[n-1]).last_line; \
389 (loc).last_column = ((rhs)[n-1]).last_column; \
392 #endif /* YYLLOC_DEFAULT */
393 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
396 #ifndef YYLVQUEUEGROWTH
397 #define YYLVQUEUEGROWTH 32
399 #endif /* YYBTYACC */
401 /* define the initial stack-sizes */
404 #define YYMAXDEPTH YYSTACKSIZE
407 #define YYSTACKSIZE YYMAXDEPTH
409 #define YYSTACKSIZE 10000
410 #define YYMAXDEPTH 10000
414 #ifndef YYINITSTACKSIZE
415 #define YYINITSTACKSIZE 200
425 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
432 struct YYParseState_s
434 struct YYParseState_s *save; /* Previously saved parser state */
435 YYSTACKDATA yystack; /* saved parser stack */
436 int state; /* saved parser state */
437 int errflag; /* saved error recovery status */
438 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
439 YYINT ctry; /* saved index in yyctable[] for this conflict */
441 typedef struct YYParseState_s YYParseState;
442 #endif /* YYBTYACC */
443 #line 104 "ok_syntax1.y"
444 /* start of programs */
447 extern int YYLEX_DECL();
456 while(!feof(stdin)) {
457 yyparse(regs, &base);
462 #define UNUSED(x) ((void)(x))
467 UNUSED(regs); /* %parse-param regs is not actually used here */
468 UNUSED(base); /* %parse-param base is not actually used here */
469 fprintf(stderr, "%s\n", s);
475 /* lexical analysis routine */
476 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
477 /* return DIGIT for a digit, yylval = 0 through 9 */
478 /* all other characters are returned immediately */
482 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
484 /* c is now nonblank */
487 yylval->ival = (c - 'a');
491 yylval->ival = (c - '0') % (*base);
496 #line 497 "ok_syntax1.tab.c"
498 /* For use in generated program */
499 #define yydepth (int)(yystack.s_mark - yystack.s_base)
501 #define yytrial (yyps->save)
502 #endif /* YYBTYACC */
505 #include <stdio.h> /* needed for printf */
508 #include <stdlib.h> /* needed for malloc, etc */
509 #include <string.h> /* needed for memset */
511 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
512 static int yygrowstack(YYSTACKDATA *data)
518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
522 if ((newsize = data->stacksize) == 0)
523 newsize = YYINITSTACKSIZE;
524 else if (newsize >= YYMAXDEPTH)
526 else if ((newsize *= 2) > YYMAXDEPTH)
527 newsize = YYMAXDEPTH;
529 i = (int) (data->s_mark - data->s_base);
530 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
534 data->s_base = newss;
535 data->s_mark = newss + i;
537 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
541 data->l_base = newvs;
542 data->l_mark = newvs + i;
544 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
545 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
549 data->p_base = newps;
550 data->p_mark = newps + i;
553 data->stacksize = newsize;
554 data->s_last = data->s_base + newsize - 1;
558 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
563 #if YYPURE || defined(YY_NO_LEAKS)
564 static void yyfreestack(YYSTACKDATA *data)
568 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
571 memset(data, 0, sizeof(*data));
574 #define yyfreestack(data) /* nothing */
575 #endif /* YYPURE || defined(YY_NO_LEAKS) */
578 static YYParseState *
579 yyNewState(unsigned size)
581 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
582 if (p == NULL) return NULL;
584 p->yystack.stacksize = size;
587 p->yystack.s_base = NULL;
588 p->yystack.l_base = NULL;
589 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
590 p->yystack.p_base = NULL;
594 p->yystack.s_base = (short *) malloc(size * sizeof(short));
595 if (p->yystack.s_base == NULL) return NULL;
596 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
597 if (p->yystack.l_base == NULL) return NULL;
598 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
599 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
600 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
601 if (p->yystack.p_base == NULL) return NULL;
602 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
609 yyFreeState(YYParseState *p)
611 yyfreestack(&p->yystack);
614 #endif /* YYBTYACC */
616 #define YYABORT goto yyabort
617 #define YYREJECT goto yyabort
618 #define YYACCEPT goto yyaccept
619 #define YYERROR goto yyerrlab
621 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
622 #define YYVALID_NESTED do { if (yyps->save && \
623 yyps->save->save == 0) goto yyvalid; } while(0)
624 #endif /* YYBTYACC */
633 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
634 YYLTYPE yyloc; /* position returned by actions */
635 YYLTYPE yylloc; /* position from the lexer */
638 /* variables for the parser stack */
642 /* Current parser state */
643 static YYParseState *yyps = 0;
645 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
646 static YYParseState *yypath = 0;
648 /* Base of the lexical value queue */
649 static YYSTYPE *yylvals = 0;
651 /* Current position at lexical value queue */
652 static YYSTYPE *yylvp = 0;
654 /* End position of lexical value queue */
655 static YYSTYPE *yylve = 0;
657 /* The last allocated position at the lexical value queue */
658 static YYSTYPE *yylvlim = 0;
660 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
661 /* Base of the lexical position queue */
662 static YYLTYPE *yylpsns = 0;
664 /* Current position at lexical position queue */
665 static YYLTYPE *yylpp = 0;
667 /* End position of lexical position queue */
668 static YYLTYPE *yylpe = 0;
670 /* The last allocated position at the lexical position queue */
671 static YYLTYPE *yylplim = 0;
674 /* Current position at lexical token queue */
675 static short *yylexp = 0;
677 static short *yylexemes = 0;
678 #endif /* YYBTYACC */
679 int yym, yyn, yystate, yyresult;
682 YYParseState *yyerrctx = NULL;
683 #endif /* YYBTYACC */
684 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
685 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
690 if ((yys = getenv("YYDEBUG")) != 0)
693 if (yyn >= '0' && yyn <= '9')
697 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
701 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
703 #endif /* YYBTYACC */
710 memset(&yystack, 0, sizeof(yystack));
713 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
714 yystack.s_mark = yystack.s_base;
715 yystack.l_mark = yystack.l_base;
716 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
717 yystack.p_mark = yystack.p_base;
723 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
730 /* we're currently re-reading tokens */
732 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
740 /* in trial mode; save scanner results for future parse attempts */
741 if (yylvp == yylvlim)
742 { /* Enlarge lexical value queue */
743 size_t p = (size_t) (yylvp - yylvals);
744 size_t s = (size_t) (yylvlim - yylvals);
746 s += YYLVQUEUEGROWTH;
747 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
748 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
749 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
750 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
752 yylvp = yylve = yylvals + p;
753 yylvlim = yylvals + s;
754 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
755 yylpp = yylpe = yylpsns + p;
756 yylplim = yylpsns + s;
758 yylexp = yylexemes + p;
760 *yylexp = (short) YYLEX;
763 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
770 /* normal operation, no conflict encountered */
771 #endif /* YYBTYACC */
775 #endif /* YYBTYACC */
776 if (yychar < 0) yychar = YYEOF;
777 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
781 yys = yyname[YYTRANSLATE(yychar)];
782 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
783 YYDEBUGSTR, yydepth, yystate, yychar, yys);
784 #ifdef YYSTYPE_TOSTRING
787 #endif /* YYBTYACC */
788 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
796 /* Do we have a conflict? */
797 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
798 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
807 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
808 YYDEBUGSTR, yydepth, yystate);
810 /* Switch to the next conflict context */
815 if (save->state != yystate) YYABORT;
822 /* Unresolved conflict - start/continue trial parse */
827 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
829 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
831 fputs("Starting trial parse.\n", stderr);
834 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
835 if (save == NULL) goto yyenomem;
836 save->save = yyps->save;
837 save->state = yystate;
838 save->errflag = yyerrflag;
839 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
840 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
841 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
842 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
843 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
844 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
845 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
848 if (yyctable[ctry] == -1)
851 if (yydebug && yychar >= YYEOF)
852 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
857 if (yyps->save == NULL)
859 /* If this is a first conflict in the stack, start saving lexemes */
862 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
863 if (yylexemes == NULL) goto yyenomem;
864 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
865 if (yylvals == NULL) goto yyenomem;
866 yylvlim = yylvals + YYLVQUEUEGROWTH;
867 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
868 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
869 if (yylpsns == NULL) goto yyenomem;
870 yylplim = yylpsns + YYLVQUEUEGROWTH;
875 yylvp = yylve = yylvals;
876 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
877 yylpp = yylpe = yylpsns;
883 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
886 *yylexp = (short) yychar;
894 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
900 save->lexeme = (int) (yylvp - yylvals);
903 if (yytable[yyn] == ctry)
907 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
908 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
913 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
918 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
920 yystate = yyctable[ctry];
921 *++yystack.s_mark = (short) yystate;
922 *++yystack.l_mark = yylval;
923 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
924 *++yystack.p_mark = yylloc;
927 if (yyerrflag > 0) --yyerrflag;
932 yyn = yyctable[ctry];
935 } /* End of code dealing with conflicts */
936 #endif /* YYBTYACC */
937 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
938 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
942 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
943 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
945 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
946 yystate = yytable[yyn];
947 *++yystack.s_mark = yytable[yyn];
948 *++yystack.l_mark = yylval;
949 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
950 *++yystack.p_mark = yylloc;
953 if (yyerrflag > 0) --yyerrflag;
956 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
957 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
962 if (yyerrflag != 0) goto yyinrecovery;
975 YYParseState *save = yyps->save;
978 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
979 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
980 (int)(yylvp - yylvals - yyps->save->lexeme));
982 /* Memorize most forward-looking error state in case it's really an error. */
983 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
985 /* Free old saved error context state */
986 if (yyerrctx) yyFreeState(yyerrctx);
987 /* Create and fill out new saved error context state */
988 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
989 if (yyerrctx == NULL) goto yyenomem;
990 yyerrctx->save = yyps->save;
991 yyerrctx->state = yystate;
992 yyerrctx->errflag = yyerrflag;
993 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
994 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
995 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
996 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
997 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
998 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
999 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1001 yyerrctx->lexeme = (int) (yylvp - yylvals);
1003 yylvp = yylvals + save->lexeme;
1004 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1005 yylpp = yylpsns + save->lexeme;
1007 yylexp = yylexemes + save->lexeme;
1009 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1010 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1011 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1012 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1013 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1014 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1015 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1017 ctry = ++save->ctry;
1018 yystate = save->state;
1019 /* We tried shift, try reduce now */
1020 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1021 yyps->save = save->save;
1025 /* Nothing left on the stack -- error */
1030 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1033 /* Restore state as it was in the most forward-advanced error */
1034 yylvp = yylvals + yyerrctx->lexeme;
1035 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1036 yylpp = yylpsns + yyerrctx->lexeme;
1038 yylexp = yylexemes + yyerrctx->lexeme;
1039 yychar = yylexp[-1];
1041 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1044 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1045 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1046 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1047 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1048 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1049 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1050 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1052 yystate = yyerrctx->state;
1053 yyFreeState(yyerrctx);
1058 if (yynewerrflag == 0) goto yyinrecovery;
1059 #endif /* YYBTYACC */
1061 YYERROR_CALL("syntax error");
1062 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1063 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1078 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1079 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1083 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1084 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1086 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1087 yystate = yytable[yyn];
1088 *++yystack.s_mark = yytable[yyn];
1089 *++yystack.l_mark = yylval;
1090 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1091 /* lookahead position is error end position */
1092 yyerror_loc_range[1] = yylloc;
1093 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1094 *++yystack.p_mark = yyloc;
1102 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1103 YYDEBUGSTR, yydepth, *yystack.s_mark);
1105 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1106 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1107 /* the current TOS position is the error start position */
1108 yyerror_loc_range[0] = *yystack.p_mark;
1110 #if defined(YYDESTRUCT_CALL)
1113 #endif /* YYBTYACC */
1114 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1115 YYDESTRUCT_CALL("error: discarding state",
1116 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1118 YYDESTRUCT_CALL("error: discarding state",
1119 yystos[*yystack.s_mark], yystack.l_mark);
1120 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1121 #endif /* defined(YYDESTRUCT_CALL) */
1124 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1132 if (yychar == YYEOF) goto yyabort;
1136 yys = yyname[YYTRANSLATE(yychar)];
1137 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1138 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1141 #if defined(YYDESTRUCT_CALL)
1144 #endif /* YYBTYACC */
1145 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1146 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1148 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1149 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1150 #endif /* defined(YYDESTRUCT_CALL) */
1160 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1161 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1162 #ifdef YYSTYPE_TOSTRING
1165 #endif /* YYBTYACC */
1170 for (i = yym; i > 0; i--)
1172 if (i != yym) fputs(", ", stderr);
1173 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1174 yystack.l_mark[1-i]), stderr);
1179 fputc('\n', stderr);
1183 yyval = yystack.l_mark[1-yym];
1185 memset(&yyval, 0, sizeof yyval);
1186 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1188 /* Perform position reduction */
1189 memset(&yyloc, 0, sizeof(yyloc));
1192 #endif /* YYBTYACC */
1194 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1195 /* just in case YYERROR is invoked within the action, save
1196 the start of the rhs as the error start position */
1197 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1204 #line 66 "ok_syntax1.y"
1208 #line 70 "ok_syntax1.y"
1209 { printf("%d\n",yystack.l_mark[0].ival);}
1212 #line 72 "ok_syntax1.y"
1213 { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; }
1216 #line 76 "ok_syntax1.y"
1217 { yyval.ival = yystack.l_mark[-1].ival; }
1220 #line 78 "ok_syntax1.y"
1221 { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; }
1224 #line 80 "ok_syntax1.y"
1225 { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; }
1228 #line 82 "ok_syntax1.y"
1229 { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; }
1232 #line 84 "ok_syntax1.y"
1233 { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; }
1236 #line 86 "ok_syntax1.y"
1237 { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; }
1240 #line 88 "ok_syntax1.y"
1241 { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; }
1244 #line 90 "ok_syntax1.y"
1245 { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; }
1248 #line 92 "ok_syntax1.y"
1249 { yyval.ival = - yystack.l_mark[0].ival; }
1252 #line 94 "ok_syntax1.y"
1253 { yyval.ival = regs[yystack.l_mark[0].ival]; }
1256 #line 99 "ok_syntax1.y"
1257 { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; }
1260 #line 101 "ok_syntax1.y"
1261 { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; }
1263 #line 1264 "ok_syntax1.tab.c"
1267 yystack.s_mark -= yym;
1268 yystate = *yystack.s_mark;
1269 yystack.l_mark -= yym;
1270 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1271 yystack.p_mark -= yym;
1274 if (yystate == 0 && yym == 0)
1279 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1280 #ifdef YYSTYPE_TOSTRING
1283 #endif /* YYBTYACC */
1284 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1286 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1290 *++yystack.s_mark = YYFINAL;
1291 *++yystack.l_mark = yyval;
1292 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1293 *++yystack.p_mark = yyloc;
1301 /* we're currently re-reading tokens */
1303 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1311 /* in trial mode; save scanner results for future parse attempts */
1312 if (yylvp == yylvlim)
1313 { /* Enlarge lexical value queue */
1314 size_t p = (size_t) (yylvp - yylvals);
1315 size_t s = (size_t) (yylvlim - yylvals);
1317 s += YYLVQUEUEGROWTH;
1318 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1320 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1322 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1323 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1326 yylvp = yylve = yylvals + p;
1327 yylvlim = yylvals + s;
1328 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1329 yylpp = yylpe = yylpsns + p;
1330 yylplim = yylpsns + s;
1332 yylexp = yylexemes + p;
1334 *yylexp = (short) YYLEX;
1337 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1344 /* normal operation, no conflict encountered */
1345 #endif /* YYBTYACC */
1349 #endif /* YYBTYACC */
1350 if (yychar < 0) yychar = YYEOF;
1351 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1355 yys = yyname[YYTRANSLATE(yychar)];
1356 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1357 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1361 if (yychar == YYEOF) goto yyaccept;
1364 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1365 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1366 yystate = yytable[yyn];
1368 yystate = yydgoto[yym];
1372 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1373 #ifdef YYSTYPE_TOSTRING
1376 #endif /* YYBTYACC */
1377 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1379 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1382 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1383 *++yystack.s_mark = (short) yystate;
1384 *++yystack.l_mark = yyval;
1385 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1386 *++yystack.p_mark = yyloc;
1391 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1393 if (yypath) YYABORT;
1396 YYParseState *save = yyps->save;
1397 yyps->save = save->save;
1398 save->save = yypath;
1403 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1404 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1408 yyFreeState(yyerrctx);
1411 yylvp = yylvals + yypath->lexeme;
1412 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1413 yylpp = yylpsns + yypath->lexeme;
1415 yylexp = yylexemes + yypath->lexeme;
1417 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1418 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1419 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1420 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1421 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1422 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1423 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1425 yystate = yypath->state;
1427 #endif /* YYBTYACC */
1430 YYERROR_CALL("yacc stack overflow");
1434 YYERROR_CALL("memory exhausted");
1436 #endif /* YYBTYACC */
1446 if (yyps->save) goto yyvalid;
1447 #endif /* YYBTYACC */
1451 #if defined(YYDESTRUCT_CALL)
1452 if (yychar != YYEOF && yychar != YYEMPTY)
1453 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1454 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1456 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1457 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1461 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1464 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1465 YYDESTRUCT_CALL("cleanup: discarding state",
1466 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1468 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1469 YYDESTRUCT_CALL("cleanup: discarding state",
1470 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1471 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1473 #endif /* defined(YYDESTRUCT_CALL) */
1478 yyFreeState(yyerrctx);
1483 YYParseState *save = yyps;
1490 YYParseState *save = yypath;
1491 yypath = save->save;
1495 #endif /* YYBTYACC */
1496 yyfreestack(&yystack);