1 | |
---|
2 | /* A Bison parser, made from ../factory-normal/readcf.y |
---|
3 | by GNU Bison version 1.25 |
---|
4 | */ |
---|
5 | |
---|
6 | #define YYBISON 1 /* Identify Bison output. */ |
---|
7 | |
---|
8 | #define NUM 258 |
---|
9 | #define NEG 259 |
---|
10 | |
---|
11 | #line 4 "../factory-normal/readcf.y" |
---|
12 | |
---|
13 | |
---|
14 | #if defined(WINNT) && ! defined(__GNUC__) |
---|
15 | #include <malloc.h> |
---|
16 | #include <memory.h> |
---|
17 | #define alloca _alloca |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <config.h> |
---|
21 | |
---|
22 | #include <ctype.h> |
---|
23 | #include <iostream.h> |
---|
24 | |
---|
25 | #include "assert.h" |
---|
26 | |
---|
27 | #include "canonicalform.h" |
---|
28 | #include "cf_defs.h" |
---|
29 | #include "gfops.h" |
---|
30 | #include "parseutil.h" |
---|
31 | #include "variable.h" |
---|
32 | |
---|
33 | #ifndef BISONPP |
---|
34 | #define YYSTYPE ParseUtil |
---|
35 | #else |
---|
36 | #define YY_parse_USE_GOTO 1 |
---|
37 | #define YY_parse_STYPE ParseUtil |
---|
38 | #endif |
---|
39 | |
---|
40 | static char* readString( istream& ); |
---|
41 | |
---|
42 | #ifndef BISONPP |
---|
43 | void yyerror( char * s ); |
---|
44 | int yylex(); |
---|
45 | #endif |
---|
46 | |
---|
47 | static istream * defaultin = 0; |
---|
48 | |
---|
49 | static CanonicalForm * retvalue = 0; |
---|
50 | |
---|
51 | #ifndef YYSTYPE |
---|
52 | #define YYSTYPE int |
---|
53 | #endif |
---|
54 | #include <stdio.h> |
---|
55 | |
---|
56 | #ifndef __cplusplus |
---|
57 | #ifndef __STDC__ |
---|
58 | #define const |
---|
59 | #endif |
---|
60 | #endif |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | #define YYFINAL 25 |
---|
65 | #define YYFLAG -32768 |
---|
66 | #define YYNTBASE 13 |
---|
67 | |
---|
68 | #define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 16) |
---|
69 | |
---|
70 | static const char yytranslate[] = { 0, |
---|
71 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
72 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
73 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
74 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, |
---|
75 | 12, 6, 5, 2, 4, 2, 7, 2, 2, 2, |
---|
76 | 2, 2, 2, 2, 2, 2, 2, 2, 10, 2, |
---|
77 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
78 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
79 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
80 | 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, |
---|
81 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
82 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
83 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
84 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
85 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
86 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
87 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
88 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
89 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
90 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
91 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
92 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
93 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
94 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
95 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
96 | 2, 2, 2, 2, 2, 1, 2, 3, 8 |
---|
97 | }; |
---|
98 | |
---|
99 | #if YYDEBUG != 0 |
---|
100 | static const short yyprhs[] = { 0, |
---|
101 | 0, 1, 4, 6, 9, 11, 15, 19, 23, 27, |
---|
102 | 30, 33, 37 |
---|
103 | }; |
---|
104 | |
---|
105 | static const short yyrhs[] = { -1, |
---|
106 | 13, 14, 0, 10, 0, 15, 10, 0, 3, 0, |
---|
107 | 15, 5, 15, 0, 15, 4, 15, 0, 15, 6, |
---|
108 | 15, 0, 15, 7, 15, 0, 4, 15, 0, 5, |
---|
109 | 15, 0, 15, 9, 3, 0, 11, 15, 12, 0 |
---|
110 | }; |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|
114 | #if YYDEBUG != 0 |
---|
115 | static const short yyrline[] = { 0, |
---|
116 | 56, 57, 60, 61, 64, 65, 66, 67, 68, 69, |
---|
117 | 70, 71, 72 |
---|
118 | }; |
---|
119 | #endif |
---|
120 | |
---|
121 | |
---|
122 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
---|
123 | |
---|
124 | static const char * const yytname[] = { "$","error","$undefined.","NUM","'-'", |
---|
125 | "'+'","'*'","'/'","NEG","'^'","';'","'('","')'","input","line","exp", NULL |
---|
126 | }; |
---|
127 | #endif |
---|
128 | |
---|
129 | static const short yyr1[] = { 0, |
---|
130 | 13, 13, 14, 14, 15, 15, 15, 15, 15, 15, |
---|
131 | 15, 15, 15 |
---|
132 | }; |
---|
133 | |
---|
134 | static const short yyr2[] = { 0, |
---|
135 | 0, 2, 1, 2, 1, 3, 3, 3, 3, 2, |
---|
136 | 2, 3, 3 |
---|
137 | }; |
---|
138 | |
---|
139 | static const short yydefact[] = { 1, |
---|
140 | 0, 5, 0, 0, 3, 0, 2, 0, 10, 11, |
---|
141 | 0, 0, 0, 0, 0, 0, 4, 13, 7, 6, |
---|
142 | 8, 9, 12, 0, 0 |
---|
143 | }; |
---|
144 | |
---|
145 | static const short yydefgoto[] = { 1, |
---|
146 | 7, 8 |
---|
147 | }; |
---|
148 | |
---|
149 | static const short yypact[] = {-32768, |
---|
150 | 13,-32768, 3, 3,-32768, 3,-32768, 30, -7, -7, |
---|
151 | 21, 3, 3, 3, 3, 1,-32768,-32768, 35, 35, |
---|
152 | -7, -7,-32768, 5,-32768 |
---|
153 | }; |
---|
154 | |
---|
155 | static const short yypgoto[] = {-32768, |
---|
156 | -32768, -3 |
---|
157 | }; |
---|
158 | |
---|
159 | |
---|
160 | #define YYLAST 44 |
---|
161 | |
---|
162 | |
---|
163 | static const short yytable[] = { 9, |
---|
164 | 10, 16, 11, 23, 25, 2, 3, 4, 19, 20, |
---|
165 | 21, 22, 24, 6, 0, 2, 3, 4, 0, 0, |
---|
166 | 0, 0, 5, 6, 12, 13, 14, 15, 0, 16, |
---|
167 | 0, 0, 18, 12, 13, 14, 15, 0, 16, 17, |
---|
168 | 14, 15, 0, 16 |
---|
169 | }; |
---|
170 | |
---|
171 | static const short yycheck[] = { 3, |
---|
172 | 4, 9, 6, 3, 0, 3, 4, 5, 12, 13, |
---|
173 | 14, 15, 0, 11, -1, 3, 4, 5, -1, -1, |
---|
174 | -1, -1, 10, 11, 4, 5, 6, 7, -1, 9, |
---|
175 | -1, -1, 12, 4, 5, 6, 7, -1, 9, 10, |
---|
176 | 6, 7, -1, 9 |
---|
177 | }; |
---|
178 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
---|
179 | #line 3 "/usr/lib/bison.simple" |
---|
180 | |
---|
181 | /* Skeleton output parser for bison, |
---|
182 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
---|
183 | |
---|
184 | This program is free software; you can redistribute it and/or modify |
---|
185 | it under the terms of the GNU General Public License as published by |
---|
186 | the Free Software Foundation; either version 2, or (at your option) |
---|
187 | any later version. |
---|
188 | |
---|
189 | This program is distributed in the hope that it will be useful, |
---|
190 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
191 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
192 | GNU General Public License for more details. |
---|
193 | |
---|
194 | You should have received a copy of the GNU General Public License |
---|
195 | along with this program; if not, write to the Free Software |
---|
196 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
---|
197 | |
---|
198 | /* As a special exception, when this file is copied by Bison into a |
---|
199 | Bison output file, you may use that output file without restriction. |
---|
200 | This special exception was added by the Free Software Foundation |
---|
201 | in version 1.24 of Bison. */ |
---|
202 | |
---|
203 | #ifndef alloca |
---|
204 | #ifdef __GNUC__ |
---|
205 | #define alloca __builtin_alloca |
---|
206 | #else /* not GNU C. */ |
---|
207 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) |
---|
208 | #include <alloca.h> |
---|
209 | #else /* not sparc */ |
---|
210 | #if defined (MSDOS) && !defined (__TURBOC__) |
---|
211 | #include <malloc.h> |
---|
212 | #else /* not MSDOS, or __TURBOC__ */ |
---|
213 | #if defined(_AIX) |
---|
214 | #include <malloc.h> |
---|
215 | #pragma alloca |
---|
216 | #else /* not MSDOS, __TURBOC__, or _AIX */ |
---|
217 | #ifdef __hpux |
---|
218 | #ifdef __cplusplus |
---|
219 | extern "C" { |
---|
220 | void *alloca (unsigned int); |
---|
221 | }; |
---|
222 | #else /* not __cplusplus */ |
---|
223 | void *alloca (); |
---|
224 | #endif /* not __cplusplus */ |
---|
225 | #endif /* __hpux */ |
---|
226 | #endif /* not _AIX */ |
---|
227 | #endif /* not MSDOS, or __TURBOC__ */ |
---|
228 | #endif /* not sparc. */ |
---|
229 | #endif /* not GNU C. */ |
---|
230 | #endif /* alloca not defined. */ |
---|
231 | |
---|
232 | /* This is the parser code that is written into each bison parser |
---|
233 | when the %semantic_parser declaration is not specified in the grammar. |
---|
234 | It was written by Richard Stallman by simplifying the hairy parser |
---|
235 | used when %semantic_parser is specified. */ |
---|
236 | |
---|
237 | /* Note: there must be only one dollar sign in this file. |
---|
238 | It is replaced by the list of actions, each action |
---|
239 | as one case of the switch. */ |
---|
240 | |
---|
241 | #define yyerrok (yyerrstatus = 0) |
---|
242 | #define yyclearin (yychar = YYEMPTY) |
---|
243 | #define YYEMPTY -2 |
---|
244 | #define YYEOF 0 |
---|
245 | #define YYACCEPT return(0) |
---|
246 | #define YYABORT return(1) |
---|
247 | #define YYERROR goto yyerrlab1 |
---|
248 | /* Like YYERROR except do call yyerror. |
---|
249 | This remains here temporarily to ease the |
---|
250 | transition to the new meaning of YYERROR, for GCC. |
---|
251 | Once GCC version 2 has supplanted version 1, this can go. */ |
---|
252 | #define YYFAIL goto yyerrlab |
---|
253 | #define YYRECOVERING() (!!yyerrstatus) |
---|
254 | #define YYBACKUP(token, value) \ |
---|
255 | do \ |
---|
256 | if (yychar == YYEMPTY && yylen == 1) \ |
---|
257 | { yychar = (token), yylval = (value); \ |
---|
258 | yychar1 = YYTRANSLATE (yychar); \ |
---|
259 | YYPOPSTACK; \ |
---|
260 | goto yybackup; \ |
---|
261 | } \ |
---|
262 | else \ |
---|
263 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
---|
264 | while (0) |
---|
265 | |
---|
266 | #define YYTERROR 1 |
---|
267 | #define YYERRCODE 256 |
---|
268 | |
---|
269 | #ifndef YYPURE |
---|
270 | #define YYLEX yylex() |
---|
271 | #endif |
---|
272 | |
---|
273 | #ifdef YYPURE |
---|
274 | #ifdef YYLSP_NEEDED |
---|
275 | #ifdef YYLEX_PARAM |
---|
276 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
---|
277 | #else |
---|
278 | #define YYLEX yylex(&yylval, &yylloc) |
---|
279 | #endif |
---|
280 | #else /* not YYLSP_NEEDED */ |
---|
281 | #ifdef YYLEX_PARAM |
---|
282 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
---|
283 | #else |
---|
284 | #define YYLEX yylex(&yylval) |
---|
285 | #endif |
---|
286 | #endif /* not YYLSP_NEEDED */ |
---|
287 | #endif |
---|
288 | |
---|
289 | /* If nonreentrant, generate the variables here */ |
---|
290 | |
---|
291 | #ifndef YYPURE |
---|
292 | |
---|
293 | int yychar; /* the lookahead symbol */ |
---|
294 | YYSTYPE yylval; /* the semantic value of the */ |
---|
295 | /* lookahead symbol */ |
---|
296 | |
---|
297 | #ifdef YYLSP_NEEDED |
---|
298 | YYLTYPE yylloc; /* location data for the lookahead */ |
---|
299 | /* symbol */ |
---|
300 | #endif |
---|
301 | |
---|
302 | int yynerrs; /* number of parse errors so far */ |
---|
303 | #endif /* not YYPURE */ |
---|
304 | |
---|
305 | #if YYDEBUG != 0 |
---|
306 | int yydebug; /* nonzero means print parse trace */ |
---|
307 | /* Since this is uninitialized, it does not stop multiple parsers |
---|
308 | from coexisting. */ |
---|
309 | #endif |
---|
310 | |
---|
311 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
---|
312 | |
---|
313 | #ifndef YYINITDEPTH |
---|
314 | #define YYINITDEPTH 200 |
---|
315 | #endif |
---|
316 | |
---|
317 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
---|
318 | (effective only if the built-in stack extension method is used). */ |
---|
319 | |
---|
320 | #if YYMAXDEPTH == 0 |
---|
321 | #undef YYMAXDEPTH |
---|
322 | #endif |
---|
323 | |
---|
324 | #ifndef YYMAXDEPTH |
---|
325 | #define YYMAXDEPTH 10000 |
---|
326 | #endif |
---|
327 | |
---|
328 | /* Prevent warning if -Wstrict-prototypes. */ |
---|
329 | #ifdef __GNUC__ |
---|
330 | int yyparse (void); |
---|
331 | #endif |
---|
332 | |
---|
333 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
---|
334 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
---|
335 | #else /* not GNU C or C++ */ |
---|
336 | #ifndef __cplusplus |
---|
337 | |
---|
338 | /* This is the most reliable way to avoid incompatibilities |
---|
339 | in available built-in functions on various systems. */ |
---|
340 | static void |
---|
341 | __yy_memcpy (to, from, count) |
---|
342 | char *to; |
---|
343 | char *from; |
---|
344 | int count; |
---|
345 | { |
---|
346 | register char *f = from; |
---|
347 | register char *t = to; |
---|
348 | register int i = count; |
---|
349 | |
---|
350 | while (i-- > 0) |
---|
351 | *t++ = *f++; |
---|
352 | } |
---|
353 | |
---|
354 | #else /* __cplusplus */ |
---|
355 | |
---|
356 | /* This is the most reliable way to avoid incompatibilities |
---|
357 | in available built-in functions on various systems. */ |
---|
358 | static void |
---|
359 | __yy_memcpy (char *to, char *from, int count) |
---|
360 | { |
---|
361 | register char *f = from; |
---|
362 | register char *t = to; |
---|
363 | register int i = count; |
---|
364 | |
---|
365 | while (i-- > 0) |
---|
366 | *t++ = *f++; |
---|
367 | } |
---|
368 | |
---|
369 | #endif |
---|
370 | #endif |
---|
371 | |
---|
372 | #line 196 "/usr/lib/bison.simple" |
---|
373 | |
---|
374 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
---|
375 | into yyparse. The argument should have type void *. |
---|
376 | It should actually point to an object. |
---|
377 | Grammar actions can access the variable by casting it |
---|
378 | to the proper pointer type. */ |
---|
379 | |
---|
380 | #ifdef YYPARSE_PARAM |
---|
381 | #ifdef __cplusplus |
---|
382 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
---|
383 | #define YYPARSE_PARAM_DECL |
---|
384 | #else /* not __cplusplus */ |
---|
385 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
---|
386 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
---|
387 | #endif /* not __cplusplus */ |
---|
388 | #else /* not YYPARSE_PARAM */ |
---|
389 | #define YYPARSE_PARAM_ARG |
---|
390 | #define YYPARSE_PARAM_DECL |
---|
391 | #endif /* not YYPARSE_PARAM */ |
---|
392 | |
---|
393 | int |
---|
394 | yyparse(YYPARSE_PARAM_ARG) |
---|
395 | YYPARSE_PARAM_DECL |
---|
396 | { |
---|
397 | register int yystate; |
---|
398 | register int yyn; |
---|
399 | register short *yyssp; |
---|
400 | register YYSTYPE *yyvsp; |
---|
401 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
---|
402 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
---|
403 | |
---|
404 | short yyssa[YYINITDEPTH]; /* the state stack */ |
---|
405 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
---|
406 | |
---|
407 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
---|
408 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
---|
409 | |
---|
410 | #ifdef YYLSP_NEEDED |
---|
411 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
---|
412 | YYLTYPE *yyls = yylsa; |
---|
413 | YYLTYPE *yylsp; |
---|
414 | |
---|
415 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
---|
416 | #else |
---|
417 | #define YYPOPSTACK (yyvsp--, yyssp--) |
---|
418 | #endif |
---|
419 | |
---|
420 | int yystacksize = YYINITDEPTH; |
---|
421 | |
---|
422 | #ifdef YYPURE |
---|
423 | int yychar; |
---|
424 | YYSTYPE yylval; |
---|
425 | int yynerrs; |
---|
426 | #ifdef YYLSP_NEEDED |
---|
427 | YYLTYPE yylloc; |
---|
428 | #endif |
---|
429 | #endif |
---|
430 | |
---|
431 | YYSTYPE yyval; /* the variable used to return */ |
---|
432 | /* semantic values from the action */ |
---|
433 | /* routines */ |
---|
434 | |
---|
435 | int yylen; |
---|
436 | |
---|
437 | #if YYDEBUG != 0 |
---|
438 | if (yydebug) |
---|
439 | fprintf(stderr, "Starting parse\n"); |
---|
440 | #endif |
---|
441 | |
---|
442 | yystate = 0; |
---|
443 | yyerrstatus = 0; |
---|
444 | yynerrs = 0; |
---|
445 | yychar = YYEMPTY; /* Cause a token to be read. */ |
---|
446 | |
---|
447 | /* Initialize stack pointers. |
---|
448 | Waste one element of value and location stack |
---|
449 | so that they stay on the same level as the state stack. |
---|
450 | The wasted elements are never initialized. */ |
---|
451 | |
---|
452 | yyssp = yyss - 1; |
---|
453 | yyvsp = yyvs; |
---|
454 | #ifdef YYLSP_NEEDED |
---|
455 | yylsp = yyls; |
---|
456 | #endif |
---|
457 | |
---|
458 | /* Push a new state, which is found in yystate . */ |
---|
459 | /* In all cases, when you get here, the value and location stacks |
---|
460 | have just been pushed. so pushing a state here evens the stacks. */ |
---|
461 | yynewstate: |
---|
462 | |
---|
463 | *++yyssp = yystate; |
---|
464 | |
---|
465 | if (yyssp >= yyss + yystacksize - 1) |
---|
466 | { |
---|
467 | /* Give user a chance to reallocate the stack */ |
---|
468 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
---|
469 | YYSTYPE *yyvs1 = yyvs; |
---|
470 | short *yyss1 = yyss; |
---|
471 | #ifdef YYLSP_NEEDED |
---|
472 | YYLTYPE *yyls1 = yyls; |
---|
473 | #endif |
---|
474 | |
---|
475 | /* Get the current used size of the three stacks, in elements. */ |
---|
476 | int size = yyssp - yyss + 1; |
---|
477 | |
---|
478 | #ifdef yyoverflow |
---|
479 | /* Each stack pointer address is followed by the size of |
---|
480 | the data in use in that stack, in bytes. */ |
---|
481 | #ifdef YYLSP_NEEDED |
---|
482 | /* This used to be a conditional around just the two extra args, |
---|
483 | but that might be undefined if yyoverflow is a macro. */ |
---|
484 | yyoverflow("parser stack overflow", |
---|
485 | &yyss1, size * sizeof (*yyssp), |
---|
486 | &yyvs1, size * sizeof (*yyvsp), |
---|
487 | &yyls1, size * sizeof (*yylsp), |
---|
488 | &yystacksize); |
---|
489 | #else |
---|
490 | yyoverflow("parser stack overflow", |
---|
491 | &yyss1, size * sizeof (*yyssp), |
---|
492 | &yyvs1, size * sizeof (*yyvsp), |
---|
493 | &yystacksize); |
---|
494 | #endif |
---|
495 | |
---|
496 | yyss = yyss1; yyvs = yyvs1; |
---|
497 | #ifdef YYLSP_NEEDED |
---|
498 | yyls = yyls1; |
---|
499 | #endif |
---|
500 | #else /* no yyoverflow */ |
---|
501 | /* Extend the stack our own way. */ |
---|
502 | if (yystacksize >= YYMAXDEPTH) |
---|
503 | { |
---|
504 | yyerror("parser stack overflow"); |
---|
505 | return 2; |
---|
506 | } |
---|
507 | yystacksize *= 2; |
---|
508 | if (yystacksize > YYMAXDEPTH) |
---|
509 | yystacksize = YYMAXDEPTH; |
---|
510 | yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); |
---|
511 | __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); |
---|
512 | yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); |
---|
513 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); |
---|
514 | #ifdef YYLSP_NEEDED |
---|
515 | yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); |
---|
516 | __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); |
---|
517 | #endif |
---|
518 | #endif /* no yyoverflow */ |
---|
519 | |
---|
520 | yyssp = yyss + size - 1; |
---|
521 | yyvsp = yyvs + size - 1; |
---|
522 | #ifdef YYLSP_NEEDED |
---|
523 | yylsp = yyls + size - 1; |
---|
524 | #endif |
---|
525 | |
---|
526 | #if YYDEBUG != 0 |
---|
527 | if (yydebug) |
---|
528 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
---|
529 | #endif |
---|
530 | |
---|
531 | if (yyssp >= yyss + yystacksize - 1) |
---|
532 | YYABORT; |
---|
533 | } |
---|
534 | |
---|
535 | #if YYDEBUG != 0 |
---|
536 | if (yydebug) |
---|
537 | fprintf(stderr, "Entering state %d\n", yystate); |
---|
538 | #endif |
---|
539 | |
---|
540 | goto yybackup; |
---|
541 | yybackup: |
---|
542 | |
---|
543 | /* Do appropriate processing given the current state. */ |
---|
544 | /* Read a lookahead token if we need one and don't already have one. */ |
---|
545 | /* yyresume: */ |
---|
546 | |
---|
547 | /* First try to decide what to do without reference to lookahead token. */ |
---|
548 | |
---|
549 | yyn = yypact[yystate]; |
---|
550 | if (yyn == YYFLAG) |
---|
551 | goto yydefault; |
---|
552 | |
---|
553 | /* Not known => get a lookahead token if don't already have one. */ |
---|
554 | |
---|
555 | /* yychar is either YYEMPTY or YYEOF |
---|
556 | or a valid token in external form. */ |
---|
557 | |
---|
558 | if (yychar == YYEMPTY) |
---|
559 | { |
---|
560 | #if YYDEBUG != 0 |
---|
561 | if (yydebug) |
---|
562 | fprintf(stderr, "Reading a token: "); |
---|
563 | #endif |
---|
564 | yychar = YYLEX; |
---|
565 | } |
---|
566 | |
---|
567 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
---|
568 | |
---|
569 | if (yychar <= 0) /* This means end of input. */ |
---|
570 | { |
---|
571 | yychar1 = 0; |
---|
572 | yychar = YYEOF; /* Don't call YYLEX any more */ |
---|
573 | |
---|
574 | #if YYDEBUG != 0 |
---|
575 | if (yydebug) |
---|
576 | fprintf(stderr, "Now at end of input.\n"); |
---|
577 | #endif |
---|
578 | } |
---|
579 | else |
---|
580 | { |
---|
581 | yychar1 = YYTRANSLATE(yychar); |
---|
582 | |
---|
583 | #if YYDEBUG != 0 |
---|
584 | if (yydebug) |
---|
585 | { |
---|
586 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
---|
587 | /* Give the individual parser a way to print the precise meaning |
---|
588 | of a token, for further debugging info. */ |
---|
589 | #ifdef YYPRINT |
---|
590 | YYPRINT (stderr, yychar, yylval); |
---|
591 | #endif |
---|
592 | fprintf (stderr, ")\n"); |
---|
593 | } |
---|
594 | #endif |
---|
595 | } |
---|
596 | |
---|
597 | yyn += yychar1; |
---|
598 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
---|
599 | goto yydefault; |
---|
600 | |
---|
601 | yyn = yytable[yyn]; |
---|
602 | |
---|
603 | /* yyn is what to do for this token type in this state. |
---|
604 | Negative => reduce, -yyn is rule number. |
---|
605 | Positive => shift, yyn is new state. |
---|
606 | New state is final state => don't bother to shift, |
---|
607 | just return success. |
---|
608 | 0, or most negative number => error. */ |
---|
609 | |
---|
610 | if (yyn < 0) |
---|
611 | { |
---|
612 | if (yyn == YYFLAG) |
---|
613 | goto yyerrlab; |
---|
614 | yyn = -yyn; |
---|
615 | goto yyreduce; |
---|
616 | } |
---|
617 | else if (yyn == 0) |
---|
618 | goto yyerrlab; |
---|
619 | |
---|
620 | if (yyn == YYFINAL) |
---|
621 | YYACCEPT; |
---|
622 | |
---|
623 | /* Shift the lookahead token. */ |
---|
624 | |
---|
625 | #if YYDEBUG != 0 |
---|
626 | if (yydebug) |
---|
627 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
---|
628 | #endif |
---|
629 | |
---|
630 | /* Discard the token being shifted unless it is eof. */ |
---|
631 | if (yychar != YYEOF) |
---|
632 | yychar = YYEMPTY; |
---|
633 | |
---|
634 | *++yyvsp = yylval; |
---|
635 | #ifdef YYLSP_NEEDED |
---|
636 | *++yylsp = yylloc; |
---|
637 | #endif |
---|
638 | |
---|
639 | /* count tokens shifted since error; after three, turn off error status. */ |
---|
640 | if (yyerrstatus) yyerrstatus--; |
---|
641 | |
---|
642 | yystate = yyn; |
---|
643 | goto yynewstate; |
---|
644 | |
---|
645 | /* Do the default action for the current state. */ |
---|
646 | yydefault: |
---|
647 | |
---|
648 | yyn = yydefact[yystate]; |
---|
649 | if (yyn == 0) |
---|
650 | goto yyerrlab; |
---|
651 | |
---|
652 | /* Do a reduction. yyn is the number of a rule to reduce with. */ |
---|
653 | yyreduce: |
---|
654 | yylen = yyr2[yyn]; |
---|
655 | if (yylen > 0) |
---|
656 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
---|
657 | |
---|
658 | #if YYDEBUG != 0 |
---|
659 | if (yydebug) |
---|
660 | { |
---|
661 | int i; |
---|
662 | |
---|
663 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
---|
664 | yyn, yyrline[yyn]); |
---|
665 | |
---|
666 | /* Print the symbols being reduced, and their result. */ |
---|
667 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
---|
668 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
---|
669 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
---|
670 | } |
---|
671 | #endif |
---|
672 | |
---|
673 | |
---|
674 | switch (yyn) { |
---|
675 | |
---|
676 | case 4: |
---|
677 | #line 61 "../factory-normal/readcf.y" |
---|
678 | { *retvalue = yyvsp[-1].getval(); return 0; ; |
---|
679 | break;} |
---|
680 | case 5: |
---|
681 | #line 64 "../factory-normal/readcf.y" |
---|
682 | { yyval = yyvsp[0]; ; |
---|
683 | break;} |
---|
684 | case 6: |
---|
685 | #line 65 "../factory-normal/readcf.y" |
---|
686 | { yyval = yyvsp[-2].getval() + yyvsp[0].getval(); ; |
---|
687 | break;} |
---|
688 | case 7: |
---|
689 | #line 66 "../factory-normal/readcf.y" |
---|
690 | { yyval = yyvsp[-2].getval() - yyvsp[0].getval(); ; |
---|
691 | break;} |
---|
692 | case 8: |
---|
693 | #line 67 "../factory-normal/readcf.y" |
---|
694 | { yyval = yyvsp[-2].getval() * yyvsp[0].getval(); ; |
---|
695 | break;} |
---|
696 | case 9: |
---|
697 | #line 68 "../factory-normal/readcf.y" |
---|
698 | { yyval = yyvsp[-2].getval() / yyvsp[0].getval(); ; |
---|
699 | break;} |
---|
700 | case 10: |
---|
701 | #line 69 "../factory-normal/readcf.y" |
---|
702 | { yyval = -yyvsp[0].getval(); ; |
---|
703 | break;} |
---|
704 | case 11: |
---|
705 | #line 70 "../factory-normal/readcf.y" |
---|
706 | { yyval = yyvsp[0].getval(); ; |
---|
707 | break;} |
---|
708 | case 12: |
---|
709 | #line 71 "../factory-normal/readcf.y" |
---|
710 | { yyval = power( yyvsp[-2].getval(), yyvsp[0].getintval() ); ; |
---|
711 | break;} |
---|
712 | case 13: |
---|
713 | #line 72 "../factory-normal/readcf.y" |
---|
714 | { yyval = yyvsp[-1].getval(); ; |
---|
715 | break;} |
---|
716 | } |
---|
717 | /* the action file gets copied in in place of this dollarsign */ |
---|
718 | #line 498 "/usr/lib/bison.simple" |
---|
719 | |
---|
720 | yyvsp -= yylen; |
---|
721 | yyssp -= yylen; |
---|
722 | #ifdef YYLSP_NEEDED |
---|
723 | yylsp -= yylen; |
---|
724 | #endif |
---|
725 | |
---|
726 | #if YYDEBUG != 0 |
---|
727 | if (yydebug) |
---|
728 | { |
---|
729 | short *ssp1 = yyss - 1; |
---|
730 | fprintf (stderr, "state stack now"); |
---|
731 | while (ssp1 != yyssp) |
---|
732 | fprintf (stderr, " %d", *++ssp1); |
---|
733 | fprintf (stderr, "\n"); |
---|
734 | } |
---|
735 | #endif |
---|
736 | |
---|
737 | *++yyvsp = yyval; |
---|
738 | |
---|
739 | #ifdef YYLSP_NEEDED |
---|
740 | yylsp++; |
---|
741 | if (yylen == 0) |
---|
742 | { |
---|
743 | yylsp->first_line = yylloc.first_line; |
---|
744 | yylsp->first_column = yylloc.first_column; |
---|
745 | yylsp->last_line = (yylsp-1)->last_line; |
---|
746 | yylsp->last_column = (yylsp-1)->last_column; |
---|
747 | yylsp->text = 0; |
---|
748 | } |
---|
749 | else |
---|
750 | { |
---|
751 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
---|
752 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
---|
753 | } |
---|
754 | #endif |
---|
755 | |
---|
756 | /* Now "shift" the result of the reduction. |
---|
757 | Determine what state that goes to, |
---|
758 | based on the state we popped back to |
---|
759 | and the rule number reduced by. */ |
---|
760 | |
---|
761 | yyn = yyr1[yyn]; |
---|
762 | |
---|
763 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
---|
764 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
---|
765 | yystate = yytable[yystate]; |
---|
766 | else |
---|
767 | yystate = yydefgoto[yyn - YYNTBASE]; |
---|
768 | |
---|
769 | goto yynewstate; |
---|
770 | |
---|
771 | yyerrlab: /* here on detecting error */ |
---|
772 | |
---|
773 | if (! yyerrstatus) |
---|
774 | /* If not already recovering from an error, report this error. */ |
---|
775 | { |
---|
776 | ++yynerrs; |
---|
777 | |
---|
778 | #ifdef YYERROR_VERBOSE |
---|
779 | yyn = yypact[yystate]; |
---|
780 | |
---|
781 | if (yyn > YYFLAG && yyn < YYLAST) |
---|
782 | { |
---|
783 | int size = 0; |
---|
784 | char *msg; |
---|
785 | int x, count; |
---|
786 | |
---|
787 | count = 0; |
---|
788 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
---|
789 | for (x = (yyn < 0 ? -yyn : 0); |
---|
790 | x < (sizeof(yytname) / sizeof(char *)); x++) |
---|
791 | if (yycheck[x + yyn] == x) |
---|
792 | size += strlen(yytname[x]) + 15, count++; |
---|
793 | msg = (char *) malloc(size + 15); |
---|
794 | if (msg != 0) |
---|
795 | { |
---|
796 | strcpy(msg, "parse error"); |
---|
797 | |
---|
798 | if (count < 5) |
---|
799 | { |
---|
800 | count = 0; |
---|
801 | for (x = (yyn < 0 ? -yyn : 0); |
---|
802 | x < (sizeof(yytname) / sizeof(char *)); x++) |
---|
803 | if (yycheck[x + yyn] == x) |
---|
804 | { |
---|
805 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
---|
806 | strcat(msg, yytname[x]); |
---|
807 | strcat(msg, "'"); |
---|
808 | count++; |
---|
809 | } |
---|
810 | } |
---|
811 | yyerror(msg); |
---|
812 | free(msg); |
---|
813 | } |
---|
814 | else |
---|
815 | yyerror ("parse error; also virtual memory exceeded"); |
---|
816 | } |
---|
817 | else |
---|
818 | #endif /* YYERROR_VERBOSE */ |
---|
819 | yyerror("parse error"); |
---|
820 | } |
---|
821 | |
---|
822 | goto yyerrlab1; |
---|
823 | yyerrlab1: /* here on error raised explicitly by an action */ |
---|
824 | |
---|
825 | if (yyerrstatus == 3) |
---|
826 | { |
---|
827 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
---|
828 | |
---|
829 | /* return failure if at end of input */ |
---|
830 | if (yychar == YYEOF) |
---|
831 | YYABORT; |
---|
832 | |
---|
833 | #if YYDEBUG != 0 |
---|
834 | if (yydebug) |
---|
835 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
---|
836 | #endif |
---|
837 | |
---|
838 | yychar = YYEMPTY; |
---|
839 | } |
---|
840 | |
---|
841 | /* Else will try to reuse lookahead token |
---|
842 | after shifting the error token. */ |
---|
843 | |
---|
844 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
---|
845 | |
---|
846 | goto yyerrhandle; |
---|
847 | |
---|
848 | yyerrdefault: /* current state does not do anything special for the error token. */ |
---|
849 | |
---|
850 | #if 0 |
---|
851 | /* This is wrong; only states that explicitly want error tokens |
---|
852 | should shift them. */ |
---|
853 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
---|
854 | if (yyn) goto yydefault; |
---|
855 | #endif |
---|
856 | |
---|
857 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
---|
858 | |
---|
859 | if (yyssp == yyss) YYABORT; |
---|
860 | yyvsp--; |
---|
861 | yystate = *--yyssp; |
---|
862 | #ifdef YYLSP_NEEDED |
---|
863 | yylsp--; |
---|
864 | #endif |
---|
865 | |
---|
866 | #if YYDEBUG != 0 |
---|
867 | if (yydebug) |
---|
868 | { |
---|
869 | short *ssp1 = yyss - 1; |
---|
870 | fprintf (stderr, "Error: state stack now"); |
---|
871 | while (ssp1 != yyssp) |
---|
872 | fprintf (stderr, " %d", *++ssp1); |
---|
873 | fprintf (stderr, "\n"); |
---|
874 | } |
---|
875 | #endif |
---|
876 | |
---|
877 | yyerrhandle: |
---|
878 | |
---|
879 | yyn = yypact[yystate]; |
---|
880 | if (yyn == YYFLAG) |
---|
881 | goto yyerrdefault; |
---|
882 | |
---|
883 | yyn += YYTERROR; |
---|
884 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
---|
885 | goto yyerrdefault; |
---|
886 | |
---|
887 | yyn = yytable[yyn]; |
---|
888 | if (yyn < 0) |
---|
889 | { |
---|
890 | if (yyn == YYFLAG) |
---|
891 | goto yyerrpop; |
---|
892 | yyn = -yyn; |
---|
893 | goto yyreduce; |
---|
894 | } |
---|
895 | else if (yyn == 0) |
---|
896 | goto yyerrpop; |
---|
897 | |
---|
898 | if (yyn == YYFINAL) |
---|
899 | YYACCEPT; |
---|
900 | |
---|
901 | #if YYDEBUG != 0 |
---|
902 | if (yydebug) |
---|
903 | fprintf(stderr, "Shifting error token, "); |
---|
904 | #endif |
---|
905 | |
---|
906 | *++yyvsp = yylval; |
---|
907 | #ifdef YYLSP_NEEDED |
---|
908 | *++yylsp = yylloc; |
---|
909 | #endif |
---|
910 | |
---|
911 | yystate = yyn; |
---|
912 | goto yynewstate; |
---|
913 | } |
---|
914 | #line 75 "../factory-normal/readcf.y" |
---|
915 | |
---|
916 | |
---|
917 | #ifdef BISONPP |
---|
918 | void YY_parse_CLASS::yyerror( char * s ) |
---|
919 | #else |
---|
920 | void yyerror( char * s ) |
---|
921 | #endif |
---|
922 | { |
---|
923 | cerr << s << endl; |
---|
924 | } |
---|
925 | |
---|
926 | #ifdef BISONPP |
---|
927 | int YY_parse_CLASS::yylex() |
---|
928 | #else |
---|
929 | int yylex() |
---|
930 | #endif |
---|
931 | { |
---|
932 | int c; |
---|
933 | |
---|
934 | while ((c = defaultin->get()) == ' ' || c == '\t' || c == '\n' ) ; |
---|
935 | if ( isdigit( c ) ) { |
---|
936 | defaultin->putback( c ); |
---|
937 | yylval = ParseUtil( readString( *defaultin ) ); |
---|
938 | return NUM; |
---|
939 | } |
---|
940 | else if ( isalpha( c ) ) { |
---|
941 | // look for generators of GF(q) |
---|
942 | if ( getCharacteristic() > 0 && getGFDegree() > 1 && c == gf_name ) { |
---|
943 | #ifdef BISONPP |
---|
944 | this->yylval = getGFGenerator(); |
---|
945 | #else |
---|
946 | yylval = getGFGenerator(); |
---|
947 | #endif |
---|
948 | } |
---|
949 | else if ( c == getDefaultVarName() ) { |
---|
950 | int cc; |
---|
951 | cc = defaultin->get(); |
---|
952 | if ( cc == '_' ) { |
---|
953 | ParseUtil index( readString( *defaultin ) ); |
---|
954 | #ifdef BISONPP |
---|
955 | this->yylval = Variable( index.getintval() ); |
---|
956 | #else |
---|
957 | yylval = Variable( index.getintval() ); |
---|
958 | #endif |
---|
959 | } |
---|
960 | else { |
---|
961 | defaultin->putback( cc ); |
---|
962 | #ifdef BISONPP |
---|
963 | this->yylval = Variable( (char)c ); |
---|
964 | #else |
---|
965 | yylval = Variable( (char)c ); |
---|
966 | #endif |
---|
967 | } |
---|
968 | } |
---|
969 | else { |
---|
970 | #ifdef BISONPP |
---|
971 | this->yylval = Variable( (char)c ); |
---|
972 | #else |
---|
973 | yylval = Variable( (char)c ); |
---|
974 | #endif |
---|
975 | } |
---|
976 | return NUM; |
---|
977 | } |
---|
978 | return c; |
---|
979 | } |
---|
980 | |
---|
981 | CanonicalForm readCF( istream& str ) |
---|
982 | { |
---|
983 | CanonicalForm theRetvalue; |
---|
984 | retvalue = new CanonicalForm(); |
---|
985 | #ifdef BISONPP |
---|
986 | YY_parse_CLASS my_parser; |
---|
987 | defaultin = &str; |
---|
988 | if ( my_parser.yyparse() == 0 ) { |
---|
989 | theRetvalue = *retvalue; |
---|
990 | delete retvalue; |
---|
991 | return theRetvalue; |
---|
992 | } |
---|
993 | else { |
---|
994 | delete retvalue; |
---|
995 | return 0; |
---|
996 | } |
---|
997 | #else |
---|
998 | defaultin = &str; |
---|
999 | if ( yyparse() == 0 ) { |
---|
1000 | theRetvalue = *retvalue; |
---|
1001 | delete retvalue; |
---|
1002 | return theRetvalue; |
---|
1003 | } |
---|
1004 | else { |
---|
1005 | delete retvalue; |
---|
1006 | return 0; |
---|
1007 | } |
---|
1008 | #endif |
---|
1009 | } |
---|
1010 | |
---|
1011 | char* readString( istream& s ) |
---|
1012 | { |
---|
1013 | static char * buffer = 0; |
---|
1014 | static int bufsize = 0; |
---|
1015 | |
---|
1016 | if ( buffer == 0 ) { |
---|
1017 | bufsize = 10000; |
---|
1018 | buffer = new char[bufsize]; |
---|
1019 | } |
---|
1020 | int i = 0, c, goon = 1; |
---|
1021 | while ( goon ) { |
---|
1022 | while ( isdigit( c = s.get() ) && i < bufsize - 2 ) { |
---|
1023 | buffer[i] = c; |
---|
1024 | i++; |
---|
1025 | } |
---|
1026 | if ( isdigit( c ) ) { |
---|
1027 | bufsize += 1000; |
---|
1028 | char * newbuffer = (char*)memcpy( new char[bufsize], buffer, bufsize - 1000 ); |
---|
1029 | delete [] buffer; |
---|
1030 | buffer = newbuffer; |
---|
1031 | buffer[i] = c; |
---|
1032 | i++; |
---|
1033 | } |
---|
1034 | else { |
---|
1035 | goon = 0; |
---|
1036 | buffer[i] = '\0'; |
---|
1037 | s.putback( c ); |
---|
1038 | } |
---|
1039 | } |
---|
1040 | return buffer; |
---|
1041 | } |
---|