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