1 /* A Bison parser, made by GNU Bison 2.7.12-4996.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5       Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29 
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42 
43 /* Identify Bison output.  */
44 #define YYBISON 1
45 
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.7.12-4996"
48 
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers.  */
53 #define YYPURE 0
54 
55 /* Push parsers.  */
56 #define YYPUSH 0
57 
58 /* Pull parsers.  */
59 #define YYPULL 1
60 
61 
62 
63 
64 /* Copy the first part of user declarations.  */
65 /* Line 371 of yacc.c  */
66 #line 1 "../../../gmp/demos/calc/calc.y"
67 
68 /* A simple integer desk calculator using yacc and gmp.
69 
70 Copyright 2000-2002 Free Software Foundation, Inc.
71 
72 This file is part of the GNU MP Library.
73 
74 This program is free software; you can redistribute it and/or modify it under
75 the terms of the GNU General Public License as published by the Free Software
76 Foundation; either version 3 of the License, or (at your option) any later
77 version.
78 
79 This program is distributed in the hope that it will be useful, but WITHOUT ANY
80 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
81 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
82 
83 You should have received a copy of the GNU General Public License along with
84 this program.  If not, see https://www.gnu.org/licenses/.  */
85 
86 
87 /* This is a simple program, meant only to show one way to use GMP for this
88    sort of thing.  There's few features, and error checking is minimal.
89    Standard input is read, calc_help() below shows the inputs accepted.
90 
91    Expressions are evaluated as they're read.  If user defined functions
92    were wanted it'd be necessary to build a parse tree like pexpr.c does, or
93    a list of operations for a stack based evaluator.  That would also make
94    it possible to detect and optimize evaluations "mod m" like pexpr.c does.
95 
96    A stack is used for intermediate values in the expression evaluation,
97    separate from the yacc parser stack.  This is simple, makes error
98    recovery easy, minimizes the junk around mpz calls in the rules, and
99    saves initializing or clearing "mpz_t"s during a calculation.  A
100    disadvantage though is that variables must be copied to the stack to be
101    worked on.  A more sophisticated calculator or language system might be
102    able to avoid that when executing a compiled or semi-compiled form.
103 
104    Avoiding repeated initializing and clearing of "mpz_t"s is important.  In
105    this program the time spent parsing is obviously much greater than any
106    possible saving from this, but a proper calculator or language should
107    take some trouble over it.  Don't be surprised if an init/clear takes 3
108    or more times as long as a 10 limb addition, depending on the system (see
109    the mpz_init_realloc_clear example in tune/README).  */
110 
111 
112 #include <stdio.h>
113 #include <stdlib.h>
114 #include <string.h>
115 #include "gmp.h"
116 #define NO_CALC_H /* because it conflicts with normal calc.c stuff */
117 #include "calc-common.h"
118 
119 
120 #define numberof(x)  (sizeof (x) / sizeof ((x)[0]))
121 
122 
123 void
calc_help(void)124 calc_help (void)
125 {
126   printf ("Examples:\n");
127   printf ("    2+3*4        expressions are evaluated\n");
128   printf ("    x=5^6        variables a to z can be set and used\n");
129   printf ("Operators:\n");
130   printf ("    + - *        arithmetic\n");
131   printf ("    / %%          division and remainder (rounding towards negative infinity)\n");
132   printf ("    ^            exponentiation\n");
133   printf ("    !            factorial\n");
134   printf ("    << >>        left and right shifts\n");
135   printf ("    <= >= >      \\ comparisons, giving 1 if true, 0 if false\n");
136   printf ("    == != <      /\n");
137   printf ("    && ||        logical and/or, giving 1 if true, 0 if false\n");
138   printf ("Functions:\n");
139   printf ("    abs(n)       absolute value\n");
140   printf ("    bin(n,m)     binomial coefficient\n");
141   printf ("    fib(n)       fibonacci number\n");
142   printf ("    gcd(a,b,..)  greatest common divisor\n");
143   printf ("    kron(a,b)    kronecker symbol\n");
144   printf ("    lcm(a,b,..)  least common multiple\n");
145   printf ("    lucnum(n)    lucas number\n");
146   printf ("    nextprime(n) next prime after n\n");
147   printf ("    powm(b,e,m)  modulo powering, b^e%%m\n");
148   printf ("    root(n,r)    r-th root\n");
149   printf ("    sqrt(n)      square root\n");
150   printf ("Other:\n");
151   printf ("    hex          \\ set hex or decimal for input and output\n");
152   printf ("    decimal      /   (\"0x\" can be used for hex too)\n");
153   printf ("    quit         exit program (EOF works too)\n");
154   printf ("    ;            statements are separated with a ; or newline\n");
155   printf ("    \\            continue expressions with \\ before newline\n");
156   printf ("    # xxx        comments are # though to newline\n");
157   printf ("Hex numbers must be entered in upper case, to distinguish them from the\n");
158   printf ("variables a to f (like in bc).\n");
159 }
160 
161 
162 int  ibase = 0;
163 int  obase = 10;
164 
165 
166 /* The stack is a fixed size, which means there's a limit on the nesting
167    allowed in expressions.  A more sophisticated program could let it grow
168    dynamically.  */
169 
170 mpz_t    stack[100];
171 mpz_ptr  sp = stack[0];
172 
173 #define CHECK_OVERFLOW()                                                  \
174   if (sp >= stack[numberof(stack)])	/* FIXME */			\
175     {                                                                     \
176       fprintf (stderr,                                                    \
177                "Value stack overflow, too much nesting in expression\n"); \
178       YYERROR;                                                            \
179     }
180 
181 #define CHECK_EMPTY()                                                   \
182   if (sp != stack[0])                                                   \
183     {                                                                   \
184       fprintf (stderr, "Oops, expected the value stack to be empty\n"); \
185       sp = stack[0];                                                    \
186     }
187 
188 
189 mpz_t  variable[26];
190 
191 #define CHECK_VARIABLE(var)                                             \
192   if ((var) < 0 || (var) >= numberof (variable))                        \
193     {                                                                   \
194       fprintf (stderr, "Oops, bad variable somehow: %d\n", var);        \
195       YYERROR;                                                          \
196     }
197 
198 
199 #define CHECK_UI(name,z)                        \
200   if (! mpz_fits_ulong_p (z))                   \
201     {                                           \
202       fprintf (stderr, "%s too big\n", name);   \
203       YYERROR;                                  \
204     }
205 
206 
207 /* Line 371 of yacc.c  */
208 #line 209 "calc.c"
209 
210 # ifndef YY_NULL
211 #  if defined __cplusplus && 201103L <= __cplusplus
212 #   define YY_NULL nullptr
213 #  else
214 #   define YY_NULL 0
215 #  endif
216 # endif
217 
218 /* Enabling verbose error messages.  */
219 #ifdef YYERROR_VERBOSE
220 # undef YYERROR_VERBOSE
221 # define YYERROR_VERBOSE 1
222 #else
223 # define YYERROR_VERBOSE 0
224 #endif
225 
226 /* In a future release of Bison, this section will be replaced
227    by #include "y.tab.h".  */
228 #ifndef YY_YY_CALC_H_INCLUDED
229 # define YY_YY_CALC_H_INCLUDED
230 /* Enabling traces.  */
231 #ifndef YYDEBUG
232 # define YYDEBUG 0
233 #endif
234 #if YYDEBUG
235 extern int yydebug;
236 #endif
237 
238 /* Tokens.  */
239 #ifndef YYTOKENTYPE
240 # define YYTOKENTYPE
241    /* Put the tokens into the symbol table, so that GDB and other debuggers
242       know about them.  */
243    enum yytokentype {
244      EOS = 258,
245      BAD = 259,
246      HELP = 260,
247      HEX = 261,
248      DECIMAL = 262,
249      QUIT = 263,
250      ABS = 264,
251      BIN = 265,
252      FIB = 266,
253      GCD = 267,
254      KRON = 268,
255      LCM = 269,
256      LUCNUM = 270,
257      NEXTPRIME = 271,
258      POWM = 272,
259      ROOT = 273,
260      SQRT = 274,
261      NUMBER = 275,
262      VARIABLE = 276,
263      LOR = 277,
264      LAND = 278,
265      GE = 279,
266      LE = 280,
267      NE = 281,
268      EQ = 282,
269      RSHIFT = 283,
270      LSHIFT = 284,
271      UMINUS = 285
272    };
273 #endif
274 /* Tokens.  */
275 #define EOS 258
276 #define BAD 259
277 #define HELP 260
278 #define HEX 261
279 #define DECIMAL 262
280 #define QUIT 263
281 #define ABS 264
282 #define BIN 265
283 #define FIB 266
284 #define GCD 267
285 #define KRON 268
286 #define LCM 269
287 #define LUCNUM 270
288 #define NEXTPRIME 271
289 #define POWM 272
290 #define ROOT 273
291 #define SQRT 274
292 #define NUMBER 275
293 #define VARIABLE 276
294 #define LOR 277
295 #define LAND 278
296 #define GE 279
297 #define LE 280
298 #define NE 281
299 #define EQ 282
300 #define RSHIFT 283
301 #define LSHIFT 284
302 #define UMINUS 285
303 
304 
305 
306 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
307 typedef union YYSTYPE
308 {
309 /* Line 387 of yacc.c  */
310 #line 142 "../../../gmp/demos/calc/calc.y"
311 
312   char  *str;
313   int   var;
314 
315 
316 /* Line 387 of yacc.c  */
317 #line 318 "calc.c"
318 } YYSTYPE;
319 # define YYSTYPE_IS_TRIVIAL 1
320 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
321 # define YYSTYPE_IS_DECLARED 1
322 #endif
323 
324 extern YYSTYPE yylval;
325 
326 #ifdef YYPARSE_PARAM
327 #if defined __STDC__ || defined __cplusplus
328 int yyparse (void *YYPARSE_PARAM);
329 #else
330 int yyparse ();
331 #endif
332 #else /* ! YYPARSE_PARAM */
333 #if defined __STDC__ || defined __cplusplus
334 int yyparse (void);
335 #else
336 int yyparse ();
337 #endif
338 #endif /* ! YYPARSE_PARAM */
339 
340 #endif /* !YY_YY_CALC_H_INCLUDED  */
341 
342 /* Copy the second part of user declarations.  */
343 
344 /* Line 390 of yacc.c  */
345 #line 346 "calc.c"
346 
347 #ifdef short
348 # undef short
349 #endif
350 
351 #ifdef YYTYPE_UINT8
352 typedef YYTYPE_UINT8 yytype_uint8;
353 #else
354 typedef unsigned char yytype_uint8;
355 #endif
356 
357 #ifdef YYTYPE_INT8
358 typedef YYTYPE_INT8 yytype_int8;
359 #elif (defined __STDC__ || defined __C99__FUNC__ \
360      || defined __cplusplus || defined _MSC_VER)
361 typedef signed char yytype_int8;
362 #else
363 typedef short int yytype_int8;
364 #endif
365 
366 #ifdef YYTYPE_UINT16
367 typedef YYTYPE_UINT16 yytype_uint16;
368 #else
369 typedef unsigned short int yytype_uint16;
370 #endif
371 
372 #ifdef YYTYPE_INT16
373 typedef YYTYPE_INT16 yytype_int16;
374 #else
375 typedef short int yytype_int16;
376 #endif
377 
378 #ifndef YYSIZE_T
379 # ifdef __SIZE_TYPE__
380 #  define YYSIZE_T __SIZE_TYPE__
381 # elif defined size_t
382 #  define YYSIZE_T size_t
383 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
384      || defined __cplusplus || defined _MSC_VER)
385 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
386 #  define YYSIZE_T size_t
387 # else
388 #  define YYSIZE_T unsigned int
389 # endif
390 #endif
391 
392 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
393 
394 #ifndef YY_
395 # if defined YYENABLE_NLS && YYENABLE_NLS
396 #  if ENABLE_NLS
397 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
398 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
399 #  endif
400 # endif
401 # ifndef YY_
402 #  define YY_(Msgid) Msgid
403 # endif
404 #endif
405 
406 #ifndef __attribute__
407 /* This feature is available in gcc versions 2.5 and later.  */
408 # if (! defined __GNUC__ || __GNUC__ < 2 \
409       || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
410 #  define __attribute__(Spec) /* empty */
411 # endif
412 #endif
413 
414 /* Suppress unused-variable warnings by "using" E.  */
415 #if ! defined lint || defined __GNUC__
416 # define YYUSE(E) ((void) (E))
417 #else
418 # define YYUSE(E) /* empty */
419 #endif
420 
421 
422 /* Identity function, used to suppress warnings about constant conditions.  */
423 #ifndef lint
424 # define YYID(N) (N)
425 #else
426 #if (defined __STDC__ || defined __C99__FUNC__ \
427      || defined __cplusplus || defined _MSC_VER)
428 static int
YYID(int yyi)429 YYID (int yyi)
430 #else
431 static int
432 YYID (yyi)
433     int yyi;
434 #endif
435 {
436   return yyi;
437 }
438 #endif
439 
440 #if ! defined yyoverflow || YYERROR_VERBOSE
441 
442 /* The parser invokes alloca or malloc; define the necessary symbols.  */
443 
444 # ifdef YYSTACK_USE_ALLOCA
445 #  if YYSTACK_USE_ALLOCA
446 #   ifdef __GNUC__
447 #    define YYSTACK_ALLOC __builtin_alloca
448 #   elif defined __BUILTIN_VA_ARG_INCR
449 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
450 #   elif defined _AIX
451 #    define YYSTACK_ALLOC __alloca
452 #   elif defined _MSC_VER
453 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
454 #    define alloca _alloca
455 #   else
456 #    define YYSTACK_ALLOC alloca
457 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
458      || defined __cplusplus || defined _MSC_VER)
459 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
460       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
461 #     ifndef EXIT_SUCCESS
462 #      define EXIT_SUCCESS 0
463 #     endif
464 #    endif
465 #   endif
466 #  endif
467 # endif
468 
469 # ifdef YYSTACK_ALLOC
470    /* Pacify GCC's `empty if-body' warning.  */
471 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
472 #  ifndef YYSTACK_ALLOC_MAXIMUM
473     /* The OS might guarantee only one guard page at the bottom of the stack,
474        and a page size can be as small as 4096 bytes.  So we cannot safely
475        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
476        to allow for a few compiler-allocated temporary stack slots.  */
477 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
478 #  endif
479 # else
480 #  define YYSTACK_ALLOC YYMALLOC
481 #  define YYSTACK_FREE YYFREE
482 #  ifndef YYSTACK_ALLOC_MAXIMUM
483 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
484 #  endif
485 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
486        && ! ((defined YYMALLOC || defined malloc) \
487 	     && (defined YYFREE || defined free)))
488 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
489 #   ifndef EXIT_SUCCESS
490 #    define EXIT_SUCCESS 0
491 #   endif
492 #  endif
493 #  ifndef YYMALLOC
494 #   define YYMALLOC malloc
495 #   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
496      || defined __cplusplus || defined _MSC_VER)
497 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
498 #   endif
499 #  endif
500 #  ifndef YYFREE
501 #   define YYFREE free
502 #   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
503      || defined __cplusplus || defined _MSC_VER)
504 void free (void *); /* INFRINGES ON USER NAME SPACE */
505 #   endif
506 #  endif
507 # endif
508 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
509 
510 
511 #if (! defined yyoverflow \
512      && (! defined __cplusplus \
513 	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
514 
515 /* A type that is properly aligned for any stack member.  */
516 union yyalloc
517 {
518   yytype_int16 yyss_alloc;
519   YYSTYPE yyvs_alloc;
520 };
521 
522 /* The size of the maximum gap between one aligned stack and the next.  */
523 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
524 
525 /* The size of an array large to enough to hold all stacks, each with
526    N elements.  */
527 # define YYSTACK_BYTES(N) \
528      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
529       + YYSTACK_GAP_MAXIMUM)
530 
531 # define YYCOPY_NEEDED 1
532 
533 /* Relocate STACK from its old location to the new one.  The
534    local variables YYSIZE and YYSTACKSIZE give the old and new number of
535    elements in the stack, and YYPTR gives the new location of the
536    stack.  Advance YYPTR to a properly aligned location for the next
537    stack.  */
538 # define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
539     do									\
540       {									\
541 	YYSIZE_T yynewbytes;						\
542 	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
543 	Stack = &yyptr->Stack_alloc;					\
544 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
545 	yyptr += yynewbytes / sizeof (*yyptr);				\
546       }									\
547     while (YYID (0))
548 
549 #endif
550 
551 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
552 /* Copy COUNT objects from SRC to DST.  The source and destination do
553    not overlap.  */
554 # ifndef YYCOPY
555 #  if defined __GNUC__ && 1 < __GNUC__
556 #   define YYCOPY(Dst, Src, Count) \
557       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
558 #  else
559 #   define YYCOPY(Dst, Src, Count)              \
560       do                                        \
561         {                                       \
562           YYSIZE_T yyi;                         \
563           for (yyi = 0; yyi < (Count); yyi++)   \
564             (Dst)[yyi] = (Src)[yyi];            \
565         }                                       \
566       while (YYID (0))
567 #  endif
568 # endif
569 #endif /* !YYCOPY_NEEDED */
570 
571 /* YYFINAL -- State number of the termination state.  */
572 #define YYFINAL  41
573 /* YYLAST -- Last index in YYTABLE.  */
574 #define YYLAST   552
575 
576 /* YYNTOKENS -- Number of terminals.  */
577 #define YYNTOKENS  44
578 /* YYNNTS -- Number of nonterminals.  */
579 #define YYNNTS  7
580 /* YYNRULES -- Number of rules.  */
581 #define YYNRULES  49
582 /* YYNRULES -- Number of states.  */
583 #define YYNSTATES  118
584 
585 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
586 #define YYUNDEFTOK  2
587 #define YYMAXUTOK   285
588 
589 #define YYTRANSLATE(YYX)						\
590   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
591 
592 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
593 static const yytype_uint8 yytranslate[] =
594 {
595        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
596        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
597        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
598        2,     2,     2,    39,     2,     2,     2,    36,     2,     2,
599       41,    42,    34,    32,    43,    33,     2,    35,     2,     2,
600        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
601       24,    40,    25,     2,     2,     2,     2,     2,     2,     2,
602        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
603        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
604        2,     2,     2,     2,    38,     2,     2,     2,     2,     2,
605        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
606        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
607        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
608        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
609        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
610        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
611        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
612        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
613        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
614        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
615        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
616        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
617        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
618        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
619        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
620        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
621        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
622       15,    16,    17,    18,    19,    20,    21,    22,    23,    26,
623       27,    28,    29,    30,    31,    37
624 };
625 
626 #if YYDEBUG
627 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
628    YYRHS.  */
629 static const yytype_uint8 yyprhs[] =
630 {
631        0,     0,     3,     5,     8,    11,    15,    18,    19,    21,
632       25,    27,    29,    31,    33,    37,    41,    45,    49,    53,
633       57,    61,    65,    69,    72,    75,    79,    83,    87,    91,
634       95,    99,   103,   107,   112,   119,   124,   129,   136,   141,
635      146,   151,   160,   167,   172,   174,   176,   178,   182,   184
636 };
637 
638 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
639 static const yytype_int8 yyrhs[] =
640 {
641       45,     0,    -1,    47,    -1,    46,    47,    -1,    47,     3,
642       -1,    46,    47,     3,    -1,     1,     3,    -1,    -1,    48,
643       -1,    21,    40,    48,    -1,     5,    -1,     6,    -1,     7,
644       -1,     8,    -1,    41,    48,    42,    -1,    48,    32,    48,
645       -1,    48,    33,    48,    -1,    48,    34,    48,    -1,    48,
646       35,    48,    -1,    48,    36,    48,    -1,    48,    38,    48,
647       -1,    48,    31,    48,    -1,    48,    30,    48,    -1,    48,
648       39,    -1,    33,    48,    -1,    48,    24,    48,    -1,    48,
649       27,    48,    -1,    48,    29,    48,    -1,    48,    28,    48,
650       -1,    48,    26,    48,    -1,    48,    25,    48,    -1,    48,
651       23,    48,    -1,    48,    22,    48,    -1,     9,    41,    48,
652       42,    -1,    10,    41,    48,    43,    48,    42,    -1,    11,
653       41,    48,    42,    -1,    12,    41,    49,    42,    -1,    13,
654       41,    48,    43,    48,    42,    -1,    14,    41,    50,    42,
655       -1,    15,    41,    48,    42,    -1,    16,    41,    48,    42,
656       -1,    17,    41,    48,    43,    48,    43,    48,    42,    -1,
657       18,    41,    48,    43,    48,    42,    -1,    19,    41,    48,
658       42,    -1,    21,    -1,    20,    -1,    48,    -1,    49,    43,
659       48,    -1,    48,    -1,    50,    43,    48,    -1
660 };
661 
662 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
663 static const yytype_uint16 yyrline[] =
664 {
665        0,   167,   167,   168,   171,   172,   173,   175,   177,   182,
666      188,   189,   190,   191,   197,   198,   199,   200,   201,   202,
667      203,   205,   207,   209,   211,   213,   214,   215,   216,   217,
668      218,   220,   221,   223,   224,   226,   228,   229,   231,   232,
669      234,   235,   236,   238,   240,   246,   257,   258,   261,   262
670 };
671 #endif
672 
673 #if YYDEBUG || YYERROR_VERBOSE || 0
674 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
675    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
676 static const char *const yytname[] =
677 {
678   "$end", "error", "$undefined", "EOS", "BAD", "HELP", "HEX", "DECIMAL",
679   "QUIT", "ABS", "BIN", "FIB", "GCD", "KRON", "LCM", "LUCNUM", "NEXTPRIME",
680   "POWM", "ROOT", "SQRT", "NUMBER", "VARIABLE", "LOR", "LAND", "'<'",
681   "'>'", "GE", "LE", "NE", "EQ", "RSHIFT", "LSHIFT", "'+'", "'-'", "'*'",
682   "'/'", "'%'", "UMINUS", "'^'", "'!'", "'='", "'('", "')'", "','",
683   "$accept", "top", "statements", "statement", "e", "gcdlist", "lcmlist", YY_NULL
684 };
685 #endif
686 
687 # ifdef YYPRINT
688 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
689    token YYLEX-NUM.  */
690 static const yytype_uint16 yytoknum[] =
691 {
692        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
693      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
694      275,   276,   277,   278,    60,    62,   279,   280,   281,   282,
695      283,   284,    43,    45,    42,    47,    37,   285,    94,    33,
696       61,    40,    41,    44
697 };
698 # endif
699 
700 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
701 static const yytype_uint8 yyr1[] =
702 {
703        0,    44,    45,    45,    46,    46,    46,    47,    47,    47,
704       47,    47,    47,    47,    48,    48,    48,    48,    48,    48,
705       48,    48,    48,    48,    48,    48,    48,    48,    48,    48,
706       48,    48,    48,    48,    48,    48,    48,    48,    48,    48,
707       48,    48,    48,    48,    48,    48,    49,    49,    50,    50
708 };
709 
710 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
711 static const yytype_uint8 yyr2[] =
712 {
713        0,     2,     1,     2,     2,     3,     2,     0,     1,     3,
714        1,     1,     1,     1,     3,     3,     3,     3,     3,     3,
715        3,     3,     3,     2,     2,     3,     3,     3,     3,     3,
716        3,     3,     3,     4,     6,     4,     4,     6,     4,     4,
717        4,     8,     6,     4,     1,     1,     1,     3,     1,     3
718 };
719 
720 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
721    Performed when YYTABLE doesn't specify something else to do.  Zero
722    means the default is an error.  */
723 static const yytype_uint8 yydefact[] =
724 {
725        0,     0,    10,    11,    12,    13,     0,     0,     0,     0,
726        0,     0,     0,     0,     0,     0,     0,    45,    44,     0,
727        0,     0,     7,     2,     8,     6,     0,     0,     0,     0,
728        0,     0,     0,     0,     0,     0,     0,     0,    44,    24,
729        0,     1,     3,     4,     0,     0,     0,     0,     0,     0,
730        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
731       23,     0,     0,     0,    46,     0,     0,    48,     0,     0,
732        0,     0,     0,     0,     9,    14,     5,    32,    31,    25,
733       30,    29,    26,    28,    27,    22,    21,    15,    16,    17,
734       18,    19,    20,    33,     0,    35,    36,     0,     0,    38,
735        0,    39,    40,     0,     0,    43,     0,    47,     0,    49,
736        0,     0,    34,    37,     0,    42,     0,    41
737 };
738 
739 /* YYDEFGOTO[NTERM-NUM].  */
740 static const yytype_int8 yydefgoto[] =
741 {
742       -1,    21,    22,    23,    24,    65,    68
743 };
744 
745 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
746    STATE-NUM.  */
747 #define YYPACT_NINF -39
748 static const yytype_int16 yypact[] =
749 {
750       41,     3,   -39,   -39,   -39,   -39,     2,     4,    27,    32,
751       35,    36,    39,    42,    45,    46,    47,   -39,   -18,   124,
752      124,    89,    91,    87,   464,   -39,   124,   124,   124,   124,
753      124,   124,   124,   124,   124,   124,   124,   124,   -39,   -36,
754      254,   -39,    88,   -39,   124,   124,   124,   124,   124,   124,
755      124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
756      -39,   275,   144,   296,   464,   -38,   166,   464,    29,   317,
757      338,   188,   210,   359,   464,   -39,   -39,   481,   497,   513,
758      513,   513,   513,   513,   513,    31,    31,   -15,   -15,   -36,
759      -36,   -36,   -36,   -39,   124,   -39,   -39,   124,   124,   -39,
760      124,   -39,   -39,   124,   124,   -39,   380,   464,   401,   464,
761      232,   422,   -39,   -39,   124,   -39,   443,   -39
762 };
763 
764 /* YYPGOTO[NTERM-NUM].  */
765 static const yytype_int8 yypgoto[] =
766 {
767      -39,   -39,   -39,    70,   -19,   -39,   -39
768 };
769 
770 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
771    positive, shift that token.  If negative, reduce the rule which
772    number is the opposite.  If YYTABLE_NINF, syntax error.  */
773 #define YYTABLE_NINF -8
774 static const yytype_int8 yytable[] =
775 {
776       39,    40,    59,    60,    96,    97,    25,    61,    62,    63,
777       64,    66,    67,    69,    70,    71,    72,    73,    74,    56,
778       57,    58,    37,    59,    60,    77,    78,    79,    80,    81,
779       82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
780       92,    -7,     1,    26,    -7,    27,     2,     3,     4,     5,
781        6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
782       16,    17,    18,    54,    55,    56,    57,    58,    28,    59,
783       60,    99,   100,    29,    19,   106,    30,    31,   107,   108,
784       32,   109,    20,    33,   110,   111,    34,    35,    36,    41,
785       43,    76,    42,     0,     0,   116,     2,     3,     4,     5,
786        6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
787       16,    17,    18,     0,     0,     0,     0,     0,     0,     0,
788        0,     0,     0,     0,    19,     0,     0,     0,     0,     0,
789        0,     0,    20,     6,     7,     8,     9,    10,    11,    12,
790       13,    14,    15,    16,    17,    38,     0,     0,     0,     0,
791        0,     0,     0,     0,     0,     0,     0,    19,     0,     0,
792        0,     0,     0,     0,     0,    20,    44,    45,    46,    47,
793       48,    49,    50,    51,    52,    53,    54,    55,    56,    57,
794       58,     0,    59,    60,     0,     0,     0,    94,    44,    45,
795       46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
796       56,    57,    58,     0,    59,    60,     0,     0,     0,    98,
797       44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
798       54,    55,    56,    57,    58,     0,    59,    60,     0,     0,
799        0,   103,    44,    45,    46,    47,    48,    49,    50,    51,
800       52,    53,    54,    55,    56,    57,    58,     0,    59,    60,
801        0,     0,     0,   104,    44,    45,    46,    47,    48,    49,
802       50,    51,    52,    53,    54,    55,    56,    57,    58,     0,
803       59,    60,     0,     0,     0,   114,    44,    45,    46,    47,
804       48,    49,    50,    51,    52,    53,    54,    55,    56,    57,
805       58,     0,    59,    60,     0,     0,    75,    44,    45,    46,
806       47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
807       57,    58,     0,    59,    60,     0,     0,    93,    44,    45,
808       46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
809       56,    57,    58,     0,    59,    60,     0,     0,    95,    44,
810       45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
811       55,    56,    57,    58,     0,    59,    60,     0,     0,   101,
812       44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
813       54,    55,    56,    57,    58,     0,    59,    60,     0,     0,
814      102,    44,    45,    46,    47,    48,    49,    50,    51,    52,
815       53,    54,    55,    56,    57,    58,     0,    59,    60,     0,
816        0,   105,    44,    45,    46,    47,    48,    49,    50,    51,
817       52,    53,    54,    55,    56,    57,    58,     0,    59,    60,
818        0,     0,   112,    44,    45,    46,    47,    48,    49,    50,
819       51,    52,    53,    54,    55,    56,    57,    58,     0,    59,
820       60,     0,     0,   113,    44,    45,    46,    47,    48,    49,
821       50,    51,    52,    53,    54,    55,    56,    57,    58,     0,
822       59,    60,     0,     0,   115,    44,    45,    46,    47,    48,
823       49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
824        0,    59,    60,     0,     0,   117,    44,    45,    46,    47,
825       48,    49,    50,    51,    52,    53,    54,    55,    56,    57,
826       58,     0,    59,    60,    45,    46,    47,    48,    49,    50,
827       51,    52,    53,    54,    55,    56,    57,    58,     0,    59,
828       60,    46,    47,    48,    49,    50,    51,    52,    53,    54,
829       55,    56,    57,    58,     0,    59,    60,    -8,    -8,    -8,
830       -8,    -8,    -8,    52,    53,    54,    55,    56,    57,    58,
831        0,    59,    60
832 };
833 
834 #define yypact_value_is_default(Yystate) \
835   (!!((Yystate) == (-39)))
836 
837 #define yytable_value_is_error(Yytable_value) \
838   (!!((Yytable_value) == (-8)))
839 
840 static const yytype_int8 yycheck[] =
841 {
842       19,    20,    38,    39,    42,    43,     3,    26,    27,    28,
843       29,    30,    31,    32,    33,    34,    35,    36,    37,    34,
844       35,    36,    40,    38,    39,    44,    45,    46,    47,    48,
845       49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
846       59,     0,     1,    41,     3,    41,     5,     6,     7,     8,
847        9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
848       19,    20,    21,    32,    33,    34,    35,    36,    41,    38,
849       39,    42,    43,    41,    33,    94,    41,    41,    97,    98,
850       41,   100,    41,    41,   103,   104,    41,    41,    41,     0,
851        3,     3,    22,    -1,    -1,   114,     5,     6,     7,     8,
852        9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
853       19,    20,    21,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
854       -1,    -1,    -1,    -1,    33,    -1,    -1,    -1,    -1,    -1,
855       -1,    -1,    41,     9,    10,    11,    12,    13,    14,    15,
856       16,    17,    18,    19,    20,    21,    -1,    -1,    -1,    -1,
857       -1,    -1,    -1,    -1,    -1,    -1,    -1,    33,    -1,    -1,
858       -1,    -1,    -1,    -1,    -1,    41,    22,    23,    24,    25,
859       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
860       36,    -1,    38,    39,    -1,    -1,    -1,    43,    22,    23,
861       24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
862       34,    35,    36,    -1,    38,    39,    -1,    -1,    -1,    43,
863       22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
864       32,    33,    34,    35,    36,    -1,    38,    39,    -1,    -1,
865       -1,    43,    22,    23,    24,    25,    26,    27,    28,    29,
866       30,    31,    32,    33,    34,    35,    36,    -1,    38,    39,
867       -1,    -1,    -1,    43,    22,    23,    24,    25,    26,    27,
868       28,    29,    30,    31,    32,    33,    34,    35,    36,    -1,
869       38,    39,    -1,    -1,    -1,    43,    22,    23,    24,    25,
870       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
871       36,    -1,    38,    39,    -1,    -1,    42,    22,    23,    24,
872       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
873       35,    36,    -1,    38,    39,    -1,    -1,    42,    22,    23,
874       24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
875       34,    35,    36,    -1,    38,    39,    -1,    -1,    42,    22,
876       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
877       33,    34,    35,    36,    -1,    38,    39,    -1,    -1,    42,
878       22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
879       32,    33,    34,    35,    36,    -1,    38,    39,    -1,    -1,
880       42,    22,    23,    24,    25,    26,    27,    28,    29,    30,
881       31,    32,    33,    34,    35,    36,    -1,    38,    39,    -1,
882       -1,    42,    22,    23,    24,    25,    26,    27,    28,    29,
883       30,    31,    32,    33,    34,    35,    36,    -1,    38,    39,
884       -1,    -1,    42,    22,    23,    24,    25,    26,    27,    28,
885       29,    30,    31,    32,    33,    34,    35,    36,    -1,    38,
886       39,    -1,    -1,    42,    22,    23,    24,    25,    26,    27,
887       28,    29,    30,    31,    32,    33,    34,    35,    36,    -1,
888       38,    39,    -1,    -1,    42,    22,    23,    24,    25,    26,
889       27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
890       -1,    38,    39,    -1,    -1,    42,    22,    23,    24,    25,
891       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
892       36,    -1,    38,    39,    23,    24,    25,    26,    27,    28,
893       29,    30,    31,    32,    33,    34,    35,    36,    -1,    38,
894       39,    24,    25,    26,    27,    28,    29,    30,    31,    32,
895       33,    34,    35,    36,    -1,    38,    39,    24,    25,    26,
896       27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
897       -1,    38,    39
898 };
899 
900 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
901    symbol of state STATE-NUM.  */
902 static const yytype_uint8 yystos[] =
903 {
904        0,     1,     5,     6,     7,     8,     9,    10,    11,    12,
905       13,    14,    15,    16,    17,    18,    19,    20,    21,    33,
906       41,    45,    46,    47,    48,     3,    41,    41,    41,    41,
907       41,    41,    41,    41,    41,    41,    41,    40,    21,    48,
908       48,     0,    47,     3,    22,    23,    24,    25,    26,    27,
909       28,    29,    30,    31,    32,    33,    34,    35,    36,    38,
910       39,    48,    48,    48,    48,    49,    48,    48,    50,    48,
911       48,    48,    48,    48,    48,    42,     3,    48,    48,    48,
912       48,    48,    48,    48,    48,    48,    48,    48,    48,    48,
913       48,    48,    48,    42,    43,    42,    42,    43,    43,    42,
914       43,    42,    42,    43,    43,    42,    48,    48,    48,    48,
915       48,    48,    42,    42,    43,    42,    48,    42
916 };
917 
918 #define yyerrok		(yyerrstatus = 0)
919 #define yyclearin	(yychar = YYEMPTY)
920 #define YYEMPTY		(-2)
921 #define YYEOF		0
922 
923 #define YYACCEPT	goto yyacceptlab
924 #define YYABORT		goto yyabortlab
925 #define YYERROR		goto yyerrorlab
926 
927 
928 /* Like YYERROR except do call yyerror.  This remains here temporarily
929    to ease the transition to the new meaning of YYERROR, for GCC.
930    Once GCC version 2 has supplanted version 1, this can go.  However,
931    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
932    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
933    discussed.  */
934 
935 #define YYFAIL		goto yyerrlab
936 #if defined YYFAIL
937   /* This is here to suppress warnings from the GCC cpp's
938      -Wunused-macros.  Normally we don't worry about that warning, but
939      some users do, and we want to make it easy for users to remove
940      YYFAIL uses, which will produce warnings from Bison 2.5.  */
941 #endif
942 
943 #define YYRECOVERING()  (!!yyerrstatus)
944 
945 #define YYBACKUP(Token, Value)                                  \
946 do                                                              \
947   if (yychar == YYEMPTY)                                        \
948     {                                                           \
949       yychar = (Token);                                         \
950       yylval = (Value);                                         \
951       YYPOPSTACK (yylen);                                       \
952       yystate = *yyssp;                                         \
953       goto yybackup;                                            \
954     }                                                           \
955   else                                                          \
956     {                                                           \
957       yyerror (YY_("syntax error: cannot back up")); \
958       YYERROR;							\
959     }								\
960 while (YYID (0))
961 
962 /* Error token number */
963 #define YYTERROR	1
964 #define YYERRCODE	256
965 
966 
967 /* This macro is provided for backward compatibility. */
968 #ifndef YY_LOCATION_PRINT
969 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
970 #endif
971 
972 
973 /* YYLEX -- calling `yylex' with the right arguments.  */
974 #ifdef YYLEX_PARAM
975 # define YYLEX yylex (YYLEX_PARAM)
976 #else
977 # define YYLEX yylex ()
978 #endif
979 
980 /* Enable debugging if requested.  */
981 #if YYDEBUG
982 
983 # ifndef YYFPRINTF
984 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
985 #  define YYFPRINTF fprintf
986 # endif
987 
988 # define YYDPRINTF(Args)			\
989 do {						\
990   if (yydebug)					\
991     YYFPRINTF Args;				\
992 } while (YYID (0))
993 
994 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
995 do {									  \
996   if (yydebug)								  \
997     {									  \
998       YYFPRINTF (stderr, "%s ", Title);					  \
999       yy_symbol_print (stderr,						  \
1000 		  Type, Value); \
1001       YYFPRINTF (stderr, "\n");						  \
1002     }									  \
1003 } while (YYID (0))
1004 
1005 
1006 /*--------------------------------.
1007 | Print this symbol on YYOUTPUT.  |
1008 `--------------------------------*/
1009 
1010 /*ARGSUSED*/
1011 #if (defined __STDC__ || defined __C99__FUNC__ \
1012      || defined __cplusplus || defined _MSC_VER)
1013 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)1014 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1015 #else
1016 static void
1017 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1018     FILE *yyoutput;
1019     int yytype;
1020     YYSTYPE const * const yyvaluep;
1021 #endif
1022 {
1023   FILE *yyo = yyoutput;
1024   YYUSE (yyo);
1025   if (!yyvaluep)
1026     return;
1027 # ifdef YYPRINT
1028   if (yytype < YYNTOKENS)
1029     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1030 # else
1031   YYUSE (yyoutput);
1032 # endif
1033   YYUSE (yytype);
1034 }
1035 
1036 
1037 /*--------------------------------.
1038 | Print this symbol on YYOUTPUT.  |
1039 `--------------------------------*/
1040 
1041 #if (defined __STDC__ || defined __C99__FUNC__ \
1042      || defined __cplusplus || defined _MSC_VER)
1043 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)1044 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1045 #else
1046 static void
1047 yy_symbol_print (yyoutput, yytype, yyvaluep)
1048     FILE *yyoutput;
1049     int yytype;
1050     YYSTYPE const * const yyvaluep;
1051 #endif
1052 {
1053   if (yytype < YYNTOKENS)
1054     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1055   else
1056     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1057 
1058   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1059   YYFPRINTF (yyoutput, ")");
1060 }
1061 
1062 /*------------------------------------------------------------------.
1063 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1064 | TOP (included).                                                   |
1065 `------------------------------------------------------------------*/
1066 
1067 #if (defined __STDC__ || defined __C99__FUNC__ \
1068      || defined __cplusplus || defined _MSC_VER)
1069 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)1070 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1071 #else
1072 static void
1073 yy_stack_print (yybottom, yytop)
1074     yytype_int16 *yybottom;
1075     yytype_int16 *yytop;
1076 #endif
1077 {
1078   YYFPRINTF (stderr, "Stack now");
1079   for (; yybottom <= yytop; yybottom++)
1080     {
1081       int yybot = *yybottom;
1082       YYFPRINTF (stderr, " %d", yybot);
1083     }
1084   YYFPRINTF (stderr, "\n");
1085 }
1086 
1087 # define YY_STACK_PRINT(Bottom, Top)				\
1088 do {								\
1089   if (yydebug)							\
1090     yy_stack_print ((Bottom), (Top));				\
1091 } while (YYID (0))
1092 
1093 
1094 /*------------------------------------------------.
1095 | Report that the YYRULE is going to be reduced.  |
1096 `------------------------------------------------*/
1097 
1098 #if (defined __STDC__ || defined __C99__FUNC__ \
1099      || defined __cplusplus || defined _MSC_VER)
1100 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)1101 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1102 #else
1103 static void
1104 yy_reduce_print (yyvsp, yyrule)
1105     YYSTYPE *yyvsp;
1106     int yyrule;
1107 #endif
1108 {
1109   int yynrhs = yyr2[yyrule];
1110   int yyi;
1111   unsigned long int yylno = yyrline[yyrule];
1112   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1113 	     yyrule - 1, yylno);
1114   /* The symbols being reduced.  */
1115   for (yyi = 0; yyi < yynrhs; yyi++)
1116     {
1117       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1118       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1119 		       &(yyvsp[(yyi + 1) - (yynrhs)])
1120 		       		       );
1121       YYFPRINTF (stderr, "\n");
1122     }
1123 }
1124 
1125 # define YY_REDUCE_PRINT(Rule)		\
1126 do {					\
1127   if (yydebug)				\
1128     yy_reduce_print (yyvsp, Rule); \
1129 } while (YYID (0))
1130 
1131 /* Nonzero means print parse trace.  It is left uninitialized so that
1132    multiple parsers can coexist.  */
1133 int yydebug;
1134 #else /* !YYDEBUG */
1135 # define YYDPRINTF(Args)
1136 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1137 # define YY_STACK_PRINT(Bottom, Top)
1138 # define YY_REDUCE_PRINT(Rule)
1139 #endif /* !YYDEBUG */
1140 
1141 
1142 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1143 #ifndef	YYINITDEPTH
1144 # define YYINITDEPTH 200
1145 #endif
1146 
1147 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1148    if the built-in stack extension method is used).
1149 
1150    Do not make this value too large; the results are undefined if
1151    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1152    evaluated with infinite-precision integer arithmetic.  */
1153 
1154 #ifndef YYMAXDEPTH
1155 # define YYMAXDEPTH 10000
1156 #endif
1157 
1158 
1159 #if YYERROR_VERBOSE
1160 
1161 # ifndef yystrlen
1162 #  if defined __GLIBC__ && defined _STRING_H
1163 #   define yystrlen strlen
1164 #  else
1165 /* Return the length of YYSTR.  */
1166 #if (defined __STDC__ || defined __C99__FUNC__ \
1167      || defined __cplusplus || defined _MSC_VER)
1168 static YYSIZE_T
yystrlen(const char * yystr)1169 yystrlen (const char *yystr)
1170 #else
1171 static YYSIZE_T
1172 yystrlen (yystr)
1173     const char *yystr;
1174 #endif
1175 {
1176   YYSIZE_T yylen;
1177   for (yylen = 0; yystr[yylen]; yylen++)
1178     continue;
1179   return yylen;
1180 }
1181 #  endif
1182 # endif
1183 
1184 # ifndef yystpcpy
1185 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1186 #   define yystpcpy stpcpy
1187 #  else
1188 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1189    YYDEST.  */
1190 #if (defined __STDC__ || defined __C99__FUNC__ \
1191      || defined __cplusplus || defined _MSC_VER)
1192 static char *
yystpcpy(char * yydest,const char * yysrc)1193 yystpcpy (char *yydest, const char *yysrc)
1194 #else
1195 static char *
1196 yystpcpy (yydest, yysrc)
1197     char *yydest;
1198     const char *yysrc;
1199 #endif
1200 {
1201   char *yyd = yydest;
1202   const char *yys = yysrc;
1203 
1204   while ((*yyd++ = *yys++) != '\0')
1205     continue;
1206 
1207   return yyd - 1;
1208 }
1209 #  endif
1210 # endif
1211 
1212 # ifndef yytnamerr
1213 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1214    quotes and backslashes, so that it's suitable for yyerror.  The
1215    heuristic is that double-quoting is unnecessary unless the string
1216    contains an apostrophe, a comma, or backslash (other than
1217    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1218    null, do not copy; instead, return the length of what the result
1219    would have been.  */
1220 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1221 yytnamerr (char *yyres, const char *yystr)
1222 {
1223   if (*yystr == '"')
1224     {
1225       YYSIZE_T yyn = 0;
1226       char const *yyp = yystr;
1227 
1228       for (;;)
1229 	switch (*++yyp)
1230 	  {
1231 	  case '\'':
1232 	  case ',':
1233 	    goto do_not_strip_quotes;
1234 
1235 	  case '\\':
1236 	    if (*++yyp != '\\')
1237 	      goto do_not_strip_quotes;
1238 	    /* Fall through.  */
1239 	  default:
1240 	    if (yyres)
1241 	      yyres[yyn] = *yyp;
1242 	    yyn++;
1243 	    break;
1244 
1245 	  case '"':
1246 	    if (yyres)
1247 	      yyres[yyn] = '\0';
1248 	    return yyn;
1249 	  }
1250     do_not_strip_quotes: ;
1251     }
1252 
1253   if (! yyres)
1254     return yystrlen (yystr);
1255 
1256   return yystpcpy (yyres, yystr) - yyres;
1257 }
1258 # endif
1259 
1260 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1261    about the unexpected token YYTOKEN for the state stack whose top is
1262    YYSSP.
1263 
1264    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1265    not large enough to hold the message.  In that case, also set
1266    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1267    required number of bytes is too large to store.  */
1268 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1269 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1270                 yytype_int16 *yyssp, int yytoken)
1271 {
1272   YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1273   YYSIZE_T yysize = yysize0;
1274   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1275   /* Internationalized format string. */
1276   const char *yyformat = YY_NULL;
1277   /* Arguments of yyformat. */
1278   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1279   /* Number of reported tokens (one for the "unexpected", one per
1280      "expected"). */
1281   int yycount = 0;
1282 
1283   /* There are many possibilities here to consider:
1284      - Assume YYFAIL is not used.  It's too flawed to consider.  See
1285        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1286        for details.  YYERROR is fine as it does not invoke this
1287        function.
1288      - If this state is a consistent state with a default action, then
1289        the only way this function was invoked is if the default action
1290        is an error action.  In that case, don't check for expected
1291        tokens because there are none.
1292      - The only way there can be no lookahead present (in yychar) is if
1293        this state is a consistent state with a default action.  Thus,
1294        detecting the absence of a lookahead is sufficient to determine
1295        that there is no unexpected or expected token to report.  In that
1296        case, just report a simple "syntax error".
1297      - Don't assume there isn't a lookahead just because this state is a
1298        consistent state with a default action.  There might have been a
1299        previous inconsistent state, consistent state with a non-default
1300        action, or user semantic action that manipulated yychar.
1301      - Of course, the expected token list depends on states to have
1302        correct lookahead information, and it depends on the parser not
1303        to perform extra reductions after fetching a lookahead from the
1304        scanner and before detecting a syntax error.  Thus, state merging
1305        (from LALR or IELR) and default reductions corrupt the expected
1306        token list.  However, the list is correct for canonical LR with
1307        one exception: it will still contain any token that will not be
1308        accepted due to an error action in a later state.
1309   */
1310   if (yytoken != YYEMPTY)
1311     {
1312       int yyn = yypact[*yyssp];
1313       yyarg[yycount++] = yytname[yytoken];
1314       if (!yypact_value_is_default (yyn))
1315         {
1316           /* Start YYX at -YYN if negative to avoid negative indexes in
1317              YYCHECK.  In other words, skip the first -YYN actions for
1318              this state because they are default actions.  */
1319           int yyxbegin = yyn < 0 ? -yyn : 0;
1320           /* Stay within bounds of both yycheck and yytname.  */
1321           int yychecklim = YYLAST - yyn + 1;
1322           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1323           int yyx;
1324 
1325           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1326             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1327                 && !yytable_value_is_error (yytable[yyx + yyn]))
1328               {
1329                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1330                   {
1331                     yycount = 1;
1332                     yysize = yysize0;
1333                     break;
1334                   }
1335                 yyarg[yycount++] = yytname[yyx];
1336                 {
1337                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1338                   if (! (yysize <= yysize1
1339                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1340                     return 2;
1341                   yysize = yysize1;
1342                 }
1343               }
1344         }
1345     }
1346 
1347   switch (yycount)
1348     {
1349 # define YYCASE_(N, S)                      \
1350       case N:                               \
1351         yyformat = S;                       \
1352       break
1353       YYCASE_(0, YY_("syntax error"));
1354       YYCASE_(1, YY_("syntax error, unexpected %s"));
1355       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1356       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1357       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1358       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1359 # undef YYCASE_
1360     }
1361 
1362   {
1363     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1364     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1365       return 2;
1366     yysize = yysize1;
1367   }
1368 
1369   if (*yymsg_alloc < yysize)
1370     {
1371       *yymsg_alloc = 2 * yysize;
1372       if (! (yysize <= *yymsg_alloc
1373              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1374         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1375       return 1;
1376     }
1377 
1378   /* Avoid sprintf, as that infringes on the user's name space.
1379      Don't have undefined behavior even if the translation
1380      produced a string with the wrong number of "%s"s.  */
1381   {
1382     char *yyp = *yymsg;
1383     int yyi = 0;
1384     while ((*yyp = *yyformat) != '\0')
1385       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1386         {
1387           yyp += yytnamerr (yyp, yyarg[yyi++]);
1388           yyformat += 2;
1389         }
1390       else
1391         {
1392           yyp++;
1393           yyformat++;
1394         }
1395   }
1396   return 0;
1397 }
1398 #endif /* YYERROR_VERBOSE */
1399 
1400 /*-----------------------------------------------.
1401 | Release the memory associated to this symbol.  |
1402 `-----------------------------------------------*/
1403 
1404 /*ARGSUSED*/
1405 #if (defined __STDC__ || defined __C99__FUNC__ \
1406      || defined __cplusplus || defined _MSC_VER)
1407 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1408 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1409 #else
1410 static void
1411 yydestruct (yymsg, yytype, yyvaluep)
1412     const char *yymsg;
1413     int yytype;
1414     YYSTYPE *yyvaluep;
1415 #endif
1416 {
1417   YYUSE (yyvaluep);
1418 
1419   if (!yymsg)
1420     yymsg = "Deleting";
1421   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1422 
1423   YYUSE (yytype);
1424 }
1425 
1426 
1427 
1428 
1429 /* The lookahead symbol.  */
1430 int yychar;
1431 
1432 
1433 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1434 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1435 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1436 #endif
1437 #ifndef YY_INITIAL_VALUE
1438 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1439 #endif
1440 
1441 /* The semantic value of the lookahead symbol.  */
1442 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1443 
1444 /* Number of syntax errors so far.  */
1445 int yynerrs;
1446 
1447 
1448 /*----------.
1449 | yyparse.  |
1450 `----------*/
1451 
1452 #ifdef YYPARSE_PARAM
1453 #if (defined __STDC__ || defined __C99__FUNC__ \
1454      || defined __cplusplus || defined _MSC_VER)
1455 int
yyparse(void * YYPARSE_PARAM)1456 yyparse (void *YYPARSE_PARAM)
1457 #else
1458 int
1459 yyparse (YYPARSE_PARAM)
1460     void *YYPARSE_PARAM;
1461 #endif
1462 #else /* ! YYPARSE_PARAM */
1463 #if (defined __STDC__ || defined __C99__FUNC__ \
1464      || defined __cplusplus || defined _MSC_VER)
1465 int
1466 yyparse (void)
1467 #else
1468 int
1469 yyparse ()
1470 
1471 #endif
1472 #endif
1473 {
1474     int yystate;
1475     /* Number of tokens to shift before error messages enabled.  */
1476     int yyerrstatus;
1477 
1478     /* The stacks and their tools:
1479        `yyss': related to states.
1480        `yyvs': related to semantic values.
1481 
1482        Refer to the stacks through separate pointers, to allow yyoverflow
1483        to reallocate them elsewhere.  */
1484 
1485     /* The state stack.  */
1486     yytype_int16 yyssa[YYINITDEPTH];
1487     yytype_int16 *yyss;
1488     yytype_int16 *yyssp;
1489 
1490     /* The semantic value stack.  */
1491     YYSTYPE yyvsa[YYINITDEPTH];
1492     YYSTYPE *yyvs;
1493     YYSTYPE *yyvsp;
1494 
1495     YYSIZE_T yystacksize;
1496 
1497   int yyn;
1498   int yyresult;
1499   /* Lookahead token as an internal (translated) token number.  */
1500   int yytoken = 0;
1501   /* The variables used to return semantic value and location from the
1502      action routines.  */
1503   YYSTYPE yyval;
1504 
1505 #if YYERROR_VERBOSE
1506   /* Buffer for error messages, and its allocated size.  */
1507   char yymsgbuf[128];
1508   char *yymsg = yymsgbuf;
1509   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1510 #endif
1511 
1512 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1513 
1514   /* The number of symbols on the RHS of the reduced rule.
1515      Keep to zero when no symbol should be popped.  */
1516   int yylen = 0;
1517 
1518   yyssp = yyss = yyssa;
1519   yyvsp = yyvs = yyvsa;
1520   yystacksize = YYINITDEPTH;
1521 
1522   YYDPRINTF ((stderr, "Starting parse\n"));
1523 
1524   yystate = 0;
1525   yyerrstatus = 0;
1526   yynerrs = 0;
1527   yychar = YYEMPTY; /* Cause a token to be read.  */
1528   goto yysetstate;
1529 
1530 /*------------------------------------------------------------.
1531 | yynewstate -- Push a new state, which is found in yystate.  |
1532 `------------------------------------------------------------*/
1533  yynewstate:
1534   /* In all cases, when you get here, the value and location stacks
1535      have just been pushed.  So pushing a state here evens the stacks.  */
1536   yyssp++;
1537 
1538  yysetstate:
1539   *yyssp = yystate;
1540 
1541   if (yyss + yystacksize - 1 <= yyssp)
1542     {
1543       /* Get the current used size of the three stacks, in elements.  */
1544       YYSIZE_T yysize = yyssp - yyss + 1;
1545 
1546 #ifdef yyoverflow
1547       {
1548 	/* Give user a chance to reallocate the stack.  Use copies of
1549 	   these so that the &'s don't force the real ones into
1550 	   memory.  */
1551 	YYSTYPE *yyvs1 = yyvs;
1552 	yytype_int16 *yyss1 = yyss;
1553 
1554 	/* Each stack pointer address is followed by the size of the
1555 	   data in use in that stack, in bytes.  This used to be a
1556 	   conditional around just the two extra args, but that might
1557 	   be undefined if yyoverflow is a macro.  */
1558 	yyoverflow (YY_("memory exhausted"),
1559 		    &yyss1, yysize * sizeof (*yyssp),
1560 		    &yyvs1, yysize * sizeof (*yyvsp),
1561 		    &yystacksize);
1562 
1563 	yyss = yyss1;
1564 	yyvs = yyvs1;
1565       }
1566 #else /* no yyoverflow */
1567 # ifndef YYSTACK_RELOCATE
1568       goto yyexhaustedlab;
1569 # else
1570       /* Extend the stack our own way.  */
1571       if (YYMAXDEPTH <= yystacksize)
1572 	goto yyexhaustedlab;
1573       yystacksize *= 2;
1574       if (YYMAXDEPTH < yystacksize)
1575 	yystacksize = YYMAXDEPTH;
1576 
1577       {
1578 	yytype_int16 *yyss1 = yyss;
1579 	union yyalloc *yyptr =
1580 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1581 	if (! yyptr)
1582 	  goto yyexhaustedlab;
1583 	YYSTACK_RELOCATE (yyss_alloc, yyss);
1584 	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1585 #  undef YYSTACK_RELOCATE
1586 	if (yyss1 != yyssa)
1587 	  YYSTACK_FREE (yyss1);
1588       }
1589 # endif
1590 #endif /* no yyoverflow */
1591 
1592       yyssp = yyss + yysize - 1;
1593       yyvsp = yyvs + yysize - 1;
1594 
1595       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1596 		  (unsigned long int) yystacksize));
1597 
1598       if (yyss + yystacksize - 1 <= yyssp)
1599 	YYABORT;
1600     }
1601 
1602   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1603 
1604   if (yystate == YYFINAL)
1605     YYACCEPT;
1606 
1607   goto yybackup;
1608 
1609 /*-----------.
1610 | yybackup.  |
1611 `-----------*/
1612 yybackup:
1613 
1614   /* Do appropriate processing given the current state.  Read a
1615      lookahead token if we need one and don't already have one.  */
1616 
1617   /* First try to decide what to do without reference to lookahead token.  */
1618   yyn = yypact[yystate];
1619   if (yypact_value_is_default (yyn))
1620     goto yydefault;
1621 
1622   /* Not known => get a lookahead token if don't already have one.  */
1623 
1624   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1625   if (yychar == YYEMPTY)
1626     {
1627       YYDPRINTF ((stderr, "Reading a token: "));
1628       yychar = YYLEX;
1629     }
1630 
1631   if (yychar <= YYEOF)
1632     {
1633       yychar = yytoken = YYEOF;
1634       YYDPRINTF ((stderr, "Now at end of input.\n"));
1635     }
1636   else
1637     {
1638       yytoken = YYTRANSLATE (yychar);
1639       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1640     }
1641 
1642   /* If the proper action on seeing token YYTOKEN is to reduce or to
1643      detect an error, take that action.  */
1644   yyn += yytoken;
1645   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1646     goto yydefault;
1647   yyn = yytable[yyn];
1648   if (yyn <= 0)
1649     {
1650       if (yytable_value_is_error (yyn))
1651         goto yyerrlab;
1652       yyn = -yyn;
1653       goto yyreduce;
1654     }
1655 
1656   /* Count tokens shifted since error; after three, turn off error
1657      status.  */
1658   if (yyerrstatus)
1659     yyerrstatus--;
1660 
1661   /* Shift the lookahead token.  */
1662   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1663 
1664   /* Discard the shifted token.  */
1665   yychar = YYEMPTY;
1666 
1667   yystate = yyn;
1668   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1669   *++yyvsp = yylval;
1670   YY_IGNORE_MAYBE_UNINITIALIZED_END
1671 
1672   goto yynewstate;
1673 
1674 
1675 /*-----------------------------------------------------------.
1676 | yydefault -- do the default action for the current state.  |
1677 `-----------------------------------------------------------*/
1678 yydefault:
1679   yyn = yydefact[yystate];
1680   if (yyn == 0)
1681     goto yyerrlab;
1682   goto yyreduce;
1683 
1684 
1685 /*-----------------------------.
1686 | yyreduce -- Do a reduction.  |
1687 `-----------------------------*/
1688 yyreduce:
1689   /* yyn is the number of a rule to reduce with.  */
1690   yylen = yyr2[yyn];
1691 
1692   /* If YYLEN is nonzero, implement the default value of the action:
1693      `$$ = $1'.
1694 
1695      Otherwise, the following line sets YYVAL to garbage.
1696      This behavior is undocumented and Bison
1697      users should not rely upon it.  Assigning to YYVAL
1698      unconditionally makes the parser a bit smaller, and it avoids a
1699      GCC warning that YYVAL may be used uninitialized.  */
1700   yyval = yyvsp[1-yylen];
1701 
1702 
1703   YY_REDUCE_PRINT (yyn);
1704   switch (yyn)
1705     {
1706         case 6:
1707 /* Line 1787 of yacc.c  */
1708 #line 173 "../../../gmp/demos/calc/calc.y"
1709     { sp = stack[0]; yyerrok; }
1710     break;
1711 
1712   case 8:
1713 /* Line 1787 of yacc.c  */
1714 #line 177 "../../../gmp/demos/calc/calc.y"
1715     {
1716       mpz_out_str (stdout, obase, sp); putchar ('\n');
1717       sp--;
1718       CHECK_EMPTY ();
1719     }
1720     break;
1721 
1722   case 9:
1723 /* Line 1787 of yacc.c  */
1724 #line 182 "../../../gmp/demos/calc/calc.y"
1725     {
1726       CHECK_VARIABLE ((yyvsp[(1) - (3)].var));
1727       mpz_swap (variable[(yyvsp[(1) - (3)].var)], sp);
1728       sp--;
1729       CHECK_EMPTY ();
1730     }
1731     break;
1732 
1733   case 10:
1734 /* Line 1787 of yacc.c  */
1735 #line 188 "../../../gmp/demos/calc/calc.y"
1736     { calc_help (); }
1737     break;
1738 
1739   case 11:
1740 /* Line 1787 of yacc.c  */
1741 #line 189 "../../../gmp/demos/calc/calc.y"
1742     { ibase = 16; obase = -16; }
1743     break;
1744 
1745   case 12:
1746 /* Line 1787 of yacc.c  */
1747 #line 190 "../../../gmp/demos/calc/calc.y"
1748     { ibase = 0;  obase = 10; }
1749     break;
1750 
1751   case 13:
1752 /* Line 1787 of yacc.c  */
1753 #line 191 "../../../gmp/demos/calc/calc.y"
1754     { exit (0); }
1755     break;
1756 
1757   case 15:
1758 /* Line 1787 of yacc.c  */
1759 #line 198 "../../../gmp/demos/calc/calc.y"
1760     { sp--; mpz_add    (sp, sp, sp+1); }
1761     break;
1762 
1763   case 16:
1764 /* Line 1787 of yacc.c  */
1765 #line 199 "../../../gmp/demos/calc/calc.y"
1766     { sp--; mpz_sub    (sp, sp, sp+1); }
1767     break;
1768 
1769   case 17:
1770 /* Line 1787 of yacc.c  */
1771 #line 200 "../../../gmp/demos/calc/calc.y"
1772     { sp--; mpz_mul    (sp, sp, sp+1); }
1773     break;
1774 
1775   case 18:
1776 /* Line 1787 of yacc.c  */
1777 #line 201 "../../../gmp/demos/calc/calc.y"
1778     { sp--; mpz_fdiv_q (sp, sp, sp+1); }
1779     break;
1780 
1781   case 19:
1782 /* Line 1787 of yacc.c  */
1783 #line 202 "../../../gmp/demos/calc/calc.y"
1784     { sp--; mpz_fdiv_r (sp, sp, sp+1); }
1785     break;
1786 
1787   case 20:
1788 /* Line 1787 of yacc.c  */
1789 #line 203 "../../../gmp/demos/calc/calc.y"
1790     { CHECK_UI ("Exponent", sp);
1791                     sp--; mpz_pow_ui (sp, sp, mpz_get_ui (sp+1)); }
1792     break;
1793 
1794   case 21:
1795 /* Line 1787 of yacc.c  */
1796 #line 205 "../../../gmp/demos/calc/calc.y"
1797     { CHECK_UI ("Shift count", sp);
1798                     sp--; mpz_mul_2exp (sp, sp, mpz_get_ui (sp+1)); }
1799     break;
1800 
1801   case 22:
1802 /* Line 1787 of yacc.c  */
1803 #line 207 "../../../gmp/demos/calc/calc.y"
1804     { CHECK_UI ("Shift count", sp);
1805                     sp--; mpz_fdiv_q_2exp (sp, sp, mpz_get_ui (sp+1)); }
1806     break;
1807 
1808   case 23:
1809 /* Line 1787 of yacc.c  */
1810 #line 209 "../../../gmp/demos/calc/calc.y"
1811     { CHECK_UI ("Factorial", sp);
1812                     mpz_fac_ui (sp, mpz_get_ui (sp)); }
1813     break;
1814 
1815   case 24:
1816 /* Line 1787 of yacc.c  */
1817 #line 211 "../../../gmp/demos/calc/calc.y"
1818     { mpz_neg (sp, sp); }
1819     break;
1820 
1821   case 25:
1822 /* Line 1787 of yacc.c  */
1823 #line 213 "../../../gmp/demos/calc/calc.y"
1824     { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <  0); }
1825     break;
1826 
1827   case 26:
1828 /* Line 1787 of yacc.c  */
1829 #line 214 "../../../gmp/demos/calc/calc.y"
1830     { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <= 0); }
1831     break;
1832 
1833   case 27:
1834 /* Line 1787 of yacc.c  */
1835 #line 215 "../../../gmp/demos/calc/calc.y"
1836     { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) == 0); }
1837     break;
1838 
1839   case 28:
1840 /* Line 1787 of yacc.c  */
1841 #line 216 "../../../gmp/demos/calc/calc.y"
1842     { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) != 0); }
1843     break;
1844 
1845   case 29:
1846 /* Line 1787 of yacc.c  */
1847 #line 217 "../../../gmp/demos/calc/calc.y"
1848     { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >= 0); }
1849     break;
1850 
1851   case 30:
1852 /* Line 1787 of yacc.c  */
1853 #line 218 "../../../gmp/demos/calc/calc.y"
1854     { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >  0); }
1855     break;
1856 
1857   case 31:
1858 /* Line 1787 of yacc.c  */
1859 #line 220 "../../../gmp/demos/calc/calc.y"
1860     { sp--; mpz_set_ui (sp, mpz_sgn (sp) && mpz_sgn (sp+1)); }
1861     break;
1862 
1863   case 32:
1864 /* Line 1787 of yacc.c  */
1865 #line 221 "../../../gmp/demos/calc/calc.y"
1866     { sp--; mpz_set_ui (sp, mpz_sgn (sp) || mpz_sgn (sp+1)); }
1867     break;
1868 
1869   case 33:
1870 /* Line 1787 of yacc.c  */
1871 #line 223 "../../../gmp/demos/calc/calc.y"
1872     { mpz_abs (sp, sp); }
1873     break;
1874 
1875   case 34:
1876 /* Line 1787 of yacc.c  */
1877 #line 224 "../../../gmp/demos/calc/calc.y"
1878     { sp--; CHECK_UI ("Binomial base", sp+1);
1879                                    mpz_bin_ui (sp, sp, mpz_get_ui (sp+1)); }
1880     break;
1881 
1882   case 35:
1883 /* Line 1787 of yacc.c  */
1884 #line 226 "../../../gmp/demos/calc/calc.y"
1885     { CHECK_UI ("Fibonacci", sp);
1886                                    mpz_fib_ui (sp, mpz_get_ui (sp)); }
1887     break;
1888 
1889   case 37:
1890 /* Line 1787 of yacc.c  */
1891 #line 229 "../../../gmp/demos/calc/calc.y"
1892     { sp--; mpz_set_si (sp,
1893                                          mpz_kronecker (sp, sp+1)); }
1894     break;
1895 
1896   case 39:
1897 /* Line 1787 of yacc.c  */
1898 #line 232 "../../../gmp/demos/calc/calc.y"
1899     { CHECK_UI ("Lucas number", sp);
1900                                    mpz_lucnum_ui (sp, mpz_get_ui (sp)); }
1901     break;
1902 
1903   case 40:
1904 /* Line 1787 of yacc.c  */
1905 #line 234 "../../../gmp/demos/calc/calc.y"
1906     { mpz_nextprime (sp, sp); }
1907     break;
1908 
1909   case 41:
1910 /* Line 1787 of yacc.c  */
1911 #line 235 "../../../gmp/demos/calc/calc.y"
1912     { sp -= 2; mpz_powm (sp, sp, sp+1, sp+2); }
1913     break;
1914 
1915   case 42:
1916 /* Line 1787 of yacc.c  */
1917 #line 236 "../../../gmp/demos/calc/calc.y"
1918     { sp--; CHECK_UI ("Nth-root", sp+1);
1919                                    mpz_root (sp, sp, mpz_get_ui (sp+1)); }
1920     break;
1921 
1922   case 43:
1923 /* Line 1787 of yacc.c  */
1924 #line 238 "../../../gmp/demos/calc/calc.y"
1925     { mpz_sqrt (sp, sp); }
1926     break;
1927 
1928   case 44:
1929 /* Line 1787 of yacc.c  */
1930 #line 240 "../../../gmp/demos/calc/calc.y"
1931     {
1932         sp++;
1933         CHECK_OVERFLOW ();
1934         CHECK_VARIABLE ((yyvsp[(1) - (1)].var));
1935         mpz_set (sp, variable[(yyvsp[(1) - (1)].var)]);
1936       }
1937     break;
1938 
1939   case 45:
1940 /* Line 1787 of yacc.c  */
1941 #line 246 "../../../gmp/demos/calc/calc.y"
1942     {
1943         sp++;
1944         CHECK_OVERFLOW ();
1945         if (mpz_set_str (sp, (yyvsp[(1) - (1)].str), ibase) != 0)
1946           {
1947             fprintf (stderr, "Invalid number: %s\n", (yyvsp[(1) - (1)].str));
1948             YYERROR;
1949           }
1950       }
1951     break;
1952 
1953   case 47:
1954 /* Line 1787 of yacc.c  */
1955 #line 258 "../../../gmp/demos/calc/calc.y"
1956     { sp--; mpz_gcd (sp, sp, sp+1); }
1957     break;
1958 
1959   case 49:
1960 /* Line 1787 of yacc.c  */
1961 #line 262 "../../../gmp/demos/calc/calc.y"
1962     { sp--; mpz_lcm (sp, sp, sp+1); }
1963     break;
1964 
1965 
1966 /* Line 1787 of yacc.c  */
1967 #line 1968 "calc.c"
1968       default: break;
1969     }
1970   /* User semantic actions sometimes alter yychar, and that requires
1971      that yytoken be updated with the new translation.  We take the
1972      approach of translating immediately before every use of yytoken.
1973      One alternative is translating here after every semantic action,
1974      but that translation would be missed if the semantic action invokes
1975      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1976      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1977      incorrect destructor might then be invoked immediately.  In the
1978      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1979      to an incorrect destructor call or verbose syntax error message
1980      before the lookahead is translated.  */
1981   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1982 
1983   YYPOPSTACK (yylen);
1984   yylen = 0;
1985   YY_STACK_PRINT (yyss, yyssp);
1986 
1987   *++yyvsp = yyval;
1988 
1989   /* Now `shift' the result of the reduction.  Determine what state
1990      that goes to, based on the state we popped back to and the rule
1991      number reduced by.  */
1992 
1993   yyn = yyr1[yyn];
1994 
1995   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1996   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1997     yystate = yytable[yystate];
1998   else
1999     yystate = yydefgoto[yyn - YYNTOKENS];
2000 
2001   goto yynewstate;
2002 
2003 
2004 /*------------------------------------.
2005 | yyerrlab -- here on detecting error |
2006 `------------------------------------*/
2007 yyerrlab:
2008   /* Make sure we have latest lookahead translation.  See comments at
2009      user semantic actions for why this is necessary.  */
2010   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2011 
2012   /* If not already recovering from an error, report this error.  */
2013   if (!yyerrstatus)
2014     {
2015       ++yynerrs;
2016 #if ! YYERROR_VERBOSE
2017       yyerror (YY_("syntax error"));
2018 #else
2019 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2020                                         yyssp, yytoken)
2021       {
2022         char const *yymsgp = YY_("syntax error");
2023         int yysyntax_error_status;
2024         yysyntax_error_status = YYSYNTAX_ERROR;
2025         if (yysyntax_error_status == 0)
2026           yymsgp = yymsg;
2027         else if (yysyntax_error_status == 1)
2028           {
2029             if (yymsg != yymsgbuf)
2030               YYSTACK_FREE (yymsg);
2031             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2032             if (!yymsg)
2033               {
2034                 yymsg = yymsgbuf;
2035                 yymsg_alloc = sizeof yymsgbuf;
2036                 yysyntax_error_status = 2;
2037               }
2038             else
2039               {
2040                 yysyntax_error_status = YYSYNTAX_ERROR;
2041                 yymsgp = yymsg;
2042               }
2043           }
2044         yyerror (yymsgp);
2045         if (yysyntax_error_status == 2)
2046           goto yyexhaustedlab;
2047       }
2048 # undef YYSYNTAX_ERROR
2049 #endif
2050     }
2051 
2052 
2053 
2054   if (yyerrstatus == 3)
2055     {
2056       /* If just tried and failed to reuse lookahead token after an
2057 	 error, discard it.  */
2058 
2059       if (yychar <= YYEOF)
2060 	{
2061 	  /* Return failure if at end of input.  */
2062 	  if (yychar == YYEOF)
2063 	    YYABORT;
2064 	}
2065       else
2066 	{
2067 	  yydestruct ("Error: discarding",
2068 		      yytoken, &yylval);
2069 	  yychar = YYEMPTY;
2070 	}
2071     }
2072 
2073   /* Else will try to reuse lookahead token after shifting the error
2074      token.  */
2075   goto yyerrlab1;
2076 
2077 
2078 /*---------------------------------------------------.
2079 | yyerrorlab -- error raised explicitly by YYERROR.  |
2080 `---------------------------------------------------*/
2081 yyerrorlab:
2082 
2083   /* Pacify compilers like GCC when the user code never invokes
2084      YYERROR and the label yyerrorlab therefore never appears in user
2085      code.  */
2086   if (/*CONSTCOND*/ 0)
2087      goto yyerrorlab;
2088 
2089   /* Do not reclaim the symbols of the rule which action triggered
2090      this YYERROR.  */
2091   YYPOPSTACK (yylen);
2092   yylen = 0;
2093   YY_STACK_PRINT (yyss, yyssp);
2094   yystate = *yyssp;
2095   goto yyerrlab1;
2096 
2097 
2098 /*-------------------------------------------------------------.
2099 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2100 `-------------------------------------------------------------*/
2101 yyerrlab1:
2102   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
2103 
2104   for (;;)
2105     {
2106       yyn = yypact[yystate];
2107       if (!yypact_value_is_default (yyn))
2108 	{
2109 	  yyn += YYTERROR;
2110 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2111 	    {
2112 	      yyn = yytable[yyn];
2113 	      if (0 < yyn)
2114 		break;
2115 	    }
2116 	}
2117 
2118       /* Pop the current state because it cannot handle the error token.  */
2119       if (yyssp == yyss)
2120 	YYABORT;
2121 
2122 
2123       yydestruct ("Error: popping",
2124 		  yystos[yystate], yyvsp);
2125       YYPOPSTACK (1);
2126       yystate = *yyssp;
2127       YY_STACK_PRINT (yyss, yyssp);
2128     }
2129 
2130   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2131   *++yyvsp = yylval;
2132   YY_IGNORE_MAYBE_UNINITIALIZED_END
2133 
2134 
2135   /* Shift the error token.  */
2136   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2137 
2138   yystate = yyn;
2139   goto yynewstate;
2140 
2141 
2142 /*-------------------------------------.
2143 | yyacceptlab -- YYACCEPT comes here.  |
2144 `-------------------------------------*/
2145 yyacceptlab:
2146   yyresult = 0;
2147   goto yyreturn;
2148 
2149 /*-----------------------------------.
2150 | yyabortlab -- YYABORT comes here.  |
2151 `-----------------------------------*/
2152 yyabortlab:
2153   yyresult = 1;
2154   goto yyreturn;
2155 
2156 #if !defined yyoverflow || YYERROR_VERBOSE
2157 /*-------------------------------------------------.
2158 | yyexhaustedlab -- memory exhaustion comes here.  |
2159 `-------------------------------------------------*/
2160 yyexhaustedlab:
2161   yyerror (YY_("memory exhausted"));
2162   yyresult = 2;
2163   /* Fall through.  */
2164 #endif
2165 
2166 yyreturn:
2167   if (yychar != YYEMPTY)
2168     {
2169       /* Make sure we have latest lookahead translation.  See comments at
2170          user semantic actions for why this is necessary.  */
2171       yytoken = YYTRANSLATE (yychar);
2172       yydestruct ("Cleanup: discarding lookahead",
2173                   yytoken, &yylval);
2174     }
2175   /* Do not reclaim the symbols of the rule which action triggered
2176      this YYABORT or YYACCEPT.  */
2177   YYPOPSTACK (yylen);
2178   YY_STACK_PRINT (yyss, yyssp);
2179   while (yyssp != yyss)
2180     {
2181       yydestruct ("Cleanup: popping",
2182 		  yystos[*yyssp], yyvsp);
2183       YYPOPSTACK (1);
2184     }
2185 #ifndef yyoverflow
2186   if (yyss != yyssa)
2187     YYSTACK_FREE (yyss);
2188 #endif
2189 #if YYERROR_VERBOSE
2190   if (yymsg != yymsgbuf)
2191     YYSTACK_FREE (yymsg);
2192 #endif
2193   /* Make sure YYID is used.  */
2194   return YYID (yyresult);
2195 }
2196 
2197 
2198 /* Line 2050 of yacc.c  */
2199 #line 264 "../../../gmp/demos/calc/calc.y"
2200 
2201 
yyerror(char * s)2202 yyerror (char *s)
2203 {
2204   fprintf (stderr, "%s\n", s);
2205 }
2206 
2207 int calc_option_readline = -1;
2208 
2209 int
main(int argc,char * argv[])2210 main (int argc, char *argv[])
2211 {
2212   int  i;
2213 
2214   for (i = 1; i < argc; i++)
2215     {
2216       if (strcmp (argv[i], "--readline") == 0)
2217         calc_option_readline = 1;
2218       else if (strcmp (argv[i], "--noreadline") == 0)
2219         calc_option_readline = 0;
2220       else if (strcmp (argv[i], "--help") == 0)
2221         {
2222           printf ("Usage: calc [--option]...\n");
2223           printf ("  --readline    use readline\n");
2224           printf ("  --noreadline  don't use readline\n");
2225           printf ("  --help        this message\n");
2226           printf ("Readline is only available when compiled in,\n");
2227           printf ("and in that case it's the default on a tty.\n");
2228           exit (0);
2229         }
2230       else
2231         {
2232           fprintf (stderr, "Unrecognised option: %s\n", argv[i]);
2233           exit (1);
2234         }
2235     }
2236 
2237 #if WITH_READLINE
2238   calc_init_readline ();
2239 #else
2240   if (calc_option_readline == 1)
2241     {
2242       fprintf (stderr, "Readline support not available\n");
2243       exit (1);
2244     }
2245 #endif
2246 
2247   for (i = 0; i < numberof (variable); i++)
2248     mpz_init (variable[i]);
2249 
2250   for (i = 0; i < numberof (stack); i++)
2251     mpz_init (stack[i]);
2252 
2253   return yyparse ();
2254 }
2255