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