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