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