1 /* A Bison parser, made by GNU Bison 2.3. */ 2 3 /* Skeleton implementation for Bison's Yacc-like parsers in C 4 5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 6 Free Software Foundation, 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 2, or (at your option) 11 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, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 Boston, MA 02110-1301, USA. */ 22 23 /* As a special exception, you may create a larger work that contains 24 part or all of the Bison parser skeleton and distribute that work 25 under terms of your choice, so long as that work isn't itself a 26 parser generator using the skeleton or a modified version thereof 27 as a parser skeleton. Alternatively, if you modify or redistribute 28 the parser skeleton itself, you may (at your option) remove this 29 special exception, which will cause the skeleton and the resulting 30 Bison output files to be licensed under the GNU General Public 31 License without this special exception. 32 33 This special exception was added by the Free Software Foundation in 34 version 2.2 of Bison. */ 35 36 /* C LALR(1) parser skeleton written by Richard Stallman, by 37 simplifying the original so-called "semantic" parser. */ 38 39 /* All symbols defined below should begin with yy or YY, to avoid 40 infringing on user name space. This should be done even for local 41 variables, as they might otherwise be expanded by user macros. 42 There are some unavoidable exceptions within include files to 43 define necessary library symbols; they are noted "INFRINGES ON 44 USER NAME SPACE" below. */ 45 46 /* Identify Bison output. */ 47 #define YYBISON 1 48 49 /* Bison version. */ 50 #define YYBISON_VERSION "2.3" 51 52 /* Skeleton name. */ 53 #define YYSKELETON_NAME "yacc.c" 54 55 /* Pure parsers. */ 56 #define YYPURE 0 57 58 /* Using locations. */ 59 #define YYLSP_NEEDED 0 60 61 62 63 /* Tokens. */ 64 #ifndef YYTOKENTYPE 65 # define YYTOKENTYPE 66 /* Put the tokens into the symbol table, so that GDB and other debuggers 67 know about them. */ 68 enum yytokentype { 69 NUM = 258, 70 NEG = 259 71 }; 72 #endif 73 /* Tokens. */ 74 #define NUM 258 75 #define NEG 259 76 77 78 79 80 /* Copy the first part of user declarations. */ 81 #line 1 "calc.y" 82 83 #define YYSTYPE complex long double 84 // long double 85 #include <math.h> 86 #include <complex.h> 87 #include <stdio.h> 88 int yylex (void); 89 void yyerror (char const *); 90 91 YYSTYPE yylval; 92 93 /* Called by yyparse on error. */ 94 void yyerror (char const *s) 95 { 96 fprintf (stderr, "%s\n", s); 97 } 98 99 #include <ctype.h> 100 101 int yylex (void) 102 { 103 int c; 104 long double aaa; 105 106 /* Skip white space. */ 107 while ((c = getchar ()) == ' ' || c == '\t') 108 ; 109 /* Process numbers. */ 110 if (c == '.' || isdigit (c)) 111 { 112 ungetc (c, stdin); 113 scanf ("%Lf", &aaa); 114 while ((c = getchar ()) == ' ' || c == '\t') 115 ; 116 yylval = aaa; 117 if (c == 'i') 118 yylval = aaa * _Complex_I; 119 else 120 ungetc(c, stdin); 121 return NUM; 122 } else if (c == 'i') { 123 yylval = _Complex_I; 124 return NUM; 125 } 126 /* Return end-of-input. */ 127 if (c == EOF) 128 return 0; 129 /* Return a single char. */ 130 return c; 131 } 132 133 int main (void) 134 { 135 return yyparse (); 136 } 137 138 139 140 /* Enabling traces. */ 141 #ifndef YYDEBUG 142 # define YYDEBUG 0 143 #endif 144 145 /* Enabling verbose error messages. */ 146 #ifdef YYERROR_VERBOSE 147 # undef YYERROR_VERBOSE 148 # define YYERROR_VERBOSE 1 149 #else 150 # define YYERROR_VERBOSE 0 151 #endif 152 153 /* Enabling the token table. */ 154 #ifndef YYTOKEN_TABLE 155 # define YYTOKEN_TABLE 0 156 #endif 157 158 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 159 typedef int YYSTYPE; 160 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 161 # define YYSTYPE_IS_DECLARED 1 162 # define YYSTYPE_IS_TRIVIAL 1 163 #endif 164 165 166 167 /* Copy the second part of user declarations. */ 168 169 170 /* Line 216 of yacc.c. */ 171 #line 172 "calc.tab.c" 172 173 #ifdef short 174 # undef short 175 #endif 176 177 #ifdef YYTYPE_UINT8 178 typedef YYTYPE_UINT8 yytype_uint8; 179 #else 180 typedef unsigned char yytype_uint8; 181 #endif 182 183 #ifdef YYTYPE_INT8 184 typedef YYTYPE_INT8 yytype_int8; 185 #elif (defined __STDC__ || defined __C99__FUNC__ \ 186 || defined __cplusplus || defined _MSC_VER) 187 typedef signed char yytype_int8; 188 #else 189 typedef short int yytype_int8; 190 #endif 191 192 #ifdef YYTYPE_UINT16 193 typedef YYTYPE_UINT16 yytype_uint16; 194 #else 195 typedef unsigned short int yytype_uint16; 196 #endif 197 198 #ifdef YYTYPE_INT16 199 typedef YYTYPE_INT16 yytype_int16; 200 #else 201 typedef short int yytype_int16; 202 #endif 203 204 #ifndef YYSIZE_T 205 # ifdef __SIZE_TYPE__ 206 # define YYSIZE_T __SIZE_TYPE__ 207 # elif defined size_t 208 # define YYSIZE_T size_t 209 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ 210 || defined __cplusplus || defined _MSC_VER) 211 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 212 # define YYSIZE_T size_t 213 # else 214 # define YYSIZE_T unsigned int 215 # endif 216 #endif 217 218 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) 219 220 #ifndef YY_ 221 # if YYENABLE_NLS 222 # if ENABLE_NLS 223 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 224 # define YY_(msgid) dgettext ("bison-runtime", msgid) 225 # endif 226 # endif 227 # ifndef YY_ 228 # define YY_(msgid) msgid 229 # endif 230 #endif 231 232 /* Suppress unused-variable warnings by "using" E. */ 233 #if ! defined lint || defined __GNUC__ 234 # define YYUSE(e) ((void) (e)) 235 #else 236 # define YYUSE(e) /* empty */ 237 #endif 238 239 /* Identity function, used to suppress warnings about constant conditions. */ 240 #ifndef lint 241 # define YYID(n) (n) 242 #else 243 #if (defined __STDC__ || defined __C99__FUNC__ \ 244 || defined __cplusplus || defined _MSC_VER) 245 static int 246 YYID (int i) 247 #else 248 static int 249 YYID (i) 250 int i; 251 #endif 252 { 253 return i; 254 } 255 #endif 256 257 #if ! defined yyoverflow || YYERROR_VERBOSE 258 259 /* The parser invokes alloca or malloc; define the necessary symbols. */ 260 261 # ifdef YYSTACK_USE_ALLOCA 262 # if YYSTACK_USE_ALLOCA 263 # ifdef __GNUC__ 264 # define YYSTACK_ALLOC __builtin_alloca 265 # elif defined __BUILTIN_VA_ARG_INCR 266 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ 267 # elif defined _AIX 268 # define YYSTACK_ALLOC __alloca 269 # elif defined _MSC_VER 270 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ 271 # define alloca _alloca 272 # else 273 # define YYSTACK_ALLOC alloca 274 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 275 || defined __cplusplus || defined _MSC_VER) 276 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 277 # ifndef _STDLIB_H 278 # define _STDLIB_H 1 279 # endif 280 # endif 281 # endif 282 # endif 283 # endif 284 285 # ifdef YYSTACK_ALLOC 286 /* Pacify GCC's `empty if-body' warning. */ 287 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) 288 # ifndef YYSTACK_ALLOC_MAXIMUM 289 /* The OS might guarantee only one guard page at the bottom of the stack, 290 and a page size can be as small as 4096 bytes. So we cannot safely 291 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 292 to allow for a few compiler-allocated temporary stack slots. */ 293 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ 294 # endif 295 # else 296 # define YYSTACK_ALLOC YYMALLOC 297 # define YYSTACK_FREE YYFREE 298 # ifndef YYSTACK_ALLOC_MAXIMUM 299 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 300 # endif 301 # if (defined __cplusplus && ! defined _STDLIB_H \ 302 && ! ((defined YYMALLOC || defined malloc) \ 303 && (defined YYFREE || defined free))) 304 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 305 # ifndef _STDLIB_H 306 # define _STDLIB_H 1 307 # endif 308 # endif 309 # ifndef YYMALLOC 310 # define YYMALLOC malloc 311 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 312 || defined __cplusplus || defined _MSC_VER) 313 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 314 # endif 315 # endif 316 # ifndef YYFREE 317 # define YYFREE free 318 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 319 || defined __cplusplus || defined _MSC_VER) 320 void free (void *); /* INFRINGES ON USER NAME SPACE */ 321 # endif 322 # endif 323 # endif 324 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ 325 326 327 #if (! defined yyoverflow \ 328 && (! defined __cplusplus \ 329 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 330 331 /* A type that is properly aligned for any stack member. */ 332 union yyalloc 333 { 334 yytype_int16 yyss; 335 YYSTYPE yyvs; 336 }; 337 338 /* The size of the maximum gap between one aligned stack and the next. */ 339 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 340 341 /* The size of an array large to enough to hold all stacks, each with 342 N elements. */ 343 # define YYSTACK_BYTES(N) \ 344 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 345 + YYSTACK_GAP_MAXIMUM) 346 347 /* Copy COUNT objects from FROM to TO. The source and destination do 348 not overlap. */ 349 # ifndef YYCOPY 350 # if defined __GNUC__ && 1 < __GNUC__ 351 # define YYCOPY(To, From, Count) \ 352 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 353 # else 354 # define YYCOPY(To, From, Count) \ 355 do \ 356 { \ 357 YYSIZE_T yyi; \ 358 for (yyi = 0; yyi < (Count); yyi++) \ 359 (To)[yyi] = (From)[yyi]; \ 360 } \ 361 while (YYID (0)) 362 # endif 363 # endif 364 365 /* Relocate STACK from its old location to the new one. The 366 local variables YYSIZE and YYSTACKSIZE give the old and new number of 367 elements in the stack, and YYPTR gives the new location of the 368 stack. Advance YYPTR to a properly aligned location for the next 369 stack. */ 370 # define YYSTACK_RELOCATE(Stack) \ 371 do \ 372 { \ 373 YYSIZE_T yynewbytes; \ 374 YYCOPY (&yyptr->Stack, Stack, yysize); \ 375 Stack = &yyptr->Stack; \ 376 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 377 yyptr += yynewbytes / sizeof (*yyptr); \ 378 } \ 379 while (YYID (0)) 380 381 #endif 382 383 /* YYFINAL -- State number of the termination state. */ 384 #define YYFINAL 2 385 /* YYLAST -- Last index in YYTABLE. */ 386 #define YYLAST 43 387 388 /* YYNTOKENS -- Number of terminals. */ 389 #define YYNTOKENS 14 390 /* YYNNTS -- Number of nonterminals. */ 391 #define YYNNTS 4 392 /* YYNRULES -- Number of rules. */ 393 #define YYNRULES 14 394 /* YYNRULES -- Number of states. */ 395 #define YYNSTATES 25 396 397 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 398 #define YYUNDEFTOK 2 399 #define YYMAXUTOK 259 400 401 #define YYTRANSLATE(YYX) \ 402 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 403 404 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 405 static const yytype_uint8 yytranslate[] = 406 { 407 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 408 11, 2, 2, 2, 2, 2, 2, 2, 2, 2, 409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 411 12, 13, 6, 5, 2, 4, 2, 7, 2, 2, 412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 416 2, 2, 2, 2, 10, 2, 2, 2, 2, 2, 417 2, 8, 2, 2, 2, 2, 2, 2, 2, 2, 418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 432 2, 2, 2, 2, 2, 2, 1, 2, 3, 9 433 }; 434 435 #if YYDEBUG 436 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 437 YYRHS. */ 438 static const yytype_uint8 yyprhs[] = 439 { 440 0, 0, 3, 4, 7, 9, 12, 14, 18, 22, 441 26, 30, 34, 37, 41 442 }; 443 444 /* YYRHS -- A `-1'-separated list of the rules' RHS. */ 445 static const yytype_int8 yyrhs[] = 446 { 447 15, 0, -1, -1, 15, 16, -1, 11, -1, 17, 448 11, -1, 3, -1, 17, 5, 17, -1, 17, 4, 449 17, -1, 17, 6, 17, -1, 17, 7, 17, -1, 450 17, 8, 17, -1, 4, 17, -1, 17, 10, 17, 451 -1, 12, 17, 13, -1 452 }; 453 454 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 455 static const yytype_uint8 yyrline[] = 456 { 457 0, 68, 68, 69, 72, 73, 76, 77, 78, 79, 458 80, 81, 82, 83, 84 459 }; 460 #endif 461 462 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 463 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 464 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 465 static const char *const yytname[] = 466 { 467 "$end", "error", "$undefined", "NUM", "'-'", "'+'", "'*'", "'/'", "'e'", 468 "NEG", "'^'", "'\\n'", "'('", "')'", "$accept", "input", "line", "exp", 0 469 }; 470 #endif 471 472 # ifdef YYPRINT 473 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 474 token YYLEX-NUM. */ 475 static const yytype_uint16 yytoknum[] = 476 { 477 0, 256, 257, 258, 45, 43, 42, 47, 101, 259, 478 94, 10, 40, 41 479 }; 480 # endif 481 482 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 483 static const yytype_uint8 yyr1[] = 484 { 485 0, 14, 15, 15, 16, 16, 17, 17, 17, 17, 486 17, 17, 17, 17, 17 487 }; 488 489 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 490 static const yytype_uint8 yyr2[] = 491 { 492 0, 2, 0, 2, 1, 2, 1, 3, 3, 3, 493 3, 3, 2, 3, 3 494 }; 495 496 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 497 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 498 means the default is an error. */ 499 static const yytype_uint8 yydefact[] = 500 { 501 2, 0, 1, 6, 0, 4, 0, 3, 0, 12, 502 0, 0, 0, 0, 0, 0, 0, 5, 14, 8, 503 7, 9, 10, 11, 13 504 }; 505 506 /* YYDEFGOTO[NTERM-NUM]. */ 507 static const yytype_int8 yydefgoto[] = 508 { 509 -1, 1, 7, 8 510 }; 511 512 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 513 STATE-NUM. */ 514 #define YYPACT_NINF -8 515 static const yytype_int8 yypact[] = 516 { 517 -8, 13, -8, -8, 2, -8, 2, -8, 32, -6, 518 22, 2, 2, 2, 2, 2, 2, -8, -8, 12, 519 12, -7, -7, -6, -6 520 }; 521 522 /* YYPGOTO[NTERM-NUM]. */ 523 static const yytype_int8 yypgoto[] = 524 { 525 -8, -8, -8, -4 526 }; 527 528 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 529 positive, shift that token. If negative, reduce the rule which 530 number is the opposite. If zero, do what YYDEFACT says. 531 If YYTABLE_NINF, syntax error. */ 532 #define YYTABLE_NINF -1 533 static const yytype_uint8 yytable[] = 534 { 535 9, 15, 10, 16, 16, 3, 4, 19, 20, 21, 536 22, 23, 24, 2, 6, 0, 3, 4, 13, 14, 537 15, 0, 16, 0, 5, 6, 11, 12, 13, 14, 538 15, 0, 16, 0, 0, 18, 11, 12, 13, 14, 539 15, 0, 16, 17 540 }; 541 542 static const yytype_int8 yycheck[] = 543 { 544 4, 8, 6, 10, 10, 3, 4, 11, 12, 13, 545 14, 15, 16, 0, 12, -1, 3, 4, 6, 7, 546 8, -1, 10, -1, 11, 12, 4, 5, 6, 7, 547 8, -1, 10, -1, -1, 13, 4, 5, 6, 7, 548 8, -1, 10, 11 549 }; 550 551 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 552 symbol of state STATE-NUM. */ 553 static const yytype_uint8 yystos[] = 554 { 555 0, 15, 0, 3, 4, 11, 12, 16, 17, 17, 556 17, 4, 5, 6, 7, 8, 10, 11, 13, 17, 557 17, 17, 17, 17, 17 558 }; 559 560 static const yytype_uint8 yylocal[] = 561 { 562 49, 192, 176, 2, 205, 128, 61, 0, 0, 0, 563 0, 116, 6, 195, 49, 192, 64, 205, 128, 49, 564 219, 83, 139, 28, 36, 176, 6, 205, 128, 254, 565 4, 36, 128, 60, 36, 3, 116, 2, 235, 238, 566 102, 186, 47, 32, 232, 58, 0, 0, 0, 102, 567 186, 48, 32, 232, 49, 0, 0, 0, 102, 186, 568 49, 32, 232, 40, 0, 0, 0, 233, 22, 0, 569 0, 0, 91, 49, 192, 176, 11, 49, 201, 81, 570 83, 137, 225, 49, 210, 205, 128, 184, 1, 0, 571 0, 0, 205, 128, 232, 229, 255, 255, 255, 47, 572 98, 105, 110, 47, 115, 104, 0, 102, 137, 84, 573 36, 240, 199, 68, 36, 244, 2, 0, 0, 0, 574 199, 68, 36, 248, 1, 0, 0, 0, 199, 68, 575 36, 252, 0, 0, 0, 0, 184, 102, 0, 0, 576 0, 187, 1, 0, 0, 0, 137, 225, 129, 233, 577 12, 0, 0, 0, 205, 128, 49, 201, 198, 68, 578 36, 224, 2, 136, 76, 36, 225, 102, 139, 84, 579 36, 240, 136, 116, 36, 226, 136, 84, 36, 227, 580 199, 68, 36, 228, 92, 240, 234, 34, 137, 76, 581 36, 232, 137, 76, 36, 236, 137, 68, 36, 244, 582 137, 100, 36, 248, 129, 108, 36, 248, 32, 0, 583 0, 0, 199, 68, 36, 252, 16, 0, 0, 0, 584 184, 102, 0, 0, 0, 187, 3, 0, 0, 0, 585 137, 225, 129, 233, 12, 0, 0, 0, 205, 128, 586 61, 0, 0, 0, 0, 15, 133, 19, 255, 255, 587 255, 195, 0, 0, 0, 0, 0, 0, 0, 0 588 }; 589 590 #define yyerrok (yyerrstatus = 0) 591 #define yyclearin (yychar = YYEMPTY) 592 #define YYEMPTY (-2) 593 #define YYEOF 0 594 595 #define YYACCEPT goto yyacceptlab 596 #define YYABORT goto yyabortlab 597 #define YYERROR goto yyerrorlab 598 599 600 /* Like YYERROR except do call yyerror. This remains here temporarily 601 to ease the transition to the new meaning of YYERROR, for GCC. 602 Once GCC version 2 has supplanted version 1, this can go. */ 603 604 #define YYFAIL goto yyerrlab 605 606 #define YYRECOVERING() (!!yyerrstatus) 607 608 #define YYBACKUP(Token, Value) \ 609 do \ 610 if (yychar == YYEMPTY && yylen == 1) \ 611 { \ 612 yychar = (Token); \ 613 yylval = (Value); \ 614 yytoken = YYTRANSLATE (yychar); \ 615 YYPOPSTACK (1); \ 616 goto yybackup; \ 617 } \ 618 else \ 619 { \ 620 yyerror (YY_("syntax error: cannot back up")); \ 621 YYERROR; \ 622 } \ 623 while (YYID (0)) 624 625 626 #define YYTERROR 1 627 #define YYERRCODE 256 628 629 630 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. 631 If N is 0, then set CURRENT to the empty location which ends 632 the previous symbol: RHS[0] (always defined). */ 633 634 #define YYRHSLOC(Rhs, K) ((Rhs)[K]) 635 #ifndef YYLLOC_DEFAULT 636 # define YYLLOC_DEFAULT(Current, Rhs, N) \ 637 do \ 638 if (YYID (N)) \ 639 { \ 640 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ 641 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ 642 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ 643 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ 644 } \ 645 else \ 646 { \ 647 (Current).first_line = (Current).last_line = \ 648 YYRHSLOC (Rhs, 0).last_line; \ 649 (Current).first_column = (Current).last_column = \ 650 YYRHSLOC (Rhs, 0).last_column; \ 651 } \ 652 while (YYID (0)) 653 #endif 654 655 656 /* YY_LOCATION_PRINT -- Print the location on the stream. 657 This macro was not mandated originally: define only if we know 658 we won't break user code: when these are the locations we know. */ 659 660 #ifndef YY_LOCATION_PRINT 661 # if YYLTYPE_IS_TRIVIAL 662 # define YY_LOCATION_PRINT(File, Loc) \ 663 fprintf (File, "%d.%d-%d.%d", \ 664 (Loc).first_line, (Loc).first_column, \ 665 (Loc).last_line, (Loc).last_column) 666 # else 667 # define YY_LOCATION_PRINT(File, Loc) ((void) 0) 668 # endif 669 #endif 670 671 672 /* YYLEX -- calling `yylex' with the right arguments. */ 673 674 #ifdef YYLEX_PARAM 675 # define YYLEX yylex (YYLEX_PARAM) 676 #else 677 # define YYLEX yylex () 678 #endif 679 680 /* Enable debugging if requested. */ 681 #if YYDEBUG 682 683 # ifndef YYFPRINTF 684 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 685 # define YYFPRINTF fprintf 686 # endif 687 688 # define YYDPRINTF(Args) \ 689 do { \ 690 if (yydebug) \ 691 YYFPRINTF Args; \ 692 } while (YYID (0)) 693 694 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 695 do { \ 696 if (yydebug) \ 697 { \ 698 YYFPRINTF (stderr, "%s ", Title); \ 699 yy_symbol_print (stderr, \ 700 Type, Value); \ 701 YYFPRINTF (stderr, "\n"); \ 702 } \ 703 } while (YYID (0)) 704 705 706 /*--------------------------------. 707 | Print this symbol on YYOUTPUT. | 708 `--------------------------------*/ 709 710 /*ARGSUSED*/ 711 #if (defined __STDC__ || defined __C99__FUNC__ \ 712 || defined __cplusplus || defined _MSC_VER) 713 static void 714 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 715 #else 716 static void 717 yy_symbol_value_print (yyoutput, yytype, yyvaluep) 718 FILE *yyoutput; 719 int yytype; 720 YYSTYPE const * const yyvaluep; 721 #endif 722 { 723 if (!yyvaluep) 724 return; 725 # ifdef YYPRINT 726 if (yytype < YYNTOKENS) 727 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 728 # else 729 YYUSE (yyoutput); 730 # endif 731 switch (yytype) 732 { 733 default: 734 break; 735 } 736 } 737 738 739 /*--------------------------------. 740 | Print this symbol on YYOUTPUT. | 741 `--------------------------------*/ 742 743 #if (defined __STDC__ || defined __C99__FUNC__ \ 744 || defined __cplusplus || defined _MSC_VER) 745 static void 746 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 747 #else 748 static void 749 yy_symbol_print (yyoutput, yytype, yyvaluep) 750 FILE *yyoutput; 751 int yytype; 752 YYSTYPE const * const yyvaluep; 753 #endif 754 { 755 if (yytype < YYNTOKENS) 756 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 757 else 758 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 759 760 yy_symbol_value_print (yyoutput, yytype, yyvaluep); 761 YYFPRINTF (yyoutput, ")"); 762 } 763 764 /*------------------------------------------------------------------. 765 | yy_stack_print -- Print the state stack from its BOTTOM up to its | 766 | TOP (included). | 767 `------------------------------------------------------------------*/ 768 769 #if (defined __STDC__ || defined __C99__FUNC__ \ 770 || defined __cplusplus || defined _MSC_VER) 771 static void 772 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 773 #else 774 static void 775 yy_stack_print (bottom, top) 776 yytype_int16 *bottom; 777 yytype_int16 *top; 778 #endif 779 { 780 YYFPRINTF (stderr, "Stack now"); 781 for (; bottom <= top; ++bottom) 782 YYFPRINTF (stderr, " %d", *bottom); 783 YYFPRINTF (stderr, "\n"); 784 } 785 786 # define YY_STACK_PRINT(Bottom, Top) \ 787 do { \ 788 if (yydebug) \ 789 yy_stack_print ((Bottom), (Top)); \ 790 } while (YYID (0)) 791 792 793 /*------------------------------------------------. 794 | Report that the YYRULE is going to be reduced. | 795 `------------------------------------------------*/ 796 797 #if (defined __STDC__ || defined __C99__FUNC__ \ 798 || defined __cplusplus || defined _MSC_VER) 799 static void 800 yy_reduce_print (YYSTYPE *yyvsp, int yyrule) 801 #else 802 static void 803 yy_reduce_print (yyvsp, yyrule) 804 YYSTYPE *yyvsp; 805 int yyrule; 806 #endif 807 { 808 int yynrhs = yyr2[yyrule]; 809 int yyi; 810 unsigned long int yylno = yyrline[yyrule]; 811 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", 812 yyrule - 1, yylno); 813 /* The symbols being reduced. */ 814 for (yyi = 0; yyi < yynrhs; yyi++) 815 { 816 fprintf (stderr, " $%d = ", yyi + 1); 817 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 818 &(yyvsp[(yyi + 1) - (yynrhs)]) 819 ); 820 fprintf (stderr, "\n"); 821 } 822 } 823 824 # define YY_REDUCE_PRINT(Rule) \ 825 do { \ 826 if (yydebug) \ 827 yy_reduce_print (yyvsp, Rule); \ 828 } while (YYID (0)) 829 830 /* Nonzero means print parse trace. It is left uninitialized so that 831 multiple parsers can coexist. */ 832 int yydebug; 833 #else /* !YYDEBUG */ 834 # define YYDPRINTF(Args) 835 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) 836 # define YY_STACK_PRINT(Bottom, Top) 837 # define YY_REDUCE_PRINT(Rule) 838 #endif /* !YYDEBUG */ 839 840 841 /* YYINITDEPTH -- initial size of the parser's stacks. */ 842 #ifndef YYINITDEPTH 843 # define YYINITDEPTH 200 844 #endif 845 846 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 847 if the built-in stack extension method is used). 848 849 Do not make this value too large; the results are undefined if 850 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 851 evaluated with infinite-precision integer arithmetic. */ 852 853 #ifndef YYMAXDEPTH 854 # define YYMAXDEPTH 10000 855 #endif 856 857 858 859 #if YYERROR_VERBOSE 860 861 # ifndef yystrlen 862 # if defined __GLIBC__ && defined _STRING_H 863 # define yystrlen strlen 864 # else 865 /* Return the length of YYSTR. */ 866 #if (defined __STDC__ || defined __C99__FUNC__ \ 867 || defined __cplusplus || defined _MSC_VER) 868 static YYSIZE_T 869 yystrlen (const char *yystr) 870 #else 871 static YYSIZE_T 872 yystrlen (yystr) 873 const char *yystr; 874 #endif 875 { 876 YYSIZE_T yylen; 877 for (yylen = 0; yystr[yylen]; yylen++) 878 continue; 879 return yylen; 880 } 881 # endif 882 # endif 883 884 # ifndef yystpcpy 885 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE 886 # define yystpcpy stpcpy 887 # else 888 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 889 YYDEST. */ 890 #if (defined __STDC__ || defined __C99__FUNC__ \ 891 || defined __cplusplus || defined _MSC_VER) 892 static char * 893 yystpcpy (char *yydest, const char *yysrc) 894 #else 895 static char * 896 yystpcpy (yydest, yysrc) 897 char *yydest; 898 const char *yysrc; 899 #endif 900 { 901 char *yyd = yydest; 902 const char *yys = yysrc; 903 904 while ((*yyd++ = *yys++) != '\0') 905 continue; 906 907 return yyd - 1; 908 } 909 # endif 910 # endif 911 912 # ifndef yytnamerr 913 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary 914 quotes and backslashes, so that it's suitable for yyerror. The 915 heuristic is that double-quoting is unnecessary unless the string 916 contains an apostrophe, a comma, or backslash (other than 917 backslash-backslash). YYSTR is taken from yytname. If YYRES is 918 null, do not copy; instead, return the length of what the result 919 would have been. */ 920 static YYSIZE_T 921 yytnamerr (char *yyres, const char *yystr) 922 { 923 if (*yystr == '"') 924 { 925 YYSIZE_T yyn = 0; 926 char const *yyp = yystr; 927 928 for (;;) 929 switch (*++yyp) 930 { 931 case '\'': 932 case ',': 933 goto do_not_strip_quotes; 934 935 case '\\': 936 if (*++yyp != '\\') 937 goto do_not_strip_quotes; 938 /* Fall through. */ 939 default: 940 if (yyres) 941 yyres[yyn] = *yyp; 942 yyn++; 943 break; 944 945 case '"': 946 if (yyres) 947 yyres[yyn] = '\0'; 948 return yyn; 949 } 950 do_not_strip_quotes: ; 951 } 952 953 if (! yyres) 954 return yystrlen (yystr); 955 956 return yystpcpy (yyres, yystr) - yyres; 957 } 958 # endif 959 960 /* Copy into YYRESULT an error message about the unexpected token 961 YYCHAR while in state YYSTATE. Return the number of bytes copied, 962 including the terminating null byte. If YYRESULT is null, do not 963 copy anything; just return the number of bytes that would be 964 copied. As a special case, return 0 if an ordinary "syntax error" 965 message will do. Return YYSIZE_MAXIMUM if overflow occurs during 966 size calculation. */ 967 static YYSIZE_T 968 yysyntax_error (char *yyresult, int yystate, int yychar) 969 { 970 int yyn = yypact[yystate]; 971 972 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 973 return 0; 974 else 975 { 976 int yytype = YYTRANSLATE (yychar); 977 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 978 YYSIZE_T yysize = yysize0; 979 YYSIZE_T yysize1; 980 int yysize_overflow = 0; 981 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 982 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 983 int yyx; 984 985 # if 0 986 /* This is so xgettext sees the translatable formats that are 987 constructed on the fly. */ 988 YY_("syntax error, unexpected %s"); 989 YY_("syntax error, unexpected %s, expecting %s"); 990 YY_("syntax error, unexpected %s, expecting %s or %s"); 991 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 992 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 993 # endif 994 char *yyfmt; 995 char const *yyf; 996 static char const yyunexpected[] = "syntax error, unexpected %s"; 997 static char const yyexpecting[] = ", expecting %s"; 998 static char const yyor[] = " or %s"; 999 char yyformat[sizeof yyunexpected 1000 + sizeof yyexpecting - 1 1001 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1002 * (sizeof yyor - 1))]; 1003 char const *yyprefix = yyexpecting; 1004 1005 /* Start YYX at -YYN if negative to avoid negative indexes in 1006 YYCHECK. */ 1007 int yyxbegin = yyn < 0 ? -yyn : 0; 1008 1009 /* Stay within bounds of both yycheck and yytname. */ 1010 int yychecklim = YYLAST - yyn + 1; 1011 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 1012 int yycount = 1; 1013 1014 yyarg[0] = yytname[yytype]; 1015 yyfmt = yystpcpy (yyformat, yyunexpected); 1016 1017 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1018 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1019 { 1020 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 1021 { 1022 yycount = 1; 1023 yysize = yysize0; 1024 yyformat[sizeof yyunexpected - 1] = '\0'; 1025 break; 1026 } 1027 yyarg[yycount++] = yytname[yyx]; 1028 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 1029 yysize_overflow |= (yysize1 < yysize); 1030 yysize = yysize1; 1031 yyfmt = yystpcpy (yyfmt, yyprefix); 1032 yyprefix = yyor; 1033 } 1034 1035 yyf = YY_(yyformat); 1036 yysize1 = yysize + yystrlen (yyf); 1037 yysize_overflow |= (yysize1 < yysize); 1038 yysize = yysize1; 1039 1040 if (yysize_overflow) 1041 return YYSIZE_MAXIMUM; 1042 1043 if (yyresult) 1044 { 1045 /* Avoid sprintf, as that infringes on the user's name space. 1046 Don't have undefined behavior even if the translation 1047 produced a string with the wrong number of "%s"s. */ 1048 char *yyp = yyresult; 1049 int yyi = 0; 1050 while ((*yyp = *yyf) != '\0') 1051 { 1052 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 1053 { 1054 yyp += yytnamerr (yyp, yyarg[yyi++]); 1055 yyf += 2; 1056 } 1057 else 1058 { 1059 yyp++; 1060 yyf++; 1061 } 1062 } 1063 } 1064 return yysize; 1065 } 1066 } 1067 #endif /* YYERROR_VERBOSE */ 1068 1069 1070 /*-----------------------------------------------. 1071 | Release the memory associated to this symbol. | 1072 `-----------------------------------------------*/ 1073 1074 /*ARGSUSED*/ 1075 #if (defined __STDC__ || defined __C99__FUNC__ \ 1076 || defined __cplusplus || defined _MSC_VER) 1077 static void 1078 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) 1079 #else 1080 static void 1081 yydestruct (yymsg, yytype, yyvaluep) 1082 const char *yymsg; 1083 int yytype; 1084 YYSTYPE *yyvaluep; 1085 #endif 1086 { 1087 YYUSE (yyvaluep); 1088 1089 if (!yymsg) 1090 yymsg = "Deleting"; 1091 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1092 1093 switch (yytype) 1094 { 1095 1096 default: 1097 break; 1098 } 1099 } 1100 1101 1102 /* Prevent warnings from -Wmissing-prototypes. */ 1103 1104 #ifdef YYPARSE_PARAM 1105 #if defined __STDC__ || defined __cplusplus 1106 int yyparse (void *YYPARSE_PARAM); 1107 #else 1108 int yyparse (); 1109 #endif 1110 #else /* ! YYPARSE_PARAM */ 1111 #if defined __STDC__ || defined __cplusplus 1112 int yyparse (void); 1113 #else 1114 int yyparse (); 1115 #endif 1116 #endif /* ! YYPARSE_PARAM */ 1117 1118 1119 1120 /* The look-ahead symbol. */ 1121 int yychar; 1122 1123 /* The semantic value of the look-ahead symbol. */ 1124 YYSTYPE yylval; 1125 1126 /* Number of syntax errors so far. */ 1127 int yynerrs; 1128 1129 1130 1131 /*----------. 1132 | yyparse. | 1133 `----------*/ 1134 1135 #ifdef YYPARSE_PARAM 1136 #if (defined __STDC__ || defined __C99__FUNC__ \ 1137 || defined __cplusplus || defined _MSC_VER) 1138 int 1139 yyparse (void *YYPARSE_PARAM) 1140 #else 1141 int 1142 yyparse (YYPARSE_PARAM) 1143 void *YYPARSE_PARAM; 1144 #endif 1145 #else /* ! YYPARSE_PARAM */ 1146 #if (defined __STDC__ || defined __C99__FUNC__ \ 1147 || defined __cplusplus || defined _MSC_VER) 1148 int 1149 yyparse (void) 1150 #else 1151 int 1152 yyparse () 1153 1154 #endif 1155 #endif 1156 { 1157 1158 int yystate; 1159 int yyn; 1160 int yyresult; 1161 /* Number of tokens to shift before error messages enabled. */ 1162 int yyerrstatus; 1163 /* Look-ahead token as an internal (translated) token number. */ 1164 int yytoken = 0; 1165 void (*yyl)(); 1166 #if YYERROR_VERBOSE 1167 /* Buffer for error messages, and its allocated size. */ 1168 char yymsgbuf[128]; 1169 char *yymsg = yymsgbuf; 1170 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 1171 #endif 1172 1173 /* Three stacks and their tools: 1174 `yyss': related to states, 1175 `yyvs': related to semantic values, 1176 `yyls': related to locations. 1177 1178 Refer to the stacks thru separate pointers, to allow yyoverflow 1179 to reallocate them elsewhere. */ 1180 1181 /* The state stack. */ 1182 yytype_int16 yyssa[YYINITDEPTH]; 1183 yytype_int16 *yyss = yyssa; 1184 yytype_int16 *yyssp; 1185 1186 /* The semantic value stack. */ 1187 YYSTYPE yyvsa[YYINITDEPTH]; 1188 YYSTYPE *yyvs = yyvsa; 1189 YYSTYPE *yyvsp; 1190 1191 yyl = yylocal; 1192 1193 1194 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1195 1196 YYSIZE_T yystacksize = YYINITDEPTH; 1197 1198 /* The variables used to return semantic value and location from the 1199 action routines. */ 1200 YYSTYPE yyval; 1201 1202 1203 /* The number of symbols on the RHS of the reduced rule. 1204 Keep to zero when no symbol should be popped. */ 1205 int yylen = 0; 1206 1207 YYDPRINTF ((stderr, "Starting parse\n")); 1208 1209 yystate = 0; 1210 yyerrstatus = 0; 1211 yynerrs = 0; 1212 yychar = YYEMPTY; /* Cause a token to be read. */ 1213 1214 /* Initialize stack pointers. 1215 Waste one element of value and location stack 1216 so that they stay on the same level as the state stack. 1217 The wasted elements are never initialized. */ 1218 1219 yyssp = yyss; 1220 yyvsp = yyvs; 1221 yyl(); 1222 1223 goto yysetstate; 1224 1225 /*------------------------------------------------------------. 1226 | yynewstate -- Push a new state, which is found in yystate. | 1227 `------------------------------------------------------------*/ 1228 yynewstate: 1229 /* In all cases, when you get here, the value and location stacks 1230 have just been pushed. So pushing a state here evens the stacks. */ 1231 yyssp++; 1232 1233 yysetstate: 1234 *yyssp = yystate; 1235 1236 if (yyss + yystacksize - 1 <= yyssp) 1237 { 1238 /* Get the current used size of the three stacks, in elements. */ 1239 YYSIZE_T yysize = yyssp - yyss + 1; 1240 1241 #ifdef yyoverflow 1242 { 1243 /* Give user a chance to reallocate the stack. Use copies of 1244 these so that the &'s don't force the real ones into 1245 memory. */ 1246 YYSTYPE *yyvs1 = yyvs; 1247 yytype_int16 *yyss1 = yyss; 1248 1249 1250 /* Each stack pointer address is followed by the size of the 1251 data in use in that stack, in bytes. This used to be a 1252 conditional around just the two extra args, but that might 1253 be undefined if yyoverflow is a macro. */ 1254 yyoverflow (YY_("memory exhausted"), 1255 &yyss1, yysize * sizeof (*yyssp), 1256 &yyvs1, yysize * sizeof (*yyvsp), 1257 1258 &yystacksize); 1259 1260 yyss = yyss1; 1261 yyvs = yyvs1; 1262 } 1263 #else /* no yyoverflow */ 1264 # ifndef YYSTACK_RELOCATE 1265 goto yyexhaustedlab; 1266 # else 1267 /* Extend the stack our own way. */ 1268 if (YYMAXDEPTH <= yystacksize) 1269 goto yyexhaustedlab; 1270 yystacksize *= 2; 1271 if (YYMAXDEPTH < yystacksize) 1272 yystacksize = YYMAXDEPTH; 1273 1274 { 1275 yytype_int16 *yyss1 = yyss; 1276 union yyalloc *yyptr = 1277 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1278 if (! yyptr) 1279 goto yyexhaustedlab; 1280 YYSTACK_RELOCATE (yyss); 1281 YYSTACK_RELOCATE (yyvs); 1282 1283 # undef YYSTACK_RELOCATE 1284 if (yyss1 != yyssa) 1285 YYSTACK_FREE (yyss1); 1286 } 1287 # endif 1288 #endif /* no yyoverflow */ 1289 1290 yyssp = yyss + yysize - 1; 1291 yyvsp = yyvs + yysize - 1; 1292 1293 1294 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1295 (unsigned long int) yystacksize)); 1296 1297 if (yyss + yystacksize - 1 <= yyssp) 1298 YYABORT; 1299 } 1300 1301 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1302 1303 goto yybackup; 1304 1305 /*-----------. 1306 | yybackup. | 1307 `-----------*/ 1308 yybackup: 1309 1310 /* Do appropriate processing given the current state. Read a 1311 look-ahead token if we need one and don't already have one. */ 1312 1313 /* First try to decide what to do without reference to look-ahead token. */ 1314 yyn = yypact[yystate]; 1315 if (yyn == YYPACT_NINF) 1316 goto yydefault; 1317 1318 /* Not known => get a look-ahead token if don't already have one. */ 1319 1320 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1321 if (yychar == YYEMPTY) 1322 { 1323 YYDPRINTF ((stderr, "Reading a token: ")); 1324 yychar = YYLEX; 1325 } 1326 1327 if (yychar <= YYEOF) 1328 { 1329 yychar = yytoken = YYEOF; 1330 YYDPRINTF ((stderr, "Now at end of input.\n")); 1331 } 1332 else 1333 { 1334 yytoken = YYTRANSLATE (yychar); 1335 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1336 } 1337 1338 /* If the proper action on seeing token YYTOKEN is to reduce or to 1339 detect an error, take that action. */ 1340 yyn += yytoken; 1341 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1342 goto yydefault; 1343 yyn = yytable[yyn]; 1344 if (yyn <= 0) 1345 { 1346 if (yyn == 0 || yyn == YYTABLE_NINF) 1347 goto yyerrlab; 1348 yyn = -yyn; 1349 goto yyreduce; 1350 } 1351 1352 if (yyn == YYFINAL) 1353 YYACCEPT; 1354 1355 /* Count tokens shifted since error; after three, turn off error 1356 status. */ 1357 if (yyerrstatus) 1358 yyerrstatus--; 1359 1360 /* Shift the look-ahead token. */ 1361 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1362 1363 /* Discard the shifted token unless it is eof. */ 1364 if (yychar != YYEOF) 1365 yychar = YYEMPTY; 1366 1367 yystate = yyn; 1368 *++yyvsp = yylval; 1369 1370 goto yynewstate; 1371 1372 1373 /*-----------------------------------------------------------. 1374 | yydefault -- do the default action for the current state. | 1375 `-----------------------------------------------------------*/ 1376 yydefault: 1377 yyn = yydefact[yystate]; 1378 if (yyn == 0) 1379 goto yyerrlab; 1380 goto yyreduce; 1381 1382 1383 /*-----------------------------. 1384 | yyreduce -- Do a reduction. | 1385 `-----------------------------*/ 1386 yyreduce: 1387 /* yyn is the number of a rule to reduce with. */ 1388 yylen = yyr2[yyn]; 1389 1390 /* If YYLEN is nonzero, implement the default value of the action: 1391 `$$ = $1'. 1392 1393 Otherwise, the following line sets YYVAL to garbage. 1394 This behavior is undocumented and Bison 1395 users should not rely upon it. Assigning to YYVAL 1396 unconditionally makes the parser a bit smaller, and it avoids a 1397 GCC warning that YYVAL may be used uninitialized. */ 1398 yyval = yyvsp[1-yylen]; 1399 1400 1401 YY_REDUCE_PRINT (yyn); 1402 switch (yyn) 1403 { 1404 case 5: 1405 #line 73 "calc.y" 1406 { printf ("\t%.12Lf + %.12Lf i\n", creall((yyvsp[(1) - (2)])), cimagl((yyvsp[(1) - (2)]))); ;} 1407 break; 1408 1409 case 6: 1410 #line 76 "calc.y" 1411 { (yyval) = (yyvsp[(1) - (1)]); ;} 1412 break; 1413 1414 case 7: 1415 #line 77 "calc.y" 1416 { (yyval) = (yyvsp[(1) - (3)]) + (yyvsp[(3) - (3)]); ;} 1417 break; 1418 1419 case 8: 1420 #line 78 "calc.y" 1421 { (yyval) = (yyvsp[(1) - (3)]) - (yyvsp[(3) - (3)]); ;} 1422 break; 1423 1424 case 9: 1425 #line 79 "calc.y" 1426 { (yyval) = (yyvsp[(1) - (3)]) * (yyvsp[(3) - (3)]); ;} 1427 break; 1428 1429 case 10: 1430 #line 80 "calc.y" 1431 { (yyval) = (yyvsp[(1) - (3)]) / (yyvsp[(3) - (3)]); ;} 1432 break; 1433 1434 case 11: 1435 #line 81 "calc.y" 1436 { (yyval) = (yyvsp[(1) - (3)])*cpowl(10, (yyvsp[(3) - (3)])); ;} 1437 break; 1438 1439 case 12: 1440 #line 82 "calc.y" 1441 { (yyval) = -(yyvsp[(2) - (2)]); ;} 1442 break; 1443 1444 case 13: 1445 #line 83 "calc.y" 1446 { (yyval) = cpowl((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;} 1447 break; 1448 1449 case 14: 1450 #line 84 "calc.y" 1451 { (yyval) = (yyvsp[(2) - (3)]); ;} 1452 break; 1453 1454 1455 /* Line 1267 of yacc.c. */ 1456 #line 1424 "calc.tab.c" 1457 default: break; 1458 } 1459 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 1460 1461 YYPOPSTACK (yylen); 1462 yylen = 0; 1463 YY_STACK_PRINT (yyss, yyssp); 1464 1465 *++yyvsp = yyval; 1466 1467 1468 /* Now `shift' the result of the reduction. Determine what state 1469 that goes to, based on the state we popped back to and the rule 1470 number reduced by. */ 1471 1472 yyn = yyr1[yyn]; 1473 1474 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 1475 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1476 yystate = yytable[yystate]; 1477 else 1478 yystate = yydefgoto[yyn - YYNTOKENS]; 1479 1480 goto yynewstate; 1481 1482 1483 /*------------------------------------. 1484 | yyerrlab -- here on detecting error | 1485 `------------------------------------*/ 1486 yyerrlab: 1487 /* If not already recovering from an error, report this error. */ 1488 if (!yyerrstatus) 1489 { 1490 ++yynerrs; 1491 #if ! YYERROR_VERBOSE 1492 yyerror (YY_("syntax error")); 1493 #else 1494 { 1495 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 1496 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 1497 { 1498 YYSIZE_T yyalloc = 2 * yysize; 1499 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 1500 yyalloc = YYSTACK_ALLOC_MAXIMUM; 1501 if (yymsg != yymsgbuf) 1502 YYSTACK_FREE (yymsg); 1503 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 1504 if (yymsg) 1505 yymsg_alloc = yyalloc; 1506 else 1507 { 1508 yymsg = yymsgbuf; 1509 yymsg_alloc = sizeof yymsgbuf; 1510 } 1511 } 1512 1513 if (0 < yysize && yysize <= yymsg_alloc) 1514 { 1515 (void) yysyntax_error (yymsg, yystate, yychar); 1516 yyerror (yymsg); 1517 } 1518 else 1519 { 1520 yyerror (YY_("syntax error")); 1521 if (yysize != 0) 1522 goto yyexhaustedlab; 1523 } 1524 } 1525 #endif 1526 } 1527 1528 1529 1530 if (yyerrstatus == 3) 1531 { 1532 /* If just tried and failed to reuse look-ahead token after an 1533 error, discard it. */ 1534 1535 if (yychar <= YYEOF) 1536 { 1537 /* Return failure if at end of input. */ 1538 if (yychar == YYEOF) 1539 YYABORT; 1540 } 1541 else 1542 { 1543 yydestruct ("Error: discarding", 1544 yytoken, &yylval); 1545 yychar = YYEMPTY; 1546 } 1547 } 1548 1549 /* Else will try to reuse look-ahead token after shifting the error 1550 token. */ 1551 goto yyerrlab1; 1552 1553 1554 /*---------------------------------------------------. 1555 | yyerrorlab -- error raised explicitly by YYERROR. | 1556 `---------------------------------------------------*/ 1557 yyerrorlab: 1558 1559 /* Pacify compilers like GCC when the user code never invokes 1560 YYERROR and the label yyerrorlab therefore never appears in user 1561 code. */ 1562 if (/*CONSTCOND*/ 0) 1563 goto yyerrorlab; 1564 1565 /* Do not reclaim the symbols of the rule which action triggered 1566 this YYERROR. */ 1567 YYPOPSTACK (yylen); 1568 yylen = 0; 1569 YY_STACK_PRINT (yyss, yyssp); 1570 yystate = *yyssp; 1571 goto yyerrlab1; 1572 1573 1574 /*-------------------------------------------------------------. 1575 | yyerrlab1 -- common code for both syntax error and YYERROR. | 1576 `-------------------------------------------------------------*/ 1577 yyerrlab1: 1578 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1579 1580 for (;;) 1581 { 1582 yyn = yypact[yystate]; 1583 if (yyn != YYPACT_NINF) 1584 { 1585 yyn += YYTERROR; 1586 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 1587 { 1588 yyn = yytable[yyn]; 1589 if (0 < yyn) 1590 break; 1591 } 1592 } 1593 1594 /* Pop the current state because it cannot handle the error token. */ 1595 if (yyssp == yyss) 1596 YYABORT; 1597 1598 1599 yydestruct ("Error: popping", 1600 yystos[yystate], yyvsp); 1601 YYPOPSTACK (1); 1602 yystate = *yyssp; 1603 YY_STACK_PRINT (yyss, yyssp); 1604 } 1605 1606 if (yyn == YYFINAL) 1607 YYACCEPT; 1608 1609 *++yyvsp = yylval; 1610 1611 1612 /* Shift the error token. */ 1613 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 1614 1615 yystate = yyn; 1616 goto yynewstate; 1617 1618 1619 /*-------------------------------------. 1620 | yyacceptlab -- YYACCEPT comes here. | 1621 `-------------------------------------*/ 1622 yyacceptlab: 1623 yyresult = 0; 1624 goto yyreturn; 1625 1626 /*-----------------------------------. 1627 | yyabortlab -- YYABORT comes here. | 1628 `-----------------------------------*/ 1629 yyabortlab: 1630 yyresult = 1; 1631 goto yyreturn; 1632 1633 #ifndef yyoverflow 1634 /*-------------------------------------------------. 1635 | yyexhaustedlab -- memory exhaustion comes here. | 1636 `-------------------------------------------------*/ 1637 yyexhaustedlab: 1638 yyerror (YY_("memory exhausted")); 1639 yyresult = 2; 1640 /* Fall through. */ 1641 #endif 1642 1643 yyreturn: 1644 if (yychar != YYEOF && yychar != YYEMPTY) 1645 yydestruct ("Cleanup: discarding lookahead", 1646 yytoken, &yylval); 1647 /* Do not reclaim the symbols of the rule which action triggered 1648 this YYABORT or YYACCEPT. */ 1649 YYPOPSTACK (yylen); 1650 YY_STACK_PRINT (yyss, yyssp); 1651 while (yyssp != yyss) 1652 { 1653 yydestruct ("Cleanup: popping", 1654 yystos[*yyssp], yyvsp); 1655 YYPOPSTACK (1); 1656 } 1657 #ifndef yyoverflow 1658 if (yyss != yyssa) 1659 YYSTACK_FREE (yyss); 1660 #endif 1661 #if YYERROR_VERBOSE 1662 if (yymsg != yymsgbuf) 1663 YYSTACK_FREE (yymsg); 1664 #endif 1665 /* Make sure YYID is used. */ 1666 return YYID (yyresult); 1667 } 1668 1669 1670 #line 86 "calc.y" 1671