My Project
readcf.cc
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.8.2. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6  Inc.
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 
21 /* As a special exception, you may create a larger work that contains
22  part or all of the Bison parser skeleton and distribute that work
23  under terms of your choice, so long as that work isn't itself a
24  parser generator using the skeleton or a modified version thereof
25  as a parser skeleton. Alternatively, if you modify or redistribute
26  the parser skeleton itself, you may (at your option) remove this
27  special exception, which will cause the skeleton and the resulting
28  Bison output files to be licensed under the GNU General Public
29  License without this special exception.
30 
31  This special exception was added by the Free Software Foundation in
32  version 2.2 of Bison. */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35  simplifying the original so-called "semantic" parser. */
36 
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38  especially those whose name start with YY_ or yy_. They are
39  private implementation details that can be changed or removed. */
40 
41 /* All symbols defined below should begin with yy or YY, to avoid
42  infringing on user name space. This should be done even for local
43  variables, as they might otherwise be expanded by user macros.
44  There are some unavoidable exceptions within include files to
45  define necessary library symbols; they are noted "INFRINGES ON
46  USER NAME SPACE" below. */
47 
48 /* Identify Bison output, and Bison version. */
49 #define YYBISON 30802
50 
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.8.2"
53 
54 /* Skeleton name. */
55 #define YYSKELETON_NAME "yacc.c"
56 
57 /* Pure parsers. */
58 #define YYPURE 0
59 
60 /* Push parsers. */
61 #define YYPUSH 0
62 
63 /* Pull parsers. */
64 #define YYPULL 1
65 
66 
67 
68 
69 /* First part of user prologue. */
70 #line 3 "readcf.yy"
71 
72 
73 
74 #include "config.h"
75 
76 #include "factory/factoryconf.h"
77 
78 #if defined(WINNT) && ! defined(__GNUC__)
79 # include <malloc.h>
80 # include <memory.h>
81 # define alloca _alloca
82 #endif
83 
84 #include <cstring> // we need this for gcc 4.3
85 
86 #include <config.h>
87 
88 
89 #include <ctype.h>
90 
91 #ifdef HAVE_IOSTREAM
92 # include <iostream>
93 # define ISTREAM std::istream
94 # define CERR std::cerr
95 #elif defined(HAVE_IOSTREAM_H)
96 # include <iostream.h>
97 # define ISTREAM istream
98 # define CERR cerr
99 #endif
100 
101 
102 #include "cf_assert.h"
103 
104 #include "canonicalform.h"
105 #include "cf_defs.h"
106 #include "gfops.h"
107 #include "parseutil.h"
108 #include "variable.h"
109 
110 #ifndef BISONPP
111 # define YYSTYPE ParseUtil
112 #else
113 # define YY_parse_USE_GOTO 1
114 # define YY_parse_STYPE ParseUtil
115 #endif
116 
117 static char* readString( ISTREAM& );
118 
119 #ifndef BISONPP
120 void yyerror( char * s );
121 int yylex();
122 #endif
123 
124 static ISTREAM * defaultin = 0;
125 
126 static CanonicalForm * retvalue = 0;
127 
128 
129 #line 130 "readcf.cc"
130 
131 # ifndef YY_CAST
132 # ifdef __cplusplus
133 # define YY_CAST(Type, Val) static_cast<Type> (Val)
134 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
135 # else
136 # define YY_CAST(Type, Val) ((Type) (Val))
137 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
138 # endif
139 # endif
140 # ifndef YY_NULLPTR
141 # if defined __cplusplus
142 # if 201103L <= __cplusplus
143 # define YY_NULLPTR nullptr
144 # else
145 # define YY_NULLPTR 0
146 # endif
147 # else
148 # define YY_NULLPTR ((void*)0)
149 # endif
150 # endif
151 
152 
153 /* Debug traces. */
154 #ifndef YYDEBUG
155 # define YYDEBUG 0
156 #endif
157 #if YYDEBUG
158 extern int yydebug;
159 #endif
160 
161 /* Token kinds. */
162 #ifndef YYTOKENTYPE
163 # define YYTOKENTYPE
165  {
166  YYEMPTY = -2,
167  YYEOF = 0, /* "end of file" */
168  YYerror = 256, /* error */
169  YYUNDEF = 257, /* "invalid token" */
170  NUM = 258, /* NUM */
171  NEG = 259 /* NEG */
172  };
173  typedef enum yytokentype yytoken_kind_t;
174 #endif
175 /* Token kinds. */
176 #define YYEMPTY -2
177 #define YYEOF 0
178 #define YYerror 256
179 #define YYUNDEF 257
180 #define NUM 258
181 #define NEG 259
182 
183 /* Value type. */
184 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
185 typedef int YYSTYPE;
186 # define YYSTYPE_IS_TRIVIAL 1
187 # define YYSTYPE_IS_DECLARED 1
188 #endif
189 
190 
191 extern YYSTYPE yylval;
192 
193 
194 int yyparse (void);
195 
196 
197 
198 /* Symbol kind. */
200 {
202  YYSYMBOL_YYEOF = 0, /* "end of file" */
203  YYSYMBOL_YYerror = 1, /* error */
204  YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
205  YYSYMBOL_NUM = 3, /* NUM */
206  YYSYMBOL_4_ = 4, /* '-' */
207  YYSYMBOL_5_ = 5, /* '+' */
208  YYSYMBOL_6_ = 6, /* '*' */
209  YYSYMBOL_7_ = 7, /* '/' */
210  YYSYMBOL_NEG = 8, /* NEG */
211  YYSYMBOL_9_ = 9, /* '^' */
212  YYSYMBOL_10_ = 10, /* ';' */
213  YYSYMBOL_11_ = 11, /* '(' */
214  YYSYMBOL_12_ = 12, /* ')' */
215  YYSYMBOL_YYACCEPT = 13, /* $accept */
216  YYSYMBOL_input = 14, /* input */
217  YYSYMBOL_line = 15, /* line */
218  YYSYMBOL_exp = 16 /* exp */
219 };
220 typedef enum yysymbol_kind_t yysymbol_kind_t;
221 
222 
223 
224 
225 #ifdef short
226 # undef short
227 #endif
228 
229 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
230  <limits.h> and (if available) <stdint.h> are included
231  so that the code can choose integer types of a good width. */
232 
233 #ifndef __PTRDIFF_MAX__
234 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
235 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
236 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
237 # define YY_STDINT_H
238 # endif
239 #endif
240 
241 /* Narrow types that promote to a signed type and that can represent a
242  signed or unsigned integer of at least N bits. In tables they can
243  save space and decrease cache pressure. Promoting to a signed type
244  helps avoid bugs in integer arithmetic. */
245 
246 #ifdef __INT_LEAST8_MAX__
247 typedef __INT_LEAST8_TYPE__ yytype_int8;
248 #elif defined YY_STDINT_H
249 typedef int_least8_t yytype_int8;
250 #else
251 typedef signed char yytype_int8;
252 #endif
253 
254 #ifdef __INT_LEAST16_MAX__
255 typedef __INT_LEAST16_TYPE__ yytype_int16;
256 #elif defined YY_STDINT_H
257 typedef int_least16_t yytype_int16;
258 #else
259 typedef short yytype_int16;
260 #endif
261 
262 /* Work around bug in HP-UX 11.23, which defines these macros
263  incorrectly for preprocessor constants. This workaround can likely
264  be removed in 2023, as HPE has promised support for HP-UX 11.23
265  (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
266  <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
267 #ifdef __hpux
268 # undef UINT_LEAST8_MAX
269 # undef UINT_LEAST16_MAX
270 # define UINT_LEAST8_MAX 255
271 # define UINT_LEAST16_MAX 65535
272 #endif
273 
274 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
275 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
276 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
277  && UINT_LEAST8_MAX <= INT_MAX)
278 typedef uint_least8_t yytype_uint8;
279 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
280 typedef unsigned char yytype_uint8;
281 #else
282 typedef short yytype_uint8;
283 #endif
284 
285 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
286 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
287 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
288  && UINT_LEAST16_MAX <= INT_MAX)
289 typedef uint_least16_t yytype_uint16;
290 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
291 typedef unsigned short yytype_uint16;
292 #else
293 typedef int yytype_uint16;
294 #endif
295 
296 #ifndef YYPTRDIFF_T
297 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
298 # define YYPTRDIFF_T __PTRDIFF_TYPE__
299 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
300 # elif defined PTRDIFF_MAX
301 # ifndef ptrdiff_t
302 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
303 # endif
304 # define YYPTRDIFF_T ptrdiff_t
305 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
306 # else
307 # define YYPTRDIFF_T long
308 # define YYPTRDIFF_MAXIMUM LONG_MAX
309 # endif
310 #endif
311 
312 #ifndef YYSIZE_T
313 # ifdef __SIZE_TYPE__
314 # define YYSIZE_T __SIZE_TYPE__
315 # elif defined size_t
316 # define YYSIZE_T size_t
317 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
318 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
319 # define YYSIZE_T size_t
320 # else
321 # define YYSIZE_T unsigned
322 # endif
323 #endif
324 
325 #define YYSIZE_MAXIMUM \
326  YY_CAST (YYPTRDIFF_T, \
327  (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
328  ? YYPTRDIFF_MAXIMUM \
329  : YY_CAST (YYSIZE_T, -1)))
330 
331 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
332 
333 
334 /* Stored state numbers (used for stacks). */
336 
337 /* State numbers in computations. */
338 typedef int yy_state_fast_t;
339 
340 #ifndef YY_
341 # if defined YYENABLE_NLS && YYENABLE_NLS
342 # if ENABLE_NLS
343 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
344 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
345 # endif
346 # endif
347 # ifndef YY_
348 # define YY_(Msgid) Msgid
349 # endif
350 #endif
351 
352 
353 #ifndef YY_ATTRIBUTE_PURE
354 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
355 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
356 # else
357 # define YY_ATTRIBUTE_PURE
358 # endif
359 #endif
360 
361 #ifndef YY_ATTRIBUTE_UNUSED
362 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
363 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
364 # else
365 # define YY_ATTRIBUTE_UNUSED
366 # endif
367 #endif
368 
369 /* Suppress unused-variable warnings by "using" E. */
370 #if ! defined lint || defined __GNUC__
371 # define YY_USE(E) ((void) (E))
372 #else
373 # define YY_USE(E) /* empty */
374 #endif
375 
376 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
377 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
378 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
379 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
380  _Pragma ("GCC diagnostic push") \
381  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
382 # else
383 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
384  _Pragma ("GCC diagnostic push") \
385  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
386  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
387 # endif
388 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
389  _Pragma ("GCC diagnostic pop")
390 #else
391 # define YY_INITIAL_VALUE(Value) Value
392 #endif
393 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
394 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
395 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
396 #endif
397 #ifndef YY_INITIAL_VALUE
398 # define YY_INITIAL_VALUE(Value) /* Nothing. */
399 #endif
400 
401 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
402 # define YY_IGNORE_USELESS_CAST_BEGIN \
403  _Pragma ("GCC diagnostic push") \
404  _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
405 # define YY_IGNORE_USELESS_CAST_END \
406  _Pragma ("GCC diagnostic pop")
407 #endif
408 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
409 # define YY_IGNORE_USELESS_CAST_BEGIN
410 # define YY_IGNORE_USELESS_CAST_END
411 #endif
412 
413 
414 #define YY_ASSERT(E) ((void) (0 && (E)))
415 
416 #if !defined yyoverflow
417 
418 /* The parser invokes alloca or malloc; define the necessary symbols. */
419 
420 # ifdef YYSTACK_USE_ALLOCA
421 # if YYSTACK_USE_ALLOCA
422 # ifdef __GNUC__
423 # define YYSTACK_ALLOC __builtin_alloca
424 # elif defined __BUILTIN_VA_ARG_INCR
425 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
426 # elif defined _AIX
427 # define YYSTACK_ALLOC __alloca
428 # elif defined _MSC_VER
429 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
430 # define alloca _alloca
431 # else
432 # define YYSTACK_ALLOC alloca
433 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
434 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
435  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
436 # ifndef EXIT_SUCCESS
437 # define EXIT_SUCCESS 0
438 # endif
439 # endif
440 # endif
441 # endif
442 # endif
443 
444 # ifdef YYSTACK_ALLOC
445  /* Pacify GCC's 'empty if-body' warning. */
446 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
447 # ifndef YYSTACK_ALLOC_MAXIMUM
448  /* The OS might guarantee only one guard page at the bottom of the stack,
449  and a page size can be as small as 4096 bytes. So we cannot safely
450  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
451  to allow for a few compiler-allocated temporary stack slots. */
452 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
453 # endif
454 # else
455 # define YYSTACK_ALLOC YYMALLOC
456 # define YYSTACK_FREE YYFREE
457 # ifndef YYSTACK_ALLOC_MAXIMUM
458 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
459 # endif
460 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
461  && ! ((defined YYMALLOC || defined malloc) \
462  && (defined YYFREE || defined free)))
463 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
464 # ifndef EXIT_SUCCESS
465 # define EXIT_SUCCESS 0
466 # endif
467 # endif
468 # ifndef YYMALLOC
469 # define YYMALLOC malloc
470 # if ! defined malloc && ! defined EXIT_SUCCESS
471 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
472 # endif
473 # endif
474 # ifndef YYFREE
475 # define YYFREE free
476 # if ! defined free && ! defined EXIT_SUCCESS
477 void free (void *); /* INFRINGES ON USER NAME SPACE */
478 # endif
479 # endif
480 # endif
481 #endif /* !defined yyoverflow */
482 
483 #if (! defined yyoverflow \
484  && (! defined __cplusplus \
485  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
486 
487 /* A type that is properly aligned for any stack member. */
488 union yyalloc
489 {
490  yy_state_t yyss_alloc;
491  YYSTYPE yyvs_alloc;
492 };
493 
494 /* The size of the maximum gap between one aligned stack and the next. */
495 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
496 
497 /* The size of an array large to enough to hold all stacks, each with
498  N elements. */
499 # define YYSTACK_BYTES(N) \
500  ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
501  + YYSTACK_GAP_MAXIMUM)
502 
503 # define YYCOPY_NEEDED 1
504 
505 /* Relocate STACK from its old location to the new one. The
506  local variables YYSIZE and YYSTACKSIZE give the old and new number of
507  elements in the stack, and YYPTR gives the new location of the
508  stack. Advance YYPTR to a properly aligned location for the next
509  stack. */
510 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
511  do \
512  { \
513  YYPTRDIFF_T yynewbytes; \
514  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
515  Stack = &yyptr->Stack_alloc; \
516  yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
517  yyptr += yynewbytes / YYSIZEOF (*yyptr); \
518  } \
519  while (0)
520 
521 #endif
522 
523 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
524 /* Copy COUNT objects from SRC to DST. The source and destination do
525  not overlap. */
526 # ifndef YYCOPY
527 # if defined __GNUC__ && 1 < __GNUC__
528 # define YYCOPY(Dst, Src, Count) \
529  __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
530 # else
531 # define YYCOPY(Dst, Src, Count) \
532  do \
533  { \
534  YYPTRDIFF_T yyi; \
535  for (yyi = 0; yyi < (Count); yyi++) \
536  (Dst)[yyi] = (Src)[yyi]; \
537  } \
538  while (0)
539 # endif
540 # endif
541 #endif /* !YYCOPY_NEEDED */
542 
543 /* YYFINAL -- State number of the termination state. */
544 #define YYFINAL 2
545 /* YYLAST -- Last index in YYTABLE. */
546 #define YYLAST 44
547 
548 /* YYNTOKENS -- Number of terminals. */
549 #define YYNTOKENS 13
550 /* YYNNTS -- Number of nonterminals. */
551 #define YYNNTS 4
552 /* YYNRULES -- Number of rules. */
553 #define YYNRULES 14
554 /* YYNSTATES -- Number of states. */
555 #define YYNSTATES 25
556 
557 /* YYMAXUTOK -- Last valid token kind. */
558 #define YYMAXUTOK 259
559 
560 
561 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
562  as returned by yylex, with out-of-bounds checking. */
563 #define YYTRANSLATE(YYX) \
564  (0 <= (YYX) && (YYX) <= YYMAXUTOK \
565  ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
566  : YYSYMBOL_YYUNDEF)
567 
568 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
569  as returned by yylex. */
570 static const yytype_int8 yytranslate[] =
571 {
572  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576  11, 12, 6, 5, 2, 4, 2, 7, 2, 2,
577  2, 2, 2, 2, 2, 2, 2, 2, 2, 10,
578  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
579  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
580  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581  2, 2, 2, 2, 9, 2, 2, 2, 2, 2,
582  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
587  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
588  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
589  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
590  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
591  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
592  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
593  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
594  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
595  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
596  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
597  2, 2, 2, 2, 2, 2, 1, 2, 3, 8
598 };
599 
600 #if YYDEBUG
601 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
602 static const yytype_int8 yyrline[] =
603 {
604  0, 73, 73, 74, 77, 78, 81, 82, 83, 84,
605  85, 86, 87, 88, 89
606 };
607 #endif
608 
609 /** Accessing symbol of state STATE. */
610 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
611 
612 #if YYDEBUG || 0
613 /* The user-facing name of the symbol whose (internal) number is
614  YYSYMBOL. No bounds checking. */
615 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
616 
617 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
618  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
619 static const char *const yytname[] =
620 {
621  "\"end of file\"", "error", "\"invalid token\"", "NUM", "'-'", "'+'",
622  "'*'", "'/'", "NEG", "'^'", "';'", "'('", "')'", "$accept", "input",
623  "line", "exp", YY_NULLPTR
624 };
625 
626 static const char *
627 yysymbol_name (yysymbol_kind_t yysymbol)
628 {
629  return yytname[yysymbol];
630 }
631 #endif
632 
633 #define YYPACT_NINF (-8)
634 
635 #define yypact_value_is_default(Yyn) \
636  ((Yyn) == YYPACT_NINF)
637 
638 #define YYTABLE_NINF (-1)
639 
640 #define yytable_value_is_error(Yyn) \
641  0
642 
643 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
644  STATE-NUM. */
645 static const yytype_int8 yypact[] =
646 {
647  -8, 13, -8, -8, 3, 3, -8, 3, -8, 30,
648  -7, -7, 21, 3, 3, 3, 3, 1, -8, -8,
649  35, 35, -7, -7, -8
650 };
651 
652 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
653  Performed when YYTABLE does not specify something else to do. Zero
654  means the default is an error. */
655 static const yytype_int8 yydefact[] =
656 {
657  2, 0, 1, 6, 0, 0, 4, 0, 3, 0,
658  11, 12, 0, 0, 0, 0, 0, 0, 5, 14,
659  8, 7, 9, 10, 13
660 };
661 
662 /* YYPGOTO[NTERM-NUM]. */
663 static const yytype_int8 yypgoto[] =
664 {
665  -8, -8, -8, -4
666 };
667 
668 /* YYDEFGOTO[NTERM-NUM]. */
669 static const yytype_int8 yydefgoto[] =
670 {
671  0, 1, 8, 9
672 };
673 
674 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
675  positive, shift that token. If negative, reduce the rule whose
676  number is the opposite. If YYTABLE_NINF, syntax error. */
677 static const yytype_int8 yytable[] =
678 {
679  10, 11, 17, 12, 24, 0, 3, 4, 5, 20,
680  21, 22, 23, 2, 7, 0, 3, 4, 5, 0,
681  0, 0, 0, 6, 7, 13, 14, 15, 16, 0,
682  17, 0, 0, 19, 13, 14, 15, 16, 0, 17,
683  18, 15, 16, 0, 17
684 };
685 
686 static const yytype_int8 yycheck[] =
687 {
688  4, 5, 9, 7, 3, -1, 3, 4, 5, 13,
689  14, 15, 16, 0, 11, -1, 3, 4, 5, -1,
690  -1, -1, -1, 10, 11, 4, 5, 6, 7, -1,
691  9, -1, -1, 12, 4, 5, 6, 7, -1, 9,
692  10, 6, 7, -1, 9
693 };
694 
695 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
696  state STATE-NUM. */
697 static const yytype_int8 yystos[] =
698 {
699  0, 14, 0, 3, 4, 5, 10, 11, 15, 16,
700  16, 16, 16, 4, 5, 6, 7, 9, 10, 12,
701  16, 16, 16, 16, 3
702 };
703 
704 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
705 static const yytype_int8 yyr1[] =
706 {
707  0, 13, 14, 14, 15, 15, 16, 16, 16, 16,
708  16, 16, 16, 16, 16
709 };
710 
711 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
712 static const yytype_int8 yyr2[] =
713 {
714  0, 2, 0, 2, 1, 2, 1, 3, 3, 3,
715  3, 2, 2, 3, 3
716 };
717 
718 
719 enum { YYENOMEM = -2 };
720 
721 #define yyerrok (yyerrstatus = 0)
722 #define yyclearin (yychar = YYEMPTY)
723 
724 #define YYACCEPT goto yyacceptlab
725 #define YYABORT goto yyabortlab
726 #define YYERROR goto yyerrorlab
727 #define YYNOMEM goto yyexhaustedlab
728 
729 
730 #define YYRECOVERING() (!!yyerrstatus)
731 
732 #define YYBACKUP(Token, Value) \
733  do \
734  if (yychar == YYEMPTY) \
735  { \
736  yychar = (Token); \
737  yylval = (Value); \
738  YYPOPSTACK (yylen); \
739  yystate = *yyssp; \
740  goto yybackup; \
741  } \
742  else \
743  { \
744  yyerror (YY_("syntax error: cannot back up")); \
745  YYERROR; \
746  } \
747  while (0)
748 
749 /* Backward compatibility with an undocumented macro.
750  Use YYerror or YYUNDEF. */
751 #define YYERRCODE YYUNDEF
752 
753 
754 /* Enable debugging if requested. */
755 #if YYDEBUG
756 
757 # ifndef YYFPRINTF
758 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
759 # define YYFPRINTF fprintf
760 # endif
761 
762 # define YYDPRINTF(Args) \
763 do { \
764  if (yydebug) \
765  YYFPRINTF Args; \
766 } while (0)
767 
768 
769 
770 
771 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
772 do { \
773  if (yydebug) \
774  { \
775  YYFPRINTF (stderr, "%s ", Title); \
776  yy_symbol_print (stderr, \
777  Kind, Value); \
778  YYFPRINTF (stderr, "\n"); \
779  } \
780 } while (0)
781 
782 
783 /*-----------------------------------.
784 | Print this symbol's value on YYO. |
785 `-----------------------------------*/
786 
787 static void
788 yy_symbol_value_print (FILE *yyo,
789  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
790 {
791  FILE *yyoutput = yyo;
792  YY_USE (yyoutput);
793  if (!yyvaluep)
794  return;
796  YY_USE (yykind);
798 }
799 
800 
801 /*---------------------------.
802 | Print this symbol on YYO. |
803 `---------------------------*/
804 
805 static void
806 yy_symbol_print (FILE *yyo,
807  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
808 {
809  YYFPRINTF (yyo, "%s %s (",
810  yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
811 
812  yy_symbol_value_print (yyo, yykind, yyvaluep);
813  YYFPRINTF (yyo, ")");
814 }
815 
816 /*------------------------------------------------------------------.
817 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
818 | TOP (included). |
819 `------------------------------------------------------------------*/
820 
821 static void
822 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
823 {
824  YYFPRINTF (stderr, "Stack now");
825  for (; yybottom <= yytop; yybottom++)
826  {
827  int yybot = *yybottom;
828  YYFPRINTF (stderr, " %d", yybot);
829  }
830  YYFPRINTF (stderr, "\n");
831 }
832 
833 # define YY_STACK_PRINT(Bottom, Top) \
834 do { \
835  if (yydebug) \
836  yy_stack_print ((Bottom), (Top)); \
837 } while (0)
838 
839 
840 /*------------------------------------------------.
841 | Report that the YYRULE is going to be reduced. |
842 `------------------------------------------------*/
843 
844 static void
845 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
846  int yyrule)
847 {
848  int yylno = yyrline[yyrule];
849  int yynrhs = yyr2[yyrule];
850  int yyi;
851  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
852  yyrule - 1, yylno);
853  /* The symbols being reduced. */
854  for (yyi = 0; yyi < yynrhs; yyi++)
855  {
856  YYFPRINTF (stderr, " $%d = ", yyi + 1);
857  yy_symbol_print (stderr,
858  YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
859  &yyvsp[(yyi + 1) - (yynrhs)]);
860  YYFPRINTF (stderr, "\n");
861  }
862 }
863 
864 # define YY_REDUCE_PRINT(Rule) \
865 do { \
866  if (yydebug) \
867  yy_reduce_print (yyssp, yyvsp, Rule); \
868 } while (0)
869 
870 /* Nonzero means print parse trace. It is left uninitialized so that
871  multiple parsers can coexist. */
872 int yydebug;
873 #else /* !YYDEBUG */
874 # define YYDPRINTF(Args) ((void) 0)
875 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
876 # define YY_STACK_PRINT(Bottom, Top)
877 # define YY_REDUCE_PRINT(Rule)
878 #endif /* !YYDEBUG */
879 
880 
881 /* YYINITDEPTH -- initial size of the parser's stacks. */
882 #ifndef YYINITDEPTH
883 # define YYINITDEPTH 200
884 #endif
885 
886 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
887  if the built-in stack extension method is used).
888 
889  Do not make this value too large; the results are undefined if
890  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
891  evaluated with infinite-precision integer arithmetic. */
892 
893 #ifndef YYMAXDEPTH
894 # define YYMAXDEPTH 10000
895 #endif
896 
897 
898 
899 
900 
901 
902 /*-----------------------------------------------.
903 | Release the memory associated to this symbol. |
904 `-----------------------------------------------*/
905 
906 static void
907 yydestruct (const char *yymsg,
908  yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
909 {
910  YY_USE (yyvaluep);
911  if (!yymsg)
912  yymsg = "Deleting";
913  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
914 
916  YY_USE (yykind);
918 }
919 
920 
921 /* Lookahead token kind. */
922 int yychar;
923 
924 /* The semantic value of the lookahead symbol. */
926 /* Number of syntax errors so far. */
928 
929 
930 
931 
932 /*----------.
933 | yyparse. |
934 `----------*/
935 
936 int
937 yyparse (void)
938 {
939  yy_state_fast_t yystate = 0;
940  /* Number of tokens to shift before error messages enabled. */
941  int yyerrstatus = 0;
942 
943  /* Refer to the stacks through separate pointers, to allow yyoverflow
944  to reallocate them elsewhere. */
945 
946  /* Their size. */
947  YYPTRDIFF_T yystacksize = YYINITDEPTH;
948 
949  /* The state stack: array, bottom, top. */
950  yy_state_t yyssa[YYINITDEPTH];
951  yy_state_t *yyss = yyssa;
952  yy_state_t *yyssp = yyss;
953 
954  /* The semantic value stack: array, bottom, top. */
955  YYSTYPE yyvsa[YYINITDEPTH];
956  YYSTYPE *yyvs = yyvsa;
957  YYSTYPE *yyvsp = yyvs;
958 
959  int yyn;
960  /* The return value of yyparse. */
961  int yyresult;
962  /* Lookahead symbol kind. */
964  /* The variables used to return semantic value and location from the
965  action routines. */
966  YYSTYPE yyval;
967 
968 
969 
970 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
971 
972  /* The number of symbols on the RHS of the reduced rule.
973  Keep to zero when no symbol should be popped. */
974  int yylen = 0;
975 
976  YYDPRINTF ((stderr, "Starting parse\n"));
977 
978  yychar = YYEMPTY; /* Cause a token to be read. */
979 
980  goto yysetstate;
981 
982 
983 /*------------------------------------------------------------.
984 | yynewstate -- push a new state, which is found in yystate. |
985 `------------------------------------------------------------*/
986 yynewstate:
987  /* In all cases, when you get here, the value and location stacks
988  have just been pushed. So pushing a state here evens the stacks. */
989  yyssp++;
990 
991 
992 /*--------------------------------------------------------------------.
993 | yysetstate -- set current state (the top of the stack) to yystate. |
994 `--------------------------------------------------------------------*/
995 yysetstate:
996  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
997  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
999  *yyssp = YY_CAST (yy_state_t, yystate);
1001  YY_STACK_PRINT (yyss, yyssp);
1002 
1003  if (yyss + yystacksize - 1 <= yyssp)
1004 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1005  YYNOMEM;
1006 #else
1007  {
1008  /* Get the current used size of the three stacks, in elements. */
1009  YYPTRDIFF_T yysize = yyssp - yyss + 1;
1010 
1011 # if defined yyoverflow
1012  {
1013  /* Give user a chance to reallocate the stack. Use copies of
1014  these so that the &'s don't force the real ones into
1015  memory. */
1016  yy_state_t *yyss1 = yyss;
1017  YYSTYPE *yyvs1 = yyvs;
1018 
1019  /* Each stack pointer address is followed by the size of the
1020  data in use in that stack, in bytes. This used to be a
1021  conditional around just the two extra args, but that might
1022  be undefined if yyoverflow is a macro. */
1023  yyoverflow (YY_("memory exhausted"),
1024  &yyss1, yysize * YYSIZEOF (*yyssp),
1025  &yyvs1, yysize * YYSIZEOF (*yyvsp),
1026  &yystacksize);
1027  yyss = yyss1;
1028  yyvs = yyvs1;
1029  }
1030 # else /* defined YYSTACK_RELOCATE */
1031  /* Extend the stack our own way. */
1032  if (YYMAXDEPTH <= yystacksize)
1033  YYNOMEM;
1034  yystacksize *= 2;
1035  if (YYMAXDEPTH < yystacksize)
1036  yystacksize = YYMAXDEPTH;
1037 
1038  {
1039  yy_state_t *yyss1 = yyss;
1040  union yyalloc *yyptr =
1041  YY_CAST (union yyalloc *,
1042  YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1043  if (! yyptr)
1044  YYNOMEM;
1045  YYSTACK_RELOCATE (yyss_alloc, yyss);
1046  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1047 # undef YYSTACK_RELOCATE
1048  if (yyss1 != yyssa)
1049  YYSTACK_FREE (yyss1);
1050  }
1051 # endif
1052 
1053  yyssp = yyss + yysize - 1;
1054  yyvsp = yyvs + yysize - 1;
1055 
1057  YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1058  YY_CAST (long, yystacksize)));
1060 
1061  if (yyss + yystacksize - 1 <= yyssp)
1062  YYABORT;
1063  }
1064 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1065 
1066 
1067  if (yystate == YYFINAL)
1068  YYACCEPT;
1069 
1070  goto yybackup;
1071 
1072 
1073 /*-----------.
1074 | yybackup. |
1075 `-----------*/
1076 yybackup:
1077  /* Do appropriate processing given the current state. Read a
1078  lookahead token if we need one and don't already have one. */
1079 
1080  /* First try to decide what to do without reference to lookahead token. */
1081  yyn = yypact[yystate];
1082  if (yypact_value_is_default (yyn))
1083  goto yydefault;
1084 
1085  /* Not known => get a lookahead token if don't already have one. */
1086 
1087  /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1088  if (yychar == YYEMPTY)
1089  {
1090  YYDPRINTF ((stderr, "Reading a token\n"));
1091  yychar = yylex ();
1092  }
1093 
1094  if (yychar <= YYEOF)
1095  {
1096  yychar = YYEOF;
1097  yytoken = YYSYMBOL_YYEOF;
1098  YYDPRINTF ((stderr, "Now at end of input.\n"));
1099  }
1100  else if (yychar == YYerror)
1101  {
1102  /* The scanner already issued an error message, process directly
1103  to error recovery. But do not keep the error token as
1104  lookahead, it is too special and may lead us to an endless
1105  loop in error recovery. */
1106  yychar = YYUNDEF;
1107  yytoken = YYSYMBOL_YYerror;
1108  goto yyerrlab1;
1109  }
1110  else
1111  {
1112  yytoken = YYTRANSLATE (yychar);
1113  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1114  }
1115 
1116  /* If the proper action on seeing token YYTOKEN is to reduce or to
1117  detect an error, take that action. */
1118  yyn += yytoken;
1119  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1120  goto yydefault;
1121  yyn = yytable[yyn];
1122  if (yyn <= 0)
1123  {
1124  if (yytable_value_is_error (yyn))
1125  goto yyerrlab;
1126  yyn = -yyn;
1127  goto yyreduce;
1128  }
1129 
1130  /* Count tokens shifted since error; after three, turn off error
1131  status. */
1132  if (yyerrstatus)
1133  yyerrstatus--;
1134 
1135  /* Shift the lookahead token. */
1136  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1137  yystate = yyn;
1139  *++yyvsp = yylval;
1141 
1142  /* Discard the shifted token. */
1143  yychar = YYEMPTY;
1144  goto yynewstate;
1145 
1146 
1147 /*-----------------------------------------------------------.
1148 | yydefault -- do the default action for the current state. |
1149 `-----------------------------------------------------------*/
1150 yydefault:
1151  yyn = yydefact[yystate];
1152  if (yyn == 0)
1153  goto yyerrlab;
1154  goto yyreduce;
1155 
1156 
1157 /*-----------------------------.
1158 | yyreduce -- do a reduction. |
1159 `-----------------------------*/
1160 yyreduce:
1161  /* yyn is the number of a rule to reduce with. */
1162  yylen = yyr2[yyn];
1163 
1164  /* If YYLEN is nonzero, implement the default value of the action:
1165  '$$ = $1'.
1166 
1167  Otherwise, the following line sets YYVAL to garbage.
1168  This behavior is undocumented and Bison
1169  users should not rely upon it. Assigning to YYVAL
1170  unconditionally makes the parser a bit smaller, and it avoids a
1171  GCC warning that YYVAL may be used uninitialized. */
1172  yyval = yyvsp[1-yylen];
1173 
1174 
1175  YY_REDUCE_PRINT (yyn);
1176  switch (yyn)
1177  {
1178  case 5: /* line: exp ';' */
1179 #line 78 "readcf.yy"
1180  { *retvalue = yyvsp[-1].getval(); return 0; }
1181 #line 1182 "readcf.cc"
1182  break;
1183 
1184  case 6: /* exp: NUM */
1185 #line 81 "readcf.yy"
1186  { yyval = yyvsp[0]; }
1187 #line 1188 "readcf.cc"
1188  break;
1189 
1190  case 7: /* exp: exp '+' exp */
1191 #line 82 "readcf.yy"
1192  { yyval = yyvsp[-2].getval() + yyvsp[0].getval(); }
1193 #line 1194 "readcf.cc"
1194  break;
1195 
1196  case 8: /* exp: exp '-' exp */
1197 #line 83 "readcf.yy"
1198  { yyval = yyvsp[-2].getval() - yyvsp[0].getval(); }
1199 #line 1200 "readcf.cc"
1200  break;
1201 
1202  case 9: /* exp: exp '*' exp */
1203 #line 84 "readcf.yy"
1204  { yyval = yyvsp[-2].getval() * yyvsp[0].getval(); }
1205 #line 1206 "readcf.cc"
1206  break;
1207 
1208  case 10: /* exp: exp '/' exp */
1209 #line 85 "readcf.yy"
1210  { yyval = yyvsp[-2].getval() / yyvsp[0].getval(); }
1211 #line 1212 "readcf.cc"
1212  break;
1213 
1214  case 11: /* exp: '-' exp */
1215 #line 86 "readcf.yy"
1216  { yyval = -yyvsp[0].getval(); }
1217 #line 1218 "readcf.cc"
1218  break;
1219 
1220  case 12: /* exp: '+' exp */
1221 #line 87 "readcf.yy"
1222  { yyval = yyvsp[0].getval(); }
1223 #line 1224 "readcf.cc"
1224  break;
1225 
1226  case 13: /* exp: exp '^' NUM */
1227 #line 88 "readcf.yy"
1228  { yyval = power( yyvsp[-2].getval(), yyvsp[0].getintval() ); }
1229 #line 1230 "readcf.cc"
1230  break;
1231 
1232  case 14: /* exp: '(' exp ')' */
1233 #line 89 "readcf.yy"
1234  { yyval = yyvsp[-1].getval(); }
1235 #line 1236 "readcf.cc"
1236  break;
1237 
1238 
1239 #line 1240 "readcf.cc"
1240 
1241  default: break;
1242  }
1243  /* User semantic actions sometimes alter yychar, and that requires
1244  that yytoken be updated with the new translation. We take the
1245  approach of translating immediately before every use of yytoken.
1246  One alternative is translating here after every semantic action,
1247  but that translation would be missed if the semantic action invokes
1248  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1249  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1250  incorrect destructor might then be invoked immediately. In the
1251  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1252  to an incorrect destructor call or verbose syntax error message
1253  before the lookahead is translated. */
1254  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1255 
1256  YYPOPSTACK (yylen);
1257  yylen = 0;
1258 
1259  *++yyvsp = yyval;
1260 
1261  /* Now 'shift' the result of the reduction. Determine what state
1262  that goes to, based on the state we popped back to and the rule
1263  number reduced by. */
1264  {
1265  const int yylhs = yyr1[yyn] - YYNTOKENS;
1266  const int yyi = yypgoto[yylhs] + *yyssp;
1267  yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1268  ? yytable[yyi]
1269  : yydefgoto[yylhs]);
1270  }
1271 
1272  goto yynewstate;
1273 
1274 
1275 /*--------------------------------------.
1276 | yyerrlab -- here on detecting error. |
1277 `--------------------------------------*/
1278 yyerrlab:
1279  /* Make sure we have latest lookahead translation. See comments at
1280  user semantic actions for why this is necessary. */
1281  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1282  /* If not already recovering from an error, report this error. */
1283  if (!yyerrstatus)
1284  {
1285  ++yynerrs;
1286  yyerror (YY_("syntax error"));
1287  }
1288 
1289  if (yyerrstatus == 3)
1290  {
1291  /* If just tried and failed to reuse lookahead token after an
1292  error, discard it. */
1293 
1294  if (yychar <= YYEOF)
1295  {
1296  /* Return failure if at end of input. */
1297  if (yychar == YYEOF)
1298  YYABORT;
1299  }
1300  else
1301  {
1302  yydestruct ("Error: discarding",
1303  yytoken, &yylval);
1304  yychar = YYEMPTY;
1305  }
1306  }
1307 
1308  /* Else will try to reuse lookahead token after shifting the error
1309  token. */
1310  goto yyerrlab1;
1311 
1312 
1313 /*---------------------------------------------------.
1314 | yyerrorlab -- error raised explicitly by YYERROR. |
1315 `---------------------------------------------------*/
1316 yyerrorlab:
1317  /* Pacify compilers when the user code never invokes YYERROR and the
1318  label yyerrorlab therefore never appears in user code. */
1319  if (0)
1320  YYERROR;
1321  ++yynerrs;
1322 
1323  /* Do not reclaim the symbols of the rule whose action triggered
1324  this YYERROR. */
1325  YYPOPSTACK (yylen);
1326  yylen = 0;
1327  YY_STACK_PRINT (yyss, yyssp);
1328  yystate = *yyssp;
1329  goto yyerrlab1;
1330 
1331 
1332 /*-------------------------------------------------------------.
1333 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1334 `-------------------------------------------------------------*/
1335 yyerrlab1:
1336  yyerrstatus = 3; /* Each real token shifted decrements this. */
1337 
1338  /* Pop stack until we find a state that shifts the error token. */
1339  for (;;)
1340  {
1341  yyn = yypact[yystate];
1342  if (!yypact_value_is_default (yyn))
1343  {
1344  yyn += YYSYMBOL_YYerror;
1345  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1346  {
1347  yyn = yytable[yyn];
1348  if (0 < yyn)
1349  break;
1350  }
1351  }
1352 
1353  /* Pop the current state because it cannot handle the error token. */
1354  if (yyssp == yyss)
1355  YYABORT;
1356 
1357 
1358  yydestruct ("Error: popping",
1359  YY_ACCESSING_SYMBOL (yystate), yyvsp);
1360  YYPOPSTACK (1);
1361  yystate = *yyssp;
1362  YY_STACK_PRINT (yyss, yyssp);
1363  }
1364 
1366  *++yyvsp = yylval;
1368 
1369 
1370  /* Shift the error token. */
1371  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1372 
1373  yystate = yyn;
1374  goto yynewstate;
1375 
1376 
1377 /*-------------------------------------.
1378 | yyacceptlab -- YYACCEPT comes here. |
1379 `-------------------------------------*/
1380 yyacceptlab:
1381  yyresult = 0;
1382  goto yyreturnlab;
1383 
1384 
1385 /*-----------------------------------.
1386 | yyabortlab -- YYABORT comes here. |
1387 `-----------------------------------*/
1388 yyabortlab:
1389  yyresult = 1;
1390  goto yyreturnlab;
1391 
1392 
1393 /*-----------------------------------------------------------.
1394 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1395 `-----------------------------------------------------------*/
1396 yyexhaustedlab:
1397  yyerror (YY_("memory exhausted"));
1398  yyresult = 2;
1399  goto yyreturnlab;
1400 
1401 
1402 /*----------------------------------------------------------.
1403 | yyreturnlab -- parsing is finished, clean up and return. |
1404 `----------------------------------------------------------*/
1405 yyreturnlab:
1406  if (yychar != YYEMPTY)
1407  {
1408  /* Make sure we have latest lookahead translation. See comments at
1409  user semantic actions for why this is necessary. */
1410  yytoken = YYTRANSLATE (yychar);
1411  yydestruct ("Cleanup: discarding lookahead",
1412  yytoken, &yylval);
1413  }
1414  /* Do not reclaim the symbols of the rule whose action triggered
1415  this YYABORT or YYACCEPT. */
1416  YYPOPSTACK (yylen);
1417  YY_STACK_PRINT (yyss, yyssp);
1418  while (yyssp != yyss)
1419  {
1420  yydestruct ("Cleanup: popping",
1421  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1422  YYPOPSTACK (1);
1423  }
1424 #ifndef yyoverflow
1425  if (yyss != yyssa)
1426  YYSTACK_FREE (yyss);
1427 #endif
1428 
1429  return yyresult;
1430 }
1431 
1432 #line 92 "readcf.yy"
1433 
1434 
1435 #ifdef BISONPP
1436 void YY_parse_CLASS::yyerror( char * s )
1437 #else
1438 void yyerror( char * s )
1439 #endif
1440 {
1441  CERR << s << "\n";
1442 }
1443 
1444 #ifdef BISONPP
1446 #else
1447 int yylex()
1448 #endif
1449 {
1450  int c;
1451 
1452  while ((c = defaultin->get()) == ' ' || c == '\t' || c == '\n' ) ;
1453  if ( isdigit( c ) ) {
1454  defaultin->putback( c );
1456  return NUM;
1457  }
1458  else if ( isalpha( c ) ) {
1459  // look for generators of GF(q)
1460  if ( getCharacteristic() > 0 && getGFDegree() > 1 && c == gf_name ) {
1461 #ifdef BISONPP
1462  this->yylval = getGFGenerator();
1463 #else
1464  yylval = getGFGenerator();
1465 #endif
1466  }
1467  else if ( c == getDefaultVarName() ) {
1468  int cc;
1469  cc = defaultin->get();
1470  if ( cc == '_' ) {
1472 #ifdef BISONPP
1473  this->yylval = Variable( index.getintval() );
1474 #else
1475  yylval = Variable( index.getintval() );
1476 #endif
1477  }
1478  else {
1479  defaultin->putback( cc );
1480 #ifdef BISONPP
1481  this->yylval = Variable( (char)c );
1482 #else
1483  yylval = Variable( (char)c );
1484 #endif
1485  }
1486  }
1487  else {
1488 #ifdef BISONPP
1489  this->yylval = Variable( (char)c );
1490 #else
1491  yylval = Variable( (char)c );
1492 #endif
1493  }
1494  return NUM;
1495  }
1496  return c;
1497 }
1498 
1500 {
1501  CanonicalForm theRetvalue;
1502  retvalue = new CanonicalForm();
1503 #ifdef BISONPP
1504  YY_parse_CLASS my_parser;
1505  defaultin = &str;
1506  if ( my_parser.yyparse() == 0 ) {
1507  theRetvalue = *retvalue;
1508  delete retvalue;
1509  return theRetvalue;
1510  }
1511  else {
1512  delete retvalue;
1513  return 0;
1514  }
1515 #else
1516  defaultin = &str;
1517  if ( yyparse() == 0 ) {
1518  theRetvalue = *retvalue;
1519  delete retvalue;
1520  return theRetvalue;
1521  }
1522  else {
1523  delete retvalue;
1524  return 0;
1525  }
1526 #endif
1527 }
1528 
1530 {
1531  static char * buffer = 0;
1532  static int bufsize = 0;
1533 
1534  if ( buffer == 0 ) {
1535  bufsize = 10000;
1536  buffer = new char[bufsize];
1537  }
1538  int i = 0, c, goon = 1;
1539  while ( goon ) {
1540  while ( isdigit( c = s.get() ) && i < bufsize - 2 ) {
1541  buffer[i] = c;
1542  i++;
1543  }
1544  if ( isdigit( c ) ) {
1545  bufsize += 1000;
1546  char * newbuffer = (char*)memcpy( new char[bufsize], buffer, bufsize - 1000 );
1547  delete [] buffer;
1548  buffer = newbuffer;
1549  buffer[i] = c;
1550  i++;
1551  }
1552  else {
1553  goon = 0;
1554  buffer[i] = '\0';
1555  s.putback( c );
1556  }
1557  }
1558  return buffer;
1559 }
1560 
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Header for factory's main class CanonicalForm.
int getGFDegree()
Definition: cf_char.cc:75
CanonicalForm getGFGenerator()
Definition: cf_char.cc:81
int FACTORY_PUBLIC getCharacteristic()
Definition: cf_char.cc:70
int i
Definition: cfEzgcd.cc:132
assertions for Factory
factory switches.
factory's main class
Definition: canonicalform.h:86
InternalCF * getval() const
factory's class for variables
Definition: factory.h:127
const CanonicalForm int s
Definition: facAbsFact.cc:51
char getDefaultVarName()
Definition: variable.cc:244
VAR char gf_name
Definition: gfops.cc:52
Operations in GF, where GF is a finite field of size less than 2^16 represented by a root of Conway p...
VAR int yydebug
Definition: grammar.cc:1805
yytokentype
Definition: grammar.cc:266
static void yy_stack_print(yytype_int16 *yybottom, yytype_int16 *yytop)
Definition: grammar.cc:1742
static void yy_reduce_print(YYSTYPE *yyvsp, int yyrule)
Definition: grammar.cc:1773
static const yytype_uint16 yyrline[]
Definition: grammar.cc:743
static void yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep)
Definition: grammar.cc:1684
static void yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep)
Definition: grammar.cc:1716
static const char *const yytname[]
Definition: grammar.cc:769
signed char yytype_int8
Definition: grammar.cc:384
#define YYFPRINTF
Definition: grammar.cc:1655
char * str(leftv arg)
Definition: shared.cc:704
#define free
Definition: omAllocFunc.c:14
void * malloc(size_t size)
Definition: omalloc.c:85
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
int yynerrs
Definition: readcf.cc:927
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: readcf.cc:394
#define YYMAXDEPTH
Definition: readcf.cc:894
#define CERR
Definition: readcf.cc:94
void yyerror(char *s)
Definition: readcf.cc:1438
#define YYSTACK_FREE
Definition: readcf.cc:456
static const yytype_int8 yytranslate[]
Definition: readcf.cc:570
yysymbol_kind_t
Definition: readcf.cc:200
@ YYSYMBOL_7_
Definition: readcf.cc:209
@ YYSYMBOL_YYUNDEF
Definition: readcf.cc:204
@ YYSYMBOL_YYerror
Definition: readcf.cc:203
@ YYSYMBOL_12_
Definition: readcf.cc:214
@ YYSYMBOL_exp
Definition: readcf.cc:218
@ YYSYMBOL_10_
Definition: readcf.cc:212
@ YYSYMBOL_9_
Definition: readcf.cc:211
@ YYSYMBOL_11_
Definition: readcf.cc:213
@ YYSYMBOL_NEG
Definition: readcf.cc:210
@ YYSYMBOL_6_
Definition: readcf.cc:208
@ YYSYMBOL_line
Definition: readcf.cc:217
@ YYSYMBOL_NUM
Definition: readcf.cc:205
@ YYSYMBOL_YYACCEPT
Definition: readcf.cc:215
@ YYSYMBOL_4_
Definition: readcf.cc:206
@ YYSYMBOL_YYEOF
Definition: readcf.cc:202
@ YYSYMBOL_input
Definition: readcf.cc:216
@ YYSYMBOL_YYEMPTY
Definition: readcf.cc:201
@ YYSYMBOL_5_
Definition: readcf.cc:207
static ISTREAM * defaultin
Definition: readcf.cc:124
#define YY_ASSERT(E)
Definition: readcf.cc:414
#define YY_(Msgid)
Definition: readcf.cc:348
#define YYNOMEM
Definition: readcf.cc:727
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: readcf.cc:395
static const yytype_int8 yydefact[]
Definition: readcf.cc:655
#define YYNSTATES
Definition: readcf.cc:555
#define YYSTYPE
Definition: readcf.cc:111
#define YY_IGNORE_USELESS_CAST_END
Definition: readcf.cc:410
short yytype_int16
Definition: readcf.cc:259
#define YYEOF
Definition: readcf.cc:177
#define YYABORT
Definition: readcf.cc:725
static const yytype_int8 yycheck[]
Definition: readcf.cc:686
#define YY_REDUCE_PRINT(Rule)
Definition: readcf.cc:877
#define YY_CAST(Type, Val)
Definition: readcf.cc:133
static void yydestruct(const char *yymsg, yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
Definition: readcf.cc:907
YYSTYPE yylval
Definition: readcf.cc:925
#define YYerror
Definition: readcf.cc:178
#define YY_NULLPTR
Definition: readcf.cc:145
#define YYUNDEF
Definition: readcf.cc:179
static const yytype_int8 yypact[]
Definition: readcf.cc:645
#define YYFINAL
Definition: readcf.cc:544
#define YY_ACCESSING_SYMBOL(State)
Accessing symbol of state STATE.
Definition: readcf.cc:610
#define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
Definition: readcf.cc:875
#define YYNTOKENS
Definition: readcf.cc:549
unsigned char yytype_uint8
Definition: readcf.cc:280
#define YY_STACK_PRINT(Bottom, Top)
Definition: readcf.cc:876
#define YYSIZE_T
Definition: readcf.cc:321
#define YY_IGNORE_USELESS_CAST_BEGIN
Definition: readcf.cc:409
int yyparse(void)
Definition: readcf.cc:937
static const yytype_int8 yyr2[]
Definition: readcf.cc:712
static const yytype_int8 yytable[]
Definition: readcf.cc:677
#define YYPTRDIFF_T
Definition: readcf.cc:307
int yychar
Definition: readcf.cc:922
#define NEG
Definition: readcf.cc:181
int yylex()
Definition: readcf.cc:1447
#define YYACCEPT
Definition: readcf.cc:724
#define yytable_value_is_error(Yyn)
Definition: readcf.cc:640
static char * readString(ISTREAM &)
Definition: readcf.cc:1529
#define YYTRANSLATE(YYX)
Definition: readcf.cc:563
static const yytype_int8 yystos[]
Definition: readcf.cc:697
#define NUM
Definition: readcf.cc:180
#define YY_ATTRIBUTE_UNUSED
Definition: readcf.cc:365
@ YYENOMEM
Definition: readcf.cc:719
static const yytype_int8 yypgoto[]
Definition: readcf.cc:663
CanonicalForm readCF(ISTREAM &str)
Definition: readcf.cc:1499
static const yytype_int8 yyr1[]
Definition: readcf.cc:705
#define ISTREAM
Definition: readcf.cc:93
enum yytokentype yytoken_kind_t
Definition: readcf.cc:173
#define YYPOPSTACK(N)
int yy_state_fast_t
Definition: readcf.cc:338
unsigned short yytype_uint16
Definition: readcf.cc:291
static const yytype_int8 yydefgoto[]
Definition: readcf.cc:669
static CanonicalForm * retvalue
Definition: readcf.cc:126
#define YYEMPTY
Definition: readcf.cc:176
#define YYLAST
Definition: readcf.cc:546
#define yypact_value_is_default(Yyn)
Definition: readcf.cc:635
#define YYINITDEPTH
Definition: readcf.cc:883
signed char yytype_int8
Definition: readcf.cc:251
#define YYERROR
Definition: readcf.cc:726
#define YYSIZEOF(X)
Definition: readcf.cc:331
#define YYSTACK_ALLOC
Definition: readcf.cc:455
yytype_int8 yy_state_t
Definition: readcf.cc:335
#define YYDPRINTF(Args)
Definition: readcf.cc:874
#define YY_USE(E)
Definition: readcf.cc:371
operations on variables