xref: /freebsd/contrib/byacc/test/btyacc/calc_code_all.tab.c (revision 8e022d3cdea10ee1039a632f670c27fd93f65625)
1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4 
5 #define YYBYACC 1
6 #define YYMAJOR 2
7 #define YYMINOR 0
8 #define YYCHECK "yyyymmdd"
9 
10 #define YYEMPTY        (-1)
11 #define yyclearin      (yychar = YYEMPTY)
12 #define yyerrok        (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
14 #define YYENOMEM       (-2)
15 #define YYEOF          0
16 
17 /* %code "top" block start */
18 #line 5 "calc_code_all.y"
19 /* CODE-TOP */
20 /* %code "top" block end */
21 #line 22 "calc_code_all.tab.c"
22 #undef YYBTYACC
23 #define YYBTYACC 0
24 #define YYDEBUGSTR YYPREFIX "debug"
25 
26 #ifndef yyparse
27 #define yyparse    calc_code_all_parse
28 #endif /* yyparse */
29 
30 #ifndef yylex
31 #define yylex      calc_code_all_lex
32 #endif /* yylex */
33 
34 #ifndef yyerror
35 #define yyerror    calc_code_all_error
36 #endif /* yyerror */
37 
38 #ifndef yychar
39 #define yychar     calc_code_all_char
40 #endif /* yychar */
41 
42 #ifndef yyval
43 #define yyval      calc_code_all_val
44 #endif /* yyval */
45 
46 #ifndef yylval
47 #define yylval     calc_code_all_lval
48 #endif /* yylval */
49 
50 #ifndef yydebug
51 #define yydebug    calc_code_all_debug
52 #endif /* yydebug */
53 
54 #ifndef yynerrs
55 #define yynerrs    calc_code_all_nerrs
56 #endif /* yynerrs */
57 
58 #ifndef yyerrflag
59 #define yyerrflag  calc_code_all_errflag
60 #endif /* yyerrflag */
61 
62 #ifndef yylhs
63 #define yylhs      calc_code_all_lhs
64 #endif /* yylhs */
65 
66 #ifndef yylen
67 #define yylen      calc_code_all_len
68 #endif /* yylen */
69 
70 #ifndef yydefred
71 #define yydefred   calc_code_all_defred
72 #endif /* yydefred */
73 
74 #ifndef yystos
75 #define yystos     calc_code_all_stos
76 #endif /* yystos */
77 
78 #ifndef yydgoto
79 #define yydgoto    calc_code_all_dgoto
80 #endif /* yydgoto */
81 
82 #ifndef yysindex
83 #define yysindex   calc_code_all_sindex
84 #endif /* yysindex */
85 
86 #ifndef yyrindex
87 #define yyrindex   calc_code_all_rindex
88 #endif /* yyrindex */
89 
90 #ifndef yygindex
91 #define yygindex   calc_code_all_gindex
92 #endif /* yygindex */
93 
94 #ifndef yytable
95 #define yytable    calc_code_all_table
96 #endif /* yytable */
97 
98 #ifndef yycheck
99 #define yycheck    calc_code_all_check
100 #endif /* yycheck */
101 
102 #ifndef yyname
103 #define yyname     calc_code_all_name
104 #endif /* yyname */
105 
106 #ifndef yyrule
107 #define yyrule     calc_code_all_rule
108 #endif /* yyrule */
109 
110 #if YYBTYACC
111 
112 #ifndef yycindex
113 #define yycindex   calc_code_all_cindex
114 #endif /* yycindex */
115 
116 #ifndef yyctable
117 #define yyctable   calc_code_all_ctable
118 #endif /* yyctable */
119 
120 #endif /* YYBTYACC */
121 
122 #define YYPREFIX "calc_code_all_"
123 
124 #define YYPURE 0
125 
126 #line 9 "calc_code_all.y"
127 # include <stdio.h>
128 # include <ctype.h>
129 
130 int regs[26];
131 int base;
132 
133 extern int yylex(void);
134 static void yyerror(const char *s);
135 
136 #line 137 "calc_code_all.tab.c"
137 
138 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
139 /* Default: YYSTYPE is the semantic value type. */
140 typedef int YYSTYPE;
141 # define YYSTYPE_IS_DECLARED 1
142 #endif
143 
144 /* compatibility with bison */
145 #ifdef YYPARSE_PARAM
146 /* compatibility with FreeBSD */
147 # ifdef YYPARSE_PARAM_TYPE
148 #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
149 # else
150 #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
151 # endif
152 #else
153 # define YYPARSE_DECL() yyparse(void)
154 #endif
155 
156 /* Parameters sent to lex. */
157 #ifdef YYLEX_PARAM
158 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
159 # define YYLEX yylex(YYLEX_PARAM)
160 #else
161 # define YYLEX_DECL() yylex(void)
162 # define YYLEX yylex()
163 #endif
164 
165 /* Parameters sent to yyerror. */
166 #ifndef YYERROR_DECL
167 #define YYERROR_DECL() yyerror(const char *s)
168 #endif
169 #ifndef YYERROR_CALL
170 #define YYERROR_CALL(msg) yyerror(msg)
171 #endif
172 
173 extern int YYPARSE_DECL();
174 
175 #define DIGIT 257
176 #define LETTER 258
177 #define UMINUS 259
178 #define YYERRCODE 256
179 typedef int YYINT;
180 static const YYINT calc_code_all_lhs[] = {               -1,
181     0,    0,    0,    1,    1,    2,    2,    2,    2,    2,
182     2,    2,    2,    2,    2,    2,    3,    3,
183 };
184 static const YYINT calc_code_all_len[] = {                2,
185     0,    3,    3,    1,    3,    3,    3,    3,    3,    3,
186     3,    3,    3,    2,    1,    1,    1,    2,
187 };
188 static const YYINT calc_code_all_defred[] = {             1,
189     0,    0,   17,    0,    0,    0,    0,    0,    0,    3,
190     0,   15,   14,    0,    2,    0,    0,    0,    0,    0,
191     0,    0,   18,    0,    6,    0,    0,    0,    0,    9,
192    10,   11,
193 };
194 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
195 static const YYINT calc_code_all_stos[] = {               0,
196   261,  256,  257,  258,   45,   40,  262,  263,  264,   10,
197    61,  258,  263,  263,   10,  124,   38,   43,   45,   42,
198    47,   37,  257,  263,   41,  263,  263,  263,  263,  263,
199   263,  263,
200 };
201 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
202 static const YYINT calc_code_all_dgoto[] = {              1,
203     7,    8,    9,
204 };
205 static const YYINT calc_code_all_sindex[] = {             0,
206   -40,   -7,    0,  -55,  -38,  -38,    1,  -29, -247,    0,
207   -38,    0,    0,   22,    0,  -38,  -38,  -38,  -38,  -38,
208   -38,  -38,    0,  -29,    0,   51,   60,  -20,  -20,    0,
209     0,    0,
210 };
211 static const YYINT calc_code_all_rindex[] = {             0,
212     0,    0,    0,    2,    0,    0,    0,    9,   -9,    0,
213     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
214     0,    0,    0,   10,    0,   -6,   14,    5,   13,    0,
215     0,    0,
216 };
217 #if YYBTYACC
218 static const YYINT calc_code_all_cindex[] = {             0,
219     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
220     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
221     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
222     0,    0,
223 };
224 #endif
225 static const YYINT calc_code_all_gindex[] = {             0,
226     0,   65,    0,
227 };
228 #define YYTABLESIZE 220
229 static const YYINT calc_code_all_table[] = {              6,
230    16,    6,   10,   13,    5,   11,    5,   22,   17,   23,
231    15,   15,   20,   18,    7,   19,   22,   21,    4,    5,
232     0,   20,    8,   12,    0,    0,   21,   16,   16,    0,
233     0,   16,   16,   16,   13,   16,    0,   16,   15,   15,
234     0,    0,    7,   15,   15,    7,   15,    7,   15,    7,
235     8,   12,    0,    8,   12,    8,    0,    8,   22,   17,
236     0,    0,   25,   20,   18,    0,   19,    0,   21,   13,
237    14,    0,    0,    0,    0,   24,    0,    0,    0,    0,
238    26,   27,   28,   29,   30,   31,   32,   22,   17,    0,
239     0,    0,   20,   18,   16,   19,   22,   21,    0,    0,
240     0,   20,   18,    0,   19,    0,   21,    0,    0,    0,
241     0,    0,    0,    0,   16,    0,    0,   13,    0,    0,
242     0,    0,    0,    0,    0,   15,    0,    0,    7,    0,
243     0,    0,    0,    0,    0,    0,    8,   12,    0,    0,
244     0,    0,    0,    0,    0,   16,    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,    0,    0,    0,
250     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
251     0,    0,    0,    0,    0,    2,    3,    4,    3,   12,
252 };
253 static const YYINT calc_code_all_check[] = {             40,
254    10,   40,   10,   10,   45,   61,   45,   37,   38,  257,
255    10,   10,   42,   43,   10,   45,   37,   47,   10,   10,
256    -1,   42,   10,   10,   -1,   -1,   47,   37,   38,   -1,
257    -1,   41,   42,   43,   41,   45,   -1,   47,   37,   38,
258    -1,   -1,   38,   42,   43,   41,   45,   43,   47,   45,
259    38,   38,   -1,   41,   41,   43,   -1,   45,   37,   38,
260    -1,   -1,   41,   42,   43,   -1,   45,   -1,   47,    5,
261     6,   -1,   -1,   -1,   -1,   11,   -1,   -1,   -1,   -1,
262    16,   17,   18,   19,   20,   21,   22,   37,   38,   -1,
263    -1,   -1,   42,   43,  124,   45,   37,   47,   -1,   -1,
264    -1,   42,   43,   -1,   45,   -1,   47,   -1,   -1,   -1,
265    -1,   -1,   -1,   -1,  124,   -1,   -1,  124,   -1,   -1,
266    -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,  124,   -1,
267    -1,   -1,   -1,   -1,   -1,   -1,  124,  124,   -1,   -1,
268    -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,   -1,   -1,
269    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
270    -1,   -1,   -1,   -1,   -1,   -1,   -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,  256,  257,  258,  257,  258,
276 };
277 #if YYBTYACC
278 static const YYINT calc_code_all_ctable[] = {            -1,
279    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
280    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
281    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
282    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
283    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
284    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
285    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
286    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
287    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
288    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
289    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
290    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
291    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
292    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
293    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
294    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
295    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
296    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
297    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
298    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
299    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
300    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
301 };
302 #endif
303 #define YYFINAL 1
304 #ifndef YYDEBUG
305 #define YYDEBUG 0
306 #endif
307 #define YYMAXTOKEN 259
308 #define YYUNDFTOKEN 265
309 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
310 #if YYDEBUG
311 static const char *const calc_code_all_name[] = {
312 
313 "$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,
314 0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,
315 0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
316 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,
317 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
318 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
319 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
320 0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number",
321 "illegal-symbol",
322 };
323 static const char *const calc_code_all_rule[] = {
324 "$accept : list",
325 "list :",
326 "list : list stat '\\n'",
327 "list : list error '\\n'",
328 "stat : expr",
329 "stat : LETTER '=' expr",
330 "expr : '(' expr ')'",
331 "expr : expr '+' expr",
332 "expr : expr '-' expr",
333 "expr : expr '*' expr",
334 "expr : expr '/' expr",
335 "expr : expr '%' expr",
336 "expr : expr '&' expr",
337 "expr : expr '|' expr",
338 "expr : '-' expr",
339 "expr : LETTER",
340 "expr : number",
341 "number : DIGIT",
342 "number : number DIGIT",
343 
344 };
345 #endif
346 
347 #if YYDEBUG
348 int      yydebug;
349 #endif
350 
351 int      yyerrflag;
352 int      yychar;
353 YYSTYPE  yyval;
354 YYSTYPE  yylval;
355 int      yynerrs;
356 
357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
358 YYLTYPE  yyloc; /* position returned by actions */
359 YYLTYPE  yylloc; /* position from the lexer */
360 #endif
361 
362 /* %code "requires" block start */
363 #line 3 "calc_code_all.y"
364 /* CODE-REQUIRES */
365 /* %code "requires" block end */
366 #line 367 "calc_code_all.tab.c"
367 
368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
369 #ifndef YYLLOC_DEFAULT
370 #define YYLLOC_DEFAULT(loc, rhs, n) \
371 do \
372 { \
373     if (n == 0) \
374     { \
375         (loc).first_line   = YYRHSLOC(rhs, 0).last_line; \
376         (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
377         (loc).last_line    = YYRHSLOC(rhs, 0).last_line; \
378         (loc).last_column  = YYRHSLOC(rhs, 0).last_column; \
379     } \
380     else \
381     { \
382         (loc).first_line   = YYRHSLOC(rhs, 1).first_line; \
383         (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
384         (loc).last_line    = YYRHSLOC(rhs, n).last_line; \
385         (loc).last_column  = YYRHSLOC(rhs, n).last_column; \
386     } \
387 } while (0)
388 #endif /* YYLLOC_DEFAULT */
389 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
390 #if YYBTYACC
391 
392 #ifndef YYLVQUEUEGROWTH
393 #define YYLVQUEUEGROWTH 32
394 #endif
395 #endif /* YYBTYACC */
396 
397 /* define the initial stack-sizes */
398 #ifdef YYSTACKSIZE
399 #undef YYMAXDEPTH
400 #define YYMAXDEPTH  YYSTACKSIZE
401 #else
402 #ifdef YYMAXDEPTH
403 #define YYSTACKSIZE YYMAXDEPTH
404 #else
405 #define YYSTACKSIZE 10000
406 #define YYMAXDEPTH  10000
407 #endif
408 #endif
409 
410 #ifndef YYINITSTACKSIZE
411 #define YYINITSTACKSIZE 200
412 #endif
413 
414 typedef struct {
415     unsigned stacksize;
416     YYINT    *s_base;
417     YYINT    *s_mark;
418     YYINT    *s_last;
419     YYSTYPE  *l_base;
420     YYSTYPE  *l_mark;
421 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
422     YYLTYPE  *p_base;
423     YYLTYPE  *p_mark;
424 #endif
425 } YYSTACKDATA;
426 #if YYBTYACC
427 
428 struct YYParseState_s
429 {
430     struct YYParseState_s *save;    /* Previously saved parser state */
431     YYSTACKDATA            yystack; /* saved parser stack */
432     int                    state;   /* saved parser state */
433     int                    errflag; /* saved error recovery status */
434     int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
435     YYINT                  ctry;    /* saved index in yyctable[] for this conflict */
436 };
437 typedef struct YYParseState_s YYParseState;
438 #endif /* YYBTYACC */
439 /* variables for the parser stack */
440 static YYSTACKDATA yystack;
441 #if YYBTYACC
442 
443 /* Current parser state */
444 static YYParseState *yyps = 0;
445 
446 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
447 static YYParseState *yypath = 0;
448 
449 /* Base of the lexical value queue */
450 static YYSTYPE *yylvals = 0;
451 
452 /* Current position at lexical value queue */
453 static YYSTYPE *yylvp = 0;
454 
455 /* End position of lexical value queue */
456 static YYSTYPE *yylve = 0;
457 
458 /* The last allocated position at the lexical value queue */
459 static YYSTYPE *yylvlim = 0;
460 
461 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
462 /* Base of the lexical position queue */
463 static YYLTYPE *yylpsns = 0;
464 
465 /* Current position at lexical position queue */
466 static YYLTYPE *yylpp = 0;
467 
468 /* End position of lexical position queue */
469 static YYLTYPE *yylpe = 0;
470 
471 /* The last allocated position at the lexical position queue */
472 static YYLTYPE *yylplim = 0;
473 #endif
474 
475 /* Current position at lexical token queue */
476 static YYINT  *yylexp = 0;
477 
478 static YYINT  *yylexemes = 0;
479 #endif /* YYBTYACC */
480 
481 /* %code "provides" block start */
482 #line 4 "calc_code_all.y"
483 /* CODE-PROVIDES */
484 #line 6 "calc_code_all.y"
485 /* CODE-PROVIDES2 */
486 /* %code "provides" block end */
487 #line 488 "calc_code_all.tab.c"
488 
489 /* %code "" block start */
490 #line 1 "calc_code_all.y"
491 /* CODE-DEFAULT2 */
492 #line 2 "calc_code_all.y"
493 /* CODE-DEFAULT */
494 /* %code "" block end */
495 #line 496 "calc_code_all.tab.c"
496 #line 73 "calc_code_all.y"
497  /* start of programs */
498 
499 int
main(void)500 main (void)
501 {
502     while(!feof(stdin)) {
503 	yyparse();
504     }
505     return 0;
506 }
507 
508 static void
yyerror(const char * s)509 yyerror(const char *s)
510 {
511     fprintf(stderr, "%s\n", s);
512 }
513 
514 int
yylex(void)515 yylex(void)
516 {
517 	/* lexical analysis routine */
518 	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
519 	/* return DIGIT for a digit, yylval = 0 through 9 */
520 	/* all other characters are returned immediately */
521 
522     int c;
523 
524     while( (c=getchar()) == ' ' )   { /* skip blanks */ }
525 
526     /* c is now nonblank */
527 
528     if( islower( c )) {
529 	yylval = c - 'a';
530 	return ( LETTER );
531     }
532     if( isdigit( c )) {
533 	yylval = c - '0';
534 	return ( DIGIT );
535     }
536     return( c );
537 }
538 #line 539 "calc_code_all.tab.c"
539 
540 /* For use in generated program */
541 #define yydepth (int)(yystack.s_mark - yystack.s_base)
542 #if YYBTYACC
543 #define yytrial (yyps->save)
544 #endif /* YYBTYACC */
545 
546 #if YYDEBUG
547 #include <stdio.h>	/* needed for printf */
548 #endif
549 
550 #include <stdlib.h>	/* needed for malloc, etc */
551 #include <string.h>	/* needed for memset */
552 
553 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
yygrowstack(YYSTACKDATA * data)554 static int yygrowstack(YYSTACKDATA *data)
555 {
556     int i;
557     unsigned newsize;
558     YYINT *newss;
559     YYSTYPE *newvs;
560 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
561     YYLTYPE *newps;
562 #endif
563 
564     if ((newsize = data->stacksize) == 0)
565         newsize = YYINITSTACKSIZE;
566     else if (newsize >= YYMAXDEPTH)
567         return YYENOMEM;
568     else if ((newsize *= 2) > YYMAXDEPTH)
569         newsize = YYMAXDEPTH;
570 
571     i = (int) (data->s_mark - data->s_base);
572     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
573     if (newss == NULL)
574         return YYENOMEM;
575 
576     data->s_base = newss;
577     data->s_mark = newss + i;
578 
579     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
580     if (newvs == NULL)
581         return YYENOMEM;
582 
583     data->l_base = newvs;
584     data->l_mark = newvs + i;
585 
586 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
587     newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
588     if (newps == NULL)
589         return YYENOMEM;
590 
591     data->p_base = newps;
592     data->p_mark = newps + i;
593 #endif
594 
595     data->stacksize = newsize;
596     data->s_last = data->s_base + newsize - 1;
597 
598 #if YYDEBUG
599     if (yydebug)
600         fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
601 #endif
602     return 0;
603 }
604 
605 #if YYPURE || defined(YY_NO_LEAKS)
yyfreestack(YYSTACKDATA * data)606 static void yyfreestack(YYSTACKDATA *data)
607 {
608     free(data->s_base);
609     free(data->l_base);
610 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
611     free(data->p_base);
612 #endif
613     memset(data, 0, sizeof(*data));
614 }
615 #else
616 #define yyfreestack(data) /* nothing */
617 #endif /* YYPURE || defined(YY_NO_LEAKS) */
618 #if YYBTYACC
619 
620 static YYParseState *
yyNewState(unsigned size)621 yyNewState(unsigned size)
622 {
623     YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
624     if (p == NULL) return NULL;
625 
626     p->yystack.stacksize = size;
627     if (size == 0)
628     {
629         p->yystack.s_base = NULL;
630         p->yystack.l_base = NULL;
631 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
632         p->yystack.p_base = NULL;
633 #endif
634         return p;
635     }
636     p->yystack.s_base    = (YYINT *) malloc(size * sizeof(YYINT));
637     if (p->yystack.s_base == NULL) return NULL;
638     p->yystack.l_base    = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
639     if (p->yystack.l_base == NULL) return NULL;
640     memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
642     p->yystack.p_base    = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
643     if (p->yystack.p_base == NULL) return NULL;
644     memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
645 #endif
646 
647     return p;
648 }
649 
650 static void
yyFreeState(YYParseState * p)651 yyFreeState(YYParseState *p)
652 {
653     yyfreestack(&p->yystack);
654     free(p);
655 }
656 #endif /* YYBTYACC */
657 
658 #define YYABORT  goto yyabort
659 #define YYREJECT goto yyabort
660 #define YYACCEPT goto yyaccept
661 #define YYERROR  goto yyerrlab
662 #if YYBTYACC
663 #define YYVALID        do { if (yyps->save)            goto yyvalid; } while(0)
664 #define YYVALID_NESTED do { if (yyps->save && \
665                                 yyps->save->save == 0) goto yyvalid; } while(0)
666 #endif /* YYBTYACC */
667 
668 int
YYPARSE_DECL()669 YYPARSE_DECL()
670 {
671     int yym, yyn, yystate, yyresult;
672 #if YYBTYACC
673     int yynewerrflag;
674     YYParseState *yyerrctx = NULL;
675 #endif /* YYBTYACC */
676 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
677     YYLTYPE  yyerror_loc_range[3]; /* position of error start/end (0 unused) */
678 #endif
679 #if YYDEBUG
680     const char *yys;
681 
682     if ((yys = getenv("YYDEBUG")) != NULL)
683     {
684         yyn = *yys;
685         if (yyn >= '0' && yyn <= '9')
686             yydebug = yyn - '0';
687     }
688     if (yydebug)
689         fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
690 #endif
691 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
692     memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
693 #endif
694 
695 #if YYBTYACC
696     yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
697     yyps->save = 0;
698 #endif /* YYBTYACC */
699     yym = 0;
700     /* yyn is set below */
701     yynerrs = 0;
702     yyerrflag = 0;
703     yychar = YYEMPTY;
704     yystate = 0;
705 
706 #if YYPURE
707     memset(&yystack, 0, sizeof(yystack));
708 #endif
709 
710     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
711     yystack.s_mark = yystack.s_base;
712     yystack.l_mark = yystack.l_base;
713 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
714     yystack.p_mark = yystack.p_base;
715 #endif
716     yystate = 0;
717     *yystack.s_mark = 0;
718 
719 yyloop:
720     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
721     if (yychar < 0)
722     {
723 #if YYBTYACC
724         do {
725         if (yylvp < yylve)
726         {
727             /* we're currently re-reading tokens */
728             yylval = *yylvp++;
729 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
730             yylloc = *yylpp++;
731 #endif
732             yychar = *yylexp++;
733             break;
734         }
735         if (yyps->save)
736         {
737             /* in trial mode; save scanner results for future parse attempts */
738             if (yylvp == yylvlim)
739             {   /* Enlarge lexical value queue */
740                 size_t p = (size_t) (yylvp - yylvals);
741                 size_t s = (size_t) (yylvlim - yylvals);
742 
743                 s += YYLVQUEUEGROWTH;
744                 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
745                 if ((yylvals   = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
746 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
747                 if ((yylpsns   = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
748 #endif
749                 yylvp   = yylve = yylvals + p;
750                 yylvlim = yylvals + s;
751 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
752                 yylpp   = yylpe = yylpsns + p;
753                 yylplim = yylpsns + s;
754 #endif
755                 yylexp  = yylexemes + p;
756             }
757             *yylexp = (YYINT) YYLEX;
758             *yylvp++ = yylval;
759             yylve++;
760 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
761             *yylpp++ = yylloc;
762             yylpe++;
763 #endif
764             yychar = *yylexp++;
765             break;
766         }
767         /* normal operation, no conflict encountered */
768 #endif /* YYBTYACC */
769         yychar = YYLEX;
770 #if YYBTYACC
771         } while (0);
772 #endif /* YYBTYACC */
773         if (yychar < 0) yychar = YYEOF;
774 #if YYDEBUG
775         if (yydebug)
776         {
777             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
778             fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
779                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
780 #ifdef YYSTYPE_TOSTRING
781 #if YYBTYACC
782             if (!yytrial)
783 #endif /* YYBTYACC */
784                 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
785 #endif
786             fputc('\n', stderr);
787         }
788 #endif
789     }
790 #if YYBTYACC
791 
792     /* Do we have a conflict? */
793     if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
794         yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
795     {
796         YYINT ctry;
797 
798         if (yypath)
799         {
800             YYParseState *save;
801 #if YYDEBUG
802             if (yydebug)
803                 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
804                                 YYDEBUGSTR, yydepth, yystate);
805 #endif
806             /* Switch to the next conflict context */
807             save = yypath;
808             yypath = save->save;
809             save->save = NULL;
810             ctry = save->ctry;
811             if (save->state != yystate) YYABORT;
812             yyFreeState(save);
813 
814         }
815         else
816         {
817 
818             /* Unresolved conflict - start/continue trial parse */
819             YYParseState *save;
820 #if YYDEBUG
821             if (yydebug)
822             {
823                 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
824                 if (yyps->save)
825                     fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
826                 else
827                     fputs("Starting trial parse.\n", stderr);
828             }
829 #endif
830             save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
831             if (save == NULL) goto yyenomem;
832             save->save            = yyps->save;
833             save->state           = yystate;
834             save->errflag         = yyerrflag;
835             save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
836             memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
837             save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
838             memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
839 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
840             save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
841             memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
842 #endif
843             ctry                  = yytable[yyn];
844             if (yyctable[ctry] == -1)
845             {
846 #if YYDEBUG
847                 if (yydebug && yychar >= YYEOF)
848                     fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
849 #endif
850                 ctry++;
851             }
852             save->ctry = ctry;
853             if (yyps->save == NULL)
854             {
855                 /* If this is a first conflict in the stack, start saving lexemes */
856                 if (!yylexemes)
857                 {
858                     yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
859                     if (yylexemes == NULL) goto yyenomem;
860                     yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
861                     if (yylvals == NULL) goto yyenomem;
862                     yylvlim   = yylvals + YYLVQUEUEGROWTH;
863 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
864                     yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
865                     if (yylpsns == NULL) goto yyenomem;
866                     yylplim   = yylpsns + YYLVQUEUEGROWTH;
867 #endif
868                 }
869                 if (yylvp == yylve)
870                 {
871                     yylvp  = yylve = yylvals;
872 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
873                     yylpp  = yylpe = yylpsns;
874 #endif
875                     yylexp = yylexemes;
876                     if (yychar >= YYEOF)
877                     {
878                         *yylve++ = yylval;
879 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
880                         *yylpe++ = yylloc;
881 #endif
882                         *yylexp  = (YYINT) yychar;
883                         yychar   = YYEMPTY;
884                     }
885                 }
886             }
887             if (yychar >= YYEOF)
888             {
889                 yylvp--;
890 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
891                 yylpp--;
892 #endif
893                 yylexp--;
894                 yychar = YYEMPTY;
895             }
896             save->lexeme = (int) (yylvp - yylvals);
897             yyps->save   = save;
898         }
899         if (yytable[yyn] == ctry)
900         {
901 #if YYDEBUG
902             if (yydebug)
903                 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
904                                 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
905 #endif
906             if (yychar < 0)
907             {
908                 yylvp++;
909 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
910                 yylpp++;
911 #endif
912                 yylexp++;
913             }
914             if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
915                 goto yyoverflow;
916             yystate = yyctable[ctry];
917             *++yystack.s_mark = (YYINT) yystate;
918             *++yystack.l_mark = yylval;
919 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
920             *++yystack.p_mark = yylloc;
921 #endif
922             yychar  = YYEMPTY;
923             if (yyerrflag > 0) --yyerrflag;
924             goto yyloop;
925         }
926         else
927         {
928             yyn = yyctable[ctry];
929             goto yyreduce;
930         }
931     } /* End of code dealing with conflicts */
932 #endif /* YYBTYACC */
933     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
934             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
935     {
936 #if YYDEBUG
937         if (yydebug)
938             fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
939                             YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
940 #endif
941         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
942         yystate = yytable[yyn];
943         *++yystack.s_mark = yytable[yyn];
944         *++yystack.l_mark = yylval;
945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
946         *++yystack.p_mark = yylloc;
947 #endif
948         yychar = YYEMPTY;
949         if (yyerrflag > 0)  --yyerrflag;
950         goto yyloop;
951     }
952     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
953             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
954     {
955         yyn = yytable[yyn];
956         goto yyreduce;
957     }
958     if (yyerrflag != 0) goto yyinrecovery;
959 #if YYBTYACC
960 
961     yynewerrflag = 1;
962     goto yyerrhandler;
963     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
964 
965 yyerrlab:
966     /* explicit YYERROR from an action -- pop the rhs of the rule reduced
967      * before looking for error recovery */
968     yystack.s_mark -= yym;
969     yystate = *yystack.s_mark;
970     yystack.l_mark -= yym;
971 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
972     yystack.p_mark -= yym;
973 #endif
974 
975     yynewerrflag = 0;
976 yyerrhandler:
977     while (yyps->save)
978     {
979         int ctry;
980         YYParseState *save = yyps->save;
981 #if YYDEBUG
982         if (yydebug)
983             fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
984                             YYDEBUGSTR, yydepth, yystate, yyps->save->state,
985                     (int)(yylvp - yylvals - yyps->save->lexeme));
986 #endif
987         /* Memorize most forward-looking error state in case it's really an error. */
988         if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
989         {
990             /* Free old saved error context state */
991             if (yyerrctx) yyFreeState(yyerrctx);
992             /* Create and fill out new saved error context state */
993             yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
994             if (yyerrctx == NULL) goto yyenomem;
995             yyerrctx->save           = yyps->save;
996             yyerrctx->state          = yystate;
997             yyerrctx->errflag        = yyerrflag;
998             yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
999             memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1000             yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1001             memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1002 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1003             yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1004             memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1005 #endif
1006             yyerrctx->lexeme         = (int) (yylvp - yylvals);
1007         }
1008         yylvp          = yylvals   + save->lexeme;
1009 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1010         yylpp          = yylpsns   + save->lexeme;
1011 #endif
1012         yylexp         = yylexemes + save->lexeme;
1013         yychar         = YYEMPTY;
1014         yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1015         memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1016         yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1017         memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1018 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1019         yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1020         memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1021 #endif
1022         ctry           = ++save->ctry;
1023         yystate        = save->state;
1024         /* We tried shift, try reduce now */
1025         if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1026         yyps->save     = save->save;
1027         save->save     = NULL;
1028         yyFreeState(save);
1029 
1030         /* Nothing left on the stack -- error */
1031         if (!yyps->save)
1032         {
1033 #if YYDEBUG
1034             if (yydebug)
1035                 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1036                                 YYPREFIX, yydepth);
1037 #endif
1038             /* Restore state as it was in the most forward-advanced error */
1039             yylvp          = yylvals   + yyerrctx->lexeme;
1040 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1041             yylpp          = yylpsns   + yyerrctx->lexeme;
1042 #endif
1043             yylexp         = yylexemes + yyerrctx->lexeme;
1044             yychar         = yylexp[-1];
1045             yylval         = yylvp[-1];
1046 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1047             yylloc         = yylpp[-1];
1048 #endif
1049             yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1050             memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1051             yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1052             memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1053 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1054             yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1055             memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1056 #endif
1057             yystate        = yyerrctx->state;
1058             yyFreeState(yyerrctx);
1059             yyerrctx       = NULL;
1060         }
1061         yynewerrflag = 1;
1062     }
1063     if (yynewerrflag == 0) goto yyinrecovery;
1064 #endif /* YYBTYACC */
1065 
1066     YYERROR_CALL("syntax error");
1067 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1068     yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1069 #endif
1070 
1071 #if !YYBTYACC
1072     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1073 yyerrlab:
1074 #endif
1075     ++yynerrs;
1076 
1077 yyinrecovery:
1078     if (yyerrflag < 3)
1079     {
1080         yyerrflag = 3;
1081         for (;;)
1082         {
1083             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1084                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1085             {
1086 #if YYDEBUG
1087                 if (yydebug)
1088                     fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1089                                     YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1090 #endif
1091                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1092                 yystate = yytable[yyn];
1093                 *++yystack.s_mark = yytable[yyn];
1094                 *++yystack.l_mark = yylval;
1095 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1096                 /* lookahead position is error end position */
1097                 yyerror_loc_range[2] = yylloc;
1098                 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1099                 *++yystack.p_mark = yyloc;
1100 #endif
1101                 goto yyloop;
1102             }
1103             else
1104             {
1105 #if YYDEBUG
1106                 if (yydebug)
1107                     fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1108                                     YYDEBUGSTR, yydepth, *yystack.s_mark);
1109 #endif
1110                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1111 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1112                 /* the current TOS position is the error start position */
1113                 yyerror_loc_range[1] = *yystack.p_mark;
1114 #endif
1115 #if defined(YYDESTRUCT_CALL)
1116 #if YYBTYACC
1117                 if (!yytrial)
1118 #endif /* YYBTYACC */
1119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1120                     YYDESTRUCT_CALL("error: discarding state",
1121                                     yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1122 #else
1123                     YYDESTRUCT_CALL("error: discarding state",
1124                                     yystos[*yystack.s_mark], yystack.l_mark);
1125 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1126 #endif /* defined(YYDESTRUCT_CALL) */
1127                 --yystack.s_mark;
1128                 --yystack.l_mark;
1129 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1130                 --yystack.p_mark;
1131 #endif
1132             }
1133         }
1134     }
1135     else
1136     {
1137         if (yychar == YYEOF) goto yyabort;
1138 #if YYDEBUG
1139         if (yydebug)
1140         {
1141             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1142             fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1143                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
1144         }
1145 #endif
1146 #if defined(YYDESTRUCT_CALL)
1147 #if YYBTYACC
1148         if (!yytrial)
1149 #endif /* YYBTYACC */
1150 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1151             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1152 #else
1153             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1154 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1155 #endif /* defined(YYDESTRUCT_CALL) */
1156         yychar = YYEMPTY;
1157         goto yyloop;
1158     }
1159 
1160 yyreduce:
1161     yym = yylen[yyn];
1162 #if YYDEBUG
1163     if (yydebug)
1164     {
1165         fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1166                         YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1167 #ifdef YYSTYPE_TOSTRING
1168 #if YYBTYACC
1169         if (!yytrial)
1170 #endif /* YYBTYACC */
1171             if (yym > 0)
1172             {
1173                 int i;
1174                 fputc('<', stderr);
1175                 for (i = yym; i > 0; i--)
1176                 {
1177                     if (i != yym) fputs(", ", stderr);
1178                     fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1179                                            yystack.l_mark[1-i]), stderr);
1180                 }
1181                 fputc('>', stderr);
1182             }
1183 #endif
1184         fputc('\n', stderr);
1185     }
1186 #endif
1187     if (yym > 0)
1188         yyval = yystack.l_mark[1-yym];
1189     else
1190         memset(&yyval, 0, sizeof yyval);
1191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1192 
1193     /* Perform position reduction */
1194     memset(&yyloc, 0, sizeof(yyloc));
1195 #if YYBTYACC
1196     if (!yytrial)
1197 #endif /* YYBTYACC */
1198     {
1199         YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1200         /* just in case YYERROR is invoked within the action, save
1201            the start of the rhs as the error start position */
1202         yyerror_loc_range[1] = yystack.p_mark[1-yym];
1203     }
1204 #endif
1205 
1206     switch (yyn)
1207     {
1208 case 3:
1209 #line 35 "calc_code_all.y"
1210 	{  yyerrok ; }
1211 #line 1212 "calc_code_all.tab.c"
1212 break;
1213 case 4:
1214 #line 39 "calc_code_all.y"
1215 	{  printf("%d\n",yystack.l_mark[0]);}
1216 #line 1217 "calc_code_all.tab.c"
1217 break;
1218 case 5:
1219 #line 41 "calc_code_all.y"
1220 	{  regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1221 #line 1222 "calc_code_all.tab.c"
1222 break;
1223 case 6:
1224 #line 45 "calc_code_all.y"
1225 	{  yyval = yystack.l_mark[-1]; }
1226 #line 1227 "calc_code_all.tab.c"
1227 break;
1228 case 7:
1229 #line 47 "calc_code_all.y"
1230 	{  yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1231 #line 1232 "calc_code_all.tab.c"
1232 break;
1233 case 8:
1234 #line 49 "calc_code_all.y"
1235 	{  yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1236 #line 1237 "calc_code_all.tab.c"
1237 break;
1238 case 9:
1239 #line 51 "calc_code_all.y"
1240 	{  yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1241 #line 1242 "calc_code_all.tab.c"
1242 break;
1243 case 10:
1244 #line 53 "calc_code_all.y"
1245 	{  yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1246 #line 1247 "calc_code_all.tab.c"
1247 break;
1248 case 11:
1249 #line 55 "calc_code_all.y"
1250 	{  yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1251 #line 1252 "calc_code_all.tab.c"
1252 break;
1253 case 12:
1254 #line 57 "calc_code_all.y"
1255 	{  yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1256 #line 1257 "calc_code_all.tab.c"
1257 break;
1258 case 13:
1259 #line 59 "calc_code_all.y"
1260 	{  yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1261 #line 1262 "calc_code_all.tab.c"
1262 break;
1263 case 14:
1264 #line 61 "calc_code_all.y"
1265 	{  yyval = - yystack.l_mark[0]; }
1266 #line 1267 "calc_code_all.tab.c"
1267 break;
1268 case 15:
1269 #line 63 "calc_code_all.y"
1270 	{  yyval = regs[yystack.l_mark[0]]; }
1271 #line 1272 "calc_code_all.tab.c"
1272 break;
1273 case 17:
1274 #line 68 "calc_code_all.y"
1275 	{  yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1276 #line 1277 "calc_code_all.tab.c"
1277 break;
1278 case 18:
1279 #line 70 "calc_code_all.y"
1280 	{  yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1281 #line 1282 "calc_code_all.tab.c"
1282 break;
1283 #line 1284 "calc_code_all.tab.c"
1284     default:
1285         break;
1286     }
1287     yystack.s_mark -= yym;
1288     yystate = *yystack.s_mark;
1289     yystack.l_mark -= yym;
1290 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1291     yystack.p_mark -= yym;
1292 #endif
1293     yym = yylhs[yyn];
1294     if (yystate == 0 && yym == 0)
1295     {
1296 #if YYDEBUG
1297         if (yydebug)
1298         {
1299             fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1300 #ifdef YYSTYPE_TOSTRING
1301 #if YYBTYACC
1302             if (!yytrial)
1303 #endif /* YYBTYACC */
1304                 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1305 #endif
1306             fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1307         }
1308 #endif
1309         yystate = YYFINAL;
1310         *++yystack.s_mark = YYFINAL;
1311         *++yystack.l_mark = yyval;
1312 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1313         *++yystack.p_mark = yyloc;
1314 #endif
1315         if (yychar < 0)
1316         {
1317 #if YYBTYACC
1318             do {
1319             if (yylvp < yylve)
1320             {
1321                 /* we're currently re-reading tokens */
1322                 yylval = *yylvp++;
1323 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1324                 yylloc = *yylpp++;
1325 #endif
1326                 yychar = *yylexp++;
1327                 break;
1328             }
1329             if (yyps->save)
1330             {
1331                 /* in trial mode; save scanner results for future parse attempts */
1332                 if (yylvp == yylvlim)
1333                 {   /* Enlarge lexical value queue */
1334                     size_t p = (size_t) (yylvp - yylvals);
1335                     size_t s = (size_t) (yylvlim - yylvals);
1336 
1337                     s += YYLVQUEUEGROWTH;
1338                     if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1339                         goto yyenomem;
1340                     if ((yylvals   = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1341                         goto yyenomem;
1342 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1343                     if ((yylpsns   = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1344                         goto yyenomem;
1345 #endif
1346                     yylvp   = yylve = yylvals + p;
1347                     yylvlim = yylvals + s;
1348 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1349                     yylpp   = yylpe = yylpsns + p;
1350                     yylplim = yylpsns + s;
1351 #endif
1352                     yylexp  = yylexemes + p;
1353                 }
1354                 *yylexp = (YYINT) YYLEX;
1355                 *yylvp++ = yylval;
1356                 yylve++;
1357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1358                 *yylpp++ = yylloc;
1359                 yylpe++;
1360 #endif
1361                 yychar = *yylexp++;
1362                 break;
1363             }
1364             /* normal operation, no conflict encountered */
1365 #endif /* YYBTYACC */
1366             yychar = YYLEX;
1367 #if YYBTYACC
1368             } while (0);
1369 #endif /* YYBTYACC */
1370             if (yychar < 0) yychar = YYEOF;
1371 #if YYDEBUG
1372             if (yydebug)
1373             {
1374                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1375                 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1376                                 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1377             }
1378 #endif
1379         }
1380         if (yychar == YYEOF) goto yyaccept;
1381         goto yyloop;
1382     }
1383     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1384             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1385         yystate = yytable[yyn];
1386     else
1387         yystate = yydgoto[yym];
1388 #if YYDEBUG
1389     if (yydebug)
1390     {
1391         fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1392 #ifdef YYSTYPE_TOSTRING
1393 #if YYBTYACC
1394         if (!yytrial)
1395 #endif /* YYBTYACC */
1396             fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1397 #endif
1398         fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1399     }
1400 #endif
1401     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1402     *++yystack.s_mark = (YYINT) yystate;
1403     *++yystack.l_mark = yyval;
1404 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1405     *++yystack.p_mark = yyloc;
1406 #endif
1407     goto yyloop;
1408 #if YYBTYACC
1409 
1410     /* Reduction declares that this path is valid. Set yypath and do a full parse */
1411 yyvalid:
1412     if (yypath) YYABORT;
1413     while (yyps->save)
1414     {
1415         YYParseState *save = yyps->save;
1416         yyps->save = save->save;
1417         save->save = yypath;
1418         yypath = save;
1419     }
1420 #if YYDEBUG
1421     if (yydebug)
1422         fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1423                         YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1424 #endif
1425     if (yyerrctx)
1426     {
1427         yyFreeState(yyerrctx);
1428         yyerrctx = NULL;
1429     }
1430     yylvp          = yylvals + yypath->lexeme;
1431 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1432     yylpp          = yylpsns + yypath->lexeme;
1433 #endif
1434     yylexp         = yylexemes + yypath->lexeme;
1435     yychar         = YYEMPTY;
1436     yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1437     memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1438     yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1439     memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1440 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1441     yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1442     memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1443 #endif
1444     yystate        = yypath->state;
1445     goto yyloop;
1446 #endif /* YYBTYACC */
1447 
1448 yyoverflow:
1449     YYERROR_CALL("yacc stack overflow");
1450 #if YYBTYACC
1451     goto yyabort_nomem;
1452 yyenomem:
1453     YYERROR_CALL("memory exhausted");
1454 yyabort_nomem:
1455 #endif /* YYBTYACC */
1456     yyresult = 2;
1457     goto yyreturn;
1458 
1459 yyabort:
1460     yyresult = 1;
1461     goto yyreturn;
1462 
1463 yyaccept:
1464 #if YYBTYACC
1465     if (yyps->save) goto yyvalid;
1466 #endif /* YYBTYACC */
1467     yyresult = 0;
1468 
1469 yyreturn:
1470 #if defined(YYDESTRUCT_CALL)
1471     if (yychar != YYEOF && yychar != YYEMPTY)
1472 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1473         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1474 #else
1475         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1476 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1477 
1478     {
1479         YYSTYPE *pv;
1480 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1481         YYLTYPE *pp;
1482 
1483         for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1484              YYDESTRUCT_CALL("cleanup: discarding state",
1485                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1486 #else
1487         for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1488              YYDESTRUCT_CALL("cleanup: discarding state",
1489                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1490 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1491     }
1492 #endif /* defined(YYDESTRUCT_CALL) */
1493 
1494 #if YYBTYACC
1495     if (yyerrctx)
1496     {
1497         yyFreeState(yyerrctx);
1498         yyerrctx = NULL;
1499     }
1500     while (yyps)
1501     {
1502         YYParseState *save = yyps;
1503         yyps = save->save;
1504         save->save = NULL;
1505         yyFreeState(save);
1506     }
1507     while (yypath)
1508     {
1509         YYParseState *save = yypath;
1510         yypath = save->save;
1511         save->save = NULL;
1512         yyFreeState(save);
1513     }
1514 #endif /* YYBTYACC */
1515     yyfreestack(&yystack);
1516     return (yyresult);
1517 }
1518