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