1 /* A Bison parser, made by GNU Bison 3.8.2. */ 2 3 /* Bison implementation for Yacc-like parsers in C 4 5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, 6 Inc. 7 8 This program is free software: you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation, either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 20 21 /* As a special exception, you may create a larger work that contains 22 part or all of the Bison parser skeleton and distribute that work 23 under terms of your choice, so long as that work isn't itself a 24 parser generator using the skeleton or a modified version thereof 25 as a parser skeleton. Alternatively, if you modify or redistribute 26 the parser skeleton itself, you may (at your option) remove this 27 special exception, which will cause the skeleton and the resulting 28 Bison output files to be licensed under the GNU General Public 29 License without this special exception. 30 31 This special exception was added by the Free Software Foundation in 32 version 2.2 of Bison. */ 33 34 /* C LALR(1) parser skeleton written by Richard Stallman, by 35 simplifying the original so-called "semantic" parser. */ 36 37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 38 especially those whose name start with YY_ or yy_. They are 39 private implementation details that can be changed or removed. */ 40 41 /* All symbols defined below should begin with yy or YY, to avoid 42 infringing on user name space. This should be done even for local 43 variables, as they might otherwise be expanded by user macros. 44 There are some unavoidable exceptions within include files to 45 define necessary library symbols; they are noted "INFRINGES ON 46 USER NAME SPACE" below. */ 47 48 /* Identify Bison output, and Bison version. */ 49 #define YYBISON 30802 50 51 /* Bison version string. */ 52 #define YYBISON_VERSION "3.8.2" 53 54 /* Skeleton name. */ 55 #define YYSKELETON_NAME "yacc.c" 56 57 /* Pure parsers. */ 58 #define YYPURE 0 59 60 /* Push parsers. */ 61 #define YYPUSH 0 62 63 /* Pull parsers. */ 64 #define YYPULL 1 65 66 67 68 69 /* First part of user prologue. */ 70 #line 21 "./itbl-parse.y" 71 72 73 /* 74 75 Yacc grammar for instruction table entries. 76 77 ======================================================================= 78 Original Instruction table specification document: 79 80 MIPS Coprocessor Table Specification 81 ==================================== 82 83 This document describes the format of the MIPS coprocessor table. The 84 table specifies a list of valid functions, data registers and control 85 registers that can be used in coprocessor instructions. This list, 86 together with the coprocessor instruction classes listed below, 87 specifies the complete list of coprocessor instructions that will 88 be recognized and assembled by the GNU assembler. In effect, 89 this makes the GNU assembler table-driven, where the table is 90 specified by the programmer. 91 92 The table is an ordinary text file that the GNU assembler reads when 93 it starts. Using the information in the table, the assembler 94 generates an internal list of valid coprocessor registers and 95 functions. The assembler uses this internal list in addition to the 96 standard MIPS registers and instructions which are built-in to the 97 assembler during code generation. 98 99 To specify the coprocessor table when invoking the GNU assembler, use 100 the command line option "--itbl file", where file is the 101 complete name of the table, including path and extension. 102 103 Examples: 104 105 gas -t cop.tbl test.s -o test.o 106 gas -t /usr/local/lib/cop.tbl test.s -o test.o 107 gas --itbl d:\gnu\data\cop.tbl test.s -o test.o 108 109 Only one table may be supplied during a single invocation of 110 the assembler. 111 112 113 Instruction classes 114 =================== 115 116 Below is a list of the valid coprocessor instruction classes for 117 any given coprocessor "z". These instructions are already recognized 118 by the assembler, and are listed here only for reference. 119 120 Class format instructions 121 ------------------------------------------------- 122 Class1: 123 op base rt offset 124 LWCz rt,offset (base) 125 SWCz rt,offset (base) 126 Class2: 127 COPz sub rt rd 0 128 MTCz rt,rd 129 MFCz rt,rd 130 CTCz rt,rd 131 CFCz rt,rd 132 Class3: 133 COPz CO cofun 134 COPz cofun 135 Class4: 136 COPz BC br offset 137 BCzT offset 138 BCzF offset 139 Class5: 140 COPz sub rt rd 0 141 DMFCz rt,rd 142 DMTCz rt,rd 143 Class6: 144 op base rt offset 145 LDCz rt,offset (base) 146 SDCz rt,offset (base) 147 Class7: 148 COPz BC br offset 149 BCzTL offset 150 BCzFL offset 151 152 The coprocessor table defines coprocessor-specific registers that can 153 be used with all of the above classes of instructions, where 154 appropriate. It also defines additional coprocessor-specific 155 functions for Class3 (COPz cofun) instructions, Thus, the table allows 156 the programmer to use convenient mnemonics and operands for these 157 functions, instead of the COPz mmenmonic and cofun operand. 158 159 The names of the MIPS general registers and their aliases are defined 160 by the assembler and will be recognized as valid register names by the 161 assembler when used (where allowed) in coprocessor instructions. 162 However, the names and values of all coprocessor data and control 163 register mnemonics must be specified in the coprocessor table. 164 165 166 Table Grammar 167 ============= 168 169 Here is the grammar for the coprocessor table: 170 171 table -> entry* 172 173 entry -> [z entrydef] [comment] '\n' 174 175 entrydef -> type name val 176 entrydef -> 'insn' name val funcdef ; type of entry (instruction) 177 178 z -> 'p'['0'..'3'] ; processor number 179 type -> ['dreg' | 'creg' | 'greg' ] ; type of entry (register) 180 ; 'dreg', 'creg' or 'greg' specifies a data, control, or general 181 ; register mnemonic, respectively 182 name -> [ltr|dec]* ; mnemonic of register/function 183 val -> [dec|hex] ; register/function number (integer constant) 184 185 funcdef -> frange flags fields 186 ; bitfield range for opcode 187 ; list of fields' formats 188 fields -> field* 189 field -> [','] ftype frange flags 190 flags -> ['*' flagexpr] 191 flagexpr -> '[' flagexpr ']' 192 flagexpr -> val '|' flagexpr 193 ftype -> [ type | 'immed' | 'addr' ] 194 ; 'immed' specifies an immediate value; see grammar for "val" above 195 ; 'addr' specifies a C identifier; name of symbol to be resolved at 196 ; link time 197 frange -> ':' val '-' val ; starting to ending bit positions, where 198 ; where 0 is least significant bit 199 frange -> (null) ; default range of 31-0 will be assumed 200 201 comment -> [';'|'#'] [char]* 202 char -> any printable character 203 ltr -> ['a'..'z'|'A'..'Z'] 204 dec -> ['0'..'9']* ; value in decimal 205 hex -> '0x'['0'..'9' | 'a'..'f' | 'A'..'F']* ; value in hexadecimal 206 207 208 Examples 209 ======== 210 211 Example 1: 212 213 The table: 214 215 p1 dreg d1 1 ; data register "d1" for COP1 has value 1 216 p1 creg c3 3 ; ctrl register "c3" for COP1 has value 3 217 p3 func fill 0x1f:24-20 ; function "fill" for COP3 has value 31 and 218 ; no fields 219 220 will allow the assembler to accept the following coprocessor instructions: 221 222 LWC1 d1,0x100 ($2) 223 fill 224 225 Here, the general purpose register "$2", and instruction "LWC1", are standard 226 mnemonics built-in to the MIPS assembler. 227 228 229 Example 2: 230 231 The table: 232 233 p3 dreg d3 3 ; data register "d3" for COP3 has value 3 234 p3 creg c2 22 ; control register "c2" for COP3 has value 22 235 p3 func fee 0x1f:24-20 dreg:17-13 creg:12-8 immed:7-0 236 ; function "fee" for COP3 has value 31, and 3 fields 237 ; consisting of a data register, a control register, 238 ; and an immediate value. 239 240 will allow the assembler to accept the following coprocessor instruction: 241 242 fee d3,c2,0x1 243 244 and will emit the object code: 245 246 31-26 25 24-20 19-18 17-13 12-8 7-0 247 COPz CO fun dreg creg immed 248 010011 1 11111 00 00011 10110 00000001 249 250 0x4ff07601 251 252 253 Example 3: 254 255 The table: 256 257 p3 dreg d3 3 ; data register "d3" for COP3 has value 3 258 p3 creg c2 22 ; control register "c2" for COP3 has value 22 259 p3 func fuu 0x01f00001 dreg:17-13 creg:12-8 260 261 will allow the assembler to accept the following coprocessor 262 instruction: 263 264 fuu d3,c2 265 266 and will emit the object code: 267 268 31-26 25 24-20 19-18 17-13 12-8 7-0 269 COPz CO fun dreg creg 270 010011 1 11111 00 00011 10110 00000001 271 272 0x4ff07601 273 274 In this way, the programmer can force arbitrary bits of an instruction 275 to have predefined values. 276 277 ======================================================================= 278 Additional notes: 279 280 Encoding of ranges: 281 To handle more than one bit position range within an instruction, 282 use 0s to mask out the ranges which don't apply. 283 May decide to modify the syntax to allow commas separate multiple 284 ranges within an instruction (range','range). 285 286 Changes in grammar: 287 The number of parms argument to the function entry 288 was deleted from the original format such that we now count the fields. 289 290 ---- 291 FIXME! should really change lexical analyzer 292 to recognize 'dreg' etc. in context sensitive way. 293 Currently function names or mnemonics may be incorrectly parsed as keywords 294 295 FIXME! hex is ambiguous with any digit 296 297 */ 298 299 #include "as.h" 300 #include "itbl-lex.h" 301 #include "itbl-ops.h" 302 303 /* #define DEBUG */ 304 305 #ifdef DEBUG 306 #ifndef DBG_LVL 307 #define DBG_LVL 1 308 #endif 309 #else 310 #define DBG_LVL 0 311 #endif 312 313 #if DBG_LVL >= 1 314 #define DBG(x) printf x 315 #else 316 #define DBG(x) 317 #endif 318 319 #if DBG_LVL >= 2 320 #define DBGL2(x) printf x 321 #else 322 #define DBGL2(x) 323 #endif 324 325 static int sbit, ebit; 326 static struct itbl_entry *insn=0; 327 static void yyerror (const char *); 328 329 330 #line 331 "itbl-parse.c" 331 332 # ifndef YY_CAST 333 # ifdef __cplusplus 334 # define YY_CAST(Type, Val) static_cast<Type> (Val) 335 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) 336 # else 337 # define YY_CAST(Type, Val) ((Type) (Val)) 338 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) 339 # endif 340 # endif 341 # ifndef YY_NULLPTR 342 # if defined __cplusplus 343 # if 201103L <= __cplusplus 344 # define YY_NULLPTR nullptr 345 # else 346 # define YY_NULLPTR 0 347 # endif 348 # else 349 # define YY_NULLPTR ((void*)0) 350 # endif 351 # endif 352 353 /* Use api.header.include to #include this header 354 instead of duplicating it here. */ 355 #ifndef YY_YY_ITBL_PARSE_H_INCLUDED 356 # define YY_YY_ITBL_PARSE_H_INCLUDED 357 /* Debug traces. */ 358 #ifndef YYDEBUG 359 # define YYDEBUG 0 360 #endif 361 #if YYDEBUG 362 extern int yydebug; 363 #endif 364 365 /* Token kinds. */ 366 #ifndef YYTOKENTYPE 367 # define YYTOKENTYPE 368 enum yytokentype 369 { 370 YYEMPTY = -2, 371 YYEOF = 0, /* "end of file" */ 372 YYerror = 256, /* error */ 373 YYUNDEF = 257, /* "invalid token" */ 374 DREG = 258, /* DREG */ 375 CREG = 259, /* CREG */ 376 GREG = 260, /* GREG */ 377 IMMED = 261, /* IMMED */ 378 ADDR = 262, /* ADDR */ 379 INSN = 263, /* INSN */ 380 NUM = 264, /* NUM */ 381 ID = 265, /* ID */ 382 NL = 266, /* NL */ 383 PNUM = 267 /* PNUM */ 384 }; 385 typedef enum yytokentype yytoken_kind_t; 386 #endif 387 /* Token kinds. */ 388 #define YYEMPTY -2 389 #define YYEOF 0 390 #define YYerror 256 391 #define YYUNDEF 257 392 #define DREG 258 393 #define CREG 259 394 #define GREG 260 395 #define IMMED 261 396 #define ADDR 262 397 #define INSN 263 398 #define NUM 264 399 #define ID 265 400 #define NL 266 401 #define PNUM 267 402 403 /* Value type. */ 404 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 405 union YYSTYPE 406 { 407 #line 282 "./itbl-parse.y" 408 409 char *str; 410 int num; 411 int processor; 412 unsigned long val; 413 414 415 #line 416 "itbl-parse.c" 416 417 }; 418 typedef union YYSTYPE YYSTYPE; 419 # define YYSTYPE_IS_TRIVIAL 1 420 # define YYSTYPE_IS_DECLARED 1 421 #endif 422 423 424 extern YYSTYPE yylval; 425 426 427 int yyparse (void); 428 429 430 #endif /* !YY_YY_ITBL_PARSE_H_INCLUDED */ 431 /* Symbol kind. */ 432 enum yysymbol_kind_t 433 { 434 YYSYMBOL_YYEMPTY = -2, 435 YYSYMBOL_YYEOF = 0, /* "end of file" */ 436 YYSYMBOL_YYerror = 1, /* error */ 437 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ 438 YYSYMBOL_DREG = 3, /* DREG */ 439 YYSYMBOL_CREG = 4, /* CREG */ 440 YYSYMBOL_GREG = 5, /* GREG */ 441 YYSYMBOL_IMMED = 6, /* IMMED */ 442 YYSYMBOL_ADDR = 7, /* ADDR */ 443 YYSYMBOL_INSN = 8, /* INSN */ 444 YYSYMBOL_NUM = 9, /* NUM */ 445 YYSYMBOL_ID = 10, /* ID */ 446 YYSYMBOL_NL = 11, /* NL */ 447 YYSYMBOL_PNUM = 12, /* PNUM */ 448 YYSYMBOL_13_ = 13, /* ',' */ 449 YYSYMBOL_14_ = 14, /* '|' */ 450 YYSYMBOL_15_ = 15, /* '[' */ 451 YYSYMBOL_16_ = 16, /* ']' */ 452 YYSYMBOL_17_ = 17, /* '*' */ 453 YYSYMBOL_18_ = 18, /* ':' */ 454 YYSYMBOL_19_ = 19, /* '-' */ 455 YYSYMBOL_YYACCEPT = 20, /* $accept */ 456 YYSYMBOL_insntbl = 21, /* insntbl */ 457 YYSYMBOL_entrys = 22, /* entrys */ 458 YYSYMBOL_entry = 23, /* entry */ 459 YYSYMBOL_24_1 = 24, /* $@1 */ 460 YYSYMBOL_fieldspecs = 25, /* fieldspecs */ 461 YYSYMBOL_ftype = 26, /* ftype */ 462 YYSYMBOL_fieldspec = 27, /* fieldspec */ 463 YYSYMBOL_flagexpr = 28, /* flagexpr */ 464 YYSYMBOL_flags = 29, /* flags */ 465 YYSYMBOL_range = 30, /* range */ 466 YYSYMBOL_pnum = 31, /* pnum */ 467 YYSYMBOL_regtype = 32, /* regtype */ 468 YYSYMBOL_name = 33, /* name */ 469 YYSYMBOL_value = 34 /* value */ 470 }; 471 typedef enum yysymbol_kind_t yysymbol_kind_t; 472 473 474 475 476 #ifdef short 477 # undef short 478 #endif 479 480 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure 481 <limits.h> and (if available) <stdint.h> are included 482 so that the code can choose integer types of a good width. */ 483 484 #ifndef __PTRDIFF_MAX__ 485 # include <limits.h> /* INFRINGES ON USER NAME SPACE */ 486 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ 487 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */ 488 # define YY_STDINT_H 489 # endif 490 #endif 491 492 /* Narrow types that promote to a signed type and that can represent a 493 signed or unsigned integer of at least N bits. In tables they can 494 save space and decrease cache pressure. Promoting to a signed type 495 helps avoid bugs in integer arithmetic. */ 496 497 #ifdef __INT_LEAST8_MAX__ 498 typedef __INT_LEAST8_TYPE__ yytype_int8; 499 #elif defined YY_STDINT_H 500 typedef int_least8_t yytype_int8; 501 #else 502 typedef signed char yytype_int8; 503 #endif 504 505 #ifdef __INT_LEAST16_MAX__ 506 typedef __INT_LEAST16_TYPE__ yytype_int16; 507 #elif defined YY_STDINT_H 508 typedef int_least16_t yytype_int16; 509 #else 510 typedef short yytype_int16; 511 #endif 512 513 /* Work around bug in HP-UX 11.23, which defines these macros 514 incorrectly for preprocessor constants. This workaround can likely 515 be removed in 2023, as HPE has promised support for HP-UX 11.23 516 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of 517 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */ 518 #ifdef __hpux 519 # undef UINT_LEAST8_MAX 520 # undef UINT_LEAST16_MAX 521 # define UINT_LEAST8_MAX 255 522 # define UINT_LEAST16_MAX 65535 523 #endif 524 525 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ 526 typedef __UINT_LEAST8_TYPE__ yytype_uint8; 527 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ 528 && UINT_LEAST8_MAX <= INT_MAX) 529 typedef uint_least8_t yytype_uint8; 530 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX 531 typedef unsigned char yytype_uint8; 532 #else 533 typedef short yytype_uint8; 534 #endif 535 536 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ 537 typedef __UINT_LEAST16_TYPE__ yytype_uint16; 538 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ 539 && UINT_LEAST16_MAX <= INT_MAX) 540 typedef uint_least16_t yytype_uint16; 541 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX 542 typedef unsigned short yytype_uint16; 543 #else 544 typedef int yytype_uint16; 545 #endif 546 547 #ifndef YYPTRDIFF_T 548 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ 549 # define YYPTRDIFF_T __PTRDIFF_TYPE__ 550 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ 551 # elif defined PTRDIFF_MAX 552 # ifndef ptrdiff_t 553 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 554 # endif 555 # define YYPTRDIFF_T ptrdiff_t 556 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX 557 # else 558 # define YYPTRDIFF_T long 559 # define YYPTRDIFF_MAXIMUM LONG_MAX 560 # endif 561 #endif 562 563 #ifndef YYSIZE_T 564 # ifdef __SIZE_TYPE__ 565 # define YYSIZE_T __SIZE_TYPE__ 566 # elif defined size_t 567 # define YYSIZE_T size_t 568 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ 569 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 570 # define YYSIZE_T size_t 571 # else 572 # define YYSIZE_T unsigned 573 # endif 574 #endif 575 576 #define YYSIZE_MAXIMUM \ 577 YY_CAST (YYPTRDIFF_T, \ 578 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ 579 ? YYPTRDIFF_MAXIMUM \ 580 : YY_CAST (YYSIZE_T, -1))) 581 582 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) 583 584 585 /* Stored state numbers (used for stacks). */ 586 typedef yytype_int8 yy_state_t; 587 588 /* State numbers in computations. */ 589 typedef int yy_state_fast_t; 590 591 #ifndef YY_ 592 # if defined YYENABLE_NLS && YYENABLE_NLS 593 # if ENABLE_NLS 594 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 595 # define YY_(Msgid) dgettext ("bison-runtime", Msgid) 596 # endif 597 # endif 598 # ifndef YY_ 599 # define YY_(Msgid) Msgid 600 # endif 601 #endif 602 603 604 #ifndef YY_ATTRIBUTE_PURE 605 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) 606 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) 607 # else 608 # define YY_ATTRIBUTE_PURE 609 # endif 610 #endif 611 612 #ifndef YY_ATTRIBUTE_UNUSED 613 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) 614 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 615 # else 616 # define YY_ATTRIBUTE_UNUSED 617 # endif 618 #endif 619 620 /* Suppress unused-variable warnings by "using" E. */ 621 #if ! defined lint || defined __GNUC__ 622 # define YY_USE(E) ((void) (E)) 623 #else 624 # define YY_USE(E) /* empty */ 625 #endif 626 627 /* Suppress an incorrect diagnostic about yylval being uninitialized. */ 628 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ 629 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407 630 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 631 _Pragma ("GCC diagnostic push") \ 632 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") 633 # else 634 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 635 _Pragma ("GCC diagnostic push") \ 636 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ 637 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") 638 # endif 639 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ 640 _Pragma ("GCC diagnostic pop") 641 #else 642 # define YY_INITIAL_VALUE(Value) Value 643 #endif 644 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 645 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 646 # define YY_IGNORE_MAYBE_UNINITIALIZED_END 647 #endif 648 #ifndef YY_INITIAL_VALUE 649 # define YY_INITIAL_VALUE(Value) /* Nothing. */ 650 #endif 651 652 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ 653 # define YY_IGNORE_USELESS_CAST_BEGIN \ 654 _Pragma ("GCC diagnostic push") \ 655 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") 656 # define YY_IGNORE_USELESS_CAST_END \ 657 _Pragma ("GCC diagnostic pop") 658 #endif 659 #ifndef YY_IGNORE_USELESS_CAST_BEGIN 660 # define YY_IGNORE_USELESS_CAST_BEGIN 661 # define YY_IGNORE_USELESS_CAST_END 662 #endif 663 664 665 #define YY_ASSERT(E) ((void) (0 && (E))) 666 667 #if !defined yyoverflow 668 669 /* The parser invokes alloca or malloc; define the necessary symbols. */ 670 671 # ifdef YYSTACK_USE_ALLOCA 672 # if YYSTACK_USE_ALLOCA 673 # ifdef __GNUC__ 674 # define YYSTACK_ALLOC __builtin_alloca 675 # elif defined __BUILTIN_VA_ARG_INCR 676 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ 677 # elif defined _AIX 678 # define YYSTACK_ALLOC __alloca 679 # elif defined _MSC_VER 680 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ 681 # define alloca _alloca 682 # else 683 # define YYSTACK_ALLOC alloca 684 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS 685 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 686 /* Use EXIT_SUCCESS as a witness for stdlib.h. */ 687 # ifndef EXIT_SUCCESS 688 # define EXIT_SUCCESS 0 689 # endif 690 # endif 691 # endif 692 # endif 693 # endif 694 695 # ifdef YYSTACK_ALLOC 696 /* Pacify GCC's 'empty if-body' warning. */ 697 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 698 # ifndef YYSTACK_ALLOC_MAXIMUM 699 /* The OS might guarantee only one guard page at the bottom of the stack, 700 and a page size can be as small as 4096 bytes. So we cannot safely 701 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 702 to allow for a few compiler-allocated temporary stack slots. */ 703 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ 704 # endif 705 # else 706 # define YYSTACK_ALLOC YYMALLOC 707 # define YYSTACK_FREE YYFREE 708 # ifndef YYSTACK_ALLOC_MAXIMUM 709 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 710 # endif 711 # if (defined __cplusplus && ! defined EXIT_SUCCESS \ 712 && ! ((defined YYMALLOC || defined malloc) \ 713 && (defined YYFREE || defined free))) 714 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 715 # ifndef EXIT_SUCCESS 716 # define EXIT_SUCCESS 0 717 # endif 718 # endif 719 # ifndef YYMALLOC 720 # define YYMALLOC malloc 721 # if ! defined malloc && ! defined EXIT_SUCCESS 722 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 723 # endif 724 # endif 725 # ifndef YYFREE 726 # define YYFREE free 727 # if ! defined free && ! defined EXIT_SUCCESS 728 void free (void *); /* INFRINGES ON USER NAME SPACE */ 729 # endif 730 # endif 731 # endif 732 #endif /* !defined yyoverflow */ 733 734 #if (! defined yyoverflow \ 735 && (! defined __cplusplus \ 736 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 737 738 /* A type that is properly aligned for any stack member. */ 739 union yyalloc 740 { 741 yy_state_t yyss_alloc; 742 YYSTYPE yyvs_alloc; 743 }; 744 745 /* The size of the maximum gap between one aligned stack and the next. */ 746 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) 747 748 /* The size of an array large to enough to hold all stacks, each with 749 N elements. */ 750 # define YYSTACK_BYTES(N) \ 751 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ 752 + YYSTACK_GAP_MAXIMUM) 753 754 # define YYCOPY_NEEDED 1 755 756 /* Relocate STACK from its old location to the new one. The 757 local variables YYSIZE and YYSTACKSIZE give the old and new number of 758 elements in the stack, and YYPTR gives the new location of the 759 stack. Advance YYPTR to a properly aligned location for the next 760 stack. */ 761 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ 762 do \ 763 { \ 764 YYPTRDIFF_T yynewbytes; \ 765 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ 766 Stack = &yyptr->Stack_alloc; \ 767 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ 768 yyptr += yynewbytes / YYSIZEOF (*yyptr); \ 769 } \ 770 while (0) 771 772 #endif 773 774 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED 775 /* Copy COUNT objects from SRC to DST. The source and destination do 776 not overlap. */ 777 # ifndef YYCOPY 778 # if defined __GNUC__ && 1 < __GNUC__ 779 # define YYCOPY(Dst, Src, Count) \ 780 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) 781 # else 782 # define YYCOPY(Dst, Src, Count) \ 783 do \ 784 { \ 785 YYPTRDIFF_T yyi; \ 786 for (yyi = 0; yyi < (Count); yyi++) \ 787 (Dst)[yyi] = (Src)[yyi]; \ 788 } \ 789 while (0) 790 # endif 791 # endif 792 #endif /* !YYCOPY_NEEDED */ 793 794 /* YYFINAL -- State number of the termination state. */ 795 #define YYFINAL 9 796 /* YYLAST -- Last index in YYTABLE. */ 797 #define YYLAST 46 798 799 /* YYNTOKENS -- Number of terminals. */ 800 #define YYNTOKENS 20 801 /* YYNNTS -- Number of nonterminals. */ 802 #define YYNNTS 15 803 /* YYNRULES -- Number of rules. */ 804 #define YYNRULES 29 805 /* YYNSTATES -- Number of states. */ 806 #define YYNSTATES 51 807 808 /* YYMAXUTOK -- Last valid token kind. */ 809 #define YYMAXUTOK 267 810 811 812 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM 813 as returned by yylex, with out-of-bounds checking. */ 814 #define YYTRANSLATE(YYX) \ 815 (0 <= (YYX) && (YYX) <= YYMAXUTOK \ 816 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ 817 : YYSYMBOL_YYUNDEF) 818 819 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM 820 as returned by yylex. */ 821 static const yytype_int8 yytranslate[] = 822 { 823 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 824 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 825 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 826 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 827 2, 2, 17, 2, 13, 19, 2, 2, 2, 2, 828 2, 2, 2, 2, 2, 2, 2, 2, 18, 2, 829 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 830 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 831 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 832 2, 15, 2, 16, 2, 2, 2, 2, 2, 2, 833 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 834 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 835 2, 2, 2, 2, 14, 2, 2, 2, 2, 2, 836 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 837 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 838 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 839 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 840 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 841 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 842 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 843 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 844 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 845 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 846 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 847 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 848 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 849 5, 6, 7, 8, 9, 10, 11, 12 850 }; 851 852 #if YYDEBUG 853 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ 854 static const yytype_int16 yyrline[] = 855 { 856 0, 299, 299, 303, 304, 308, 315, 314, 323, 324, 857 328, 329, 330, 334, 339, 344, 352, 361, 365, 369, 858 376, 382, 388, 395, 402, 410, 415, 420, 428, 444 859 }; 860 #endif 861 862 /** Accessing symbol of state STATE. */ 863 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) 864 865 #if YYDEBUG || 0 866 /* The user-facing name of the symbol whose (internal) number is 867 YYSYMBOL. No bounds checking. */ 868 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; 869 870 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 871 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 872 static const char *const yytname[] = 873 { 874 "\"end of file\"", "error", "\"invalid token\"", "DREG", "CREG", "GREG", 875 "IMMED", "ADDR", "INSN", "NUM", "ID", "NL", "PNUM", "','", "'|'", "'['", 876 "']'", "'*'", "':'", "'-'", "$accept", "insntbl", "entrys", "entry", 877 "$@1", "fieldspecs", "ftype", "fieldspec", "flagexpr", "flags", "range", 878 "pnum", "regtype", "name", "value", YY_NULLPTR 879 }; 880 881 static const char * 882 yysymbol_name (yysymbol_kind_t yysymbol) 883 { 884 return yytname[yysymbol]; 885 } 886 #endif 887 888 #define YYPACT_NINF (-16) 889 890 #define yypact_value_is_default(Yyn) \ 891 ((Yyn) == YYPACT_NINF) 892 893 #define YYTABLE_NINF (-5) 894 895 #define yytable_value_is_error(Yyn) \ 896 0 897 898 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 899 STATE-NUM. */ 900 static const yytype_int8 yypact[] = 901 { 902 0, -9, -16, -16, 10, -16, 0, 12, -16, -16, 903 -16, -16, -16, -16, 3, 3, -16, 9, 9, -16, 904 11, 8, 19, 15, -16, 14, -6, -16, 25, 21, 905 -6, -16, 1, -16, -6, 20, -16, -16, 18, 26, 906 11, 1, -16, -16, -16, 1, -16, 15, -16, -16, 907 -16 908 }; 909 910 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 911 Performed when YYTABLE does not specify something else to do. Zero 912 means the default is an error. */ 913 static const yytype_int8 yydefact[] = 914 { 915 0, 0, 8, 24, 0, 2, 0, 0, 9, 1, 916 3, 25, 26, 27, 0, 0, 28, 0, 0, 29, 917 23, 0, 0, 21, 5, 0, 0, 6, 0, 19, 918 0, 20, 12, 22, 0, 0, 15, 14, 0, 0, 919 23, 12, 13, 17, 18, 12, 7, 21, 11, 10, 920 16 921 }; 922 923 /* YYPGOTO[NTERM-NUM]. */ 924 static const yytype_int8 yypgoto[] = 925 { 926 -16, -16, 32, -16, -16, -15, -16, 2, -3, -8, 927 4, -16, 34, 27, 28 928 }; 929 930 /* YYDEFGOTO[NTERM-NUM]. */ 931 static const yytype_int8 yydefgoto[] = 932 { 933 0, 4, 5, 6, 32, 39, 40, 41, 31, 27, 934 23, 7, 42, 17, 20 935 }; 936 937 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 938 positive, shift that token. If negative, reduce the rule whose 939 number is the opposite. If YYTABLE_NINF, syntax error. */ 940 static const yytype_int8 yytable[] = 941 { 942 -4, 1, 8, 29, 11, 12, 13, 36, 37, 30, 943 9, 2, 3, 16, 38, 11, 12, 13, 19, 24, 944 14, 11, 12, 13, 36, 37, 48, 35, 25, 22, 945 49, 43, 26, 28, 33, 34, 44, 46, 10, 50, 946 45, 15, 18, 0, 47, 0, 21 947 }; 948 949 static const yytype_int8 yycheck[] = 950 { 951 0, 1, 11, 9, 3, 4, 5, 6, 7, 15, 952 0, 11, 12, 10, 13, 3, 4, 5, 9, 11, 953 8, 3, 4, 5, 6, 7, 41, 30, 9, 18, 954 45, 34, 17, 19, 9, 14, 16, 11, 6, 47, 955 38, 7, 15, -1, 40, -1, 18 956 }; 957 958 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of 959 state STATE-NUM. */ 960 static const yytype_int8 yystos[] = 961 { 962 0, 1, 11, 12, 21, 22, 23, 31, 11, 0, 963 22, 3, 4, 5, 8, 32, 10, 33, 33, 9, 964 34, 34, 18, 30, 11, 9, 17, 29, 19, 9, 965 15, 28, 24, 9, 14, 28, 6, 7, 13, 25, 966 26, 27, 32, 28, 16, 27, 11, 30, 25, 25, 967 29 968 }; 969 970 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ 971 static const yytype_int8 yyr1[] = 972 { 973 0, 20, 21, 22, 22, 23, 24, 23, 23, 23, 974 25, 25, 25, 26, 26, 26, 27, 28, 28, 28, 975 29, 29, 30, 30, 31, 32, 32, 32, 33, 34 976 }; 977 978 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ 979 static const yytype_int8 yyr2[] = 980 { 981 0, 2, 1, 2, 0, 5, 0, 9, 1, 2, 982 3, 2, 0, 1, 1, 1, 3, 3, 3, 1, 983 2, 0, 4, 0, 1, 1, 1, 1, 1, 1 984 }; 985 986 987 enum { YYENOMEM = -2 }; 988 989 #define yyerrok (yyerrstatus = 0) 990 #define yyclearin (yychar = YYEMPTY) 991 992 #define YYACCEPT goto yyacceptlab 993 #define YYABORT goto yyabortlab 994 #define YYERROR goto yyerrorlab 995 #define YYNOMEM goto yyexhaustedlab 996 997 998 #define YYRECOVERING() (!!yyerrstatus) 999 1000 #define YYBACKUP(Token, Value) \ 1001 do \ 1002 if (yychar == YYEMPTY) \ 1003 { \ 1004 yychar = (Token); \ 1005 yylval = (Value); \ 1006 YYPOPSTACK (yylen); \ 1007 yystate = *yyssp; \ 1008 goto yybackup; \ 1009 } \ 1010 else \ 1011 { \ 1012 yyerror (YY_("syntax error: cannot back up")); \ 1013 YYERROR; \ 1014 } \ 1015 while (0) 1016 1017 /* Backward compatibility with an undocumented macro. 1018 Use YYerror or YYUNDEF. */ 1019 #define YYERRCODE YYUNDEF 1020 1021 1022 /* Enable debugging if requested. */ 1023 #if YYDEBUG 1024 1025 # ifndef YYFPRINTF 1026 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 1027 # define YYFPRINTF fprintf 1028 # endif 1029 1030 # define YYDPRINTF(Args) \ 1031 do { \ 1032 if (yydebug) \ 1033 YYFPRINTF Args; \ 1034 } while (0) 1035 1036 1037 1038 1039 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ 1040 do { \ 1041 if (yydebug) \ 1042 { \ 1043 YYFPRINTF (stderr, "%s ", Title); \ 1044 yy_symbol_print (stderr, \ 1045 Kind, Value); \ 1046 YYFPRINTF (stderr, "\n"); \ 1047 } \ 1048 } while (0) 1049 1050 1051 /*-----------------------------------. 1052 | Print this symbol's value on YYO. | 1053 `-----------------------------------*/ 1054 1055 static void 1056 yy_symbol_value_print (FILE *yyo, 1057 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) 1058 { 1059 FILE *yyoutput = yyo; 1060 YY_USE (yyoutput); 1061 if (!yyvaluep) 1062 return; 1063 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1064 YY_USE (yykind); 1065 YY_IGNORE_MAYBE_UNINITIALIZED_END 1066 } 1067 1068 1069 /*---------------------------. 1070 | Print this symbol on YYO. | 1071 `---------------------------*/ 1072 1073 static void 1074 yy_symbol_print (FILE *yyo, 1075 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) 1076 { 1077 YYFPRINTF (yyo, "%s %s (", 1078 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); 1079 1080 yy_symbol_value_print (yyo, yykind, yyvaluep); 1081 YYFPRINTF (yyo, ")"); 1082 } 1083 1084 /*------------------------------------------------------------------. 1085 | yy_stack_print -- Print the state stack from its BOTTOM up to its | 1086 | TOP (included). | 1087 `------------------------------------------------------------------*/ 1088 1089 static void 1090 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) 1091 { 1092 YYFPRINTF (stderr, "Stack now"); 1093 for (; yybottom <= yytop; yybottom++) 1094 { 1095 int yybot = *yybottom; 1096 YYFPRINTF (stderr, " %d", yybot); 1097 } 1098 YYFPRINTF (stderr, "\n"); 1099 } 1100 1101 # define YY_STACK_PRINT(Bottom, Top) \ 1102 do { \ 1103 if (yydebug) \ 1104 yy_stack_print ((Bottom), (Top)); \ 1105 } while (0) 1106 1107 1108 /*------------------------------------------------. 1109 | Report that the YYRULE is going to be reduced. | 1110 `------------------------------------------------*/ 1111 1112 static void 1113 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, 1114 int yyrule) 1115 { 1116 int yylno = yyrline[yyrule]; 1117 int yynrhs = yyr2[yyrule]; 1118 int yyi; 1119 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", 1120 yyrule - 1, yylno); 1121 /* The symbols being reduced. */ 1122 for (yyi = 0; yyi < yynrhs; yyi++) 1123 { 1124 YYFPRINTF (stderr, " $%d = ", yyi + 1); 1125 yy_symbol_print (stderr, 1126 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), 1127 &yyvsp[(yyi + 1) - (yynrhs)]); 1128 YYFPRINTF (stderr, "\n"); 1129 } 1130 } 1131 1132 # define YY_REDUCE_PRINT(Rule) \ 1133 do { \ 1134 if (yydebug) \ 1135 yy_reduce_print (yyssp, yyvsp, Rule); \ 1136 } while (0) 1137 1138 /* Nonzero means print parse trace. It is left uninitialized so that 1139 multiple parsers can coexist. */ 1140 int yydebug; 1141 #else /* !YYDEBUG */ 1142 # define YYDPRINTF(Args) ((void) 0) 1143 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) 1144 # define YY_STACK_PRINT(Bottom, Top) 1145 # define YY_REDUCE_PRINT(Rule) 1146 #endif /* !YYDEBUG */ 1147 1148 1149 /* YYINITDEPTH -- initial size of the parser's stacks. */ 1150 #ifndef YYINITDEPTH 1151 # define YYINITDEPTH 200 1152 #endif 1153 1154 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 1155 if the built-in stack extension method is used). 1156 1157 Do not make this value too large; the results are undefined if 1158 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 1159 evaluated with infinite-precision integer arithmetic. */ 1160 1161 #ifndef YYMAXDEPTH 1162 # define YYMAXDEPTH 10000 1163 #endif 1164 1165 1166 1167 1168 1169 1170 /*-----------------------------------------------. 1171 | Release the memory associated to this symbol. | 1172 `-----------------------------------------------*/ 1173 1174 static void 1175 yydestruct (const char *yymsg, 1176 yysymbol_kind_t yykind, YYSTYPE *yyvaluep) 1177 { 1178 YY_USE (yyvaluep); 1179 if (!yymsg) 1180 yymsg = "Deleting"; 1181 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); 1182 1183 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1184 YY_USE (yykind); 1185 YY_IGNORE_MAYBE_UNINITIALIZED_END 1186 } 1187 1188 1189 /* Lookahead token kind. */ 1190 int yychar; 1191 1192 /* The semantic value of the lookahead symbol. */ 1193 YYSTYPE yylval; 1194 /* Number of syntax errors so far. */ 1195 int yynerrs; 1196 1197 1198 1199 1200 /*----------. 1201 | yyparse. | 1202 `----------*/ 1203 1204 int 1205 yyparse (void) 1206 { 1207 yy_state_fast_t yystate = 0; 1208 /* Number of tokens to shift before error messages enabled. */ 1209 int yyerrstatus = 0; 1210 1211 /* Refer to the stacks through separate pointers, to allow yyoverflow 1212 to reallocate them elsewhere. */ 1213 1214 /* Their size. */ 1215 YYPTRDIFF_T yystacksize = YYINITDEPTH; 1216 1217 /* The state stack: array, bottom, top. */ 1218 yy_state_t yyssa[YYINITDEPTH]; 1219 yy_state_t *yyss = yyssa; 1220 yy_state_t *yyssp = yyss; 1221 1222 /* The semantic value stack: array, bottom, top. */ 1223 YYSTYPE yyvsa[YYINITDEPTH]; 1224 YYSTYPE *yyvs = yyvsa; 1225 YYSTYPE *yyvsp = yyvs; 1226 1227 int yyn; 1228 /* The return value of yyparse. */ 1229 int yyresult; 1230 /* Lookahead symbol kind. */ 1231 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; 1232 /* The variables used to return semantic value and location from the 1233 action routines. */ 1234 YYSTYPE yyval; 1235 1236 1237 1238 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1239 1240 /* The number of symbols on the RHS of the reduced rule. 1241 Keep to zero when no symbol should be popped. */ 1242 int yylen = 0; 1243 1244 YYDPRINTF ((stderr, "Starting parse\n")); 1245 1246 yychar = YYEMPTY; /* Cause a token to be read. */ 1247 1248 goto yysetstate; 1249 1250 1251 /*------------------------------------------------------------. 1252 | yynewstate -- push a new state, which is found in yystate. | 1253 `------------------------------------------------------------*/ 1254 yynewstate: 1255 /* In all cases, when you get here, the value and location stacks 1256 have just been pushed. So pushing a state here evens the stacks. */ 1257 yyssp++; 1258 1259 1260 /*--------------------------------------------------------------------. 1261 | yysetstate -- set current state (the top of the stack) to yystate. | 1262 `--------------------------------------------------------------------*/ 1263 yysetstate: 1264 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1265 YY_ASSERT (0 <= yystate && yystate < YYNSTATES); 1266 YY_IGNORE_USELESS_CAST_BEGIN 1267 *yyssp = YY_CAST (yy_state_t, yystate); 1268 YY_IGNORE_USELESS_CAST_END 1269 YY_STACK_PRINT (yyss, yyssp); 1270 1271 if (yyss + yystacksize - 1 <= yyssp) 1272 #if !defined yyoverflow && !defined YYSTACK_RELOCATE 1273 YYNOMEM; 1274 #else 1275 { 1276 /* Get the current used size of the three stacks, in elements. */ 1277 YYPTRDIFF_T yysize = yyssp - yyss + 1; 1278 1279 # if defined yyoverflow 1280 { 1281 /* Give user a chance to reallocate the stack. Use copies of 1282 these so that the &'s don't force the real ones into 1283 memory. */ 1284 yy_state_t *yyss1 = yyss; 1285 YYSTYPE *yyvs1 = yyvs; 1286 1287 /* Each stack pointer address is followed by the size of the 1288 data in use in that stack, in bytes. This used to be a 1289 conditional around just the two extra args, but that might 1290 be undefined if yyoverflow is a macro. */ 1291 yyoverflow (YY_("memory exhausted"), 1292 &yyss1, yysize * YYSIZEOF (*yyssp), 1293 &yyvs1, yysize * YYSIZEOF (*yyvsp), 1294 &yystacksize); 1295 yyss = yyss1; 1296 yyvs = yyvs1; 1297 } 1298 # else /* defined YYSTACK_RELOCATE */ 1299 /* Extend the stack our own way. */ 1300 if (YYMAXDEPTH <= yystacksize) 1301 YYNOMEM; 1302 yystacksize *= 2; 1303 if (YYMAXDEPTH < yystacksize) 1304 yystacksize = YYMAXDEPTH; 1305 1306 { 1307 yy_state_t *yyss1 = yyss; 1308 union yyalloc *yyptr = 1309 YY_CAST (union yyalloc *, 1310 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); 1311 if (! yyptr) 1312 YYNOMEM; 1313 YYSTACK_RELOCATE (yyss_alloc, yyss); 1314 YYSTACK_RELOCATE (yyvs_alloc, yyvs); 1315 # undef YYSTACK_RELOCATE 1316 if (yyss1 != yyssa) 1317 YYSTACK_FREE (yyss1); 1318 } 1319 # endif 1320 1321 yyssp = yyss + yysize - 1; 1322 yyvsp = yyvs + yysize - 1; 1323 1324 YY_IGNORE_USELESS_CAST_BEGIN 1325 YYDPRINTF ((stderr, "Stack size increased to %ld\n", 1326 YY_CAST (long, yystacksize))); 1327 YY_IGNORE_USELESS_CAST_END 1328 1329 if (yyss + yystacksize - 1 <= yyssp) 1330 YYABORT; 1331 } 1332 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ 1333 1334 1335 if (yystate == YYFINAL) 1336 YYACCEPT; 1337 1338 goto yybackup; 1339 1340 1341 /*-----------. 1342 | yybackup. | 1343 `-----------*/ 1344 yybackup: 1345 /* Do appropriate processing given the current state. Read a 1346 lookahead token if we need one and don't already have one. */ 1347 1348 /* First try to decide what to do without reference to lookahead token. */ 1349 yyn = yypact[yystate]; 1350 if (yypact_value_is_default (yyn)) 1351 goto yydefault; 1352 1353 /* Not known => get a lookahead token if don't already have one. */ 1354 1355 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ 1356 if (yychar == YYEMPTY) 1357 { 1358 YYDPRINTF ((stderr, "Reading a token\n")); 1359 yychar = yylex (); 1360 } 1361 1362 if (yychar <= YYEOF) 1363 { 1364 yychar = YYEOF; 1365 yytoken = YYSYMBOL_YYEOF; 1366 YYDPRINTF ((stderr, "Now at end of input.\n")); 1367 } 1368 else if (yychar == YYerror) 1369 { 1370 /* The scanner already issued an error message, process directly 1371 to error recovery. But do not keep the error token as 1372 lookahead, it is too special and may lead us to an endless 1373 loop in error recovery. */ 1374 yychar = YYUNDEF; 1375 yytoken = YYSYMBOL_YYerror; 1376 goto yyerrlab1; 1377 } 1378 else 1379 { 1380 yytoken = YYTRANSLATE (yychar); 1381 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1382 } 1383 1384 /* If the proper action on seeing token YYTOKEN is to reduce or to 1385 detect an error, take that action. */ 1386 yyn += yytoken; 1387 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1388 goto yydefault; 1389 yyn = yytable[yyn]; 1390 if (yyn <= 0) 1391 { 1392 if (yytable_value_is_error (yyn)) 1393 goto yyerrlab; 1394 yyn = -yyn; 1395 goto yyreduce; 1396 } 1397 1398 /* Count tokens shifted since error; after three, turn off error 1399 status. */ 1400 if (yyerrstatus) 1401 yyerrstatus--; 1402 1403 /* Shift the lookahead token. */ 1404 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1405 yystate = yyn; 1406 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1407 *++yyvsp = yylval; 1408 YY_IGNORE_MAYBE_UNINITIALIZED_END 1409 1410 /* Discard the shifted token. */ 1411 yychar = YYEMPTY; 1412 goto yynewstate; 1413 1414 1415 /*-----------------------------------------------------------. 1416 | yydefault -- do the default action for the current state. | 1417 `-----------------------------------------------------------*/ 1418 yydefault: 1419 yyn = yydefact[yystate]; 1420 if (yyn == 0) 1421 goto yyerrlab; 1422 goto yyreduce; 1423 1424 1425 /*-----------------------------. 1426 | yyreduce -- do a reduction. | 1427 `-----------------------------*/ 1428 yyreduce: 1429 /* yyn is the number of a rule to reduce with. */ 1430 yylen = yyr2[yyn]; 1431 1432 /* If YYLEN is nonzero, implement the default value of the action: 1433 '$$ = $1'. 1434 1435 Otherwise, the following line sets YYVAL to garbage. 1436 This behavior is undocumented and Bison 1437 users should not rely upon it. Assigning to YYVAL 1438 unconditionally makes the parser a bit smaller, and it avoids a 1439 GCC warning that YYVAL may be used uninitialized. */ 1440 yyval = yyvsp[1-yylen]; 1441 1442 1443 YY_REDUCE_PRINT (yyn); 1444 switch (yyn) 1445 { 1446 case 5: /* entry: pnum regtype name value NL */ 1447 #line 309 "./itbl-parse.y" 1448 { 1449 DBG (("line %d: entry pnum=%d type=%d name=%s value=x%x\n", 1450 insntbl_line, (yyvsp[-4].num), (yyvsp[-3].num), (yyvsp[-2].str), (yyvsp[-1].val))); 1451 itbl_add_reg ((yyvsp[-4].num), (yyvsp[-3].num), (yyvsp[-2].str), (yyvsp[-1].val)); 1452 } 1453 #line 1454 "itbl-parse.c" 1454 break; 1455 1456 case 6: /* $@1: %empty */ 1457 #line 315 "./itbl-parse.y" 1458 { 1459 DBG (("line %d: entry pnum=%d type=INSN name=%s value=x%x", 1460 insntbl_line, (yyvsp[-5].num), (yyvsp[-3].str), (yyvsp[-2].val))); 1461 DBG ((" sbit=%d ebit=%d flags=0x%x\n", sbit, ebit, (yyvsp[0].val))); 1462 insn=itbl_add_insn ((yyvsp[-5].num), (yyvsp[-3].str), (yyvsp[-2].val), sbit, ebit, (yyvsp[0].val)); 1463 } 1464 #line 1465 "itbl-parse.c" 1465 break; 1466 1467 case 7: /* entry: pnum INSN name value range flags $@1 fieldspecs NL */ 1468 #line 322 "./itbl-parse.y" 1469 {} 1470 #line 1471 "itbl-parse.c" 1471 break; 1472 1473 case 13: /* ftype: regtype */ 1474 #line 335 "./itbl-parse.y" 1475 { 1476 DBGL2 (("ftype\n")); 1477 (yyval.num) = (yyvsp[0].num); 1478 } 1479 #line 1480 "itbl-parse.c" 1480 break; 1481 1482 case 14: /* ftype: ADDR */ 1483 #line 340 "./itbl-parse.y" 1484 { 1485 DBGL2 (("addr\n")); 1486 (yyval.num) = ADDR; 1487 } 1488 #line 1489 "itbl-parse.c" 1489 break; 1490 1491 case 15: /* ftype: IMMED */ 1492 #line 345 "./itbl-parse.y" 1493 { 1494 DBGL2 (("immed\n")); 1495 (yyval.num) = IMMED; 1496 } 1497 #line 1498 "itbl-parse.c" 1498 break; 1499 1500 case 16: /* fieldspec: ftype range flags */ 1501 #line 353 "./itbl-parse.y" 1502 { 1503 DBG (("line %d: field type=%d sbit=%d ebit=%d, flags=0x%x\n", 1504 insntbl_line, (yyvsp[-2].num), sbit, ebit, (yyvsp[0].val))); 1505 itbl_add_operand (insn, (yyvsp[-2].num), sbit, ebit, (yyvsp[0].val)); 1506 } 1507 #line 1508 "itbl-parse.c" 1508 break; 1509 1510 case 17: /* flagexpr: NUM '|' flagexpr */ 1511 #line 362 "./itbl-parse.y" 1512 { 1513 (yyval.val) = (yyvsp[-2].num) | (yyvsp[0].val); 1514 } 1515 #line 1516 "itbl-parse.c" 1516 break; 1517 1518 case 18: /* flagexpr: '[' flagexpr ']' */ 1519 #line 366 "./itbl-parse.y" 1520 { 1521 (yyval.val) = (yyvsp[-1].val); 1522 } 1523 #line 1524 "itbl-parse.c" 1524 break; 1525 1526 case 19: /* flagexpr: NUM */ 1527 #line 370 "./itbl-parse.y" 1528 { 1529 (yyval.val) = (yyvsp[0].num); 1530 } 1531 #line 1532 "itbl-parse.c" 1532 break; 1533 1534 case 20: /* flags: '*' flagexpr */ 1535 #line 377 "./itbl-parse.y" 1536 { 1537 DBGL2 (("flags=%d\n", (yyvsp[0].val))); 1538 (yyval.val) = (yyvsp[0].val); 1539 } 1540 #line 1541 "itbl-parse.c" 1541 break; 1542 1543 case 21: /* flags: %empty */ 1544 #line 382 "./itbl-parse.y" 1545 { 1546 (yyval.val) = 0; 1547 } 1548 #line 1549 "itbl-parse.c" 1549 break; 1550 1551 case 22: /* range: ':' NUM '-' NUM */ 1552 #line 389 "./itbl-parse.y" 1553 { 1554 DBGL2 (("range %d %d\n", (yyvsp[-2].num), (yyvsp[0].num))); 1555 sbit = (yyvsp[-2].num); 1556 ebit = (yyvsp[0].num); 1557 } 1558 #line 1559 "itbl-parse.c" 1559 break; 1560 1561 case 23: /* range: %empty */ 1562 #line 395 "./itbl-parse.y" 1563 { 1564 sbit = 31; 1565 ebit = 0; 1566 } 1567 #line 1568 "itbl-parse.c" 1568 break; 1569 1570 case 24: /* pnum: PNUM */ 1571 #line 403 "./itbl-parse.y" 1572 { 1573 DBGL2 (("pnum=%d\n",(yyvsp[0].num))); 1574 (yyval.num) = (yyvsp[0].num); 1575 } 1576 #line 1577 "itbl-parse.c" 1577 break; 1578 1579 case 25: /* regtype: DREG */ 1580 #line 411 "./itbl-parse.y" 1581 { 1582 DBGL2 (("dreg\n")); 1583 (yyval.num) = DREG; 1584 } 1585 #line 1586 "itbl-parse.c" 1586 break; 1587 1588 case 26: /* regtype: CREG */ 1589 #line 416 "./itbl-parse.y" 1590 { 1591 DBGL2 (("creg\n")); 1592 (yyval.num) = CREG; 1593 } 1594 #line 1595 "itbl-parse.c" 1595 break; 1596 1597 case 27: /* regtype: GREG */ 1598 #line 421 "./itbl-parse.y" 1599 { 1600 DBGL2 (("greg\n")); 1601 (yyval.num) = GREG; 1602 } 1603 #line 1604 "itbl-parse.c" 1604 break; 1605 1606 case 28: /* name: ID */ 1607 #line 429 "./itbl-parse.y" 1608 { 1609 DBGL2 (("name=%s\n",(yyvsp[0].str))); 1610 (yyval.str) = (yyvsp[0].str); 1611 } 1612 #line 1613 "itbl-parse.c" 1613 break; 1614 1615 case 29: /* value: NUM */ 1616 #line 445 "./itbl-parse.y" 1617 { 1618 DBGL2 (("val=x%x\n",(yyvsp[0].num))); 1619 (yyval.val) = (yyvsp[0].num); 1620 } 1621 #line 1622 "itbl-parse.c" 1622 break; 1623 1624 1625 #line 1626 "itbl-parse.c" 1626 1627 default: break; 1628 } 1629 /* User semantic actions sometimes alter yychar, and that requires 1630 that yytoken be updated with the new translation. We take the 1631 approach of translating immediately before every use of yytoken. 1632 One alternative is translating here after every semantic action, 1633 but that translation would be missed if the semantic action invokes 1634 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or 1635 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an 1636 incorrect destructor might then be invoked immediately. In the 1637 case of YYERROR or YYBACKUP, subsequent parser actions might lead 1638 to an incorrect destructor call or verbose syntax error message 1639 before the lookahead is translated. */ 1640 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); 1641 1642 YYPOPSTACK (yylen); 1643 yylen = 0; 1644 1645 *++yyvsp = yyval; 1646 1647 /* Now 'shift' the result of the reduction. Determine what state 1648 that goes to, based on the state we popped back to and the rule 1649 number reduced by. */ 1650 { 1651 const int yylhs = yyr1[yyn] - YYNTOKENS; 1652 const int yyi = yypgoto[yylhs] + *yyssp; 1653 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp 1654 ? yytable[yyi] 1655 : yydefgoto[yylhs]); 1656 } 1657 1658 goto yynewstate; 1659 1660 1661 /*--------------------------------------. 1662 | yyerrlab -- here on detecting error. | 1663 `--------------------------------------*/ 1664 yyerrlab: 1665 /* Make sure we have latest lookahead translation. See comments at 1666 user semantic actions for why this is necessary. */ 1667 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); 1668 /* If not already recovering from an error, report this error. */ 1669 if (!yyerrstatus) 1670 { 1671 ++yynerrs; 1672 yyerror (YY_("syntax error")); 1673 } 1674 1675 if (yyerrstatus == 3) 1676 { 1677 /* If just tried and failed to reuse lookahead token after an 1678 error, discard it. */ 1679 1680 if (yychar <= YYEOF) 1681 { 1682 /* Return failure if at end of input. */ 1683 if (yychar == YYEOF) 1684 YYABORT; 1685 } 1686 else 1687 { 1688 yydestruct ("Error: discarding", 1689 yytoken, &yylval); 1690 yychar = YYEMPTY; 1691 } 1692 } 1693 1694 /* Else will try to reuse lookahead token after shifting the error 1695 token. */ 1696 goto yyerrlab1; 1697 1698 1699 /*---------------------------------------------------. 1700 | yyerrorlab -- error raised explicitly by YYERROR. | 1701 `---------------------------------------------------*/ 1702 yyerrorlab: 1703 /* Pacify compilers when the user code never invokes YYERROR and the 1704 label yyerrorlab therefore never appears in user code. */ 1705 if (0) 1706 YYERROR; 1707 ++yynerrs; 1708 1709 /* Do not reclaim the symbols of the rule whose action triggered 1710 this YYERROR. */ 1711 YYPOPSTACK (yylen); 1712 yylen = 0; 1713 YY_STACK_PRINT (yyss, yyssp); 1714 yystate = *yyssp; 1715 goto yyerrlab1; 1716 1717 1718 /*-------------------------------------------------------------. 1719 | yyerrlab1 -- common code for both syntax error and YYERROR. | 1720 `-------------------------------------------------------------*/ 1721 yyerrlab1: 1722 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1723 1724 /* Pop stack until we find a state that shifts the error token. */ 1725 for (;;) 1726 { 1727 yyn = yypact[yystate]; 1728 if (!yypact_value_is_default (yyn)) 1729 { 1730 yyn += YYSYMBOL_YYerror; 1731 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) 1732 { 1733 yyn = yytable[yyn]; 1734 if (0 < yyn) 1735 break; 1736 } 1737 } 1738 1739 /* Pop the current state because it cannot handle the error token. */ 1740 if (yyssp == yyss) 1741 YYABORT; 1742 1743 1744 yydestruct ("Error: popping", 1745 YY_ACCESSING_SYMBOL (yystate), yyvsp); 1746 YYPOPSTACK (1); 1747 yystate = *yyssp; 1748 YY_STACK_PRINT (yyss, yyssp); 1749 } 1750 1751 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1752 *++yyvsp = yylval; 1753 YY_IGNORE_MAYBE_UNINITIALIZED_END 1754 1755 1756 /* Shift the error token. */ 1757 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); 1758 1759 yystate = yyn; 1760 goto yynewstate; 1761 1762 1763 /*-------------------------------------. 1764 | yyacceptlab -- YYACCEPT comes here. | 1765 `-------------------------------------*/ 1766 yyacceptlab: 1767 yyresult = 0; 1768 goto yyreturnlab; 1769 1770 1771 /*-----------------------------------. 1772 | yyabortlab -- YYABORT comes here. | 1773 `-----------------------------------*/ 1774 yyabortlab: 1775 yyresult = 1; 1776 goto yyreturnlab; 1777 1778 1779 /*-----------------------------------------------------------. 1780 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | 1781 `-----------------------------------------------------------*/ 1782 yyexhaustedlab: 1783 yyerror (YY_("memory exhausted")); 1784 yyresult = 2; 1785 goto yyreturnlab; 1786 1787 1788 /*----------------------------------------------------------. 1789 | yyreturnlab -- parsing is finished, clean up and return. | 1790 `----------------------------------------------------------*/ 1791 yyreturnlab: 1792 if (yychar != YYEMPTY) 1793 { 1794 /* Make sure we have latest lookahead translation. See comments at 1795 user semantic actions for why this is necessary. */ 1796 yytoken = YYTRANSLATE (yychar); 1797 yydestruct ("Cleanup: discarding lookahead", 1798 yytoken, &yylval); 1799 } 1800 /* Do not reclaim the symbols of the rule whose action triggered 1801 this YYABORT or YYACCEPT. */ 1802 YYPOPSTACK (yylen); 1803 YY_STACK_PRINT (yyss, yyssp); 1804 while (yyssp != yyss) 1805 { 1806 yydestruct ("Cleanup: popping", 1807 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); 1808 YYPOPSTACK (1); 1809 } 1810 #ifndef yyoverflow 1811 if (yyss != yyssa) 1812 YYSTACK_FREE (yyss); 1813 #endif 1814 1815 return yyresult; 1816 } 1817 1818 #line 450 "./itbl-parse.y" 1819 1820 1821 static void 1822 yyerror (const char *msg) 1823 { 1824 printf ("line %d: %s\n", insntbl_line, msg); 1825 } 1826