quote_calc-s.tab.c revision 1.3 1 /* $NetBSD: quote_calc-s.tab.c,v 1.3 2017/06/05 18:54:30 christos Exp $ */
2
3 /* original parser id follows */
4 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
5 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
6
7 #define YYBYACC 1
8 #define YYMAJOR 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 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
681 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
682 #endif
683
684 #if YYBTYACC
685 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
686 yyps->save = 0;
687 #endif /* YYBTYACC */
688 yym = 0;
689 yyn = 0;
690 yynerrs = 0;
691 yyerrflag = 0;
692 yychar = YYEMPTY;
693 yystate = 0;
694
695 #if YYPURE
696 memset(&yystack, 0, sizeof(yystack));
697 #endif
698
699 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
700 yystack.s_mark = yystack.s_base;
701 yystack.l_mark = yystack.l_base;
702 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
703 yystack.p_mark = yystack.p_base;
704 #endif
705 yystate = 0;
706 *yystack.s_mark = 0;
707
708 yyloop:
709 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
710 if (yychar < 0)
711 {
712 #if YYBTYACC
713 do {
714 if (yylvp < yylve)
715 {
716 /* we're currently re-reading tokens */
717 yylval = *yylvp++;
718 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
719 yylloc = *yylpp++;
720 #endif
721 yychar = *yylexp++;
722 break;
723 }
724 if (yyps->save)
725 {
726 /* in trial mode; save scanner results for future parse attempts */
727 if (yylvp == yylvlim)
728 { /* Enlarge lexical value queue */
729 size_t p = (size_t) (yylvp - yylvals);
730 size_t s = (size_t) (yylvlim - yylvals);
731
732 s += YYLVQUEUEGROWTH;
733 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
734 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
735 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
736 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
737 #endif
738 yylvp = yylve = yylvals + p;
739 yylvlim = yylvals + s;
740 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
741 yylpp = yylpe = yylpsns + p;
742 yylplim = yylpsns + s;
743 #endif
744 yylexp = yylexemes + p;
745 }
746 *yylexp = (YYINT) YYLEX;
747 *yylvp++ = yylval;
748 yylve++;
749 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
750 *yylpp++ = yylloc;
751 yylpe++;
752 #endif
753 yychar = *yylexp++;
754 break;
755 }
756 /* normal operation, no conflict encountered */
757 #endif /* YYBTYACC */
758 yychar = YYLEX;
759 #if YYBTYACC
760 } while (0);
761 #endif /* YYBTYACC */
762 if (yychar < 0) yychar = YYEOF;
763 #if YYDEBUG
764 if (yydebug)
765 {
766 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
767 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
768 YYDEBUGSTR, yydepth, yystate, yychar, yys);
769 #ifdef YYSTYPE_TOSTRING
770 #if YYBTYACC
771 if (!yytrial)
772 #endif /* YYBTYACC */
773 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
774 #endif
775 fputc('\n', stderr);
776 }
777 #endif
778 }
779 #if YYBTYACC
780
781 /* Do we have a conflict? */
782 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
783 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
784 {
785 YYINT ctry;
786
787 if (yypath)
788 {
789 YYParseState *save;
790 #if YYDEBUG
791 if (yydebug)
792 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
793 YYDEBUGSTR, yydepth, yystate);
794 #endif
795 /* Switch to the next conflict context */
796 save = yypath;
797 yypath = save->save;
798 save->save = NULL;
799 ctry = save->ctry;
800 if (save->state != yystate) YYABORT;
801 yyFreeState(save);
802
803 }
804 else
805 {
806
807 /* Unresolved conflict - start/continue trial parse */
808 YYParseState *save;
809 #if YYDEBUG
810 if (yydebug)
811 {
812 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
813 if (yyps->save)
814 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
815 else
816 fputs("Starting trial parse.\n", stderr);
817 }
818 #endif
819 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
820 if (save == NULL) goto yyenomem;
821 save->save = yyps->save;
822 save->state = yystate;
823 save->errflag = yyerrflag;
824 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
825 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
826 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
827 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
828 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
829 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
830 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
831 #endif
832 ctry = yytable[yyn];
833 if (yyctable[ctry] == -1)
834 {
835 #if YYDEBUG
836 if (yydebug && yychar >= YYEOF)
837 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
838 #endif
839 ctry++;
840 }
841 save->ctry = ctry;
842 if (yyps->save == NULL)
843 {
844 /* If this is a first conflict in the stack, start saving lexemes */
845 if (!yylexemes)
846 {
847 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
848 if (yylexemes == NULL) goto yyenomem;
849 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
850 if (yylvals == NULL) goto yyenomem;
851 yylvlim = yylvals + YYLVQUEUEGROWTH;
852 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
853 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
854 if (yylpsns == NULL) goto yyenomem;
855 yylplim = yylpsns + YYLVQUEUEGROWTH;
856 #endif
857 }
858 if (yylvp == yylve)
859 {
860 yylvp = yylve = yylvals;
861 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
862 yylpp = yylpe = yylpsns;
863 #endif
864 yylexp = yylexemes;
865 if (yychar >= YYEOF)
866 {
867 *yylve++ = yylval;
868 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
869 *yylpe++ = yylloc;
870 #endif
871 *yylexp = (YYINT) yychar;
872 yychar = YYEMPTY;
873 }
874 }
875 }
876 if (yychar >= YYEOF)
877 {
878 yylvp--;
879 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
880 yylpp--;
881 #endif
882 yylexp--;
883 yychar = YYEMPTY;
884 }
885 save->lexeme = (int) (yylvp - yylvals);
886 yyps->save = save;
887 }
888 if (yytable[yyn] == ctry)
889 {
890 #if YYDEBUG
891 if (yydebug)
892 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
893 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
894 #endif
895 if (yychar < 0)
896 {
897 yylvp++;
898 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
899 yylpp++;
900 #endif
901 yylexp++;
902 }
903 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
904 goto yyoverflow;
905 yystate = yyctable[ctry];
906 *++yystack.s_mark = (YYINT) yystate;
907 *++yystack.l_mark = yylval;
908 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
909 *++yystack.p_mark = yylloc;
910 #endif
911 yychar = YYEMPTY;
912 if (yyerrflag > 0) --yyerrflag;
913 goto yyloop;
914 }
915 else
916 {
917 yyn = yyctable[ctry];
918 goto yyreduce;
919 }
920 } /* End of code dealing with conflicts */
921 #endif /* YYBTYACC */
922 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
923 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
924 {
925 #if YYDEBUG
926 if (yydebug)
927 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
928 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
929 #endif
930 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
931 yystate = yytable[yyn];
932 *++yystack.s_mark = yytable[yyn];
933 *++yystack.l_mark = yylval;
934 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
935 *++yystack.p_mark = yylloc;
936 #endif
937 yychar = YYEMPTY;
938 if (yyerrflag > 0) --yyerrflag;
939 goto yyloop;
940 }
941 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
942 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
943 {
944 yyn = yytable[yyn];
945 goto yyreduce;
946 }
947 if (yyerrflag != 0) goto yyinrecovery;
948 #if YYBTYACC
949
950 yynewerrflag = 1;
951 goto yyerrhandler;
952 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
953
954 yyerrlab:
955 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
956 * before looking for error recovery */
957 yystack.s_mark -= yym;
958 yystate = *yystack.s_mark;
959 yystack.l_mark -= yym;
960 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
961 yystack.p_mark -= yym;
962 #endif
963
964 yynewerrflag = 0;
965 yyerrhandler:
966 while (yyps->save)
967 {
968 int ctry;
969 YYParseState *save = yyps->save;
970 #if YYDEBUG
971 if (yydebug)
972 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
973 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
974 (int)(yylvp - yylvals - yyps->save->lexeme));
975 #endif
976 /* Memorize most forward-looking error state in case it's really an error. */
977 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
978 {
979 /* Free old saved error context state */
980 if (yyerrctx) yyFreeState(yyerrctx);
981 /* Create and fill out new saved error context state */
982 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
983 if (yyerrctx == NULL) goto yyenomem;
984 yyerrctx->save = yyps->save;
985 yyerrctx->state = yystate;
986 yyerrctx->errflag = yyerrflag;
987 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
988 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
989 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
990 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
991 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
992 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
993 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
994 #endif
995 yyerrctx->lexeme = (int) (yylvp - yylvals);
996 }
997 yylvp = yylvals + save->lexeme;
998 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
999 yylpp = yylpsns + save->lexeme;
1000 #endif
1001 yylexp = yylexemes + save->lexeme;
1002 yychar = YYEMPTY;
1003 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1004 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1005 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1006 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1007 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1008 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1009 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1010 #endif
1011 ctry = ++save->ctry;
1012 yystate = save->state;
1013 /* We tried shift, try reduce now */
1014 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1015 yyps->save = save->save;
1016 save->save = NULL;
1017 yyFreeState(save);
1018
1019 /* Nothing left on the stack -- error */
1020 if (!yyps->save)
1021 {
1022 #if YYDEBUG
1023 if (yydebug)
1024 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1025 YYPREFIX, yydepth);
1026 #endif
1027 /* Restore state as it was in the most forward-advanced error */
1028 yylvp = yylvals + yyerrctx->lexeme;
1029 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1030 yylpp = yylpsns + yyerrctx->lexeme;
1031 #endif
1032 yylexp = yylexemes + yyerrctx->lexeme;
1033 yychar = yylexp[-1];
1034 yylval = yylvp[-1];
1035 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1036 yylloc = yylpp[-1];
1037 #endif
1038 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1039 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1040 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1041 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1042 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1043 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1044 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1045 #endif
1046 yystate = yyerrctx->state;
1047 yyFreeState(yyerrctx);
1048 yyerrctx = NULL;
1049 }
1050 yynewerrflag = 1;
1051 }
1052 if (yynewerrflag == 0) goto yyinrecovery;
1053 #endif /* YYBTYACC */
1054
1055 YYERROR_CALL("syntax error");
1056 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1057 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1058 #endif
1059
1060 #if !YYBTYACC
1061 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1062 yyerrlab:
1063 #endif
1064 ++yynerrs;
1065
1066 yyinrecovery:
1067 if (yyerrflag < 3)
1068 {
1069 yyerrflag = 3;
1070 for (;;)
1071 {
1072 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1073 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1074 {
1075 #if YYDEBUG
1076 if (yydebug)
1077 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1078 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1079 #endif
1080 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1081 yystate = yytable[yyn];
1082 *++yystack.s_mark = yytable[yyn];
1083 *++yystack.l_mark = yylval;
1084 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1085 /* lookahead position is error end position */
1086 yyerror_loc_range[1] = yylloc;
1087 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1088 *++yystack.p_mark = yyloc;
1089 #endif
1090 goto yyloop;
1091 }
1092 else
1093 {
1094 #if YYDEBUG
1095 if (yydebug)
1096 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1097 YYDEBUGSTR, yydepth, *yystack.s_mark);
1098 #endif
1099 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1100 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1101 /* the current TOS position is the error start position */
1102 yyerror_loc_range[0] = *yystack.p_mark;
1103 #endif
1104 #if defined(YYDESTRUCT_CALL)
1105 #if YYBTYACC
1106 if (!yytrial)
1107 #endif /* YYBTYACC */
1108 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1109 YYDESTRUCT_CALL("error: discarding state",
1110 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1111 #else
1112 YYDESTRUCT_CALL("error: discarding state",
1113 yystos[*yystack.s_mark], yystack.l_mark);
1114 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1115 #endif /* defined(YYDESTRUCT_CALL) */
1116 --yystack.s_mark;
1117 --yystack.l_mark;
1118 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1119 --yystack.p_mark;
1120 #endif
1121 }
1122 }
1123 }
1124 else
1125 {
1126 if (yychar == YYEOF) goto yyabort;
1127 #if YYDEBUG
1128 if (yydebug)
1129 {
1130 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1131 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1132 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1133 }
1134 #endif
1135 #if defined(YYDESTRUCT_CALL)
1136 #if YYBTYACC
1137 if (!yytrial)
1138 #endif /* YYBTYACC */
1139 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1140 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1141 #else
1142 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1143 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1144 #endif /* defined(YYDESTRUCT_CALL) */
1145 yychar = YYEMPTY;
1146 goto yyloop;
1147 }
1148
1149 yyreduce:
1150 yym = yylen[yyn];
1151 #if YYDEBUG
1152 if (yydebug)
1153 {
1154 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1155 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1156 #ifdef YYSTYPE_TOSTRING
1157 #if YYBTYACC
1158 if (!yytrial)
1159 #endif /* YYBTYACC */
1160 if (yym > 0)
1161 {
1162 int i;
1163 fputc('<', stderr);
1164 for (i = yym; i > 0; i--)
1165 {
1166 if (i != yym) fputs(", ", stderr);
1167 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1168 yystack.l_mark[1-i]), stderr);
1169 }
1170 fputc('>', stderr);
1171 }
1172 #endif
1173 fputc('\n', stderr);
1174 }
1175 #endif
1176 if (yym > 0)
1177 yyval = yystack.l_mark[1-yym];
1178 else
1179 memset(&yyval, 0, sizeof yyval);
1180 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1181
1182 /* Perform position reduction */
1183 memset(&yyloc, 0, sizeof(yyloc));
1184 #if YYBTYACC
1185 if (!yytrial)
1186 #endif /* YYBTYACC */
1187 {
1188 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1189 /* just in case YYERROR is invoked within the action, save
1190 the start of the rhs as the error start position */
1191 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1192 }
1193 #endif
1194
1195 switch (yyn)
1196 {
1197 case 3:
1198 #line 35 "quote_calc.y"
1199 { yyerrok ; }
1200 break;
1201 case 4:
1202 #line 39 "quote_calc.y"
1203 { printf("%d\n",yystack.l_mark[0]);}
1204 break;
1205 case 5:
1206 #line 41 "quote_calc.y"
1207 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1208 break;
1209 case 6:
1210 #line 45 "quote_calc.y"
1211 { yyval = yystack.l_mark[-1]; }
1212 break;
1213 case 7:
1214 #line 47 "quote_calc.y"
1215 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1216 break;
1217 case 8:
1218 #line 49 "quote_calc.y"
1219 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1220 break;
1221 case 9:
1222 #line 51 "quote_calc.y"
1223 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1224 break;
1225 case 10:
1226 #line 53 "quote_calc.y"
1227 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1228 break;
1229 case 11:
1230 #line 55 "quote_calc.y"
1231 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1232 break;
1233 case 12:
1234 #line 57 "quote_calc.y"
1235 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1236 break;
1237 case 13:
1238 #line 59 "quote_calc.y"
1239 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1240 break;
1241 case 14:
1242 #line 61 "quote_calc.y"
1243 { yyval = - yystack.l_mark[0]; }
1244 break;
1245 case 15:
1246 #line 63 "quote_calc.y"
1247 { yyval = regs[yystack.l_mark[0]]; }
1248 break;
1249 case 17:
1250 #line 68 "quote_calc.y"
1251 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
1252 break;
1253 case 18:
1254 #line 70 "quote_calc.y"
1255 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
1256 break;
1257 #line 1256 "quote_calc-s.tab.c"
1258 default:
1259 break;
1260 }
1261 yystack.s_mark -= yym;
1262 yystate = *yystack.s_mark;
1263 yystack.l_mark -= yym;
1264 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1265 yystack.p_mark -= yym;
1266 #endif
1267 yym = yylhs[yyn];
1268 if (yystate == 0 && yym == 0)
1269 {
1270 #if YYDEBUG
1271 if (yydebug)
1272 {
1273 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1274 #ifdef YYSTYPE_TOSTRING
1275 #if YYBTYACC
1276 if (!yytrial)
1277 #endif /* YYBTYACC */
1278 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1279 #endif
1280 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1281 }
1282 #endif
1283 yystate = YYFINAL;
1284 *++yystack.s_mark = YYFINAL;
1285 *++yystack.l_mark = yyval;
1286 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1287 *++yystack.p_mark = yyloc;
1288 #endif
1289 if (yychar < 0)
1290 {
1291 #if YYBTYACC
1292 do {
1293 if (yylvp < yylve)
1294 {
1295 /* we're currently re-reading tokens */
1296 yylval = *yylvp++;
1297 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1298 yylloc = *yylpp++;
1299 #endif
1300 yychar = *yylexp++;
1301 break;
1302 }
1303 if (yyps->save)
1304 {
1305 /* in trial mode; save scanner results for future parse attempts */
1306 if (yylvp == yylvlim)
1307 { /* Enlarge lexical value queue */
1308 size_t p = (size_t) (yylvp - yylvals);
1309 size_t s = (size_t) (yylvlim - yylvals);
1310
1311 s += YYLVQUEUEGROWTH;
1312 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1313 goto yyenomem;
1314 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1315 goto yyenomem;
1316 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1317 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1318 goto yyenomem;
1319 #endif
1320 yylvp = yylve = yylvals + p;
1321 yylvlim = yylvals + s;
1322 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1323 yylpp = yylpe = yylpsns + p;
1324 yylplim = yylpsns + s;
1325 #endif
1326 yylexp = yylexemes + p;
1327 }
1328 *yylexp = (YYINT) YYLEX;
1329 *yylvp++ = yylval;
1330 yylve++;
1331 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1332 *yylpp++ = yylloc;
1333 yylpe++;
1334 #endif
1335 yychar = *yylexp++;
1336 break;
1337 }
1338 /* normal operation, no conflict encountered */
1339 #endif /* YYBTYACC */
1340 yychar = YYLEX;
1341 #if YYBTYACC
1342 } while (0);
1343 #endif /* YYBTYACC */
1344 if (yychar < 0) yychar = YYEOF;
1345 #if YYDEBUG
1346 if (yydebug)
1347 {
1348 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1349 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1350 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1351 }
1352 #endif
1353 }
1354 if (yychar == YYEOF) goto yyaccept;
1355 goto yyloop;
1356 }
1357 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1358 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1359 yystate = yytable[yyn];
1360 else
1361 yystate = yydgoto[yym];
1362 #if YYDEBUG
1363 if (yydebug)
1364 {
1365 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1366 #ifdef YYSTYPE_TOSTRING
1367 #if YYBTYACC
1368 if (!yytrial)
1369 #endif /* YYBTYACC */
1370 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1371 #endif
1372 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1373 }
1374 #endif
1375 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1376 *++yystack.s_mark = (YYINT) yystate;
1377 *++yystack.l_mark = yyval;
1378 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1379 *++yystack.p_mark = yyloc;
1380 #endif
1381 goto yyloop;
1382 #if YYBTYACC
1383
1384 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1385 yyvalid:
1386 if (yypath) YYABORT;
1387 while (yyps->save)
1388 {
1389 YYParseState *save = yyps->save;
1390 yyps->save = save->save;
1391 save->save = yypath;
1392 yypath = save;
1393 }
1394 #if YYDEBUG
1395 if (yydebug)
1396 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1397 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1398 #endif
1399 if (yyerrctx)
1400 {
1401 yyFreeState(yyerrctx);
1402 yyerrctx = NULL;
1403 }
1404 yylvp = yylvals + yypath->lexeme;
1405 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1406 yylpp = yylpsns + yypath->lexeme;
1407 #endif
1408 yylexp = yylexemes + yypath->lexeme;
1409 yychar = YYEMPTY;
1410 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1411 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1412 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1413 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1414 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1415 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1416 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1417 #endif
1418 yystate = yypath->state;
1419 goto yyloop;
1420 #endif /* YYBTYACC */
1421
1422 yyoverflow:
1423 YYERROR_CALL("yacc stack overflow");
1424 #if YYBTYACC
1425 goto yyabort_nomem;
1426 yyenomem:
1427 YYERROR_CALL("memory exhausted");
1428 yyabort_nomem:
1429 #endif /* YYBTYACC */
1430 yyresult = 2;
1431 goto yyreturn;
1432
1433 yyabort:
1434 yyresult = 1;
1435 goto yyreturn;
1436
1437 yyaccept:
1438 #if YYBTYACC
1439 if (yyps->save) goto yyvalid;
1440 #endif /* YYBTYACC */
1441 yyresult = 0;
1442
1443 yyreturn:
1444 #if defined(YYDESTRUCT_CALL)
1445 if (yychar != YYEOF && yychar != YYEMPTY)
1446 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1447 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1448 #else
1449 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1450 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1451
1452 {
1453 YYSTYPE *pv;
1454 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1455 YYLTYPE *pp;
1456
1457 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1458 YYDESTRUCT_CALL("cleanup: discarding state",
1459 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1460 #else
1461 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1462 YYDESTRUCT_CALL("cleanup: discarding state",
1463 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1464 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1465 }
1466 #endif /* defined(YYDESTRUCT_CALL) */
1467
1468 #if YYBTYACC
1469 if (yyerrctx)
1470 {
1471 yyFreeState(yyerrctx);
1472 yyerrctx = NULL;
1473 }
1474 while (yyps)
1475 {
1476 YYParseState *save = yyps;
1477 yyps = save->save;
1478 save->save = NULL;
1479 yyFreeState(save);
1480 }
1481 while (yypath)
1482 {
1483 YYParseState *save = yypath;
1484 yypath = save->save;
1485 save->save = NULL;
1486 yyFreeState(save);
1487 }
1488 #endif /* YYBTYACC */
1489 yyfreestack(&yystack);
1490 return (yyresult);
1491 }
1492