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