2 /* A Bison parser, made by GNU Bison 2.4.1. */
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
38 /* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
45 /* Identify Bison output. */
49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
63 /* Using locations. */
64 #define YYLSP_NEEDED 0
68 /* Copy the first part of user declarations. */
70 /* Line 189 of yacc.c */
73 /* A simple integer desk calculator using yacc and gmp.
75 Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
77 This file is part of the GNU MP Library.
79 This program is free software; you can redistribute it and/or modify it under
80 the terms of the GNU General Public License as published by the Free Software
81 Foundation; either version 3 of the License, or (at your option) any later
84 This program is distributed in the hope that it will be useful, but WITHOUT ANY
85 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
86 PARTICULAR PURPOSE. See the GNU General Public License for more details.
88 You should have received a copy of the GNU General Public License along with
89 this program. If not, see http://www.gnu.org/licenses/. */
92 /* This is a simple program, meant only to show one way to use GMP for this
93 sort of thing. There's few features, and error checking is minimal.
94 Standard input is read, calc_help() below shows the inputs accepted.
96 Expressions are evaluated as they're read. If user defined functions
97 were wanted it'd be necessary to build a parse tree like pexpr.c does, or
98 a list of operations for a stack based evaluator. That would also make
99 it possible to detect and optimize evaluations "mod m" like pexpr.c does.
101 A stack is used for intermediate values in the expression evaluation,
102 separate from the yacc parser stack. This is simple, makes error
103 recovery easy, minimizes the junk around mpz calls in the rules, and
104 saves initializing or clearing "mpz_t"s during a calculation. A
105 disadvantage though is that variables must be copied to the stack to be
106 worked on. A more sophisticated calculator or language system might be
107 able to avoid that when executing a compiled or semi-compiled form.
109 Avoiding repeated initializing and clearing of "mpz_t"s is important. In
110 this program the time spent parsing is obviously much greater than any
111 possible saving from this, but a proper calculator or language should
112 take some trouble over it. Don't be surprised if an init/clear takes 3
113 or more times as long as a 10 limb addition, depending on the system (see
114 the mpz_init_realloc_clear example in tune/README). */
121 #define NO_CALC_H /* because it conflicts with normal calc.c stuff */
122 #include "calc-common.h"
125 #define numberof(x) (sizeof (x) / sizeof ((x)[0]))
131 printf ("Examples:\n");
132 printf (" 2+3*4 expressions are evaluated\n");
133 printf (" x=5^6 variables a to z can be set and used\n");
134 printf ("Operators:\n");
135 printf (" + - * arithmetic\n");
136 printf (" / %% division and remainder (rounding towards negative infinity)\n");
137 printf (" ^ exponentiation\n");
138 printf (" ! factorial\n");
139 printf (" << >> left and right shifts\n");
140 printf (" <= >= > \\ comparisons, giving 1 if true, 0 if false\n");
141 printf (" == != < /\n");
142 printf (" && || logical and/or, giving 1 if true, 0 if false\n");
143 printf ("Functions:\n");
144 printf (" abs(n) absolute value\n");
145 printf (" bin(n,m) binomial coefficient\n");
146 printf (" fib(n) fibonacci number\n");
147 printf (" gcd(a,b,..) greatest common divisor\n");
148 printf (" kron(a,b) kronecker symbol\n");
149 printf (" lcm(a,b,..) least common multiple\n");
150 printf (" lucnum(n) lucas number\n");
151 printf (" nextprime(n) next prime after n\n");
152 printf (" powm(b,e,m) modulo powering, b^e%%m\n");
153 printf (" root(n,r) r-th root\n");
154 printf (" sqrt(n) square root\n");
156 printf (" hex \\ set hex or decimal for input and output\n");
157 printf (" decimal / (\"0x\" can be used for hex too)\n");
158 printf (" quit exit program (EOF works too)\n");
159 printf (" ; statements are separated with a ; or newline\n");
160 printf (" \\ continue expressions with \\ before newline\n");
161 printf (" # xxx comments are # though to newline\n");
162 printf ("Hex numbers must be entered in upper case, to distinguish them from the\n");
163 printf ("variables a to f (like in bc).\n");
171 /* The stack is a fixed size, which means there's a limit on the nesting
172 allowed in expressions. A more sophisticated program could let it grow
176 mpz_ptr sp = stack[0];
178 #define CHECK_OVERFLOW() \
179 if (sp >= stack[numberof(stack)]) /* FIXME */ \
182 "Value stack overflow, too much nesting in expression\n"); \
186 #define CHECK_EMPTY() \
187 if (sp != stack[0]) \
189 fprintf (stderr, "Oops, expected the value stack to be empty\n"); \
196 #define CHECK_VARIABLE(var) \
197 if ((var) < 0 || (var) >= numberof (variable)) \
199 fprintf (stderr, "Oops, bad variable somehow: %d\n", var); \
204 #define CHECK_UI(name,z) \
205 if (! mpz_fits_ulong_p (z)) \
207 fprintf (stderr, "%s too big\n", name); \
213 /* Line 189 of yacc.c */
216 /* Enabling traces. */
221 /* Enabling verbose error messages. */
222 #ifdef YYERROR_VERBOSE
223 # undef YYERROR_VERBOSE
224 # define YYERROR_VERBOSE 1
226 # define YYERROR_VERBOSE 0
229 /* Enabling the token table. */
230 #ifndef YYTOKEN_TABLE
231 # define YYTOKEN_TABLE 0
238 /* Put the tokens into the symbol table, so that GDB and other debuggers
285 #define NEXTPRIME 271
304 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
305 typedef union YYSTYPE
308 /* Line 214 of yacc.c */
316 /* Line 214 of yacc.c */
319 # define YYSTYPE_IS_TRIVIAL 1
320 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
321 # define YYSTYPE_IS_DECLARED 1
325 /* Copy the second part of user declarations. */
328 /* Line 264 of yacc.c */
336 typedef YYTYPE_UINT8 yytype_uint8;
338 typedef unsigned char yytype_uint8;
342 typedef YYTYPE_INT8 yytype_int8;
343 #elif (defined __STDC__ || defined __C99__FUNC__ \
344 || defined __cplusplus || defined _MSC_VER)
345 typedef signed char yytype_int8;
347 typedef short int yytype_int8;
351 typedef YYTYPE_UINT16 yytype_uint16;
353 typedef unsigned short int yytype_uint16;
357 typedef YYTYPE_INT16 yytype_int16;
359 typedef short int yytype_int16;
363 # ifdef __SIZE_TYPE__
364 # define YYSIZE_T __SIZE_TYPE__
365 # elif defined size_t
366 # define YYSIZE_T size_t
367 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
368 || defined __cplusplus || defined _MSC_VER)
369 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
370 # define YYSIZE_T size_t
372 # define YYSIZE_T unsigned int
376 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
381 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
382 # define YY_(msgid) dgettext ("bison-runtime", msgid)
386 # define YY_(msgid) msgid
390 /* Suppress unused-variable warnings by "using" E. */
391 #if ! defined lint || defined __GNUC__
392 # define YYUSE(e) ((void) (e))
394 # define YYUSE(e) /* empty */
397 /* Identity function, used to suppress warnings about constant conditions. */
401 #if (defined __STDC__ || defined __C99__FUNC__ \
402 || defined __cplusplus || defined _MSC_VER)
415 #if ! defined yyoverflow || YYERROR_VERBOSE
417 /* The parser invokes alloca or malloc; define the necessary symbols. */
419 # ifdef YYSTACK_USE_ALLOCA
420 # if YYSTACK_USE_ALLOCA
422 # define YYSTACK_ALLOC __builtin_alloca
423 # elif defined __BUILTIN_VA_ARG_INCR
424 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
426 # define YYSTACK_ALLOC __alloca
427 # elif defined _MSC_VER
428 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
429 # define alloca _alloca
431 # define YYSTACK_ALLOC alloca
432 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
433 || defined __cplusplus || defined _MSC_VER)
434 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
443 # ifdef YYSTACK_ALLOC
444 /* Pacify GCC's `empty if-body' warning. */
445 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
446 # ifndef YYSTACK_ALLOC_MAXIMUM
447 /* The OS might guarantee only one guard page at the bottom of the stack,
448 and a page size can be as small as 4096 bytes. So we cannot safely
449 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
450 to allow for a few compiler-allocated temporary stack slots. */
451 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
454 # define YYSTACK_ALLOC YYMALLOC
455 # define YYSTACK_FREE YYFREE
456 # ifndef YYSTACK_ALLOC_MAXIMUM
457 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
459 # if (defined __cplusplus && ! defined _STDLIB_H \
460 && ! ((defined YYMALLOC || defined malloc) \
461 && (defined YYFREE || defined free)))
462 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
468 # define YYMALLOC malloc
469 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
470 || defined __cplusplus || defined _MSC_VER)
471 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
476 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
477 || defined __cplusplus || defined _MSC_VER)
478 void free (void *); /* INFRINGES ON USER NAME SPACE */
482 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
485 #if (! defined yyoverflow \
486 && (! defined __cplusplus \
487 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
489 /* A type that is properly aligned for any stack member. */
492 yytype_int16 yyss_alloc;
496 /* The size of the maximum gap between one aligned stack and the next. */
497 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
499 /* The size of an array large to enough to hold all stacks, each with
501 # define YYSTACK_BYTES(N) \
502 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
503 + YYSTACK_GAP_MAXIMUM)
505 /* Copy COUNT objects from FROM to TO. The source and destination do
508 # if defined __GNUC__ && 1 < __GNUC__
509 # define YYCOPY(To, From, Count) \
510 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
512 # define YYCOPY(To, From, Count) \
516 for (yyi = 0; yyi < (Count); yyi++) \
517 (To)[yyi] = (From)[yyi]; \
523 /* Relocate STACK from its old location to the new one. The
524 local variables YYSIZE and YYSTACKSIZE give the old and new number of
525 elements in the stack, and YYPTR gives the new location of the
526 stack. Advance YYPTR to a properly aligned location for the next
528 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
531 YYSIZE_T yynewbytes; \
532 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
533 Stack = &yyptr->Stack_alloc; \
534 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
535 yyptr += yynewbytes / sizeof (*yyptr); \
541 /* YYFINAL -- State number of the termination state. */
543 /* YYLAST -- Last index in YYTABLE. */
546 /* YYNTOKENS -- Number of terminals. */
548 /* YYNNTS -- Number of nonterminals. */
550 /* YYNRULES -- Number of rules. */
552 /* YYNRULES -- Number of states. */
553 #define YYNSTATES 118
555 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
557 #define YYMAXUTOK 285
559 #define YYTRANSLATE(YYX) \
560 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
562 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
563 static const yytype_uint8 yytranslate[] =
565 0, 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 2, 2, 2, 39, 2, 2, 2, 36, 2, 2,
569 41, 42, 34, 32, 43, 33, 2, 35, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 24, 40, 25, 2, 2, 2, 2, 2, 2, 2,
572 2, 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, 38, 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, 2, 2, 2, 2,
590 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
591 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
592 15, 16, 17, 18, 19, 20, 21, 22, 23, 26,
593 27, 28, 29, 30, 31, 37
597 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
599 static const yytype_uint8 yyprhs[] =
601 0, 0, 3, 5, 8, 11, 15, 18, 19, 21,
602 25, 27, 29, 31, 33, 37, 41, 45, 49, 53,
603 57, 61, 65, 69, 72, 75, 79, 83, 87, 91,
604 95, 99, 103, 107, 112, 119, 124, 129, 136, 141,
605 146, 151, 160, 167, 172, 174, 176, 178, 182, 184
608 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
609 static const yytype_int8 yyrhs[] =
611 45, 0, -1, 47, -1, 46, 47, -1, 47, 3,
612 -1, 46, 47, 3, -1, 1, 3, -1, -1, 48,
613 -1, 21, 40, 48, -1, 5, -1, 6, -1, 7,
614 -1, 8, -1, 41, 48, 42, -1, 48, 32, 48,
615 -1, 48, 33, 48, -1, 48, 34, 48, -1, 48,
616 35, 48, -1, 48, 36, 48, -1, 48, 38, 48,
617 -1, 48, 31, 48, -1, 48, 30, 48, -1, 48,
618 39, -1, 33, 48, -1, 48, 24, 48, -1, 48,
619 27, 48, -1, 48, 29, 48, -1, 48, 28, 48,
620 -1, 48, 26, 48, -1, 48, 25, 48, -1, 48,
621 23, 48, -1, 48, 22, 48, -1, 9, 41, 48,
622 42, -1, 10, 41, 48, 43, 48, 42, -1, 11,
623 41, 48, 42, -1, 12, 41, 49, 42, -1, 13,
624 41, 48, 43, 48, 42, -1, 14, 41, 50, 42,
625 -1, 15, 41, 48, 42, -1, 16, 41, 48, 42,
626 -1, 17, 41, 48, 43, 48, 43, 48, 42, -1,
627 18, 41, 48, 43, 48, 42, -1, 19, 41, 48,
628 42, -1, 21, -1, 20, -1, 48, -1, 49, 43,
629 48, -1, 48, -1, 50, 43, 48, -1
632 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
633 static const yytype_uint16 yyrline[] =
635 0, 167, 167, 168, 171, 172, 173, 175, 177, 182,
636 188, 189, 190, 191, 197, 198, 199, 200, 201, 202,
637 203, 205, 207, 209, 211, 213, 214, 215, 216, 217,
638 218, 220, 221, 223, 224, 226, 228, 229, 231, 232,
639 234, 235, 236, 238, 240, 246, 257, 258, 261, 262
643 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
644 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
645 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
646 static const char *const yytname[] =
648 "$end", "error", "$undefined", "EOS", "BAD", "HELP", "HEX", "DECIMAL",
649 "QUIT", "ABS", "BIN", "FIB", "GCD", "KRON", "LCM", "LUCNUM", "NEXTPRIME",
650 "POWM", "ROOT", "SQRT", "NUMBER", "VARIABLE", "LOR", "LAND", "'<'",
651 "'>'", "GE", "LE", "NE", "EQ", "RSHIFT", "LSHIFT", "'+'", "'-'", "'*'",
652 "'/'", "'%'", "UMINUS", "'^'", "'!'", "'='", "'('", "')'", "','",
653 "$accept", "top", "statements", "statement", "e", "gcdlist", "lcmlist", 0
658 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
660 static const yytype_uint16 yytoknum[] =
662 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
663 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
664 275, 276, 277, 278, 60, 62, 279, 280, 281, 282,
665 283, 284, 43, 45, 42, 47, 37, 285, 94, 33,
670 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
671 static const yytype_uint8 yyr1[] =
673 0, 44, 45, 45, 46, 46, 46, 47, 47, 47,
674 47, 47, 47, 47, 48, 48, 48, 48, 48, 48,
675 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
676 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
677 48, 48, 48, 48, 48, 48, 49, 49, 50, 50
680 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
681 static const yytype_uint8 yyr2[] =
683 0, 2, 1, 2, 2, 3, 2, 0, 1, 3,
684 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
685 3, 3, 3, 2, 2, 3, 3, 3, 3, 3,
686 3, 3, 3, 4, 6, 4, 4, 6, 4, 4,
687 4, 8, 6, 4, 1, 1, 1, 3, 1, 3
690 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
691 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
692 means the default is an error. */
693 static const yytype_uint8 yydefact[] =
695 0, 0, 10, 11, 12, 13, 0, 0, 0, 0,
696 0, 0, 0, 0, 0, 0, 0, 45, 44, 0,
697 0, 0, 7, 2, 8, 6, 0, 0, 0, 0,
698 0, 0, 0, 0, 0, 0, 0, 0, 44, 24,
699 0, 1, 3, 4, 0, 0, 0, 0, 0, 0,
700 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
701 23, 0, 0, 0, 46, 0, 0, 48, 0, 0,
702 0, 0, 0, 0, 9, 14, 5, 32, 31, 25,
703 30, 29, 26, 28, 27, 22, 21, 15, 16, 17,
704 18, 19, 20, 33, 0, 35, 36, 0, 0, 38,
705 0, 39, 40, 0, 0, 43, 0, 47, 0, 49,
706 0, 0, 34, 37, 0, 42, 0, 41
709 /* YYDEFGOTO[NTERM-NUM]. */
710 static const yytype_int8 yydefgoto[] =
712 -1, 21, 22, 23, 24, 65, 68
715 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
717 #define YYPACT_NINF -39
718 static const yytype_int16 yypact[] =
720 41, 3, -39, -39, -39, -39, 2, 4, 27, 32,
721 35, 36, 39, 42, 45, 46, 47, -39, -18, 124,
722 124, 89, 91, 87, 464, -39, 124, 124, 124, 124,
723 124, 124, 124, 124, 124, 124, 124, 124, -39, -36,
724 254, -39, 88, -39, 124, 124, 124, 124, 124, 124,
725 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
726 -39, 275, 144, 296, 464, -38, 166, 464, 29, 317,
727 338, 188, 210, 359, 464, -39, -39, 481, 497, 513,
728 513, 513, 513, 513, 513, 31, 31, -15, -15, -36,
729 -36, -36, -36, -39, 124, -39, -39, 124, 124, -39,
730 124, -39, -39, 124, 124, -39, 380, 464, 401, 464,
731 232, 422, -39, -39, 124, -39, 443, -39
734 /* YYPGOTO[NTERM-NUM]. */
735 static const yytype_int8 yypgoto[] =
737 -39, -39, -39, 70, -19, -39, -39
740 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
741 positive, shift that token. If negative, reduce the rule which
742 number is the opposite. If zero, do what YYDEFACT says.
743 If YYTABLE_NINF, syntax error. */
744 #define YYTABLE_NINF -8
745 static const yytype_int8 yytable[] =
747 39, 40, 59, 60, 96, 97, 25, 61, 62, 63,
748 64, 66, 67, 69, 70, 71, 72, 73, 74, 56,
749 57, 58, 37, 59, 60, 77, 78, 79, 80, 81,
750 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
751 92, -7, 1, 26, -7, 27, 2, 3, 4, 5,
752 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
753 16, 17, 18, 54, 55, 56, 57, 58, 28, 59,
754 60, 99, 100, 29, 19, 106, 30, 31, 107, 108,
755 32, 109, 20, 33, 110, 111, 34, 35, 36, 41,
756 43, 76, 42, 0, 0, 116, 2, 3, 4, 5,
757 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
758 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
759 0, 0, 0, 0, 19, 0, 0, 0, 0, 0,
760 0, 0, 20, 6, 7, 8, 9, 10, 11, 12,
761 13, 14, 15, 16, 17, 38, 0, 0, 0, 0,
762 0, 0, 0, 0, 0, 0, 0, 19, 0, 0,
763 0, 0, 0, 0, 0, 20, 44, 45, 46, 47,
764 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
765 58, 0, 59, 60, 0, 0, 0, 94, 44, 45,
766 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
767 56, 57, 58, 0, 59, 60, 0, 0, 0, 98,
768 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
769 54, 55, 56, 57, 58, 0, 59, 60, 0, 0,
770 0, 103, 44, 45, 46, 47, 48, 49, 50, 51,
771 52, 53, 54, 55, 56, 57, 58, 0, 59, 60,
772 0, 0, 0, 104, 44, 45, 46, 47, 48, 49,
773 50, 51, 52, 53, 54, 55, 56, 57, 58, 0,
774 59, 60, 0, 0, 0, 114, 44, 45, 46, 47,
775 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
776 58, 0, 59, 60, 0, 0, 75, 44, 45, 46,
777 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
778 57, 58, 0, 59, 60, 0, 0, 93, 44, 45,
779 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
780 56, 57, 58, 0, 59, 60, 0, 0, 95, 44,
781 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
782 55, 56, 57, 58, 0, 59, 60, 0, 0, 101,
783 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
784 54, 55, 56, 57, 58, 0, 59, 60, 0, 0,
785 102, 44, 45, 46, 47, 48, 49, 50, 51, 52,
786 53, 54, 55, 56, 57, 58, 0, 59, 60, 0,
787 0, 105, 44, 45, 46, 47, 48, 49, 50, 51,
788 52, 53, 54, 55, 56, 57, 58, 0, 59, 60,
789 0, 0, 112, 44, 45, 46, 47, 48, 49, 50,
790 51, 52, 53, 54, 55, 56, 57, 58, 0, 59,
791 60, 0, 0, 113, 44, 45, 46, 47, 48, 49,
792 50, 51, 52, 53, 54, 55, 56, 57, 58, 0,
793 59, 60, 0, 0, 115, 44, 45, 46, 47, 48,
794 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
795 0, 59, 60, 0, 0, 117, 44, 45, 46, 47,
796 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
797 58, 0, 59, 60, 45, 46, 47, 48, 49, 50,
798 51, 52, 53, 54, 55, 56, 57, 58, 0, 59,
799 60, 46, 47, 48, 49, 50, 51, 52, 53, 54,
800 55, 56, 57, 58, 0, 59, 60, -8, -8, -8,
801 -8, -8, -8, 52, 53, 54, 55, 56, 57, 58,
805 static const yytype_int8 yycheck[] =
807 19, 20, 38, 39, 42, 43, 3, 26, 27, 28,
808 29, 30, 31, 32, 33, 34, 35, 36, 37, 34,
809 35, 36, 40, 38, 39, 44, 45, 46, 47, 48,
810 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
811 59, 0, 1, 41, 3, 41, 5, 6, 7, 8,
812 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
813 19, 20, 21, 32, 33, 34, 35, 36, 41, 38,
814 39, 42, 43, 41, 33, 94, 41, 41, 97, 98,
815 41, 100, 41, 41, 103, 104, 41, 41, 41, 0,
816 3, 3, 22, -1, -1, 114, 5, 6, 7, 8,
817 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
818 19, 20, 21, -1, -1, -1, -1, -1, -1, -1,
819 -1, -1, -1, -1, 33, -1, -1, -1, -1, -1,
820 -1, -1, 41, 9, 10, 11, 12, 13, 14, 15,
821 16, 17, 18, 19, 20, 21, -1, -1, -1, -1,
822 -1, -1, -1, -1, -1, -1, -1, 33, -1, -1,
823 -1, -1, -1, -1, -1, 41, 22, 23, 24, 25,
824 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
825 36, -1, 38, 39, -1, -1, -1, 43, 22, 23,
826 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
827 34, 35, 36, -1, 38, 39, -1, -1, -1, 43,
828 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
829 32, 33, 34, 35, 36, -1, 38, 39, -1, -1,
830 -1, 43, 22, 23, 24, 25, 26, 27, 28, 29,
831 30, 31, 32, 33, 34, 35, 36, -1, 38, 39,
832 -1, -1, -1, 43, 22, 23, 24, 25, 26, 27,
833 28, 29, 30, 31, 32, 33, 34, 35, 36, -1,
834 38, 39, -1, -1, -1, 43, 22, 23, 24, 25,
835 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
836 36, -1, 38, 39, -1, -1, 42, 22, 23, 24,
837 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
838 35, 36, -1, 38, 39, -1, -1, 42, 22, 23,
839 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
840 34, 35, 36, -1, 38, 39, -1, -1, 42, 22,
841 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
842 33, 34, 35, 36, -1, 38, 39, -1, -1, 42,
843 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
844 32, 33, 34, 35, 36, -1, 38, 39, -1, -1,
845 42, 22, 23, 24, 25, 26, 27, 28, 29, 30,
846 31, 32, 33, 34, 35, 36, -1, 38, 39, -1,
847 -1, 42, 22, 23, 24, 25, 26, 27, 28, 29,
848 30, 31, 32, 33, 34, 35, 36, -1, 38, 39,
849 -1, -1, 42, 22, 23, 24, 25, 26, 27, 28,
850 29, 30, 31, 32, 33, 34, 35, 36, -1, 38,
851 39, -1, -1, 42, 22, 23, 24, 25, 26, 27,
852 28, 29, 30, 31, 32, 33, 34, 35, 36, -1,
853 38, 39, -1, -1, 42, 22, 23, 24, 25, 26,
854 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
855 -1, 38, 39, -1, -1, 42, 22, 23, 24, 25,
856 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
857 36, -1, 38, 39, 23, 24, 25, 26, 27, 28,
858 29, 30, 31, 32, 33, 34, 35, 36, -1, 38,
859 39, 24, 25, 26, 27, 28, 29, 30, 31, 32,
860 33, 34, 35, 36, -1, 38, 39, 24, 25, 26,
861 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
865 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
866 symbol of state STATE-NUM. */
867 static const yytype_uint8 yystos[] =
869 0, 1, 5, 6, 7, 8, 9, 10, 11, 12,
870 13, 14, 15, 16, 17, 18, 19, 20, 21, 33,
871 41, 45, 46, 47, 48, 3, 41, 41, 41, 41,
872 41, 41, 41, 41, 41, 41, 41, 40, 21, 48,
873 48, 0, 47, 3, 22, 23, 24, 25, 26, 27,
874 28, 29, 30, 31, 32, 33, 34, 35, 36, 38,
875 39, 48, 48, 48, 48, 49, 48, 48, 50, 48,
876 48, 48, 48, 48, 48, 42, 3, 48, 48, 48,
877 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
878 48, 48, 48, 42, 43, 42, 42, 43, 43, 42,
879 43, 42, 42, 43, 43, 42, 48, 48, 48, 48,
880 48, 48, 42, 42, 43, 42, 48, 42
883 #define yyerrok (yyerrstatus = 0)
884 #define yyclearin (yychar = YYEMPTY)
888 #define YYACCEPT goto yyacceptlab
889 #define YYABORT goto yyabortlab
890 #define YYERROR goto yyerrorlab
893 /* Like YYERROR except do call yyerror. This remains here temporarily
894 to ease the transition to the new meaning of YYERROR, for GCC.
895 Once GCC version 2 has supplanted version 1, this can go. */
897 #define YYFAIL goto yyerrlab
899 #define YYRECOVERING() (!!yyerrstatus)
901 #define YYBACKUP(Token, Value) \
903 if (yychar == YYEMPTY && yylen == 1) \
907 yytoken = YYTRANSLATE (yychar); \
913 yyerror (YY_("syntax error: cannot back up")); \
920 #define YYERRCODE 256
923 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
924 If N is 0, then set CURRENT to the empty location which ends
925 the previous symbol: RHS[0] (always defined). */
927 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
928 #ifndef YYLLOC_DEFAULT
929 # define YYLLOC_DEFAULT(Current, Rhs, N) \
933 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
934 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
935 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
936 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
940 (Current).first_line = (Current).last_line = \
941 YYRHSLOC (Rhs, 0).last_line; \
942 (Current).first_column = (Current).last_column = \
943 YYRHSLOC (Rhs, 0).last_column; \
949 /* YY_LOCATION_PRINT -- Print the location on the stream.
950 This macro was not mandated originally: define only if we know
951 we won't break user code: when these are the locations we know. */
953 #ifndef YY_LOCATION_PRINT
954 # if YYLTYPE_IS_TRIVIAL
955 # define YY_LOCATION_PRINT(File, Loc) \
956 fprintf (File, "%d.%d-%d.%d", \
957 (Loc).first_line, (Loc).first_column, \
958 (Loc).last_line, (Loc).last_column)
960 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
965 /* YYLEX -- calling `yylex' with the right arguments. */
968 # define YYLEX yylex (YYLEX_PARAM)
970 # define YYLEX yylex ()
973 /* Enable debugging if requested. */
977 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
978 # define YYFPRINTF fprintf
981 # define YYDPRINTF(Args) \
987 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
991 YYFPRINTF (stderr, "%s ", Title); \
992 yy_symbol_print (stderr, \
994 YYFPRINTF (stderr, "\n"); \
999 /*--------------------------------.
1000 | Print this symbol on YYOUTPUT. |
1001 `--------------------------------*/
1004 #if (defined __STDC__ || defined __C99__FUNC__ \
1005 || defined __cplusplus || defined _MSC_VER)
1007 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1010 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1013 YYSTYPE const * const yyvaluep;
1019 if (yytype < YYNTOKENS)
1020 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1032 /*--------------------------------.
1033 | Print this symbol on YYOUTPUT. |
1034 `--------------------------------*/
1036 #if (defined __STDC__ || defined __C99__FUNC__ \
1037 || defined __cplusplus || defined _MSC_VER)
1039 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1042 yy_symbol_print (yyoutput, yytype, yyvaluep)
1045 YYSTYPE const * const yyvaluep;
1048 if (yytype < YYNTOKENS)
1049 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1051 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1053 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1054 YYFPRINTF (yyoutput, ")");
1057 /*------------------------------------------------------------------.
1058 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1060 `------------------------------------------------------------------*/
1062 #if (defined __STDC__ || defined __C99__FUNC__ \
1063 || defined __cplusplus || defined _MSC_VER)
1065 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1068 yy_stack_print (yybottom, yytop)
1069 yytype_int16 *yybottom;
1070 yytype_int16 *yytop;
1073 YYFPRINTF (stderr, "Stack now");
1074 for (; yybottom <= yytop; yybottom++)
1076 int yybot = *yybottom;
1077 YYFPRINTF (stderr, " %d", yybot);
1079 YYFPRINTF (stderr, "\n");
1082 # define YY_STACK_PRINT(Bottom, Top) \
1085 yy_stack_print ((Bottom), (Top)); \
1089 /*------------------------------------------------.
1090 | Report that the YYRULE is going to be reduced. |
1091 `------------------------------------------------*/
1093 #if (defined __STDC__ || defined __C99__FUNC__ \
1094 || defined __cplusplus || defined _MSC_VER)
1096 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1099 yy_reduce_print (yyvsp, yyrule)
1104 int yynrhs = yyr2[yyrule];
1106 unsigned long int yylno = yyrline[yyrule];
1107 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1109 /* The symbols being reduced. */
1110 for (yyi = 0; yyi < yynrhs; yyi++)
1112 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1113 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1114 &(yyvsp[(yyi + 1) - (yynrhs)])
1116 YYFPRINTF (stderr, "\n");
1120 # define YY_REDUCE_PRINT(Rule) \
1123 yy_reduce_print (yyvsp, Rule); \
1126 /* Nonzero means print parse trace. It is left uninitialized so that
1127 multiple parsers can coexist. */
1129 #else /* !YYDEBUG */
1130 # define YYDPRINTF(Args)
1131 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1132 # define YY_STACK_PRINT(Bottom, Top)
1133 # define YY_REDUCE_PRINT(Rule)
1134 #endif /* !YYDEBUG */
1137 /* YYINITDEPTH -- initial size of the parser's stacks. */
1139 # define YYINITDEPTH 200
1142 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1143 if the built-in stack extension method is used).
1145 Do not make this value too large; the results are undefined if
1146 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1147 evaluated with infinite-precision integer arithmetic. */
1150 # define YYMAXDEPTH 10000
1158 # if defined __GLIBC__ && defined _STRING_H
1159 # define yystrlen strlen
1161 /* Return the length of YYSTR. */
1162 #if (defined __STDC__ || defined __C99__FUNC__ \
1163 || defined __cplusplus || defined _MSC_VER)
1165 yystrlen (const char *yystr)
1173 for (yylen = 0; yystr[yylen]; yylen++)
1181 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1182 # define yystpcpy stpcpy
1184 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1186 #if (defined __STDC__ || defined __C99__FUNC__ \
1187 || defined __cplusplus || defined _MSC_VER)
1189 yystpcpy (char *yydest, const char *yysrc)
1192 yystpcpy (yydest, yysrc)
1198 const char *yys = yysrc;
1200 while ((*yyd++ = *yys++) != '\0')
1209 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1210 quotes and backslashes, so that it's suitable for yyerror. The
1211 heuristic is that double-quoting is unnecessary unless the string
1212 contains an apostrophe, a comma, or backslash (other than
1213 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1214 null, do not copy; instead, return the length of what the result
1217 yytnamerr (char *yyres, const char *yystr)
1222 char const *yyp = yystr;
1229 goto do_not_strip_quotes;
1233 goto do_not_strip_quotes;
1246 do_not_strip_quotes: ;
1250 return yystrlen (yystr);
1252 return yystpcpy (yyres, yystr) - yyres;
1256 /* Copy into YYRESULT an error message about the unexpected token
1257 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1258 including the terminating null byte. If YYRESULT is null, do not
1259 copy anything; just return the number of bytes that would be
1260 copied. As a special case, return 0 if an ordinary "syntax error"
1261 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1262 size calculation. */
1264 yysyntax_error (char *yyresult, int yystate, int yychar)
1266 int yyn = yypact[yystate];
1268 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1272 int yytype = YYTRANSLATE (yychar);
1273 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1274 YYSIZE_T yysize = yysize0;
1276 int yysize_overflow = 0;
1277 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1278 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1282 /* This is so xgettext sees the translatable formats that are
1283 constructed on the fly. */
1284 YY_("syntax error, unexpected %s");
1285 YY_("syntax error, unexpected %s, expecting %s");
1286 YY_("syntax error, unexpected %s, expecting %s or %s");
1287 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1288 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1292 static char const yyunexpected[] = "syntax error, unexpected %s";
1293 static char const yyexpecting[] = ", expecting %s";
1294 static char const yyor[] = " or %s";
1295 char yyformat[sizeof yyunexpected
1296 + sizeof yyexpecting - 1
1297 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1298 * (sizeof yyor - 1))];
1299 char const *yyprefix = yyexpecting;
1301 /* Start YYX at -YYN if negative to avoid negative indexes in
1303 int yyxbegin = yyn < 0 ? -yyn : 0;
1305 /* Stay within bounds of both yycheck and yytname. */
1306 int yychecklim = YYLAST - yyn + 1;
1307 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1310 yyarg[0] = yytname[yytype];
1311 yyfmt = yystpcpy (yyformat, yyunexpected);
1313 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1314 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1316 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1320 yyformat[sizeof yyunexpected - 1] = '\0';
1323 yyarg[yycount++] = yytname[yyx];
1324 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1325 yysize_overflow |= (yysize1 < yysize);
1327 yyfmt = yystpcpy (yyfmt, yyprefix);
1331 yyf = YY_(yyformat);
1332 yysize1 = yysize + yystrlen (yyf);
1333 yysize_overflow |= (yysize1 < yysize);
1336 if (yysize_overflow)
1337 return YYSIZE_MAXIMUM;
1341 /* Avoid sprintf, as that infringes on the user's name space.
1342 Don't have undefined behavior even if the translation
1343 produced a string with the wrong number of "%s"s. */
1344 char *yyp = yyresult;
1346 while ((*yyp = *yyf) != '\0')
1348 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1350 yyp += yytnamerr (yyp, yyarg[yyi++]);
1363 #endif /* YYERROR_VERBOSE */
1366 /*-----------------------------------------------.
1367 | Release the memory associated to this symbol. |
1368 `-----------------------------------------------*/
1371 #if (defined __STDC__ || defined __C99__FUNC__ \
1372 || defined __cplusplus || defined _MSC_VER)
1374 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1377 yydestruct (yymsg, yytype, yyvaluep)
1387 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1397 /* Prevent warnings from -Wmissing-prototypes. */
1398 #ifdef YYPARSE_PARAM
1399 #if defined __STDC__ || defined __cplusplus
1400 int yyparse (void *YYPARSE_PARAM);
1404 #else /* ! YYPARSE_PARAM */
1405 #if defined __STDC__ || defined __cplusplus
1410 #endif /* ! YYPARSE_PARAM */
1413 /* The lookahead symbol. */
1416 /* The semantic value of the lookahead symbol. */
1419 /* Number of syntax errors so far. */
1424 /*-------------------------.
1425 | yyparse or yypush_parse. |
1426 `-------------------------*/
1428 #ifdef YYPARSE_PARAM
1429 #if (defined __STDC__ || defined __C99__FUNC__ \
1430 || defined __cplusplus || defined _MSC_VER)
1432 yyparse (void *YYPARSE_PARAM)
1435 yyparse (YYPARSE_PARAM)
1436 void *YYPARSE_PARAM;
1438 #else /* ! YYPARSE_PARAM */
1439 #if (defined __STDC__ || defined __C99__FUNC__ \
1440 || defined __cplusplus || defined _MSC_VER)
1453 /* Number of tokens to shift before error messages enabled. */
1456 /* The stacks and their tools:
1457 `yyss': related to states.
1458 `yyvs': related to semantic values.
1460 Refer to the stacks thru separate pointers, to allow yyoverflow
1461 to reallocate them elsewhere. */
1463 /* The state stack. */
1464 yytype_int16 yyssa[YYINITDEPTH];
1466 yytype_int16 *yyssp;
1468 /* The semantic value stack. */
1469 YYSTYPE yyvsa[YYINITDEPTH];
1473 YYSIZE_T yystacksize;
1477 /* Lookahead token as an internal (translated) token number. */
1479 /* The variables used to return semantic value and location from the
1484 /* Buffer for error messages, and its allocated size. */
1486 char *yymsg = yymsgbuf;
1487 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1490 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1492 /* The number of symbols on the RHS of the reduced rule.
1493 Keep to zero when no symbol should be popped. */
1499 yystacksize = YYINITDEPTH;
1501 YYDPRINTF ((stderr, "Starting parse\n"));
1506 yychar = YYEMPTY; /* Cause a token to be read. */
1508 /* Initialize stack pointers.
1509 Waste one element of value and location stack
1510 so that they stay on the same level as the state stack.
1511 The wasted elements are never initialized. */
1517 /*------------------------------------------------------------.
1518 | yynewstate -- Push a new state, which is found in yystate. |
1519 `------------------------------------------------------------*/
1521 /* In all cases, when you get here, the value and location stacks
1522 have just been pushed. So pushing a state here evens the stacks. */
1528 if (yyss + yystacksize - 1 <= yyssp)
1530 /* Get the current used size of the three stacks, in elements. */
1531 YYSIZE_T yysize = yyssp - yyss + 1;
1535 /* Give user a chance to reallocate the stack. Use copies of
1536 these so that the &'s don't force the real ones into
1538 YYSTYPE *yyvs1 = yyvs;
1539 yytype_int16 *yyss1 = yyss;
1541 /* Each stack pointer address is followed by the size of the
1542 data in use in that stack, in bytes. This used to be a
1543 conditional around just the two extra args, but that might
1544 be undefined if yyoverflow is a macro. */
1545 yyoverflow (YY_("memory exhausted"),
1546 &yyss1, yysize * sizeof (*yyssp),
1547 &yyvs1, yysize * sizeof (*yyvsp),
1553 #else /* no yyoverflow */
1554 # ifndef YYSTACK_RELOCATE
1555 goto yyexhaustedlab;
1557 /* Extend the stack our own way. */
1558 if (YYMAXDEPTH <= yystacksize)
1559 goto yyexhaustedlab;
1561 if (YYMAXDEPTH < yystacksize)
1562 yystacksize = YYMAXDEPTH;
1565 yytype_int16 *yyss1 = yyss;
1566 union yyalloc *yyptr =
1567 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1569 goto yyexhaustedlab;
1570 YYSTACK_RELOCATE (yyss_alloc, yyss);
1571 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1572 # undef YYSTACK_RELOCATE
1574 YYSTACK_FREE (yyss1);
1577 #endif /* no yyoverflow */
1579 yyssp = yyss + yysize - 1;
1580 yyvsp = yyvs + yysize - 1;
1582 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1583 (unsigned long int) yystacksize));
1585 if (yyss + yystacksize - 1 <= yyssp)
1589 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1591 if (yystate == YYFINAL)
1601 /* Do appropriate processing given the current state. Read a
1602 lookahead token if we need one and don't already have one. */
1604 /* First try to decide what to do without reference to lookahead token. */
1605 yyn = yypact[yystate];
1606 if (yyn == YYPACT_NINF)
1609 /* Not known => get a lookahead token if don't already have one. */
1611 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1612 if (yychar == YYEMPTY)
1614 YYDPRINTF ((stderr, "Reading a token: "));
1618 if (yychar <= YYEOF)
1620 yychar = yytoken = YYEOF;
1621 YYDPRINTF ((stderr, "Now at end of input.\n"));
1625 yytoken = YYTRANSLATE (yychar);
1626 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1629 /* If the proper action on seeing token YYTOKEN is to reduce or to
1630 detect an error, take that action. */
1632 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1637 if (yyn == 0 || yyn == YYTABLE_NINF)
1643 /* Count tokens shifted since error; after three, turn off error
1648 /* Shift the lookahead token. */
1649 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1651 /* Discard the shifted token. */
1660 /*-----------------------------------------------------------.
1661 | yydefault -- do the default action for the current state. |
1662 `-----------------------------------------------------------*/
1664 yyn = yydefact[yystate];
1670 /*-----------------------------.
1671 | yyreduce -- Do a reduction. |
1672 `-----------------------------*/
1674 /* yyn is the number of a rule to reduce with. */
1677 /* If YYLEN is nonzero, implement the default value of the action:
1680 Otherwise, the following line sets YYVAL to garbage.
1681 This behavior is undocumented and Bison
1682 users should not rely upon it. Assigning to YYVAL
1683 unconditionally makes the parser a bit smaller, and it avoids a
1684 GCC warning that YYVAL may be used uninitialized. */
1685 yyval = yyvsp[1-yylen];
1688 YY_REDUCE_PRINT (yyn);
1693 /* Line 1455 of yacc.c */
1695 { sp = stack[0]; yyerrok; }
1700 /* Line 1455 of yacc.c */
1703 mpz_out_str (stdout, obase, sp); putchar ('\n');
1711 /* Line 1455 of yacc.c */
1714 CHECK_VARIABLE ((yyvsp[(1) - (3)].var));
1715 mpz_swap (variable[(yyvsp[(1) - (3)].var)], sp);
1723 /* Line 1455 of yacc.c */
1730 /* Line 1455 of yacc.c */
1732 { ibase = 16; obase = -16; }
1737 /* Line 1455 of yacc.c */
1739 { ibase = 0; obase = 10; }
1744 /* Line 1455 of yacc.c */
1751 /* Line 1455 of yacc.c */
1753 { sp--; mpz_add (sp, sp, sp+1); }
1758 /* Line 1455 of yacc.c */
1760 { sp--; mpz_sub (sp, sp, sp+1); }
1765 /* Line 1455 of yacc.c */
1767 { sp--; mpz_mul (sp, sp, sp+1); }
1772 /* Line 1455 of yacc.c */
1774 { sp--; mpz_fdiv_q (sp, sp, sp+1); }
1779 /* Line 1455 of yacc.c */
1781 { sp--; mpz_fdiv_r (sp, sp, sp+1); }
1786 /* Line 1455 of yacc.c */
1788 { CHECK_UI ("Exponent", sp);
1789 sp--; mpz_pow_ui (sp, sp, mpz_get_ui (sp+1)); }
1794 /* Line 1455 of yacc.c */
1796 { CHECK_UI ("Shift count", sp);
1797 sp--; mpz_mul_2exp (sp, sp, mpz_get_ui (sp+1)); }
1802 /* Line 1455 of yacc.c */
1804 { CHECK_UI ("Shift count", sp);
1805 sp--; mpz_fdiv_q_2exp (sp, sp, mpz_get_ui (sp+1)); }
1810 /* Line 1455 of yacc.c */
1812 { CHECK_UI ("Factorial", sp);
1813 mpz_fac_ui (sp, mpz_get_ui (sp)); }
1818 /* Line 1455 of yacc.c */
1820 { mpz_neg (sp, sp); }
1825 /* Line 1455 of yacc.c */
1827 { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) < 0); }
1832 /* Line 1455 of yacc.c */
1834 { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <= 0); }
1839 /* Line 1455 of yacc.c */
1841 { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) == 0); }
1846 /* Line 1455 of yacc.c */
1848 { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) != 0); }
1853 /* Line 1455 of yacc.c */
1855 { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >= 0); }
1860 /* Line 1455 of yacc.c */
1862 { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) > 0); }
1867 /* Line 1455 of yacc.c */
1869 { sp--; mpz_set_ui (sp, mpz_sgn (sp) && mpz_sgn (sp+1)); }
1874 /* Line 1455 of yacc.c */
1876 { sp--; mpz_set_ui (sp, mpz_sgn (sp) || mpz_sgn (sp+1)); }
1881 /* Line 1455 of yacc.c */
1883 { mpz_abs (sp, sp); }
1888 /* Line 1455 of yacc.c */
1890 { sp--; CHECK_UI ("Binomial base", sp+1);
1891 mpz_bin_ui (sp, sp, mpz_get_ui (sp+1)); }
1896 /* Line 1455 of yacc.c */
1898 { CHECK_UI ("Fibonacci", sp);
1899 mpz_fib_ui (sp, mpz_get_ui (sp)); }
1904 /* Line 1455 of yacc.c */
1906 { sp--; mpz_set_si (sp,
1907 mpz_kronecker (sp, sp+1)); }
1912 /* Line 1455 of yacc.c */
1914 { CHECK_UI ("Lucas number", sp);
1915 mpz_lucnum_ui (sp, mpz_get_ui (sp)); }
1920 /* Line 1455 of yacc.c */
1922 { mpz_nextprime (sp, sp); }
1927 /* Line 1455 of yacc.c */
1929 { sp -= 2; mpz_powm (sp, sp, sp+1, sp+2); }
1934 /* Line 1455 of yacc.c */
1936 { sp--; CHECK_UI ("Nth-root", sp+1);
1937 mpz_root (sp, sp, mpz_get_ui (sp+1)); }
1942 /* Line 1455 of yacc.c */
1944 { mpz_sqrt (sp, sp); }
1949 /* Line 1455 of yacc.c */
1954 CHECK_VARIABLE ((yyvsp[(1) - (1)].var));
1955 mpz_set (sp, variable[(yyvsp[(1) - (1)].var)]);
1961 /* Line 1455 of yacc.c */
1966 if (mpz_set_str (sp, (yyvsp[(1) - (1)].str), ibase) != 0)
1968 fprintf (stderr, "Invalid number: %s\n", (yyvsp[(1) - (1)].str));
1976 /* Line 1455 of yacc.c */
1978 { sp--; mpz_gcd (sp, sp, sp+1); }
1983 /* Line 1455 of yacc.c */
1985 { sp--; mpz_lcm (sp, sp, sp+1); }
1990 /* Line 1455 of yacc.c */
1994 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1998 YY_STACK_PRINT (yyss, yyssp);
2002 /* Now `shift' the result of the reduction. Determine what state
2003 that goes to, based on the state we popped back to and the rule
2004 number reduced by. */
2008 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2009 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2010 yystate = yytable[yystate];
2012 yystate = yydefgoto[yyn - YYNTOKENS];
2017 /*------------------------------------.
2018 | yyerrlab -- here on detecting error |
2019 `------------------------------------*/
2021 /* If not already recovering from an error, report this error. */
2025 #if ! YYERROR_VERBOSE
2026 yyerror (YY_("syntax error"));
2029 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2030 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2032 YYSIZE_T yyalloc = 2 * yysize;
2033 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2034 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2035 if (yymsg != yymsgbuf)
2036 YYSTACK_FREE (yymsg);
2037 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2039 yymsg_alloc = yyalloc;
2043 yymsg_alloc = sizeof yymsgbuf;
2047 if (0 < yysize && yysize <= yymsg_alloc)
2049 (void) yysyntax_error (yymsg, yystate, yychar);
2054 yyerror (YY_("syntax error"));
2056 goto yyexhaustedlab;
2064 if (yyerrstatus == 3)
2066 /* If just tried and failed to reuse lookahead token after an
2067 error, discard it. */
2069 if (yychar <= YYEOF)
2071 /* Return failure if at end of input. */
2072 if (yychar == YYEOF)
2077 yydestruct ("Error: discarding",
2083 /* Else will try to reuse lookahead token after shifting the error
2088 /*---------------------------------------------------.
2089 | yyerrorlab -- error raised explicitly by YYERROR. |
2090 `---------------------------------------------------*/
2093 /* Pacify compilers like GCC when the user code never invokes
2094 YYERROR and the label yyerrorlab therefore never appears in user
2096 if (/*CONSTCOND*/ 0)
2099 /* Do not reclaim the symbols of the rule which action triggered
2103 YY_STACK_PRINT (yyss, yyssp);
2108 /*-------------------------------------------------------------.
2109 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2110 `-------------------------------------------------------------*/
2112 yyerrstatus = 3; /* Each real token shifted decrements this. */
2116 yyn = yypact[yystate];
2117 if (yyn != YYPACT_NINF)
2120 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2128 /* Pop the current state because it cannot handle the error token. */
2133 yydestruct ("Error: popping",
2134 yystos[yystate], yyvsp);
2137 YY_STACK_PRINT (yyss, yyssp);
2143 /* Shift the error token. */
2144 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2150 /*-------------------------------------.
2151 | yyacceptlab -- YYACCEPT comes here. |
2152 `-------------------------------------*/
2157 /*-----------------------------------.
2158 | yyabortlab -- YYABORT comes here. |
2159 `-----------------------------------*/
2164 #if !defined(yyoverflow) || YYERROR_VERBOSE
2165 /*-------------------------------------------------.
2166 | yyexhaustedlab -- memory exhaustion comes here. |
2167 `-------------------------------------------------*/
2169 yyerror (YY_("memory exhausted"));
2175 if (yychar != YYEMPTY)
2176 yydestruct ("Cleanup: discarding lookahead",
2178 /* Do not reclaim the symbols of the rule which action triggered
2179 this YYABORT or YYACCEPT. */
2181 YY_STACK_PRINT (yyss, yyssp);
2182 while (yyssp != yyss)
2184 yydestruct ("Cleanup: popping",
2185 yystos[*yyssp], yyvsp);
2190 YYSTACK_FREE (yyss);
2193 if (yymsg != yymsgbuf)
2194 YYSTACK_FREE (yymsg);
2196 /* Make sure YYID is used. */
2197 return YYID (yyresult);
2202 /* Line 1675 of yacc.c */
2208 fprintf (stderr, "%s\n", s);
2211 int calc_option_readline = -1;
2214 main (int argc, char *argv[])
2218 for (i = 1; i < argc; i++)
2220 if (strcmp (argv[i], "--readline") == 0)
2221 calc_option_readline = 1;
2222 else if (strcmp (argv[i], "--noreadline") == 0)
2223 calc_option_readline = 0;
2224 else if (strcmp (argv[i], "--help") == 0)
2226 printf ("Usage: calc [--option]...\n");
2227 printf (" --readline use readline\n");
2228 printf (" --noreadline don't use readline\n");
2229 printf (" --help this message\n");
2230 printf ("Readline is only available when compiled in,\n");
2231 printf ("and in that case it's the default on a tty.\n");
2236 fprintf (stderr, "Unrecognised option: %s\n", argv[i]);
2242 calc_init_readline ();
2244 if (calc_option_readline == 1)
2246 fprintf (stderr, "Readline support not available\n");
2251 for (i = 0; i < numberof (variable); i++)
2252 mpz_init (variable[i]);
2254 for (i = 0; i < numberof (stack); i++)
2255 mpz_init (stack[i]);