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