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